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

marked faces in tetgen

Former-commit-id: a32e7aea7dc31537876ffdd9e1ad63b321d97024
Alec Jacobson 10 жил өмнө
parent
commit
892a385dfc

+ 11 - 0
include/igl/readOBJ.cpp

@@ -203,6 +203,17 @@ IGL_INLINE bool igl::readOBJ(
   return true;
 }
 
+template <typename Scalar, typename Index>
+IGL_INLINE bool igl::readOBJ(
+  const std::string obj_file_name, 
+  std::vector<std::vector<Scalar > > & V,
+  std::vector<std::vector<Index > > & F)
+{
+  std::vector<std::vector<Scalar > > TC,N;
+  std::vector<std::vector<Index > > FTC,FN;
+  return readOBJ(obj_file_name,V,TC,N,F,FTC,FN);
+}
+
 template <typename DerivedV, typename DerivedF, typename DerivedT>
 IGL_INLINE bool igl::readOBJ(
   const std::string str,

+ 6 - 0
include/igl/readOBJ.h

@@ -47,6 +47,12 @@ namespace igl
     std::vector<std::vector<Index > > & F,
     std::vector<std::vector<Index > > & FTC,
     std::vector<std::vector<Index > > & FN);
+  // Just V and F
+  template <typename Scalar, typename Index>
+  IGL_INLINE bool readOBJ(
+    const std::string obj_file_name, 
+    std::vector<std::vector<Scalar > > & V,
+    std::vector<std::vector<Index > > & F);
 
 #ifndef IGL_NO_EIGEN
   //! Read a mesh from an ascii obj file

+ 2 - 2
include/igl/slice_into.cpp

