Эх сурвалжийг харах

return false on nonmanifold

Former-commit-id: 17261705fe2a48df6ffaad48702e8cfc9c5fec12
Alec Jacobson 8 жил өмнө
parent
commit
5d956357b5

+ 8 - 0
include/igl/decimate.cpp

@@ -8,6 +8,7 @@
 #include "decimate.h"
 #include "collapse_edge.h"
 #include "edge_flaps.h"
+#include "is_edge_manifold.h"
 #include "remove_unreferenced.h"
 #include "slice_mask.h"
 #include "slice.h"
@@ -33,6 +34,13 @@ IGL_INLINE bool igl::decimate(
   DerivedV VO;
   DerivedF FO;
   igl::connect_boundary_to_infinity(V,F,VO,FO);
+  // decimate will not work correctly on non-edge-manifold meshes. By extension
+  // this includes meshes with non-manifold vertices on the boundary since these
+  // will create a non-manifold edge when connected to infinity.
+  if(!is_edge_manifold(FO))
+  {
+    return false;
+  }
   bool ret = decimate(
     VO,
     FO,

+ 8 - 0
include/igl/qslim.cpp

@@ -11,6 +11,7 @@
 #include "connect_boundary_to_infinity.h"
 #include "decimate.h"
 #include "edge_flaps.h"
+#include "is_edge_manifold.h"
 #include "max_faces_stopping_condition.h"
 #include "per_vertex_point_to_plane_quadrics.h"
 #include "qslim_optimal_collapse_edge_callbacks.h"
@@ -39,6 +40,13 @@ IGL_INLINE bool igl::qslim(
   DerivedV VO;
   DerivedF FO;
   igl::connect_boundary_to_infinity(V,F,VO,FO);
+  // decimate will not work correctly on non-edge-manifold meshes. By extension
+  // this includes meshes with non-manifold vertices on the boundary since these
+  // will create a non-manifold edge when connected to infinity.
+  if(!is_edge_manifold(FO))
+  {
+    return false;
+  }
   Eigen::VectorXi EMAP;
   Eigen::MatrixXi E,EF,EI;
   edge_flaps(FO,E,EMAP,EF,EI);