// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // 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/. #include "tetgenio_to_tetmesh.h" // IGL includes #include "../../list_to_matrix.h" // STL includes #include template < typename DerivedV, typename DerivedT, typename DerivedF, typename DerivedTM, typename DerivedR, typename DerivedN, typename DerivedPT, typename DerivedFT> IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh( const tetgenio & out, Eigen::PlainObjectBase& V, Eigen::PlainObjectBase& T, Eigen::PlainObjectBase& F, Eigen::PlainObjectBase& TM, Eigen::PlainObjectBase& R, Eigen::PlainObjectBase& N, Eigen::PlainObjectBase& PT, Eigen::PlainObjectBase& FT, int & num_regions) { // process points if(out.pointlist == NULL) { std::cerr<<"^tetgenio_to_tetmesh Error: point list is NULL\n"<= 0); assert(T.minCoeff() >= 0); assert(T.maxCoeff() < V.rows()); F.resize(out.numberoftrifaces,3); // loop over tetrahedra for(int i = 0; i < out.numberoftrifaces; i++) { F(i,0) = out.trifacelist[i * 3 + 0]; F(i,1) = out.trifacelist[i * 3 + 1]; F(i,2) = out.trifacelist[i * 3 + 2]; } if(out.pointmarkerlist) { TM.resize(out.numberofpoints); for (int i = 0; i < out.numberofpoints; ++i) { TM(i) = out.pointmarkerlist[i]; } } if(out.tetrahedronattributelist) { R.resize(out.numberoftetrahedra); std::unordered_map hashUniqueRegions; for(int i = 0; i < out.numberoftetrahedra; i++) { R(i) = out.tetrahedronattributelist[i]; hashUniqueRegions[R(i)] = i; } // extract region marks num_regions = hashUniqueRegions.size(); }else { num_regions = 0; } // extract neighbor list if(out.neighborlist) { N.resize(out.numberoftetrahedra, 4); for (int i = 0; i < out.numberoftetrahedra; i++) { for (int j = 0; j < 4; j++) { N(i,j) = out.neighborlist[i * 4 + j]; } } } // extract point 2 tetrahedron list if(out.point2tetlist) { PT.resize(out.numberofpoints); for (int i = 0; i < out.numberofpoints; i++) { PT(i) = out.point2tetlist[i]; } } //extract face to tetrahedron list if(out.face2tetlist) { FT.resize(out.numberoftrifaces,2); int triface; for (int i = 0; i < out.numberoftrifaces; i++) { for (int j = 0; j < 2; j++) { FT(i,j) = out.face2tetlist[i * 2 + j]; } } } return true; } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh template bool igl::copyleft::tetgen::tetgenio_to_tetmesh, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(tetgenio const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, int&); #endif