|
@@ -19,10 +19,9 @@ IGL_INLINE void igl::simplify_polyhedron(
|
|
|
Eigen::MatrixXi & F,
|
|
|
Eigen::VectorXi & J)
|
|
|
{
|
|
|
- assert(false && "This is incorrect. In all but simple cases, this could introduce self-intersections");
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
Eigen::MatrixXd N;
|
|
|
|
|
@@ -57,22 +56,25 @@ IGL_INLINE void igl::simplify_polyhedron(
|
|
|
const auto vj = E(e,!positive);
|
|
|
p = V.row(vj);
|
|
|
std::vector<int> faces = igl::circulation(e,positive,F,E,EMAP,EF,EI);
|
|
|
- assert(faces.size() >= 2);
|
|
|
- const Eigen::RowVectorXd nfront = N.row(faces.front());
|
|
|
- const Eigen::RowVectorXd nback = N.row(faces.back());
|
|
|
-
|
|
|
-
|
|
|
- bool matching_front = true;
|
|
|
cost = 0;
|
|
|
for(auto f : faces)
|
|
|
{
|
|
|
- const Eigen::RowVectorXd nf = N.row(f);
|
|
|
- const double epsilon = 1e-10;
|
|
|
- if(matching_front && (nf-nfront).norm()>epsilon)
|
|
|
+
|
|
|
+ if(f == EF(e,0) || f == EF(e,1))
|
|
|
{
|
|
|
- matching_front = false;
|
|
|
+ continue;
|
|
|
}
|
|
|
- if(!matching_front && (nf-nback).norm()>epsilon)
|
|
|
+ const Eigen::RowVectorXd nbefore = N.row(f);
|
|
|
+
|
|
|
+ const Eigen::RowVector3i fafter(
|
|
|
+ F(f,0) == vi ? vj : F(f,0),
|
|
|
+ F(f,1) == vi ? vj : F(f,1),
|
|
|
+ F(f,2) == vi ? vj : F(f,2));
|
|
|
+ Eigen::RowVectorXd nafter;
|
|
|
+ igl::per_face_normals(V,fafter,nafter);
|
|
|
+ const double epsilon = 1e-10;
|
|
|
+
|
|
|
+ if((nbefore-nafter).norm() > epsilon)
|
|
|
{
|
|
|
cost = std::numeric_limits<double>::infinity();
|
|
|
break;
|