@@ -20,11 +20,11 @@ IGL_INLINE void igl::slice_into(
   Eigen::SparseMatrix<T>& Y)
 {
 
+#ifndef NDEBUG
   int xm = X.rows();
   int xn = X.cols();
   assert(R.size() == xm);
   assert(C.size() == xn);
-#ifndef NDEBUG
   int ym = Y.size();
   int yn = Y.size();
   assert(R.minCoeff() >= 0);
@@ -57,9 +57,9 @@ IGL_INLINE void igl::slice_into(
 
   int xm = X.rows();
   int xn = X.cols();
+#ifndef NDEBUG
   assert(R.size() == xm);
   assert(C.size() == xn);
-#ifndef NDEBUG
   int ym = Y.size();
   int yn = Y.size();
   assert(R.minCoeff() >= 0);

+ 2 - 1
include/igl/tetgen/mesh_to_tetgenio.cpp

@@ -35,11 +35,12 @@ IGL_INLINE bool igl::mesh_to_tetgenio(
 
   in.numberoffacets = F.size();
   in.facetlist = new tetgenio::facet[in.numberoffacets];
-  in.facetmarkerlist = NULL;
+  in.facetmarkerlist = new int[in.numberoffacets];
 
   // loop over face
   for(int i = 0;i < (int)F.size(); i++)
   {
+    in.facetmarkerlist[i] = i;
     tetgenio::facet * f = &in.facetlist[i];
     f->numberofpolygons = 1;
     f->polygonlist = new tetgenio::polygon[f->numberofpolygons];

+ 42 - 3
include/igl/tetgen/tetgenio_to_tetmesh.cpp

@@ -16,7 +16,8 @@
 IGL_INLINE bool igl::tetgenio_to_tetmesh(
   const tetgenio & out,
   std::vector<std::vector<REAL > > & V, 
-  std::vector<std::vector<int> > & T)
+  std::vector<std::vector<int> > & T,
+  std::vector<std::vector<int> > & F)
 {
   using namespace std;
   // process points
@@ -62,14 +63,42 @@ IGL_INLINE bool igl::tetgenio_to_tetmesh(
   assert(max_index >= 0);
   assert(max_index < (int)V.size());
 
+  cout<<out.numberoftrifaces<<endl;
+
+  // When would this not be 4?
+  F.clear();
+  // loop over tetrahedra
+  for(int i = 0; i < out.numberoftrifaces; i++)
+  {
+    if(out.trifacemarkerlist[i]>=0)
+    {
+      vector<int> face(3);
+      for(int j = 0; j<3; j++)
+      {
+        face[j] = out.trifacelist[i * 3 + j];
+      }
+      F.push_back(face);
+    }
+  }
+
   return true;
 }
 
-template <typename DerivedV, typename DerivedT>
+IGL_INLINE bool igl::tetgenio_to_tetmesh(
+  const tetgenio & out,
+  std::vector<std::vector<REAL > > & V, 
+  std::vector<std::vector<int> > & T)
+{
+  std::vector<std::vector<int> > F;
+  return igl::tetgenio_to_tetmesh(out,V,T,F);
+}
+
+template <typename DerivedV, typename DerivedT, typename DerivedF>
 IGL_INLINE bool igl::tetgenio_to_tetmesh(
   const tetgenio & out,
   Eigen::PlainObjectBase<DerivedV>& V,
-  Eigen::PlainObjectBase<DerivedT>& T)
+  Eigen::PlainObjectBase<DerivedT>& T,
+  Eigen::PlainObjectBase<DerivedF>& F)
 {
   using namespace igl;
   using namespace std;
@@ -95,6 +124,16 @@ IGL_INLINE bool igl::tetgenio_to_tetmesh(
   return true;
 }
 
+template <typename DerivedV, typename DerivedT>
+IGL_INLINE bool igl::tetgenio_to_tetmesh(
+  const tetgenio & out,
+  Eigen::PlainObjectBase<DerivedV>& V,
+  Eigen::PlainObjectBase<DerivedT>& T)
+{
+  Eigen::PlainObjectBase<DerivedT> F;
+  return tetgenio_to_tetmesh(out,V,T,F);
+}
+
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 template bool igl::tetgenio_to_tetmesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(tetgenio const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);

+ 12 - 0
include/igl/tetgen/tetgenio_to_tetmesh.h

@@ -21,7 +21,13 @@ namespace igl
   // Outputs:
   //   V  #V by 3 vertex position list
   //   T  #T by 4 list of tetrahedra indices into V
+  //   F  #F by 3 list of marked facets
   // Returns true on success, false on error
+  IGL_INLINE bool tetgenio_to_tetmesh(
+    const tetgenio & out,
+    std::vector<std::vector<REAL > > & V, 
+    std::vector<std::vector<int> > & T,
+    std::vector<std::vector<int> > & F);
   IGL_INLINE bool tetgenio_to_tetmesh(
     const tetgenio & out,
     std::vector<std::vector<REAL > > & V, 
@@ -31,6 +37,12 @@ namespace igl
   // Templates:
   //   DerivedV  real-value: i.e. from MatrixXd
   //   DerivedT  integer-value: i.e. from MatrixXi
+  template <typename DerivedV, typename DerivedT, typename DerivedF>
+  IGL_INLINE bool tetgenio_to_tetmesh(
+    const tetgenio & out,
+    Eigen::PlainObjectBase<DerivedV>& V,
+    Eigen::PlainObjectBase<DerivedT>& T,
+    Eigen::PlainObjectBase<DerivedF>& F);
   template <typename DerivedV, typename DerivedT>
   IGL_INLINE bool tetgenio_to_tetmesh(
     const tetgenio & out,

+ 2 - 2
include/igl/tetgen/tetrahedralize.cpp

@@ -50,12 +50,12 @@ IGL_INLINE int igl::tetrahedralize(
     cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<endl;
     return 2;
   }
-  success = tetgenio_to_tetmesh(out,TV,TT);
+  success = tetgenio_to_tetmesh(out,TV,TT,TF);
   if(!success)
   {
     return -1;
   }
-  boundary_facets(TT,TF);
+  //boundary_facets(TT,TF);
   return 0;
 }