소스 검색

fixed tetgen warpper for point clouds

Teseo Schneider 6 년 전
부모
커밋
af2e58d313
1개의 변경된 파일22개의 추가작업 그리고 22개의 파일을 삭제
  1. 22 22
      include/igl/copyleft/tetgen/tetgenio_to_tetmesh.cpp

+ 22 - 22
include/igl/copyleft/tetgen/tetgenio_to_tetmesh.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 <[email protected]>
 // Copyright (C) 2013 Alec Jacobson <[email protected]>
-// 
-// 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 "tetgenio_to_tetmesh.h"
 #include "tetgenio_to_tetmesh.h"
 
 
@@ -18,11 +18,11 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
   std::vector<std::vector<REAL > > & V,
   std::vector<std::vector<REAL > > & V,
   std::vector<std::vector<int> > & T,
   std::vector<std::vector<int> > & T,
   std::vector<std::vector<int > > & F,
   std::vector<std::vector<int > > & F,
-  std::vector<std::vector<REAL > >&  R, 
+  std::vector<std::vector<REAL > >&  R,
   std::vector<std::vector<int > >& N,
   std::vector<std::vector<int > >& N,
   std::vector<std::vector<int > >& PT,
   std::vector<std::vector<int > >& PT,
   std::vector<std::vector<int > >& FT,
   std::vector<std::vector<int > >& FT,
-  size_t & nR ) 
+  size_t & nR )
 {
 {
    using namespace std;
    using namespace std;
    // process points
    // process points
@@ -63,11 +63,11 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
        max_index = (max_index < index ? index : max_index);
        max_index = (max_index < index ? index : max_index);
      }
      }
    }
    }
-  
+
    assert(min_index >= 0);
    assert(min_index >= 0);
    assert(max_index >= 0);
    assert(max_index >= 0);
    assert(max_index < (int)V.size());
    assert(max_index < (int)V.size());
- 
+
    cout<<out.numberoftrifaces<<endl;
    cout<<out.numberoftrifaces<<endl;
 
 
    // When would this not be 4?
    // When would this not be 4?
@@ -96,30 +96,30 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
    // extract region marks
    // extract region marks
    nR = hashUniqueRegions.size();
    nR = hashUniqueRegions.size();
 
 
-   // extract neighbor list 
-   N.resize(out.numberoftetrahedra, vector<int>(4));   
+   // extract neighbor list
+   N.resize(out.numberoftetrahedra, vector<int>(4));
    for (size_t i = 0; i < out.numberoftetrahedra; i++)
    for (size_t i = 0; i < out.numberoftetrahedra; i++)
    {
    {
      for (size_t j = 0; j < 4; j++)
      for (size_t j = 0; j < 4; j++)
        N[i][j] = out.neighborlist[i * 4 + j];
        N[i][j] = out.neighborlist[i * 4 + j];
-   } 
-  
-   // extract point 2 tetrahedron list 
+   }
+
+   // extract point 2 tetrahedron list
    PT.resize(out.numberofpoints, vector<int>(1));
    PT.resize(out.numberofpoints, vector<int>(1));
    for (size_t i = 0; i < out.numberofpoints; i++)
    for (size_t i = 0; i < out.numberofpoints; i++)
    {
    {
-     PT[i][0] = out.point2tetlist[i]; 
-   }	
- 
+     PT[i][0] = out.point2tetlist[i];
+   }
+
    //extract face to tetrahedron list
    //extract face to tetrahedron list
-   FT.resize(out.numberoftrifaces, vector<int>(2)); 
+   FT.resize(out.numberoftrifaces, vector<int>(2));
    int triface;
    int triface;
-   
+
    for (size_t i = 0; i < out.numberoftrifaces; i++)
    for (size_t i = 0; i < out.numberoftrifaces; i++)
    {
    {
      for (size_t j = 0; j < 2; j++)
      for (size_t j = 0; j < 2; j++)
      {
      {
-       FT[i][j] = out.face2tetlist[0]; 
+       FT[i][j] = out.face2tetlist[0];
      }
      }
    }
    }
 
 
@@ -129,7 +129,7 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
 
 
 IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
 IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
   const tetgenio & out,
   const tetgenio & out,
-  std::vector<std::vector<REAL > > & V, 
+  std::vector<std::vector<REAL > > & V,
   std::vector<std::vector<int> > & T,
   std::vector<std::vector<int> > & T,
   std::vector<std::vector<int> > & F)
   std::vector<std::vector<int> > & F)
 {
 {
@@ -182,7 +182,7 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
   // loop over tetrahedra
   // loop over tetrahedra
   for(int i = 0; i < out.numberoftrifaces; i++)
   for(int i = 0; i < out.numberoftrifaces; i++)
   {
   {
-    if(out.trifacemarkerlist[i]>=0)
+    if (out.trifacemarkerlist && out.trifacemarkerlist[i] >= 0)
     {
     {
       vector<int> face(3);
       vector<int> face(3);
       for(int j = 0; j<3; j++)
       for(int j = 0; j<3; j++)
@@ -198,7 +198,7 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
 
 
 IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
 IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
   const tetgenio & out,
   const tetgenio & out,
-  std::vector<std::vector<REAL > > & V, 
+  std::vector<std::vector<REAL > > & V,
   std::vector<std::vector<int> > & T)
   std::vector<std::vector<int> > & T)
 {
 {
   std::vector<std::vector<int> > F;
   std::vector<std::vector<int> > F;