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

Method compute

tools/Wires/Parameters/EdgeThicknessParameterDerivative.cpp:9–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace PyMesh;
8
9MatrixFr EdgeThicknessParameterDerivative::compute() {
10 WireNetwork::Ptr wire_network = m_parameter->get_wire_network();
11
12 const size_t dim = m_mesh->get_dim();
13 const size_t num_mesh_vertices = m_mesh->get_num_vertices();
14 const size_t num_mesh_faces = m_mesh->get_num_faces();
15 const size_t num_wire_edges = wire_network->get_num_edges();
16
17 assert(dim == wire_network->get_dim());
18
19 std::vector<bool> in_roi(num_wire_edges, false);
20 VectorI roi = m_parameter->get_roi();
21 const size_t roi_size = roi.size();
22 for (size_t i=0; i<roi_size; i++) {
23 in_roi[roi[i]] = true;
24 }
25
26 MatrixFr derivative_v = MatrixFr::Zero(num_mesh_vertices, dim);
27 VectorF weights = VectorF::Zero(num_mesh_vertices);
28
29 for (size_t i=0; i<num_mesh_faces; i++) {
30 const VectorI face = m_mesh->get_face(i);
31 const VectorF& normal = m_face_normals.row(i);
32 int source = m_face_source[i];
33 if (source < 0) {
34 // Source is edge
35 size_t edge_idx = -source - 1;
36 assert(edge_idx >= 0 && edge_idx < num_wire_edges);
37 if (in_roi[edge_idx]) {
38 Float w0 = m_face_voronoi_areas(i, 0);
39 Float w1 = m_face_voronoi_areas(i, 1);
40 Float w2 = m_face_voronoi_areas(i, 2);
41
42 derivative_v.row(face[0]) += w0 * normal.transpose();
43 derivative_v.row(face[1]) += w1 * normal.transpose();
44 derivative_v.row(face[2]) += w2 * normal.transpose();
45
46 weights[face[0]] += w0;
47 weights[face[1]] += w1;
48 weights[face[2]] += w2;
49 }
50 }
51 }
52
53 for (size_t i=0; i<num_mesh_vertices; i++) {
54 if (weights[i] > 0)
55 derivative_v.row(i) /= weights[i];
56 }
57 return derivative_v;
58}

Callers

nothing calls this directly

Calls 8

get_roiMethod · 0.80
get_faceMethod · 0.80
get_wire_networkMethod · 0.45
get_dimMethod · 0.45
get_num_verticesMethod · 0.45
get_num_facesMethod · 0.45
get_num_edgesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected