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

Method assert_vertex_has_zero_dist

tests/tools/BVH/BVHTest.h:65–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 }
64
65 void assert_vertex_has_zero_dist(MeshPtr mesh,
66 typename BVHEngine::Ptr bvh,
67 bool reordered=false,
68 const Float tol=1.0e-12) {
69 const size_t dim = mesh->get_dim();
70 const size_t num_vertices = mesh->get_num_vertices();
71
72 VectorF flattened_vertices = mesh->get_vertices();
73 MatrixFr vertices(num_vertices, dim);
74 std::copy( flattened_vertices.data(),
75 flattened_vertices.data() + num_vertices * dim,
76 vertices.data());
77
78 VectorF distances;
79 VectorI face_indices;
80 MatrixFr closest_points;
81 bvh->lookup(vertices, distances, face_indices, closest_points);
82
83 ASSERT_EQ(num_vertices, distances.size());
84 ASSERT_EQ(num_vertices, face_indices.size());
85 ASSERT_EQ(num_vertices, closest_points.rows());
86
87 for (size_t i=0; i<num_vertices; i++) {
88 const auto f = mesh->get_face(face_indices[i]);
89 if (!reordered) {
90 ASSERT_TRUE(f[0] == i || f[1] == i || f[2] == i);
91 }
92 ASSERT_NEAR(0.0,
93 (vertices.row(i) - closest_points.row(i)).squaredNorm(), tol);
94 ASSERT_NEAR(0.0, distances[i], tol);
95 }
96 }
97
98 void simple_triangle_test(typename BVHEngine::Ptr bvh) {
99 MatrixFr vertices(3, 3);

Callers

nothing calls this directly

Calls 6

get_faceMethod · 0.80
get_dimMethod · 0.45
get_num_verticesMethod · 0.45
get_verticesMethod · 0.45
lookupMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected