MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / compute_normals_generic

Function compute_normals_generic

pysplashsurf/src/mesh.rs:35–46  ·  view source on GitHub ↗
(
    py: Python<'py>,
    mesh: &TriMesh3d<R>,
)

Source from the content-addressed store, hash-verified

33}
34
35fn compute_normals_generic<'py, R: Real + Element>(
36 py: Python<'py>,
37 mesh: &TriMesh3d<R>,
38) -> PyResult<Bound<'py, PyUntypedArray>> {
39 let normals_vec = mesh.par_vertex_normals();
40 let normals_vec = bytemuck::allocation::cast_vec::<Unit<Vector3<R>>, R>(normals_vec);
41
42 Ok(PyArray::from_vec(py, normals_vec)
43 .reshape([mesh.vertices().len(), 3])?
44 .cast_into::<PyUntypedArray>()
45 .expect("cast should not fail"))
46}
47
48pub fn get_triangle_mesh_generic<'py>(mesh: &Bound<'py, PyAny>) -> Option<Py<PyTriMesh3d>> {
49 let py = mesh.py();

Callers 1

Calls 3

par_vertex_normalsMethod · 0.80
lenMethod · 0.45
verticesMethod · 0.45

Tested by

no test coverage detected