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

Method assert_centroid_has_zero_dist

tests/tools/BVH/BVHTest.h:32–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 void assert_centroid_has_zero_dist(MeshPtr mesh,
33 typename BVHEngine::Ptr bvh,
34 bool reordered=false,
35 const Float tol=1.0e-12) {
36 const size_t dim = mesh->get_dim();
37 const size_t num_faces = mesh->get_num_faces();
38
39 mesh->add_attribute("face_centroid");
40 VectorF flattened_centroids = mesh->get_attribute("face_centroid");
41 MatrixFr centroids(num_faces, dim);
42 std::copy(flattened_centroids.data(),
43 flattened_centroids.data() + num_faces * dim,
44 centroids.data());
45
46 VectorF distances;
47 VectorI face_indices;
48 MatrixFr closest_points;
49 bvh->lookup(centroids, distances, face_indices, closest_points);
50
51 ASSERT_EQ(num_faces, distances.size());
52 ASSERT_EQ(num_faces, face_indices.size());
53 ASSERT_EQ(num_faces, closest_points.rows());
54
55 for (size_t i=0; i<num_faces; i++) {
56 if (!reordered) {
57 ASSERT_EQ(i, face_indices[i]);
58 }
59 ASSERT_NEAR(0.0,
60 (centroids.row(i) - closest_points.row(i)).squaredNorm(), tol);
61 ASSERT_NEAR(0.0, distances[i], tol);
62 }
63 }
64
65 void assert_vertex_has_zero_dist(MeshPtr mesh,
66 typename BVHEngine::Ptr bvh,

Callers

nothing calls this directly

Calls 6

get_dimMethod · 0.45
get_num_facesMethod · 0.45
add_attributeMethod · 0.45
get_attributeMethod · 0.45
lookupMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected