MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute_from_mesh

Method compute_from_mesh

src/Attributes/FaceEdgeRatioAttribute.cpp:13–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11using namespace PyMesh;
12
13void FaceEdgeRatioAttribute::compute_from_mesh(Mesh& mesh) {
14 if (!mesh.has_attribute("edge_length")) {
15 mesh.add_attribute("edge_length");
16 }
17 const VectorF& edge_length = mesh.get_attribute("edge_length");
18
19 const size_t num_faces = mesh.get_num_faces();
20 const size_t num_vertex_per_face = mesh.get_vertex_per_face();
21
22 VectorF& edge_ratios = m_values;
23 edge_ratios = VectorF::Zero(num_faces);
24
25 for (size_t i=0; i<num_faces; i++) {
26 VectorF edges = edge_length.segment(
27 i*num_vertex_per_face, num_vertex_per_face);
28 const Float min_e = edges.minCoeff();
29 const Float max_e = edges.maxCoeff();
30 if (min_e == 0.0) {
31 edge_ratios[i] = std::numeric_limits<Float>::infinity();
32 } else {
33 edge_ratios[i] = max_e / min_e;
34 }
35 }
36
37 if (!edge_ratios.allFinite()) {
38 std::cerr << "Warning: some triangles have infinite edge ratio"
39 << std::endl;
40 }
41}

Callers

nothing calls this directly

Calls 5

has_attributeMethod · 0.45
add_attributeMethod · 0.45
get_attributeMethod · 0.45
get_num_facesMethod · 0.45
get_vertex_per_faceMethod · 0.45

Tested by

no test coverage detected