Update eigen to v5.0.1 and libigl to v2.6.0. (#11311)

* Update eigen from v3.3.7 to v5.0.1.

This updates eigen from v3.3.7 released on  December 11, 2018-12-11 to v5.0.1
released on 2025-11-11. There have be a large number of bug-fixes,
optimizations, and improvements between these releases. See the details at;

https://gitlab.com/libeigen/eigen/-/releases

It retains the previous custom minimal `CMakeLists.txt`, and adds a
README-OrcaSlicer.md that explains what version and parts of the upstream
eigen release have been included, and where the full release can be found.

* Update libigl from v2.0.0 (or older) to v2.6.0.

This updates libigl from what was probably v2.0.0 released on 2018-10-16 to
v2.6.0 released on 2025-05-15. It's possible the old version was even older
than that but there is no version indicators in the code and I ran out of
patience identifying missing changes and only went back as far as v2.0.0.

There have been a large number of bug-fixes, optimizations, and improvements
between these versions. See the following for details;

https://github.com/libigl/libigl/releases

I retained the minimal custom `CMakeLists.txt`, added `README.md` from the
libigl distribution which identifies the version, and added a
README-OrcaSlicer.md that details the version and parts that have been
included.

* Update libslic3r for libigl v2.6.0 changes.

This updates libslic3r for all changes moving to eigen v5.0.1 and libigl
v2.6.0. Despite the large number of updates to both dependencies, no changes
were required for the eigen update, and only one change was required for the
libigl update.

For libigl, `igl::Hit` was changed to a template taking the Scalar type to
use. Previously it was hard-coded to `float`, so to minimize possible impact
I've updated all places it is used from `igl::Hit` to `igl::Hit<float>`.

* Add compiler option `-DNOMINMAX` for libigl with MSVC.

MSVC by default defines `min(()` and `max()` macros that break
`std::numeric_limits<>::max()`. The upstream cmake that we don't include
adds `-DNOMINMAX` for the libigl module when compiling with MSVC, so we need
to add the same thing here.

* Fix src/libslic3r/TriangleMeshDeal.cpp for the unmodified upstream libigl.

This fixes `TriangleMeshDeal.cpp` to work with the unmodified upstream
libigl v2.6.0. loop.{h,cpp} implementation.

This file and feature was added in PR "BBS Port: Mesh Subdivision" (#12150)
which included changes to `loop.{h,cpp}` in the old version of libigl. This PR
avoids modifying the included dependencies, and uses the updated upstream
versions of those files without any modifications, which requires fixing
TriangleMeshDeal.cpp to work with them.

In particular, the modifications made to `loop.{h,cpp}` included changing the
return type from void to bool, adding additional validation checking of the
input meshes, and returning false if they failed validation. These added
checks looked unnecessary and would only have caught problems if the input
mesh was very corrupt.

To make `TriangleMeshDeal.cpp` work without this built-in checking
functionality, I removed checking/handling of any `false` return value.

There was also a hell of a lot of redundant copying and casting back and forth
between float and double, so I cleaned that up. The input and output meshs use
floats for the vertexes, and there would be no accuracy benefits from casting
to and from doubles for the simple weighted average operations done by
igl::loop(). So this just uses `Eigen:Map` to use the original input mesh
vertex data directly without requiring any copy or casting.

* Move eigen from included `deps_src` to externaly fetched `deps`.

This copys what PrusaSlicer did and moved it from an included dependency under
`deps_src` to an externaly fetched dependency under `deps`. This requires
updating some `CMakeList.txt` configs and removing the old and obsolete
`cmake/modules/FindEigen3.cmake`. The details of when this was done in
PrusaSlicer and the followup fixes are at;

* 21116995d7
* https://github.com/prusa3d/PrusaSlicer/issues/13608
* https://github.com/prusa3d/PrusaSlicer/pull/13609
* e3c277b9ee

For some reason I don't fully understand this also required fixing
`src/slic3r/GUI/GUI_App.cpp` by adding `#include <boost/nowide/cstdio.hpp>` to
fix an `error: ‘remove’ is not a member of ‘boost::nowide'`. The main thing I
don't understand is how it worked before. Note that this include is in the
PrusaSlicer version of this file, but it also significantly deviates from what
is currently in OrcaSlicer in many other ways.

* Whups... I missed adding the deps/Eigen/Eigen.cmake file...

* Tidy some whitespace indenting in CMakeLists.txt.

* Ugh... tabs indenting needing fixes.

* Change the include order of deps/Eigen.

It turns out that although Boost includes some references to Eigen, Eigen also
includes some references to Boost for supporting some of it's additional
numeric types.

I don't think it matters much since we are not using these features, but I
think technically its more correct to say Eigen depends on Boost than the
other way around, so I've re-ordered them.

* Add source for Eigen 5.0.1 download to flatpak yml config.

* Add explicit `DEPENDS dep_Boost to deps/Eigen.

I missed this before. This ensures we don't rely on include orders to make
sure Boost is installed before we configure Eigen.

* Add `DEPENDS dep_Boost dep_GMP dep_MPFR` to deps/Eigen.

It turns out Eigen can also use GMP and MPFR for multi-precision and
multi-precision-rounded numeric types if they are available.

Again, I don't think we are using these so it doesn't really matter, but it is
technically correct and ensures they are there if we ever do need them.

* Fix deps DEPENDENCY ordering for GMP, MPFR, Eigen, and CGAL.

I think this is finally correct. Apparently CGAL also optionally depends on
Eigen, so the correct dependency order from lowest to highest is GMP, MPFR, Eigen, and CGAL.

---------

Co-authored-by: Donovan Baarda <dbaarda@google.com>
Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
Donovan Baarda
2026-05-12 17:09:13 +10:00
committed by GitHub
parent 797ee70b0b
commit dc5897d7b5
1573 changed files with 63323 additions and 161343 deletions

View File

@@ -7,6 +7,7 @@
// obtain one at http://mozilla.org/MPL/2.0/.
#include "cdt.h"
#include "../../bounding_box.h"
#include "../../PlainMatrix.h"
#include "tetrahedralize.h"
template <
@@ -16,8 +17,8 @@ template <
typename DerivedTT,
typename DerivedTF>
IGL_INLINE bool igl::copyleft::tetgen::cdt(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const CDTParam & param,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
@@ -26,13 +27,13 @@ IGL_INLINE bool igl::copyleft::tetgen::cdt(
using namespace Eigen;
using namespace std;
// Effective input mesh
DerivedV U;
DerivedF G;
PlainMatrix<DerivedV,Eigen::Dynamic> U;
PlainMatrix<DerivedF,Eigen::Dynamic> G;
if(param.use_bounding_box)
{
// Construct bounding box mesh
DerivedV BV;
DerivedF BF;
PlainMatrix<DerivedV,Eigen::Dynamic> BV;
PlainMatrix<DerivedF,Eigen::Dynamic> BF;
bounding_box(V,BV,BF);
// scale bounding box
const RowVector3d mid =
@@ -60,5 +61,5 @@ IGL_INLINE bool igl::copyleft::tetgen::cdt(
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
template bool igl::copyleft::tetgen::cdt<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -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&, igl::copyleft::tetgen::CDTParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
template bool igl::copyleft::tetgen::cdt<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::copyleft::tetgen::CDTParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
#endif

View File

@@ -14,7 +14,7 @@
#ifndef TETLIBRARY
# define TETLIBRARY
#endif
#include "tetgen.h" // Defined REAL
#include <tetgen.h> // Defined REAL
namespace igl
{
@@ -22,29 +22,29 @@ namespace igl
{
namespace tetgen
{
/// Parameters for controling the CDT
struct CDTParam
{
// Tetgen can compute mesh of convex hull of input (i.e. "c") but often
// chokes. One workaround is to force it to mesh the entire bounding box.
// {false}
/// Tetgen can compute mesh of convex hull of input (i.e. "c") but often
/// chokes. One workaround is to force it to mesh the entire bounding box.
/// {false}
bool use_bounding_box = false;
// Scale the bounding box a bit so that vertices near it do not give tetgen
// problems. {1.01}
/// Scale the bounding box a bit so that vertices near it do not give tetgen
/// problems. {1.01}
double bounding_box_scale = 1.01;
// Flags to tetgen. Do not include the "c" flag here! {"Y"}
/// Flags to tetgen. Do not include the "c" flag here! {"Y"}
std::string flags = "Y";
};
// Create a constrained delaunay tessellation containing convex hull of the
// given **non-selfintersecting** mesh.
//
// Inputs:
// V #V by 3 list of input mesh vertices
// F #F by 3 list of input mesh facets
// param see above
// TV #TV by 3 list of output mesh vertices (V come first)
// TT #TT by 3 list of tetrahedra indices into TV.
// TF #TF by 3 list of facets from F potentially subdivided.
//
/// Create a constrained delaunay tessellation containing convex hull of the
/// given **non-selfintersecting** mesh.
///
/// @param[in] V #V by 3 list of input mesh vertices
/// @param[in] F #F by 3 list of input mesh facets
/// @param[in] param see above
/// @param[out] TV #TV by 3 list of output mesh vertices (V come first)
/// @param[out] TT #TT by 3 list of tetrahedra indices into TV.
/// @param[out] TF #TF by 3 list of facets from F potentially subdivided.
///
template <
typename DerivedV,
typename DerivedF,
@@ -52,8 +52,8 @@ namespace igl
typename DerivedTT,
typename DerivedTF>
IGL_INLINE bool cdt(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const CDTParam & param,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,

View File

@@ -13,66 +13,94 @@
// STL includes
#include <cassert>
IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio(
const std::vector<std::vector<REAL > > & V,
const std::vector<std::vector<int> > & F,
template <
typename DerivedV,
typename DerivedF,
typename DerivedH,
typename DerivedVM,
typename DerivedFM,
typename DerivedR>
IGL_INLINE void igl::copyleft::tetgen::mesh_to_tetgenio(
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedH>& H,
const Eigen::MatrixBase<DerivedVM>& VM,
const Eigen::MatrixBase<DerivedFM>& FM,
const Eigen::MatrixBase<DerivedR>& R,
tetgenio & in)
{
using namespace std;
// all indices start from 0
assert(V.cols() == 3 && "V should have 3 columns");
assert((VM.size() == 0 || VM.size() == V.rows()) && "VM should be empty or #V by 1");
assert((FM.size() == 0 || FM.size() == F.rows()) && "FM should be empty or #F by 1");
in.firstnumber = 0;
in.numberofpoints = V.size();
in.numberofpoints = V.rows();
in.pointlist = new REAL[in.numberofpoints * 3];
// loop over points
for(int i = 0; i < (int)V.size(); i++)
if(VM.size())
{
assert(V[i].size() == 3);
in.pointlist[i*3+0] = V[i][0];
in.pointlist[i*3+1] = V[i][1];
in.pointlist[i*3+2] = V[i][2];
in.pointmarkerlist = new int[VM.size()];
}
in.numberoffacets = F.size();
//loop over points
for(int i = 0; i < V.rows(); i++)
{
in.pointlist[i*3+0] = V(i,0);
in.pointlist[i*3+1] = V(i,1);
in.pointlist[i*3+2] = V(i,2);
if(VM.size())
{
in.pointmarkerlist[i] = VM(i);
}
}
in.numberoffacets = F.rows();
in.facetlist = new tetgenio::facet[in.numberoffacets];
in.facetmarkerlist = new int[in.numberoffacets];
// loop over face
for(int i = 0;i < (int)F.size(); i++)
for(int i = 0;i < F.rows(); i++)
{
in.facetmarkerlist[i] = i;
in.facetmarkerlist[i] = FM.size() ? FM(i) : i;
tetgenio::facet * f = &in.facetlist[i];
f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
f->numberofholes = 0;
f->holelist = NULL;
tetgenio::polygon * p = &f->polygonlist[0];
p->numberofvertices = F[i].size();
p->numberofvertices = (F.row(i).array() >= 0).count();
p->vertexlist = new int[p->numberofvertices];
// loop around face
for(int j = 0;j < (int)F[i].size(); j++)
for(int j = 0;j < p->numberofvertices; j++)
{
p->vertexlist[j] = F[i][j];
p->vertexlist[j] = F(i,j);
}
}
return true;
in.numberofholes = H.rows();
in.holelist = new REAL[3 * in.numberofholes];
// loop over holes
for(int holeID = 0; holeID < H.rows(); holeID++)
{
in.holelist[holeID * 3 + 0] = H(holeID,0);
in.holelist[holeID * 3 + 1] = H(holeID,1);
in.holelist[holeID * 3 + 2] = H(holeID,2);
}
in.numberofregions = R.rows();
in.regionlist = new REAL[ 5 * in.numberofregions];
// loop over regions
for(int regionID = 0; regionID < R.rows(); regionID++)
{
in.regionlist[regionID * 5 + 0] = R(regionID,0);
in.regionlist[regionID * 5 + 1] = R(regionID,1);
in.regionlist[regionID * 5 + 2] = R(regionID,2);
in.regionlist[regionID * 5 + 3] = R(regionID,3);
in.regionlist[regionID * 5 + 4] = R(regionID,4);
}
}
template <typename DerivedV, typename DerivedF>
IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
tetgenio & in)
{
using namespace std;
vector<vector<REAL> > vV;
vector<vector<int> > vF;
matrix_to_list(V,vV);
matrix_to_list(F,vF);
return mesh_to_tetgenio(vV,vF,in);
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
template bool igl::copyleft::tetgen::mesh_to_tetgenio<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&, tetgenio&);
// generated by autoexplicit.sh
template void igl::copyleft::tetgen::mesh_to_tetgenio<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, tetgenio&);
#endif

View File

@@ -22,26 +22,27 @@ namespace igl
{
namespace tetgen
{
// Load a vertex list and face list into a tetgenio object
// Inputs:
// V #V by 3 vertex position list
// F #F list of polygon face indices into V (0-indexed)
// Outputs:
// in tetgenio input object
// Returns true on success, false on error
IGL_INLINE bool mesh_to_tetgenio(
const std::vector<std::vector<REAL > > & V,
const std::vector<std::vector<int> > & F,
tetgenio & in);
// Wrapper with Eigen types
// Templates:
// DerivedV real-value: i.e. from MatrixXd
// DerivedF integer-value: i.e. from MatrixXi
template <typename DerivedV, typename DerivedF>
IGL_INLINE bool mesh_to_tetgenio(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
/// Load a vertex list and face list into a tetgenio object
///
/// @param[in] V #V by 3 vertex position list
/// @param[in] F #F list of polygon face indices into V (0-indexed)
/// @param[out] in tetgenio input object
/// @param[out] H #H list of seed point inside each hole
/// @param[out] R #R list of seed point inside each region
template <
typename DerivedV,
typename DerivedF,
typename DerivedH,
typename DerivedVM,
typename DerivedFM,
typename DerivedR>
IGL_INLINE void mesh_to_tetgenio(
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedH>& H,
const Eigen::MatrixBase<DerivedVM>& VM,
const Eigen::MatrixBase<DerivedFM>& FM,
const Eigen::MatrixBase<DerivedR>& R,
tetgenio & in);
}
}

View File

@@ -47,9 +47,7 @@ IGL_INLINE bool igl::copyleft::tetgen::mesh_with_skeleton(
// * has consistent orientation
// * has no self-intersections
// * has no 0-volume pieces
cerr<<"tetgen begin()"<<endl;
int status = tetrahedralize( VS,F,eff_tetgen_flags,VV,TT,FF);
cerr<<"tetgen end()"<<endl;
if(FF.rows() != F.rows())
{
// Issue a warning if the surface has changed

View File

@@ -17,25 +17,23 @@ namespace igl
{
namespace tetgen
{
// Mesh the interior of a given surface with tetrahedra which are graded
// (tend to be small near the surface and large inside) and conform to the
// given handles and samplings thereof.
//
// Inputs:
// V #V by 3 list of mesh vertex positions
// F #F by 3 list of triangle indices
// C #C by 3 list of vertex positions
// P #P list of point handle indices
// BE #BE by 2 list of bone-edge indices
// CE #CE by 2 list of cage-edge indices
// samples_per_bone #samples to add per bone
// tetgen_flags flags to pass to tetgen {""-->"pq2Y"} otherwise you're on
// your own and it's your funeral if you pass nonsense flags
// Outputs:
// VV #VV by 3 list of tet-mesh vertex positions
// TT #TT by 4 list of tetrahedra indices
// FF #FF by 3 list of surface triangle indices
// Returns true only on success
/// Mesh the interior of a given surface with tetrahedra which are graded
/// (tend to be small near the surface and large inside) and conform to the
/// given handles and samplings thereof.
///
/// @param[in] V #V by 3 list of mesh vertex positions
/// @param[in] F #F by 3 list of triangle indices
/// @param[in] C #C by 3 list of vertex positions
/// @param[in] P #P list of point handle indices
/// @param[in] BE #BE by 2 list of bone-edge indices
/// @param[in] CE #CE by 2 list of cage-edge indices
/// @param[in] samples_per_bone #samples to add per bone
/// @param[in] tetgen_flags flags to pass to tetgen {""-->"pq2Y"} otherwise you're on
/// your own and it's your funeral if you pass nonsense flags
/// @param[out] VV #VV by 3 list of tet-mesh vertex positions
/// @param[out] TT #TT by 4 list of tetrahedra indices
/// @param[out] FF #FF by 3 list of surface triangle indices
/// @return true only on success
IGL_INLINE bool mesh_with_skeleton(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
@@ -48,7 +46,7 @@ namespace igl
Eigen::MatrixXd & VV,
Eigen::MatrixXi & TT,
Eigen::MatrixXi & FF);
// Wrapper using default tetgen_flags
/// \overload
IGL_INLINE bool mesh_with_skeleton(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,

View File

@@ -1,74 +0,0 @@
// This file is part of libigl, a simple c++ geometry processing library.
//
// 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
// obtain one at http://mozilla.org/MPL/2.0/.
#include "read_into_tetgenio.h"
#include "mesh_to_tetgenio.h"
// IGL includes
#include "../../pathinfo.h"
#ifndef IGL_NO_EIGEN
# define IGL_NO_EIGEN_WAS_NOT_ALREADY_DEFINED
# define IGL_NO_EIGEN
#endif
// Include igl headers without including Eigen
#include "../../readOBJ.h"
#ifdef IGL_NO_EIGEN_WAS_NOT_ALREADY_DEFINED
# undef IGL_NO_EIGEN
#endif
// STL includes
#include <algorithm>
#include <iostream>
#include <vector>
IGL_INLINE bool igl::copyleft::tetgen::read_into_tetgenio(
const std::string & path,
tetgenio & in)
{
using namespace std;
// get file extension
string dirname,basename,ext,filename;
pathinfo(path,dirname,basename,ext,filename);
// convert to lower case for easy comparison
transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
bool success = false;
char basename_char[1024];
strcpy(basename_char,basename.c_str());
if(ext == "obj")
{
// read obj into vertex list and face list
vector<vector<REAL> > V,TC,N;
vector<vector<int> > F,FTC,FN;
success = readOBJ(path,V,TC,N,F,FTC,FN);
success &= mesh_to_tetgenio(V,F,in);
}else if(ext == "off")
{
success = in.load_off(basename_char);
}else if(ext == "node")
{
success = in.load_node(basename_char);
}else
{
if(ext.length() > 0)
{
cerr<<"^read_into_tetgenio Warning: Unsupported extension ("<<ext<<
"): try to load as basename..."<<endl;
}
// This changed as of (the so far unreleased) tetgen 1.5
//success = in.load_tetmesh(basename_char);
//int object = tetgenbehavior::NODES;
//if(ext == "mesh")
//{
// object = tetgenbehavior::MEDIT;
//}
success = in.load_tetmesh(basename_char,!tetgenbehavior::MEDIT);
}
return success;
}

View File

@@ -1,62 +0,0 @@
// This file is part of libigl, a simple c++ geometry processing library.
//
// 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
// obtain one at http://mozilla.org/MPL/2.0/.
#ifndef IGL_COPYLEFT_TETGEN_READ_INTO_TETGENIO_H
#define IGL_COPYLEFT_TETGEN_READ_INTO_TETGENIO_H
#include "../../igl_inline.h"
#include <string>
#ifndef TETLIBRARY
#define TETLIBRARY
#endif
#include "tetgen.h" // Defined tetgenio, REAL
namespace igl
{
namespace copyleft
{
namespace tetgen
{
// Read a mesh or point set into tetgenio (input object for calling
// tetgen). Many file formats are already supported by tetgen:
// .off
// .ply
// .node
// .ply
// .medit
// .vtk
// etc.
// Notably it does not support .obj which is loaded by hand here (also
// demonstrating how to load points/faces programmatically)
//
// If the file extension is not recognized the filename is assumed to be
// the basename of a collection describe a tetmesh, (of which at least
// the .node file must exist):
// [filename].node
// [filename].ele
// [filename].face
// [filename].edge
// [filename].vol
//
// Inputs:
// path path to file or basename to files
// Outputs:
// in tetgenio input object
// Returns true on success, false on error
IGL_INLINE bool read_into_tetgenio(
const std::string & path,
tetgenio & in);
}
}
}
#ifndef IGL_STATIC_LIBRARY
# include "read_into_tetgenio.cpp"
#endif
#endif

View File

@@ -1,9 +1,9 @@
// This file is part of libigl, a simple c++ geometry processing library.
//
//
// 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/.
#include "tetgenio_to_tetmesh.h"
@@ -13,134 +13,142 @@
// STL includes
#include <iostream>
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,
std::vector<std::vector<REAL > > & V,
std::vector<std::vector<int> > & T,
std::vector<std::vector<int> > & F)
Eigen::PlainObjectBase<DerivedV>& V,
Eigen::PlainObjectBase<DerivedT>& T,
Eigen::PlainObjectBase<DerivedF>& F,
Eigen::PlainObjectBase<DerivedTM>& TM,
Eigen::PlainObjectBase<DerivedR>& R,
Eigen::PlainObjectBase<DerivedN>& N,
Eigen::PlainObjectBase<DerivedPT>& PT,
Eigen::PlainObjectBase<DerivedFT>& FT,
int & num_regions)
{
using namespace std;
// process points
if(out.pointlist == NULL)
{
cerr<<"^tetgenio_to_tetmesh Error: point list is NULL\n"<<endl;
std::cerr<<"^tetgenio_to_tetmesh Error: point list is NULL\n"<<std::endl;
return false;
}
V.resize(out.numberofpoints,vector<REAL>(3));
V.resize(out.numberofpoints,3);
// loop over points
for(int i = 0;i < out.numberofpoints; i++)
{
V[i][0] = out.pointlist[i*3+0];
V[i][1] = out.pointlist[i*3+1];
V[i][2] = out.pointlist[i*3+2];
V(i,0) = out.pointlist[i*3+0];
V(i,1) = out.pointlist[i*3+1];
V(i,2) = out.pointlist[i*3+2];
}
// process tets
if(out.tetrahedronlist == NULL)
{
cerr<<"^tetgenio_to_tetmesh Error: tet list is NULL\n"<<endl;
std::cerr<<"^tetgenio_to_tetmesh Error: tet list is NULL\n"<<std::endl;
return false;
}
// When would this not be 4?
assert(out.numberofcorners == 4);
T.resize(out.numberoftetrahedra,vector<int>(out.numberofcorners));
int min_index = 1e7;
int max_index = -1e7;
T.resize(out.numberoftetrahedra,out.numberofcorners);
// loop over tetrahedra
for(int i = 0; i < out.numberoftetrahedra; i++)
{
for(int j = 0; j<out.numberofcorners; j++)
{
int index = out.tetrahedronlist[i * out.numberofcorners + j];
T[i][j] = index;
min_index = (min_index > index ? index : min_index);
max_index = (max_index < index ? index : max_index);
T(i,j) = out.tetrahedronlist[i * out.numberofcorners + j];
}
}
assert(min_index >= 0);
assert(max_index >= 0);
assert(max_index < (int)V.size());
cout<<out.numberoftrifaces<<endl;
assert(T.maxCoeff() >= 0);
assert(T.minCoeff() >= 0);
assert(T.maxCoeff() < V.rows());
// When would this not be 4?
F.clear();
F.resize(out.numberoftrifaces,3);
// loop over tetrahedra
for(int i = 0; i < out.numberoftrifaces; i++)
{
if(out.trifacemarkerlist[i]>=0)
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)
{
vector<int> face(3);
for(int j = 0; j<3; j++)
TM(i) = out.pointmarkerlist[i];
}
}
if(out.tetrahedronattributelist)
{
R.resize(out.numberoftetrahedra);
std::unordered_map<REAL, REAL> 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++)
{
face[j] = out.trifacelist[i * 3 + 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];
}
F.push_back(face);
}
}
return true;
}
IGL_INLINE bool igl::copyleft::tetgen::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 tetgenio_to_tetmesh(out,V,T,F);
}
template <typename DerivedV, typename DerivedT, typename DerivedF>
IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
const tetgenio & out,
Eigen::PlainObjectBase<DerivedV>& V,
Eigen::PlainObjectBase<DerivedT>& T,
Eigen::PlainObjectBase<DerivedF>& F)
{
using namespace std;
vector<vector<REAL> > vV;
vector<vector<int> > vT;
vector<vector<int> > vF;
bool success = tetgenio_to_tetmesh(out,vV,vT,vF);
if(!success)
{
return false;
}
bool V_rect = list_to_matrix(vV,V);
if(!V_rect)
{
// igl::list_to_matrix(vV,V) already printed error message to std err
return false;
}
bool T_rect = list_to_matrix(vT,T);
if(!T_rect)
{
// igl::list_to_matrix(vT,T) already printed error message to std err
return false;
}
bool F_rect = list_to_matrix(vF,F);
if(!F_rect)
{
return false;
}
return true;
}
template <typename DerivedV, typename DerivedT>
IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
const tetgenio & out,
Eigen::PlainObjectBase<DerivedV>& V,
Eigen::PlainObjectBase<DerivedT>& T)
{
Eigen::Matrix<typename DerivedT::Scalar,Eigen::Dynamic,3> F;
return tetgenio_to_tetmesh(out,V,T,F);
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
template bool igl::copyleft::tetgen::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> >&);
// generated by autoexplicit.sh
template bool igl::copyleft::tetgen::tetgenio_to_tetmesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -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>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, int&);
#endif

View File

@@ -14,6 +14,7 @@
#endif
#include "tetgen.h" // Defined tetgenio, REAL
#include <vector>
#include <unordered_map>
#include <Eigen/Core>
namespace igl
{
@@ -21,39 +22,40 @@ namespace igl
{
namespace tetgen
{
// Extract a tetrahedral mesh from a tetgenio object
// Inputs:
// out tetgenio output object
// 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,
std::vector<std::vector<int> > & T);
// Wrapper with Eigen types
// Templates:
// DerivedV real-value: i.e. from MatrixXd
// DerivedT integer-value: i.e. from MatrixXi
template <typename DerivedV, typename DerivedT, typename DerivedF>
/// Convert a tetgenio to a tetmesh
///
/// @param[in] out output of tetrahedralization
/// @param[out] V #V by 3 list of mesh vertex positions
/// @param[out] T #T by 4 list of mesh tet indices into V
/// @param[out] F #F by 3 list of mesh triangle indices into V
/// @param[out] TM #T by 1 list of material indices into R
/// @param[out] R #TT list of region ID for each tetrahedron
/// @param[out] N #TT by 4 list of indices neighbors for each tetrahedron ('n')
/// @param[out] PT #TV list of incident tetrahedron for a vertex ('m')
/// @param[out] FT #TF by 2 list of tetrahedrons sharing a triface ('nn')
/// @param[out] num_regions Number of regions in output mesh
///
/// \bug Assumes that out.numberoftetrahedronattributes == 1 or 0
template <
typename DerivedV,
typename DerivedT,
typename DerivedF,
typename DerivedTM,
typename DerivedR,
typename DerivedN,
typename DerivedPT,
typename DerivedFT>
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,
Eigen::PlainObjectBase<DerivedV>& V,
Eigen::PlainObjectBase<DerivedT>& T);
Eigen::PlainObjectBase<DerivedF>& F,
Eigen::PlainObjectBase<DerivedTM>& TM,
Eigen::PlainObjectBase<DerivedR>& R,
Eigen::PlainObjectBase<DerivedN>& N,
Eigen::PlainObjectBase<DerivedPT>& PT,
Eigen::PlainObjectBase<DerivedFT>& FT,
int & num_regions);
}
}
}

View File

@@ -1,15 +1,15 @@
// This file is part of libigl, a simple c++ geometry processing library.
//
//
// 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/.
#include "tetrahedralize.h"
#include "mesh_to_tetgenio.h"
#include "tetgenio_to_tetmesh.h"
// IGL includes
// IGL includes
#include "../../matrix_to_list.h"
#include "../../list_to_matrix.h"
#include "../../boundary_facets.h"
@@ -18,22 +18,43 @@
#include <cassert>
#include <iostream>
template <
typename DerivedV,
typename DerivedF,
typename DerivedH,
typename DerivedVM,
typename DerivedFM,
typename DerivedR,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF,
typename DerivedTM,
typename DerivedTR,
typename DerivedTN,
typename DerivedPT,
typename DerivedFT>
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
const std::vector<std::vector<REAL > > & V,
const std::vector<std::vector<int> > & F,
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedH>& H,
const Eigen::MatrixBase<DerivedVM>& VM,
const Eigen::MatrixBase<DerivedFM>& FM,
const Eigen::MatrixBase<DerivedR>& R,
const std::string switches,
std::vector<std::vector<REAL > > & TV,
std::vector<std::vector<int > > & TT,
std::vector<std::vector<int> > & TF)
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
Eigen::PlainObjectBase<DerivedTF>& TF,
Eigen::PlainObjectBase<DerivedTM>& TM,
Eigen::PlainObjectBase<DerivedTR>& TR,
Eigen::PlainObjectBase<DerivedTN>& TN,
Eigen::PlainObjectBase<DerivedPT>& PT,
Eigen::PlainObjectBase<DerivedFT>& FT,
int & num_regions)
{
using namespace std;
// REAL is what tetgen is using as floating point precision
// Prepare input
tetgenio in,out;
bool success;
success = mesh_to_tetgenio(V,F,in);
if(!success)
{
return -1;
}
mesh_to_tetgenio(V,F,H,VM,FM,R,in);
try
{
char * cswitches = new char[switches.size() + 1];
@@ -42,179 +63,56 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
delete[] cswitches;
}catch(int e)
{
cerr<<"^"<<__FUNCTION__<<": TETGEN CRASHED... KABOOOM!!!"<<endl;
std::cerr<<"^"<<__FUNCTION__<<": TETGEN CRASHED... KABOOOM!!!"<<std::endl;
return 1;
}
if(out.numberoftetrahedra == 0)
{
cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<endl;
std::cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<std::endl;
return 2;
}
success = tetgenio_to_tetmesh(out,TV,TT,TF);
if(!success)
// Prepare output
bool ret = tetgenio_to_tetmesh(out,TV,TT,TF,TM,TR,TN,PT,FT,num_regions);
if(!ret)
{
return -1;
}
//boundary_facets(TT,TF);
if(TF.size() == 0)
{
boundary_facets(TT,TF);
}
return 0;
}
template <
typename DerivedV,
typename DerivedF,
typename DerivedTV,
typename DerivedTT,
typename DerivedV,
typename DerivedF,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF>
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const std::string switches,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
Eigen::PlainObjectBase<DerivedTF>& TF)
{
using namespace std;
vector<vector<REAL> > vV,vTV;
vector<vector<int> > vF,vTT,vTF;
matrix_to_list(V,vV);
matrix_to_list(F,vF);
int e = tetrahedralize(vV,vF,switches,vTV,vTT,vTF);
if(e == 0)
{
bool TV_rect = list_to_matrix(vTV,TV);
if(!TV_rect)
{
return 3;
}
bool TT_rect = list_to_matrix(vTT,TT);
if(!TT_rect)
{
return 3;
}
bool TF_rect = list_to_matrix(vTF,TF);
if(!TF_rect)
{
return 3;
}
}
return e;
}
template <
typename DerivedV,
typename DerivedF,
typename DerivedVM,
typename DerivedFM,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF,
typename DerivedTM>
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
const Eigen::PlainObjectBase<DerivedVM>& VM,
const Eigen::PlainObjectBase<DerivedFM>& FM,
const std::string switches,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
Eigen::PlainObjectBase<DerivedTF>& TF,
Eigen::PlainObjectBase<DerivedTM>& TM)
{
using namespace std;
vector<vector<REAL> > vV,vTV;
vector<vector<int> > vF,vTT,vTF;
vector<int> vTM;
matrix_to_list(V,vV);
matrix_to_list(F,vF);
vector<int> vVM = matrix_to_list(VM);
vector<int> vFM = matrix_to_list(FM);
int e = tetrahedralize(vV,vF,vVM,vFM,switches,vTV,vTT,vTF,vTM);
if(e == 0)
{
bool TV_rect = list_to_matrix(vTV,TV);
if(!TV_rect)
{
return false;
}
bool TT_rect = list_to_matrix(vTT,TT);
if(!TT_rect)
{
return false;
}
bool TF_rect = list_to_matrix(vTF,TF);
if(!TF_rect)
{
return false;
}
bool TM_rect = list_to_matrix(vTM,TM);
if(!TM_rect)
{
return false;
}
}
return e;
}
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
const std::vector<std::vector<REAL > > & V,
const std::vector<std::vector<int> > & F,
const std::vector<int> & VM,
const std::vector<int> & FM,
const std::string switches,
std::vector<std::vector<REAL > > & TV,
std::vector<std::vector<int > > & TT,
std::vector<std::vector<int> > & TF,
std::vector<int> & TM)
{
using namespace std;
tetgenio in,out;
bool success;
success = mesh_to_tetgenio(V,F,in);
if(!success)
{
return -1;
}
in.pointmarkerlist = new int[VM.size()];
for (int i = 0; i < VM.size(); ++i) {
in.pointmarkerlist[i] = VM[i];
}
// These have already been created in mesh_to_tetgenio.
// Reset them here.
for (int i = 0; i < FM.size(); ++i) {
in.facetmarkerlist[i] = FM[i];
}
try
{
char * cswitches = new char[switches.size() + 1];
std::strcpy(cswitches,switches.c_str());
::tetrahedralize(cswitches,&in, &out);
delete[] cswitches;
}catch(int e)
{
cerr<<"^"<<__FUNCTION__<<": TETGEN CRASHED... KABOOOM!!!"<<endl;
return 1;
}
if(out.numberoftetrahedra == 0)
{
cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<endl;
return 2;
}
success = tetgenio_to_tetmesh(out,TV,TT,TF);
if(!success)
{
return -1;
}
TM.resize(out.numberofpoints);
for (int i = 0; i < out.numberofpoints; ++i) {
TM[i] = out.pointmarkerlist[i];
}
//boundary_facets(TT,TF);
return 0;
Eigen::VectorXi VM,FM;
Eigen::MatrixXd H,R;
Eigen::VectorXi TM,TR,PT;
Eigen::MatrixXi FT,TN;
int numRegions;
return tetrahedralize(V,F,H,VM,FM,R,switches,TV,TT,TF,TM,TR,TN,PT,FT,numRegions);
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
template int igl::copyleft::tetgen::tetrahedralize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -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&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
template int igl::copyleft::tetgen::tetrahedralize<Eigen::Matrix<double, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, 1, 0, -1, 1>,Eigen::Matrix<int, -1, 1, 0, -1, 1>,Eigen::Matrix<double, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, 1, 0, -1, 1> >(const 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<int, -1, 1, 0, -1, 1> > &,const Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > &,const std::basic_string<char, std::char_traits<char>, std::allocator<char> >,Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > &,Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > &,Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > &);
template int igl::copyleft::tetgen::tetrahedralize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -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<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
// generated by autoexplicit.sh
template int igl::copyleft::tetgen::tetrahedralize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char>>, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&);
// generated by autoexplicit.sh
template int igl::copyleft::tetgen::tetrahedralize<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, 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::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char>>, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>>&, int&);
#endif

View File

@@ -15,7 +15,7 @@
#ifndef TETLIBRARY
#define TETLIBRARY
#endif
#include "tetgen.h" // Defined REAL
#include <tetgen.h> // Defined REAL
namespace igl
{
@@ -23,107 +23,104 @@ namespace igl
{
namespace tetgen
{
// Mesh the interior of a surface mesh (V,F) using tetgen
//
// Inputs:
// V #V by 3 vertex position list
// F #F list of polygon face indices into V (0-indexed)
// switches string of tetgen options (See tetgen documentation) e.g.
// "pq1.414a0.01" tries to mesh the interior of a given surface with
// quality and area constraints
// "" will mesh the convex hull constrained to pass through V (ignores F)
// Outputs:
// TV #V by 3 vertex position list
// TT #T by 4 list of tet face indices
// TF #F by 3 list of triangle face indices
// Returns status:
// 0 success
// 1 tetgen threw exception
// 2 tetgen did not crash but could not create any tets (probably there are
// holes, duplicate faces etc.)
// -1 other error
IGL_INLINE int tetrahedralize(
const std::vector<std::vector<REAL > > & V,
const std::vector<std::vector<int> > & F,
const std::string switches,
std::vector<std::vector<REAL > > & TV,
std::vector<std::vector<int > > & TT,
std::vector<std::vector<int> > & TF);
// Wrapper with Eigen types
// Templates:
// DerivedV real-value: i.e. from MatrixXd
// DerivedF integer-value: i.e. from MatrixXi
/// Mesh the interior of a surface mesh (V,F) using tetgen
///
/// @param[in] V #V by 3 vertex position list
/// @param[in] F #F list of polygon face indices into V (0-indexed)
/// @param[in] H #H by 3 list of seed points inside holes
/// @param[in] VM #VM list of vertex markers
/// @param[in] FM #FM list of face markers
/// @param[in] R #R by 5 list of region attributes
/// @param[in] switches string of tetgen options (See tetgen documentation) e.g.
/// "pq1.414a0.01" tries to mesh the interior of a given surface with
/// quality and area constraints
/// "" will mesh the convex hull constrained to pass through V (ignores F)
/// @param[out] TV #TV by 3 vertex position list
/// @param[out] TT #TT by 4 list of tet face indices
/// @param[out] TF #TF by 3 list of triangle face indices ('f', else
/// `boundary_facets` is called on TT)
/// @param[out] TR #TT list of region ID for each tetrahedron
/// @param[out] TN #TT by 4 list of indices neighbors for each tetrahedron ('n')
/// @param[out] PT #TV list of incident tetrahedron for a vertex ('m')
/// @param[out] FT #TF by 2 list of tetrahedrons sharing a triface ('nn')
/// @param[out] num_regions Number of regions in output mesh
/// @return status:
/// 0 success
/// 1 tetgen threw exception
/// 2 tetgen did not crash but could not create any tets (probably there are
/// holes, duplicate faces etc.)
/// -1 other error
///
/// \note The polygons F can contain polygons with different number of vertices.
/// Trailing unused columns are filled with -1. For example, triangles and
/// segments can be specified using a #F x 3 matrix: for segments the third
/// column contains -1.
///
/// \note Tetgen mixes integer region ids in with other region data `attr
/// = (int) in->regionlist[i + 3];`. So it's declared safe to use integer
/// types for `TR` since this also assumes that there's a single tet
/// attribute and that it's the region id.
///
/// #### Example
///
/// ```cpp
/// Eigen::MatrixXd V;
/// Eigen::MatrixXi F;
/// …
/// Eigen::VectorXi VM,FM;
/// Eigen::MatrixXd H,R;
/// Eigen::VectorXi TM,TR,PT;
/// Eigen::MatrixXi FT,TN;
/// int numRegions;
/// tetrahedralize(V,F,H,VM,FM,R,switches,TV,TT,TF,TM,TR,TN,PT,FT,numRegions);
/// ```
template <
typename DerivedV,
typename DerivedF,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF>
typename DerivedV,
typename DerivedF,
typename DerivedH,
typename DerivedVM,
typename DerivedFM,
typename DerivedR,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF,
typename DerivedTM,
typename DerivedTR,
typename DerivedTN,
typename DerivedPT,
typename DerivedFT>
IGL_INLINE int tetrahedralize(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
const std::string switches,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
Eigen::PlainObjectBase<DerivedTF>& TF);
// Mesh the interior of a surface mesh (V,F) using tetgen
//
// Inputs:
// V #V by 3 vertex position list
// F #F list of polygon face indices into V (0-indexed)
// M #V list of markers for vertices
// switches string of tetgen options (See tetgen documentation) e.g.
// "pq1.414a0.01" tries to mesh the interior of a given surface with
// quality and area constraints
// "" will mesh the convex hull constrained to pass through V (ignores F)
// Outputs:
// TV #V by 3 vertex position list
// TT #T by 4 list of tet face indices
// TF #F by 3 list of triangle face indices
// TM #V list of markers for vertices
// Returns status:
// 0 success
// 1 tetgen threw exception
// 2 tetgen did not crash but could not create any tets (probably there are
// holes, duplicate faces etc.)
// -1 other error
IGL_INLINE int tetrahedralize(
const std::vector<std::vector<REAL > > & V,
const std::vector<std::vector<int> > & F,
const std::vector<int> & VM,
const std::vector<int> & FM,
const std::string switches,
std::vector<std::vector<REAL > > & TV,
std::vector<std::vector<int > > & TT,
std::vector<std::vector<int> > & TF,
std::vector<int> & TM);
// Wrapper with Eigen types
// Templates:
// DerivedV real-value: i.e. from MatrixXd
// DerivedF integer-value: i.e. from MatrixXi
template <
typename DerivedV,
typename DerivedF,
typename DerivedVM,
typename DerivedFM,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF,
typename DerivedTM>
IGL_INLINE int tetrahedralize(
const Eigen::PlainObjectBase<DerivedV>& V,
const Eigen::PlainObjectBase<DerivedF>& F,
const Eigen::PlainObjectBase<DerivedVM>& VM,
const Eigen::PlainObjectBase<DerivedFM>& FM,
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const Eigen::MatrixBase<DerivedH>& H,
const Eigen::MatrixBase<DerivedVM>& VM,
const Eigen::MatrixBase<DerivedFM>& FM,
const Eigen::MatrixBase<DerivedR>& R,
const std::string switches,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
Eigen::PlainObjectBase<DerivedTF>& TF,
Eigen::PlainObjectBase<DerivedTM>& TM);
}
Eigen::PlainObjectBase<DerivedTM>& TM,
Eigen::PlainObjectBase<DerivedTR>& TR,
Eigen::PlainObjectBase<DerivedTN>& TN,
Eigen::PlainObjectBase<DerivedPT>& PT,
Eigen::PlainObjectBase<DerivedFT>& FT,
int & num_regions);
/// \overload
template <
typename DerivedV,
typename DerivedF,
typename DerivedTV,
typename DerivedTT,
typename DerivedTF>
IGL_INLINE int tetrahedralize(
const Eigen::MatrixBase<DerivedV>& V,
const Eigen::MatrixBase<DerivedF>& F,
const std::string switches,
Eigen::PlainObjectBase<DerivedTV>& TV,
Eigen::PlainObjectBase<DerivedTT>& TT,
Eigen::PlainObjectBase<DerivedTF>& TF);
}
}
}