Skip to content

Commit f66ad12

Browse files
committed
"warning: mesh is not watertight" removed. Use .is_mesh_manifold() instead.
1 parent 071771a commit f66ad12

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

TriangleMeshDistance/include/tmd/TriangleMeshDistance.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ namespace tmd
125125
std::vector<Vec3d> pseudonormals_vertices;
126126
BoundingSphere root_bv;
127127
bool is_constructed = false;
128+
bool is_manifold = false;
128129

129130
/* Private methods */
130131
void _construct();
@@ -176,6 +177,13 @@ namespace tmd
176177
template<typename IndexableVector3double, typename IndexableVector3int>
177178
void construct(const std::vector<IndexableVector3double>& vertices, const std::vector<IndexableVector3int>& triangles);
178179

180+
/**
181+
* @brief Returns the result of the manifold check done at construction time.
182+
*
183+
* @return True if the mesh is watertight, with all edges being shared by exactly two triangles, false otherwise.
184+
*/
185+
bool is_mesh_manifold() const;
186+
179187
/**
180188
* @brief Computes the unsigned distance from a point to the triangle mesh. Thread safe.
181189
*
@@ -253,6 +261,11 @@ inline void tmd::TriangleMeshDistance::construct(const std::vector<IndexableVect
253261
this->_construct();
254262
}
255263

264+
inline bool tmd::TriangleMeshDistance::is_mesh_manifold() const
265+
{
266+
return this->is_manifold;
267+
}
268+
256269
inline tmd::Result tmd::TriangleMeshDistance::signed_distance(const std::array<double, 3>& point) const
257270
{
258271
const Vec3d p(point[0], point[1], point[2]);
@@ -412,22 +425,12 @@ inline void tmd::TriangleMeshDistance::_construct()
412425
}
413426

414427
// Check that the mesh is watertight: All edges appear exactly twice.
415-
bool single_edge_found = false;
416-
bool triple_edge_found = false;
428+
this->is_manifold = true;
417429
for (const auto edge_count : edges_count) {
418-
if (edge_count.second == 1) {
419-
single_edge_found = true;
420-
}
421-
else if (edge_count.second > 2) {
422-
triple_edge_found = true;
430+
if (edge_count.second != 2) {
431+
this->is_manifold = false;
423432
}
424433
}
425-
if (single_edge_found) {
426-
std::cout << "DistanceTriangleMesh warning: mesh is not watertight. At least one edge found belonging to just one triangle." << std::endl;
427-
}
428-
if (triple_edge_found) {
429-
std::cout << "DistanceTriangleMesh warning: mesh is not watertight. At least one edge found belonging to more than two triangle." << std::endl;
430-
}
431434

432435
this->is_constructed = true;
433436
}

0 commit comments

Comments
 (0)