소스 검색

fixed(?) bug in the mesh cutting

Former-commit-id: d4a763baeeaf7054c23e62edfacf30d90da84c78
Olga Diamanti 10 년 전
부모
커밋
415b35c213
4개의 변경된 파일41개의 추가작업 그리고 19개의 파일을 삭제
  1. 1 0
      include/igl/HalfEdgeIterator.h
  2. 29 11
      include/igl/cut_mesh_from_singularities.cpp
  3. 6 4
      include/igl/per_vertex_normals.cpp
  4. 5 4
      include/igl/sort.cpp

+ 1 - 0
include/igl/HalfEdgeIterator.h

@@ -12,6 +12,7 @@
 #include <Eigen/Core>
 #include <Eigen/Core>
 
 
 #include <vector>
 #include <vector>
+#include <igl/igl_inline.h>
 
 
 namespace igl
 namespace igl
 {
 {

+ 29 - 11
include/igl/cut_mesh_from_singularities.cpp

@@ -9,6 +9,7 @@
 #include "cut_mesh_from_singularities.h"
 #include "cut_mesh_from_singularities.h"
 
 
 #include <igl/triangle_triangle_adjacency.h>
 #include <igl/triangle_triangle_adjacency.h>
+#include <igl/edge_topology.h>
 
 
 #include <vector>
 #include <vector>
 #include <deque>
 #include <deque>
@@ -32,6 +33,7 @@ namespace igl {
     Eigen::PlainObjectBase<DerivedF> TT;
     Eigen::PlainObjectBase<DerivedF> TT;
     Eigen::PlainObjectBase<DerivedF> TTi;
     Eigen::PlainObjectBase<DerivedF> TTi;
 
 
+    Eigen::MatrixXi E, F2E, E2F;
   protected:
   protected:
 
 
     inline bool IsRotSeam(const int f0,const int edge)
     inline bool IsRotSeam(const int f0,const int edge)
@@ -75,17 +77,32 @@ namespace igl {
     inline void Retract(Eigen::PlainObjectBase<DerivedO> &Handle_Seams)
     inline void Retract(Eigen::PlainObjectBase<DerivedO> &Handle_Seams)
     {
     {
       std::vector<int> e(V.rows(),0); // number of edges per vert
       std::vector<int> e(V.rows(),0); // number of edges per vert
-
-      for (unsigned f=0; f<F.rows(); f++)
+      // for (unsigned f=0; f<F.rows(); f++)
+      // {
+      //   for (int s = 0; s<3; s++)
+      //   {
+      //     if (Handle_Seams(f,s))
+      //       if (TT(f,s)<=f)
+      //       {
+      //         e[ F(f,s) ] ++;
+      //         e[ F(f,(s+1)%3) ] ++;
+      //       }
+      //   }
+      // }
+      for (int ei=0; ei<E.rows(); ++ei)
       {
       {
-        for (int s = 0; s<3; s++)
+        //only need one face
+        int f0 = E2F(ei,0);
+        if (f0==-1)
+          f0 = E2F(ei,1);
+        int k=0;
+        for (k=0; k<3; ++k)
+          if (F2E(f0,k)==ei)
+            break;
+        if (Handle_Seams(f0,k))
         {
         {
-          if (Handle_Seams(f,s))
-            if (TT(f,s)<=f)
-            {
-              e[ F(f,s) ] ++;
-              e[ F(f,(s+1)%3) ] ++;
-            }
+          e[ F(f0,k) ] ++;
+          e[ F(f0,(k+1)%3) ] ++;
         }
         }
       }
       }
 
 
@@ -115,7 +132,7 @@ namespace igl {
           }
           }
         }
         }
 
 
-        if (guard++>10000)
+        if (guard++>0)
           over = true;
           over = true;
 
 
       } while (!over);
       } while (!over);
@@ -131,6 +148,7 @@ namespace igl {
     Handle_MMatch(Handle_MMatch_)
     Handle_MMatch(Handle_MMatch_)
     {
     {
       triangle_triangle_adjacency(V,F,TT,TTi);
       triangle_triangle_adjacency(V,F,TT,TTi);
+      edge_topology(V,F,E,F2E,E2F);
     };
     };
 
 
     inline void cut(Eigen::PlainObjectBase<DerivedO> &Handle_Seams)
     inline void cut(Eigen::PlainObjectBase<DerivedO> &Handle_Seams)
@@ -148,7 +166,7 @@ namespace igl {
         }
         }
       }
       }
 
 
-      // Retract(Handle_Seams);
+      Retract(Handle_Seams);
 
 
       for (unsigned int f=0;f<F.rows();f++)
       for (unsigned int f=0;f<F.rows();f++)
         for (int j=0;j<3;j++)
         for (int j=0;j<3;j++)

+ 6 - 4
include/igl/per_vertex_normals.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "per_vertex_normals.h"
 #include "per_vertex_normals.h"
 
 
@@ -98,5 +98,7 @@ IGL_INLINE void igl::per_vertex_normals(
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // Explicit template specialization
+template void igl::per_vertex_normals<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::PerVertexNormalsWeightingType, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
+template void igl::per_vertex_normals<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
 #endif
 #endif

+ 5 - 4
include/igl/sort.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "sort.h"
 #include "sort.h"
 
 
@@ -219,4 +219,5 @@ template void igl::sort<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
 template void igl::sort<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template void igl::sort<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
+template void igl::sort<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, int, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif
 #endif