mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
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 *e3c277b9eeFor 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:
@@ -3,7 +3,7 @@
|
||||
#include "../triangle/triangulate.h"
|
||||
#include "../remove_duplicate_vertices.h"
|
||||
#include "../remove_unreferenced.h"
|
||||
#include "../slice_mask.h"
|
||||
#include "../placeholders.h"
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
@@ -23,8 +23,6 @@ IGL_INLINE void igl::triangle::cdt(
|
||||
{
|
||||
assert(V.cols() == 2);
|
||||
assert(E.cols() == 2);
|
||||
typedef typename DerivedV::Scalar Scalar;
|
||||
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,2> MatrixX2S;
|
||||
//MatrixX2S BV;
|
||||
//Eigen::MatrixXi BE;
|
||||
//igl::bounding_box(V,BV,BE);
|
||||
@@ -37,7 +35,8 @@ IGL_INLINE void igl::triangle::cdt(
|
||||
Eigen::VectorXi _;
|
||||
igl::remove_duplicate_vertices(DerivedWV(WV),DerivedWE(WE),1e-10,WV,_,J,WE);
|
||||
// Remove degenerate edges
|
||||
igl::slice_mask(DerivedWE(WE),(WE.array().col(0) != WE.array().col(1)).eval(),1,WE);
|
||||
const Eigen::Array<bool,Eigen::Dynamic,1> keep = (WE.array().col(0) != WE.array().col(1));
|
||||
WE = WE(keep,igl::placeholders::all).eval();
|
||||
// c flag must be present
|
||||
igl::triangle::triangulate(DerivedWV(WV),WE,DerivedWV(),flags,WV,WF);
|
||||
Eigen::VectorXi UJ;
|
||||
|
||||
@@ -8,28 +8,22 @@ namespace igl
|
||||
{
|
||||
namespace triangle
|
||||
{
|
||||
// CDT Construct the constrained delaunay triangulation of the convex hull
|
||||
// of a given set of points and segments in 2D. This differs from a direct
|
||||
// call to triangulate because it will preprocess the input to remove
|
||||
// duplicates and return an adjusted segment list on the output.
|
||||
//
|
||||
//
|
||||
// BACKGROUND_MESH Construct a background mesh for a (messy) texture mesh with
|
||||
// cosntraint edges that are about to deform.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 2 list of texture mesh vertices
|
||||
// E #E by 2 list of constraint edge indices into V
|
||||
// flags string of triangle flags should contain "-c" unless the
|
||||
// some subset of segments are known to enclose all other
|
||||
// points/segments.
|
||||
// Outputs:
|
||||
// WV #WV by 2 list of background mesh vertices
|
||||
// WF #WF by 2 list of background mesh triangle indices into WV
|
||||
// WE #WE by 2 list of constraint edge indices into WV (might be smaller
|
||||
// than E because degenerate constraints have been removed)
|
||||
// J #V list of indices into WF/WE for each vertex in V
|
||||
//
|
||||
/// Construct the constrained delaunay triangulation of the convex hull
|
||||
/// of a given set of points and segments in 2D. This differs from a direct
|
||||
/// call to triangulate because it will preprocess the input to remove
|
||||
/// duplicates and return an adjusted segment list on the output.
|
||||
///
|
||||
/// @param[in] V #V by 2 list of texture mesh vertices
|
||||
/// @param[in] E #E by 2 list of constraint edge indices into V
|
||||
/// @param[in] flags string of triangle flags should contain "-c" unless the
|
||||
/// some subset of segments are known to enclose all other
|
||||
/// points/segments.
|
||||
/// @param[out] WV #WV by 2 list of background mesh vertices
|
||||
/// @param[out] WF #WF by 2 list of background mesh triangle indices into WV
|
||||
/// @param[out] WE #WE by 2 list of constraint edge indices into WV (might be smaller
|
||||
/// than E because degenerate constraints have been removed)
|
||||
/// @param[out] J #V list of indices into WF/WE for each vertex in V
|
||||
///
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedE,
|
||||
|
||||
110
deps_src/libigl/igl/triangle/refine.cpp
Normal file
110
deps_src/libigl/igl/triangle/refine.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2024 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 "refine.h"
|
||||
#include "triangle_header.h"
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedE,
|
||||
typename DerivedF,
|
||||
typename DerivedV2,
|
||||
typename DerivedF2>
|
||||
IGL_INLINE void igl::triangle::refine(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedE> & E,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const std::string flags,
|
||||
Eigen::PlainObjectBase<DerivedV2> & V2,
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace Eigen;
|
||||
assert(V.cols() == 2);
|
||||
assert(F.cols() == 3);
|
||||
// Prepare the flags
|
||||
std::string full_flags = flags + "rzB" + (E.size()?"p":"");
|
||||
|
||||
typedef Map< Matrix<double,Dynamic,Dynamic,RowMajor> > MapXdr;
|
||||
typedef Map< Matrix<int,Dynamic,Dynamic,RowMajor> > MapXir;
|
||||
|
||||
// To-do: reduce duplicate code with triangulate.cpp
|
||||
// Prepare the input struct
|
||||
triangulateio in;
|
||||
in.numberofpoints = V.rows();
|
||||
in.pointlist = (double*)calloc(V.size(),sizeof(double));
|
||||
{
|
||||
MapXdr inpl(in.pointlist,V.rows(),V.cols());
|
||||
inpl = V.template cast<double>();
|
||||
}
|
||||
|
||||
in.numberofpointattributes = 0;
|
||||
in.pointmarkerlist = (int*)calloc(V.size(),sizeof(int)) ;
|
||||
for(unsigned i=0;i<V.rows();++i) in.pointmarkerlist[i] = 1;
|
||||
|
||||
in.numberoftriangles = F.rows();
|
||||
in.trianglelist = (int*)calloc(F.size(),sizeof(int));
|
||||
{
|
||||
MapXir insl(in.trianglelist,F.rows(),F.cols());
|
||||
insl = F.template cast<int>();
|
||||
}
|
||||
in.numberoftriangleattributes = 0;
|
||||
in.triangleattributelist = NULL;
|
||||
|
||||
// Why?
|
||||
in.numberofcorners = 3;
|
||||
|
||||
//in.numberofsegments = 0;
|
||||
//in.segmentlist = NULL;
|
||||
//in.segmentmarkerlist = NULL;
|
||||
|
||||
in.numberofsegments = E.size()?E.rows():0;
|
||||
in.segmentlist = (int*)calloc(E.size(),sizeof(int));
|
||||
{
|
||||
MapXir insl(in.segmentlist,E.rows(),E.cols());
|
||||
insl = E.template cast<int>();
|
||||
}
|
||||
// Empty edge markers (to-do)
|
||||
Eigen::VectorXi EM;
|
||||
in.segmentmarkerlist = (int*)calloc(E.rows(),sizeof(int));
|
||||
for (unsigned i=0;i<E.rows();++i) in.segmentmarkerlist[i] = EM.size()?EM(i):1;
|
||||
|
||||
in.numberofholes = 0;
|
||||
in.holelist = NULL;
|
||||
in.numberofregions = 0;
|
||||
|
||||
// Prepare the output struct
|
||||
triangulateio out;
|
||||
out.pointlist = NULL;
|
||||
out.trianglelist = NULL;
|
||||
out.segmentlist = NULL;
|
||||
out.segmentmarkerlist = NULL;
|
||||
out.pointmarkerlist = NULL;
|
||||
|
||||
// Call triangle
|
||||
::triangulate(const_cast<char*>(full_flags.c_str()), &in, &out, 0);
|
||||
|
||||
// Return the mesh
|
||||
V2 = MapXdr(out.pointlist,out.numberofpoints,2).cast<typename DerivedV2::Scalar>();
|
||||
F2 = MapXir(out.trianglelist,out.numberoftriangles,3).cast<typename DerivedF2::Scalar>();
|
||||
|
||||
// Cleanup in
|
||||
free(in.pointlist);
|
||||
free(in.pointmarkerlist);
|
||||
free(in.trianglelist );
|
||||
// Cleanup out
|
||||
free(out.pointlist);
|
||||
free(out.trianglelist);
|
||||
free(out.segmentlist);
|
||||
free(out.segmentmarkerlist);
|
||||
free(out.pointmarkerlist);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::triangle::refine<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<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<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>>&);
|
||||
#endif
|
||||
47
deps_src/libigl/igl/triangle/refine.h
Normal file
47
deps_src/libigl/igl/triangle/refine.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2024 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/.
|
||||
#ifndef IGL_TRIANGLE_REFINE_H
|
||||
#define IGL_TRIANGLE_REFINE_H
|
||||
#include "../igl_inline.h"
|
||||
#include <string>
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace triangle
|
||||
{
|
||||
/// Refine an existing triangulation.
|
||||
///
|
||||
/// @param[in] V #V by 2 list of 2D vertex positions
|
||||
/// @param[in] E #E by 2 list of vertex ids forming segments
|
||||
/// @param[in] F #F by 3 list of vertex ids forming triangles
|
||||
/// @param[in] flags string of options pass to triangle (see triangle documentation)
|
||||
/// @param[out] V2 #V2 by 2 coordinates of the vertives of the generated triangulation
|
||||
/// @param[out] F2 #F2 by 3 list of indices forming the faces of the generated triangulation
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedE,
|
||||
typename DerivedF,
|
||||
typename DerivedV2,
|
||||
typename DerivedF2>
|
||||
IGL_INLINE void refine(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedE> & E,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const std::string flags,
|
||||
Eigen::PlainObjectBase<DerivedV2> & V2,
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "refine.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
727
deps_src/libigl/igl/triangle/scaf.cpp
Normal file
727
deps_src/libigl/igl/triangle/scaf.cpp
Normal file
@@ -0,0 +1,727 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2018 Zhongshi Jiang <jiangzs@nyu.edu>
|
||||
//
|
||||
// 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 "scaf.h"
|
||||
#include "triangulate.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/IterativeLinearSolvers>
|
||||
#include <Eigen/Sparse>
|
||||
#include <Eigen/SparseCholesky>
|
||||
#include <Eigen/SparseQR>
|
||||
#include "../PI.h"
|
||||
#include "../Timer.h"
|
||||
#include "../boundary_loop.h"
|
||||
#include "../cat.h"
|
||||
#include "../IGL_ASSERT.h"
|
||||
#include "../doublearea.h"
|
||||
#include "../flip_avoiding_line_search.h"
|
||||
#include "../flipped_triangles.h"
|
||||
#include "../grad.h"
|
||||
#include "../harmonic.h"
|
||||
#include "../local_basis.h"
|
||||
#include "../map_vertices_to_circle.h"
|
||||
#include "../polar_svd.h"
|
||||
#include "../slice.h"
|
||||
#include "../slice_into.h"
|
||||
#include "../slim.h"
|
||||
#include "../placeholders.h"
|
||||
#include "../mapping_energy_with_jacobians.h"
|
||||
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
namespace igl
|
||||
{
|
||||
namespace triangle
|
||||
{
|
||||
namespace scaf
|
||||
{
|
||||
IGL_INLINE void update_scaffold(igl::triangle::SCAFData &s)
|
||||
{
|
||||
s.mv_num = s.m_V.rows();
|
||||
s.mf_num = s.m_T.rows();
|
||||
|
||||
s.v_num = s.w_uv.rows();
|
||||
s.sf_num = s.s_T.rows();
|
||||
|
||||
s.sv_num = s.v_num - s.mv_num;
|
||||
s.f_num = s.sf_num + s.mf_num;
|
||||
|
||||
s.s_M = Eigen::VectorXd::Constant(s.sf_num, s.scaffold_factor);
|
||||
}
|
||||
|
||||
IGL_INLINE void adjusted_grad(Eigen::MatrixXd &V,
|
||||
Eigen::MatrixXi &F,
|
||||
double area_threshold,
|
||||
Eigen::SparseMatrix<double> &Dx,
|
||||
Eigen::SparseMatrix<double> &Dy,
|
||||
Eigen::SparseMatrix<double> &Dz)
|
||||
{
|
||||
Eigen::VectorXd M;
|
||||
igl::doublearea(V, F, M);
|
||||
std::vector<int> degen;
|
||||
for (int i = 0; i < M.size(); i++)
|
||||
if (M(i) < area_threshold)
|
||||
degen.push_back(i);
|
||||
|
||||
Eigen::SparseMatrix<double> G;
|
||||
igl::grad(V, F, G);
|
||||
|
||||
Dx = G.topRows(F.rows());
|
||||
Dy = G.block(F.rows(), 0, F.rows(), V.rows());
|
||||
Dz = G.bottomRows(F.rows());
|
||||
|
||||
// handcraft uniform gradient for faces area falling below threshold.
|
||||
double sin60 = std::sin(igl::PI / 3);
|
||||
double cos60 = std::cos(igl::PI / 3);
|
||||
double deno = std::sqrt(sin60 * area_threshold);
|
||||
Eigen::MatrixXd standard_grad(3, 3);
|
||||
standard_grad << -sin60 / deno, sin60 / deno, 0,
|
||||
-cos60 / deno, -cos60 / deno, 1 / deno,
|
||||
0, 0, 0;
|
||||
|
||||
for (auto k : degen)
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
Dx.coeffRef(k, F(k, j)) = standard_grad(0, j);
|
||||
Dy.coeffRef(k, F(k, j)) = standard_grad(1, j);
|
||||
Dz.coeffRef(k, F(k, j)) = standard_grad(2, j);
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void compute_scaffold_gradient_matrix(SCAFData &s,
|
||||
Eigen::SparseMatrix<double> &D1,
|
||||
Eigen::SparseMatrix<double> &D2)
|
||||
{
|
||||
using namespace Eigen;
|
||||
Eigen::SparseMatrix<double> G;
|
||||
MatrixXi F_s = s.s_T;
|
||||
int vn = s.v_num;
|
||||
MatrixXd V = MatrixXd::Zero(vn, 3);
|
||||
V.leftCols(2) = s.w_uv;
|
||||
|
||||
double min_bnd_edge_len = INFINITY;
|
||||
int acc_bnd = 0;
|
||||
for (int i = 0; i < s.bnd_sizes.size(); i++)
|
||||
{
|
||||
int current_size = s.bnd_sizes[i];
|
||||
|
||||
for (int e = acc_bnd; e < acc_bnd + current_size - 1; e++)
|
||||
{
|
||||
min_bnd_edge_len = (std::min)(min_bnd_edge_len,
|
||||
(s.w_uv.row(s.internal_bnd(e)) -
|
||||
s.w_uv.row(s.internal_bnd(e + 1)))
|
||||
.squaredNorm());
|
||||
}
|
||||
min_bnd_edge_len = (std::min)(min_bnd_edge_len,
|
||||
(s.w_uv.row(s.internal_bnd(acc_bnd)) -
|
||||
s.w_uv.row(s.internal_bnd(acc_bnd + current_size - 1)))
|
||||
.squaredNorm());
|
||||
acc_bnd += current_size;
|
||||
}
|
||||
|
||||
double area_threshold = min_bnd_edge_len / 4.0;
|
||||
Eigen::SparseMatrix<double> Dx, Dy, Dz;
|
||||
adjusted_grad(V, F_s, area_threshold, Dx, Dy, Dz);
|
||||
|
||||
MatrixXd F1, F2, F3;
|
||||
igl::local_basis(V, F_s, F1, F2, F3);
|
||||
D1 = F1.col(0).asDiagonal() * Dx + F1.col(1).asDiagonal() * Dy +
|
||||
F1.col(2).asDiagonal() * Dz;
|
||||
D2 = F2.col(0).asDiagonal() * Dx + F2.col(1).asDiagonal() * Dy +
|
||||
F2.col(2).asDiagonal() * Dz;
|
||||
}
|
||||
|
||||
IGL_INLINE void mesh_improve(igl::triangle::SCAFData &s)
|
||||
{
|
||||
using namespace Eigen;
|
||||
MatrixXd m_uv = s.w_uv.topRows(s.mv_num);
|
||||
MatrixXd V_bnd;
|
||||
V_bnd.resize(s.internal_bnd.size(), 2);
|
||||
for (int i = 0; i < s.internal_bnd.size(); i++) // redoing step 1.
|
||||
{
|
||||
V_bnd.row(i) = m_uv.row(s.internal_bnd(i));
|
||||
}
|
||||
|
||||
if (s.rect_frame_V.size() == 0)
|
||||
{
|
||||
Matrix2d ob; // = rect_corners;
|
||||
{
|
||||
VectorXd uv_max = m_uv.colwise().maxCoeff();
|
||||
VectorXd uv_min = m_uv.colwise().minCoeff();
|
||||
VectorXd uv_mid = (uv_max + uv_min) / 2.;
|
||||
|
||||
Eigen::Array2d scaf_range(3, 3);
|
||||
ob.row(0) = uv_mid.array() + scaf_range * ((uv_min - uv_mid).array());
|
||||
ob.row(1) = uv_mid.array() + scaf_range * ((uv_max - uv_mid).array());
|
||||
}
|
||||
Vector2d rect_len;
|
||||
rect_len << ob(1, 0) - ob(0, 0), ob(1, 1) - ob(0, 1);
|
||||
int frame_points = 5;
|
||||
|
||||
s.rect_frame_V.resize(4 * frame_points, 2);
|
||||
for (int i = 0; i < frame_points; i++)
|
||||
{
|
||||
// 0,0;0,1
|
||||
s.rect_frame_V.row(i) << ob(0, 0), ob(0, 1) + i * rect_len(1) / frame_points;
|
||||
// 0,0;1,1
|
||||
s.rect_frame_V.row(i + frame_points)
|
||||
<< ob(0, 0) + i * rect_len(0) / frame_points,
|
||||
ob(1, 1);
|
||||
// 1,0;1,1
|
||||
s.rect_frame_V.row(i + 2 * frame_points) << ob(1, 0), ob(1, 1) - i * rect_len(1) / frame_points;
|
||||
// 1,0;0,1
|
||||
s.rect_frame_V.row(i + 3 * frame_points)
|
||||
<< ob(1, 0) - i * rect_len(0) / frame_points,
|
||||
ob(0, 1);
|
||||
// 0,0;0,1
|
||||
}
|
||||
s.frame_ids = Eigen::VectorXi::LinSpaced(s.rect_frame_V.rows(), s.mv_num, s.mv_num + s.rect_frame_V.rows());
|
||||
}
|
||||
|
||||
// Concatenate Vert and Edge
|
||||
MatrixXd V;
|
||||
MatrixXi E;
|
||||
igl::cat(1, V_bnd, s.rect_frame_V, V);
|
||||
E.resize(V.rows(), 2);
|
||||
for (int i = 0; i < E.rows(); i++)
|
||||
E.row(i) << i, i + 1;
|
||||
int acc_bs = 0;
|
||||
for (auto bs : s.bnd_sizes)
|
||||
{
|
||||
E(acc_bs + bs - 1, 1) = acc_bs;
|
||||
acc_bs += bs;
|
||||
}
|
||||
E(V.rows() - 1, 1) = acc_bs;
|
||||
assert(acc_bs == s.internal_bnd.size());
|
||||
|
||||
MatrixXd H = MatrixXd::Zero(s.component_sizes.size(), 2);
|
||||
{
|
||||
int hole_f = 0;
|
||||
int hole_i = 0;
|
||||
for (auto cs : s.component_sizes)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
H.row(hole_i) += m_uv.row(s.m_T(hole_f, i)); // redoing step 2
|
||||
hole_f += cs;
|
||||
hole_i++;
|
||||
}
|
||||
}
|
||||
H /= 3.;
|
||||
|
||||
MatrixXd uv2;
|
||||
igl::triangle::triangulate(V, E, H, std::basic_string<char>("qYYQ"), uv2, s.s_T);
|
||||
auto bnd_n = s.internal_bnd.size();
|
||||
|
||||
for (auto i = 0; i < s.s_T.rows(); i++)
|
||||
for (auto j = 0; j < s.s_T.cols(); j++)
|
||||
{
|
||||
auto &x = s.s_T(i, j);
|
||||
if (x < bnd_n)
|
||||
x = s.internal_bnd(x);
|
||||
else
|
||||
x += m_uv.rows() - bnd_n;
|
||||
}
|
||||
|
||||
igl::cat(1, s.m_T, s.s_T, s.w_T);
|
||||
s.w_uv.conservativeResize(m_uv.rows() - bnd_n + uv2.rows(), 2);
|
||||
s.w_uv.bottomRows(uv2.rows() - bnd_n) = uv2.bottomRows(-bnd_n + uv2.rows());
|
||||
|
||||
update_scaffold(s);
|
||||
|
||||
// after_mesh_improve
|
||||
compute_scaffold_gradient_matrix(s, s.Dx_s, s.Dy_s);
|
||||
|
||||
s.Dx_s.makeCompressed();
|
||||
s.Dy_s.makeCompressed();
|
||||
s.Dz_s.makeCompressed();
|
||||
s.Ri_s = MatrixXd::Zero(s.Dx_s.rows(), s.dim * s.dim);
|
||||
s.Ji_s.resize(s.Dx_s.rows(), s.dim * s.dim);
|
||||
s.W_s.resize(s.Dx_s.rows(), s.dim * s.dim);
|
||||
}
|
||||
|
||||
IGL_INLINE void add_new_patch(igl::triangle::SCAFData &s, const Eigen::MatrixXd &V_ref,
|
||||
const Eigen::MatrixXi &F_ref,
|
||||
const Eigen::RowVectorXd &/*center*/,
|
||||
const Eigen::MatrixXd &uv_init)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
assert(uv_init.rows() != 0);
|
||||
Eigen::VectorXd M;
|
||||
igl::doublearea(V_ref, F_ref, M);
|
||||
s.mesh_measure += M.sum() / 2;
|
||||
|
||||
Eigen::VectorXi bnd;
|
||||
Eigen::MatrixXd bnd_uv;
|
||||
|
||||
std::vector<std::vector<int>> all_bnds;
|
||||
igl::boundary_loop(F_ref, all_bnds);
|
||||
|
||||
s.component_sizes.push_back(F_ref.rows());
|
||||
|
||||
MatrixXd m_uv = s.w_uv.topRows(s.mv_num);
|
||||
igl::cat(1, m_uv, uv_init, s.w_uv);
|
||||
|
||||
s.m_M.conservativeResize(s.mf_num + M.size());
|
||||
s.m_M.bottomRows(M.size()) = M / 2;
|
||||
|
||||
for (auto cur_bnd : all_bnds)
|
||||
{
|
||||
s.internal_bnd.conservativeResize(s.internal_bnd.size() + cur_bnd.size());
|
||||
s.internal_bnd.bottomRows(cur_bnd.size()) = Map<ArrayXi>(cur_bnd.data(), cur_bnd.size()) + s.mv_num;
|
||||
s.bnd_sizes.push_back(cur_bnd.size());
|
||||
}
|
||||
|
||||
s.m_T.conservativeResize(s.mf_num + F_ref.rows(), 3);
|
||||
s.m_T.bottomRows(F_ref.rows()) = F_ref.array() + s.mv_num;
|
||||
s.mf_num += F_ref.rows();
|
||||
|
||||
s.m_V.conservativeResize(s.mv_num + V_ref.rows(), 3);
|
||||
s.m_V.bottomRows(V_ref.rows()) = V_ref;
|
||||
s.mv_num += V_ref.rows();
|
||||
|
||||
s.rect_frame_V = MatrixXd();
|
||||
|
||||
mesh_improve(s);
|
||||
}
|
||||
|
||||
IGL_INLINE void compute_jacobians(SCAFData &s, const Eigen::MatrixXd &V_new, bool whole)
|
||||
{
|
||||
auto comp_J2 = [](const Eigen::MatrixXd &uv,
|
||||
const Eigen::SparseMatrix<double> &Dx,
|
||||
const Eigen::SparseMatrix<double> &Dy,
|
||||
Eigen::MatrixXd &Ji) {
|
||||
// Ji=[D1*u,D2*u,D1*v,D2*v];
|
||||
Ji.resize(Dx.rows(), 4);
|
||||
Ji.col(0) = Dx * uv.col(0);
|
||||
Ji.col(1) = Dy * uv.col(0);
|
||||
Ji.col(2) = Dx * uv.col(1);
|
||||
Ji.col(3) = Dy * uv.col(1);
|
||||
};
|
||||
|
||||
Eigen::MatrixXd m_V_new = V_new.topRows(s.mv_num);
|
||||
comp_J2(m_V_new, s.Dx_m, s.Dy_m, s.Ji_m);
|
||||
if (whole)
|
||||
comp_J2(V_new, s.Dx_s, s.Dy_s, s.Ji_s);
|
||||
}
|
||||
|
||||
IGL_INLINE double compute_energy_from_jacobians(const Eigen::MatrixXd &Ji,
|
||||
const Eigen::VectorXd &areas,
|
||||
igl::MappingEnergyType energy_type)
|
||||
{
|
||||
double energy = 0;
|
||||
if (energy_type == igl::MappingEnergyType::SYMMETRIC_DIRICHLET)
|
||||
energy = -4; // comply with paper description
|
||||
return energy + igl::mapping_energy_with_jacobians(Ji, areas, energy_type, 0);
|
||||
}
|
||||
|
||||
IGL_INLINE double compute_soft_constraint_energy(const SCAFData &s)
|
||||
{
|
||||
double e = 0;
|
||||
for (auto const &x : s.soft_cons)
|
||||
e += s.soft_const_p * (x.second - s.w_uv.row(x.first)).squaredNorm();
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
IGL_INLINE double compute_energy(SCAFData &s, const Eigen::MatrixXd &w_uv, bool whole)
|
||||
{
|
||||
if (w_uv.rows() != s.v_num)
|
||||
assert(!whole);
|
||||
compute_jacobians(s, w_uv, whole);
|
||||
double energy = compute_energy_from_jacobians(s.Ji_m, s.m_M, s.slim_energy);
|
||||
|
||||
if (whole)
|
||||
energy += compute_energy_from_jacobians(s.Ji_s, s.s_M, s.scaf_energy);
|
||||
energy += compute_soft_constraint_energy(s);
|
||||
return energy;
|
||||
}
|
||||
|
||||
IGL_INLINE void buildAm(const Eigen::VectorXd &sqrt_M,
|
||||
const Eigen::SparseMatrix<double> &Dx,
|
||||
const Eigen::SparseMatrix<double> &Dy,
|
||||
const Eigen::MatrixXd &W,
|
||||
Eigen::SparseMatrix<double> &Am)
|
||||
{
|
||||
std::vector<Eigen::Triplet<double>> IJV;
|
||||
Eigen::SparseMatrix<double> Dz;
|
||||
|
||||
Eigen::SparseMatrix<double> MDx = sqrt_M.asDiagonal() * Dx;
|
||||
Eigen::SparseMatrix<double> MDy = sqrt_M.asDiagonal() * Dy;
|
||||
igl::slim_buildA(MDx, MDy, Dz, W, IJV);
|
||||
|
||||
Am.setFromTriplets(IJV.begin(), IJV.end());
|
||||
Am.makeCompressed();
|
||||
}
|
||||
|
||||
IGL_INLINE void buildRhs(const Eigen::VectorXd &sqrt_M,
|
||||
const Eigen::MatrixXd &W,
|
||||
const Eigen::MatrixXd &Ri,
|
||||
Eigen::VectorXd &f_rhs)
|
||||
{
|
||||
const int dim = (W.cols() == 4) ? 2 : 3;
|
||||
const int f_n = W.rows();
|
||||
f_rhs.resize(dim * dim * f_n);
|
||||
|
||||
for (int i = 0; i < f_n; i++)
|
||||
{
|
||||
auto sqrt_area = sqrt_M(i);
|
||||
f_rhs(i + 0 * f_n) = sqrt_area * (W(i, 0) * Ri(i, 0) + W(i, 1) * Ri(i, 1));
|
||||
f_rhs(i + 1 * f_n) = sqrt_area * (W(i, 0) * Ri(i, 2) + W(i, 1) * Ri(i, 3));
|
||||
f_rhs(i + 2 * f_n) = sqrt_area * (W(i, 2) * Ri(i, 0) + W(i, 3) * Ri(i, 1));
|
||||
f_rhs(i + 3 * f_n) = sqrt_area * (W(i, 2) * Ri(i, 2) + W(i, 3) * Ri(i, 3));
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void get_complement(const Eigen::VectorXi &bnd_ids, int v_n, Eigen::ArrayXi &unknown_ids)
|
||||
{ // get the complement of bnd_ids.
|
||||
int assign = 0, i = 0;
|
||||
for (int get = 0; i < v_n && get < bnd_ids.size(); i++)
|
||||
{
|
||||
if (bnd_ids(get) == i)
|
||||
get++;
|
||||
else
|
||||
unknown_ids(assign++) = i;
|
||||
}
|
||||
while (i < v_n)
|
||||
unknown_ids(assign++) = i++;
|
||||
assert(assign + bnd_ids.size() == v_n);
|
||||
}
|
||||
|
||||
IGL_INLINE void build_surface_linear_system(const SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
|
||||
const int v_n = s.v_num - (s.frame_ids.size());
|
||||
const int dim = s.dim;
|
||||
const int f_n = s.mf_num;
|
||||
|
||||
// to get the complete A
|
||||
Eigen::VectorXd sqrtM = s.m_M.array().sqrt();
|
||||
Eigen::SparseMatrix<double> A(dim * dim * f_n, dim * v_n);
|
||||
auto decoy_Dx_m = s.Dx_m;
|
||||
decoy_Dx_m.conservativeResize(s.W_m.rows(), v_n);
|
||||
auto decoy_Dy_m = s.Dy_m;
|
||||
decoy_Dy_m.conservativeResize(s.W_m.rows(), v_n);
|
||||
buildAm(sqrtM, decoy_Dx_m, decoy_Dy_m, s.W_m, A);
|
||||
|
||||
const VectorXi &bnd_ids = s.fixed_ids;
|
||||
auto bnd_n = bnd_ids.size();
|
||||
if (bnd_n == 0)
|
||||
{
|
||||
|
||||
Eigen::SparseMatrix<double> At = A.transpose();
|
||||
At.makeCompressed();
|
||||
|
||||
Eigen::SparseMatrix<double> id_m(At.rows(), At.rows());
|
||||
id_m.setIdentity();
|
||||
|
||||
L = At * A;
|
||||
|
||||
Eigen::VectorXd frhs;
|
||||
buildRhs(sqrtM, s.W_m, s.Ri_m, frhs);
|
||||
rhs = At * frhs;
|
||||
}
|
||||
else
|
||||
{
|
||||
MatrixXd bnd_pos = s.w_uv(bnd_ids, igl::placeholders::all);
|
||||
|
||||
ArrayXi known_ids(bnd_ids.size() * dim);
|
||||
ArrayXi unknown_ids((v_n - bnd_ids.rows()) * dim);
|
||||
get_complement(bnd_ids, v_n, unknown_ids);
|
||||
VectorXd known_pos(bnd_ids.size() * dim);
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
auto n_b = bnd_ids.rows();
|
||||
known_ids.segment(d * n_b, n_b) = bnd_ids.array() + d * v_n;
|
||||
known_pos.segment(d * n_b, n_b) = bnd_pos.col(d);
|
||||
unknown_ids.block(d * (v_n - n_b), 0, v_n - n_b, unknown_ids.cols()) =
|
||||
unknown_ids.topRows(v_n - n_b) + d * v_n;
|
||||
}
|
||||
|
||||
Eigen::SparseMatrix<double> Au, Ae;
|
||||
igl::slice(A, unknown_ids, 2, Au);
|
||||
igl::slice(A, known_ids, 2, Ae);
|
||||
|
||||
Eigen::SparseMatrix<double> Aut = Au.transpose();
|
||||
Aut.makeCompressed();
|
||||
|
||||
L = Aut * Au;
|
||||
|
||||
Eigen::VectorXd frhs;
|
||||
buildRhs(sqrtM, s.W_m, s.Ri_m, frhs);
|
||||
|
||||
rhs = Aut * (frhs - Ae * known_pos);
|
||||
}
|
||||
|
||||
// add soft constraints.
|
||||
for (auto const &x : s.soft_cons)
|
||||
{
|
||||
int v_idx = x.first;
|
||||
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
rhs(d * (v_n) + v_idx) += s.soft_const_p * x.second(d); // rhs
|
||||
L.coeffRef(d * v_n + v_idx,
|
||||
d * v_n + v_idx) += s.soft_const_p; // diagonal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void build_scaffold_linear_system(const SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs)
|
||||
{
|
||||
using namespace Eigen;
|
||||
|
||||
const int f_n = s.W_s.rows();
|
||||
const int v_n = s.Dx_s.cols();
|
||||
const int dim = s.dim;
|
||||
|
||||
Eigen::VectorXd sqrtM = s.s_M.array().sqrt();
|
||||
Eigen::SparseMatrix<double> A(dim * dim * f_n, dim * v_n);
|
||||
buildAm(sqrtM, s.Dx_s, s.Dy_s, s.W_s, A);
|
||||
|
||||
VectorXi bnd_ids;
|
||||
igl::cat(1, s.fixed_ids, s.frame_ids, bnd_ids);
|
||||
|
||||
auto bnd_n = bnd_ids.size();
|
||||
IGL_ASSERT(bnd_n > 0);
|
||||
MatrixXd bnd_pos = s.w_uv(bnd_ids, igl::placeholders::all);
|
||||
|
||||
ArrayXi known_ids(bnd_ids.size() * dim);
|
||||
ArrayXi unknown_ids((v_n - bnd_ids.rows()) * dim);
|
||||
|
||||
get_complement(bnd_ids, v_n, unknown_ids);
|
||||
|
||||
VectorXd known_pos(bnd_ids.size() * dim);
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
auto n_b = bnd_ids.rows();
|
||||
known_ids.segment(d * n_b, n_b) = bnd_ids.array() + d * v_n;
|
||||
known_pos.segment(d * n_b, n_b) = bnd_pos.col(d);
|
||||
unknown_ids.block(d * (v_n - n_b), 0, v_n - n_b, unknown_ids.cols()) =
|
||||
unknown_ids.topRows(v_n - n_b) + d * v_n;
|
||||
}
|
||||
Eigen::VectorXd sqrt_M = s.s_M.array().sqrt();
|
||||
|
||||
// manual slicing for A(:, unknown/known)'
|
||||
Eigen::SparseMatrix<double> Au, Ae;
|
||||
igl::slice(A, unknown_ids, 2, Au);
|
||||
igl::slice(A, known_ids, 2, Ae);
|
||||
|
||||
Eigen::SparseMatrix<double> Aut = Au.transpose();
|
||||
Aut.makeCompressed();
|
||||
|
||||
L = Aut * Au;
|
||||
|
||||
Eigen::VectorXd frhs;
|
||||
buildRhs(sqrtM, s.W_s, s.Ri_s, frhs);
|
||||
|
||||
rhs = Aut * (frhs - Ae * known_pos);
|
||||
}
|
||||
|
||||
IGL_INLINE void build_weighted_arap_system(SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs)
|
||||
{
|
||||
// fixed frame solving:
|
||||
// x_e as the fixed frame, x_u for unknowns (mesh + unknown scaffold)
|
||||
// min ||(A_u*x_u + A_e*x_e) - b||^2
|
||||
// => A_u'*A_u*x_u = Au'* (b - A_e*x_e) := Au'* b_u
|
||||
//
|
||||
// separate matrix build:
|
||||
// min ||A_m x_m - b_m||^2 + ||A_s x_all - b_s||^2 + soft + proximal
|
||||
// First change dimension of A_m to fit for x_all
|
||||
// (Not just at the end, since x_all is flattened along dimensions)
|
||||
// L = A_m'*A_m + A_s'*A_s + soft + proximal
|
||||
// rhs = A_m'* b_m + A_s' * b_s + soft + proximal
|
||||
//
|
||||
Eigen::SparseMatrix<double> L_m, L_s;
|
||||
Eigen::VectorXd rhs_m, rhs_s;
|
||||
build_surface_linear_system(s, L_m, rhs_m); // complete Am, with soft
|
||||
build_scaffold_linear_system(s, L_s, rhs_s); // complete As, without proximal
|
||||
|
||||
L = L_m + L_s;
|
||||
rhs = rhs_m + rhs_s;
|
||||
L.makeCompressed();
|
||||
}
|
||||
|
||||
IGL_INLINE void solve_weighted_arap(SCAFData &s, Eigen::MatrixXd &uv)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
int dim = s.dim;
|
||||
igl::Timer timer;
|
||||
timer.start();
|
||||
|
||||
VectorXi bnd_ids;
|
||||
igl::cat(1, s.fixed_ids, s.frame_ids, bnd_ids);
|
||||
const auto v_n = s.v_num;
|
||||
const auto bnd_n = bnd_ids.size();
|
||||
assert(bnd_n > 0);
|
||||
MatrixXd bnd_pos = s.w_uv(bnd_ids, igl::placeholders::all);
|
||||
|
||||
ArrayXi known_ids(bnd_n * dim);
|
||||
ArrayXi unknown_ids((v_n - bnd_n) * dim);
|
||||
|
||||
get_complement(bnd_ids, v_n, unknown_ids);
|
||||
|
||||
VectorXd known_pos(bnd_ids.size() * dim);
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
auto n_b = bnd_ids.rows();
|
||||
known_ids.segment(d * n_b, n_b) = bnd_ids.array() + d * v_n;
|
||||
known_pos.segment(d * n_b, n_b) = bnd_pos.col(d);
|
||||
unknown_ids.block(d * (v_n - n_b), 0, v_n - n_b, unknown_ids.cols()) =
|
||||
unknown_ids.topRows(v_n - n_b) + d * v_n;
|
||||
}
|
||||
|
||||
Eigen::SparseMatrix<double> L;
|
||||
Eigen::VectorXd rhs;
|
||||
build_weighted_arap_system(s, L, rhs);
|
||||
|
||||
Eigen::VectorXd unknown_Uc((v_n - s.frame_ids.size() - s.fixed_ids.size()) * dim), Uc(dim * v_n);
|
||||
|
||||
SimplicialLDLT<Eigen::SparseMatrix<double>> solver;
|
||||
unknown_Uc = solver.compute(L).solve(rhs);
|
||||
Uc(unknown_ids) = unknown_Uc;
|
||||
Uc(known_ids) = known_pos;
|
||||
|
||||
uv = Map<Matrix<double, -1, -1, Eigen::ColMajor>>(Uc.data(), v_n, dim);
|
||||
}
|
||||
|
||||
IGL_INLINE double perform_iteration(SCAFData &s)
|
||||
{
|
||||
Eigen::MatrixXd V_out = s.w_uv;
|
||||
compute_jacobians(s, V_out, true);
|
||||
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_m, s.slim_energy, 0, s.W_m, s.Ri_m);
|
||||
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_s, s.scaf_energy, 0, s.W_s, s.Ri_s);
|
||||
solve_weighted_arap(s, V_out);
|
||||
std::function<double(Eigen::MatrixXd&)> whole_E = [&s](Eigen::MatrixXd &uv) { return compute_energy(s, uv, true); };
|
||||
|
||||
Eigen::MatrixXi w_T;
|
||||
if (s.m_T.cols() == s.s_T.cols())
|
||||
igl::cat(1, s.m_T, s.s_T, w_T);
|
||||
else
|
||||
w_T = s.s_T;
|
||||
return igl::flip_avoiding_line_search( w_T, s.w_uv, V_out, whole_E, -1) /
|
||||
s.mesh_measure;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::triangle::scaf_precompute(
|
||||
const Eigen::MatrixXd &V,
|
||||
const Eigen::MatrixXi &F,
|
||||
const Eigen::MatrixXd &V_init,
|
||||
const igl::MappingEnergyType slim_energy,
|
||||
const Eigen::VectorXi &b,
|
||||
const Eigen::MatrixXd &bc,
|
||||
const double soft_p,
|
||||
igl::triangle::SCAFData &data)
|
||||
{
|
||||
Eigen::MatrixXd CN;
|
||||
Eigen::MatrixXi FN;
|
||||
igl::triangle::scaf::add_new_patch(data, V, F, Eigen::RowVector2d(0, 0), V_init);
|
||||
data.soft_const_p = soft_p;
|
||||
for (int i = 0; i < b.rows(); i++)
|
||||
data.soft_cons[b(i)] = bc.row(i);
|
||||
data.slim_energy = slim_energy;
|
||||
|
||||
auto &s = data;
|
||||
|
||||
if (!data.has_pre_calc)
|
||||
{
|
||||
int dim = s.dim;
|
||||
Eigen::MatrixXd F1, F2, F3;
|
||||
igl::local_basis(s.m_V, s.m_T, F1, F2, F3);
|
||||
auto face_proj = [](Eigen::MatrixXd& F){
|
||||
std::vector<Eigen::Triplet<double> >IJV;
|
||||
int f_num = F.rows();
|
||||
for(int i=0; i<F.rows(); i++) {
|
||||
IJV.push_back(Eigen::Triplet<double>(i, i, F(i,0)));
|
||||
IJV.push_back(Eigen::Triplet<double>(i, i+f_num, F(i,1)));
|
||||
IJV.push_back(Eigen::Triplet<double>(i, i+2*f_num, F(i,2)));
|
||||
}
|
||||
Eigen::SparseMatrix<double> P(f_num, 3*f_num);
|
||||
P.setFromTriplets(IJV.begin(), IJV.end());
|
||||
return P;
|
||||
};
|
||||
Eigen::SparseMatrix<double> G;
|
||||
igl::grad(s.m_V, s.m_T, G);
|
||||
s.Dx_m = face_proj(F1) * G;
|
||||
s.Dy_m = face_proj(F2) * G;
|
||||
|
||||
igl::triangle::scaf::compute_scaffold_gradient_matrix(s, s.Dx_s, s.Dy_s);
|
||||
|
||||
s.Dx_m.makeCompressed();
|
||||
s.Dy_m.makeCompressed();
|
||||
s.Ri_m = Eigen::MatrixXd::Zero(s.Dx_m.rows(), dim * dim);
|
||||
s.Ji_m.resize(s.Dx_m.rows(), dim * dim);
|
||||
s.W_m.resize(s.Dx_m.rows(), dim * dim);
|
||||
|
||||
s.Dx_s.makeCompressed();
|
||||
s.Dy_s.makeCompressed();
|
||||
s.Ri_s = Eigen::MatrixXd::Zero(s.Dx_s.rows(), dim * dim);
|
||||
s.Ji_s.resize(s.Dx_s.rows(), dim * dim);
|
||||
s.W_s.resize(s.Dx_s.rows(), dim * dim);
|
||||
|
||||
data.has_pre_calc = true;
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE Eigen::MatrixXd igl::triangle::scaf_solve(const int iter_num, igl::triangle::SCAFData &s)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
s.energy = igl::triangle::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
||||
|
||||
for (int it = 0; it < iter_num; it++)
|
||||
{
|
||||
s.total_energy = igl::triangle::scaf::compute_energy(s, s.w_uv, true) / s.mesh_measure;
|
||||
s.rect_frame_V = Eigen::MatrixXd();
|
||||
igl::triangle::scaf::mesh_improve(s);
|
||||
|
||||
double new_weight = s.mesh_measure * s.energy / (s.sf_num * 100);
|
||||
s.scaffold_factor = new_weight;
|
||||
igl::triangle::scaf::update_scaffold(s);
|
||||
|
||||
s.total_energy = igl::triangle::scaf::perform_iteration(s);
|
||||
|
||||
s.energy =
|
||||
igl::triangle::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
||||
}
|
||||
|
||||
return s.w_uv.topRows(s.mv_num);
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::triangle::scaf_system(igl::triangle::SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs)
|
||||
{
|
||||
s.energy = igl::triangle::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
||||
|
||||
s.total_energy = igl::triangle::scaf::compute_energy(s, s.w_uv, true) / s.mesh_measure;
|
||||
s.rect_frame_V = Eigen::MatrixXd();
|
||||
igl::triangle::scaf::mesh_improve(s);
|
||||
|
||||
double new_weight = s.mesh_measure * s.energy / (s.sf_num * 100);
|
||||
s.scaffold_factor = new_weight;
|
||||
igl::triangle::scaf::update_scaffold(s);
|
||||
|
||||
igl::triangle::scaf::compute_jacobians(s, s.w_uv, true);
|
||||
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_m, s.slim_energy, 0, s.W_m, s.Ri_m);
|
||||
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_s, s.scaf_energy, 0, s.W_s, s.Ri_s);
|
||||
|
||||
igl::triangle::scaf::build_weighted_arap_system(s, L, rhs);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
#endif
|
||||
133
deps_src/libigl/igl/triangle/scaf.h
Normal file
133
deps_src/libigl/igl/triangle/scaf.h
Normal file
@@ -0,0 +1,133 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2018 Zhongshi Jiang <jiangzs@nyu.edu>
|
||||
//
|
||||
// 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_SCAF_H
|
||||
#define IGL_SCAF_H
|
||||
|
||||
#include "../slim.h"
|
||||
#include "../igl_inline.h"
|
||||
#include "../MappingEnergyType.h"
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace triangle
|
||||
{
|
||||
/// Use a similar interface to igl::slim
|
||||
/// Implement ready-to-use 2D version of the algorithm described in
|
||||
/// SCAF: Simplicial Complex Augmentation Framework for Bijective Maps
|
||||
/// Zhongshi Jiang, Scott Schaefer, Daniele Panozzo, ACM Trancaction on Graphics (Proc. SIGGRAPH Asia 2017)
|
||||
/// For a complete implementation and customized UI, please refer to https://github.com/jiangzhongshi/scaffold-map
|
||||
struct SCAFData
|
||||
{
|
||||
double scaffold_factor = 10;
|
||||
igl::MappingEnergyType scaf_energy = igl::MappingEnergyType::SYMMETRIC_DIRICHLET;
|
||||
igl::MappingEnergyType slim_energy = igl::MappingEnergyType::SYMMETRIC_DIRICHLET;
|
||||
|
||||
// Output
|
||||
int dim = 2;
|
||||
/// scaffold + isometric
|
||||
double total_energy;
|
||||
/// objective value
|
||||
double energy;
|
||||
|
||||
long mv_num = 0, mf_num = 0;
|
||||
long sv_num = 0, sf_num = 0;
|
||||
long v_num{}, f_num = 0;
|
||||
/// input initial mesh V
|
||||
Eigen::MatrixXd m_V;
|
||||
/// input initial mesh F/T
|
||||
Eigen::MatrixXi m_T;
|
||||
// INTERNAL
|
||||
/// whole domain uv: mesh + free vertices
|
||||
Eigen::MatrixXd w_uv;
|
||||
/// scaffold domain tets: scaffold tets
|
||||
Eigen::MatrixXi s_T;
|
||||
Eigen::MatrixXi w_T;
|
||||
|
||||
/// mesh area or volume
|
||||
Eigen::VectorXd m_M;
|
||||
/// scaffold area or volume
|
||||
Eigen::VectorXd s_M;
|
||||
/// area/volume weights for whole
|
||||
Eigen::VectorXd w_M;
|
||||
/// area or volume
|
||||
double mesh_measure = 0;
|
||||
double proximal_p = 0;
|
||||
|
||||
Eigen::VectorXi frame_ids;
|
||||
Eigen::VectorXi fixed_ids;
|
||||
|
||||
std::map<int, Eigen::RowVectorXd> soft_cons;
|
||||
double soft_const_p = 1e4;
|
||||
|
||||
Eigen::VectorXi internal_bnd;
|
||||
Eigen::MatrixXd rect_frame_V;
|
||||
// multi-chart support
|
||||
std::vector<int> component_sizes;
|
||||
std::vector<int> bnd_sizes;
|
||||
|
||||
// reweightedARAP interior variables.
|
||||
bool has_pre_calc = false;
|
||||
Eigen::SparseMatrix<double> Dx_s, Dy_s, Dz_s;
|
||||
Eigen::SparseMatrix<double> Dx_m, Dy_m, Dz_m;
|
||||
Eigen::MatrixXd Ri_m, Ji_m, Ri_s, Ji_s;
|
||||
Eigen::MatrixXd W_m, W_s;
|
||||
};
|
||||
|
||||
|
||||
/// Compute necessary information to start using SCAF
|
||||
///
|
||||
/// @param[in] V #V by 3 list of mesh vertex positions
|
||||
/// @param[in] F #F by 3 list of mesh triangles
|
||||
/// @param[in] V_init #V by 2 list of initial mesh vertex positions
|
||||
/// @param[in,out] data resulting precomputed data
|
||||
/// @param[in] slim_energy Energy type to minimize
|
||||
/// @param[in] b list of boundary indices into V (soft constraint)
|
||||
/// @param[in] bc #b by dim list of boundary conditions (soft constraint)
|
||||
/// @param[in] soft_p Soft penalty factor (can be zero)
|
||||
///
|
||||
/// \fileinfo
|
||||
IGL_INLINE void scaf_precompute(
|
||||
const Eigen::MatrixXd &V,
|
||||
const Eigen::MatrixXi &F,
|
||||
const Eigen::MatrixXd &V_init,
|
||||
const MappingEnergyType slim_energy,
|
||||
const Eigen::VectorXi& b,
|
||||
const Eigen::MatrixXd& bc,
|
||||
const double soft_p,
|
||||
triangle::SCAFData &data);
|
||||
|
||||
/// Run iter_num iterations of SCAF, with precomputed data
|
||||
/// @param[in] data precomputed data
|
||||
/// @param[in] iter_num number of iterations to run
|
||||
/// @returns resulting V_o (in SLIMData): #V by dim list of mesh vertex positions
|
||||
IGL_INLINE Eigen::MatrixXd scaf_solve(const int iter_num, triangle::SCAFData &data);
|
||||
|
||||
/// Set up the SCAF system L * uv = rhs, without solving it.
|
||||
/// @param[in] s: igl::SCAFData. Will be modified by energy and Jacobian computation.
|
||||
/// @param[out] L: m by m matrix
|
||||
/// @param[out] rhs: m by 1 vector
|
||||
/// with m = dim * (#V_mesh + #V_scaf - #V_frame)
|
||||
IGL_INLINE void scaf_system(triangle::SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs);
|
||||
|
||||
namespace scaf
|
||||
{
|
||||
/// Compute SCAF energy
|
||||
/// @param[in] s: igl::SCAFData
|
||||
/// @param[in] w_uv: (#V_mesh + #V_scaf) by dim matrix
|
||||
/// @param[in] whole: Include scaffold if true
|
||||
/// @returns energy
|
||||
IGL_INLINE double compute_energy(SCAFData &s, const Eigen::MatrixXd &w_uv, bool whole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "scaf.cpp"
|
||||
#endif
|
||||
|
||||
#endif //IGL_SCAF_H
|
||||
37
deps_src/libigl/igl/triangle/triangle_header.h
Normal file
37
deps_src/libigl/igl/triangle/triangle_header.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef IGL_TRIANGLE_TRIANGLE_HEADER_H
|
||||
#define IGL_TRIANGLE_TRIANGLE_HEADER_H
|
||||
|
||||
#ifdef ANSI_DECLARATORS
|
||||
# define IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS ANSI_DECLARATORS
|
||||
# undef ANSI_DECLARATORS
|
||||
#endif
|
||||
#ifdef REAL
|
||||
# define IGL_PREVIOUSLY_DEFINED_REAL REAL
|
||||
# undef REAL
|
||||
#endif
|
||||
#ifdef VOID
|
||||
# define IGL_PREVIOUSLY_DEFINED_VOID VOID
|
||||
# undef VOID
|
||||
#endif
|
||||
#define ANSI_DECLARATORS
|
||||
#define REAL double
|
||||
#define VOID int
|
||||
|
||||
#include <triangle.h>
|
||||
|
||||
#undef ANSI_DECLARATORS
|
||||
#ifdef IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS
|
||||
# define ANSI_DECLARATORS IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS
|
||||
#endif
|
||||
|
||||
#undef REAL
|
||||
#ifdef IGL_PREVIOUSLY_DEFINED_REAL
|
||||
# define REAL IGL_PREVIOUSLY_DEFINED_REAL
|
||||
#endif
|
||||
|
||||
#undef VOID
|
||||
#ifdef IGL_PREVIOUSLY_DEFINED_VOID
|
||||
# define VOID IGL_PREVIOUSLY_DEFINED_VOID
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -6,41 +6,8 @@
|
||||
// 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 "triangulate.h"
|
||||
#ifdef ANSI_DECLARATORS
|
||||
# define IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS ANSI_DECLARATORS
|
||||
# undef ANSI_DECLARATORS
|
||||
#endif
|
||||
#ifdef REAL
|
||||
# define IGL_PREVIOUSLY_DEFINED_REAL REAL
|
||||
# undef REAL
|
||||
#endif
|
||||
#ifdef VOID
|
||||
# define IGL_PREVIOUSLY_DEFINED_VOID VOID
|
||||
# undef VOID
|
||||
#endif
|
||||
#define ANSI_DECLARATORS
|
||||
#define REAL double
|
||||
#define VOID int
|
||||
#include "triangle_header.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <triangle.h>
|
||||
}
|
||||
|
||||
#undef ANSI_DECLARATORS
|
||||
#ifdef IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS
|
||||
# define ANSI_DECLARATORS IGL_PREVIOUSLY_DEFINED_ANSI_DECLARATORS
|
||||
#endif
|
||||
|
||||
#undef REAL
|
||||
#ifdef IGL_PREVIOUSLY_DEFINED_REAL
|
||||
# define REAL IGL_PREVIOUSLY_DEFINED_REAL
|
||||
#endif
|
||||
|
||||
#undef VOID
|
||||
#ifdef IGL_PREVIOUSLY_DEFINED_VOID
|
||||
# define VOID IGL_PREVIOUSLY_DEFINED_VOID
|
||||
#endif
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
@@ -57,7 +24,8 @@ IGL_INLINE void igl::triangle::triangulate(
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2)
|
||||
{
|
||||
Eigen::VectorXi VM,EM,VM2,EM2;
|
||||
return triangulate(V,E,H,VM,EM,flags,V2,F2,VM2,EM2);
|
||||
Eigen::MatrixXi E2;
|
||||
return triangulate(V,E,H,VM,EM,flags,V2,F2,VM2,E2,EM2);
|
||||
}
|
||||
|
||||
template <
|
||||
@@ -69,6 +37,7 @@ template <
|
||||
typename DerivedV2,
|
||||
typename DerivedF2,
|
||||
typename DerivedVM2,
|
||||
typename DerivedE2,
|
||||
typename DerivedEM2>
|
||||
IGL_INLINE void igl::triangle::triangulate(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
@@ -80,14 +49,15 @@ IGL_INLINE void igl::triangle::triangulate(
|
||||
Eigen::PlainObjectBase<DerivedV2> & V2,
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2,
|
||||
Eigen::PlainObjectBase<DerivedVM2> & VM2,
|
||||
Eigen::PlainObjectBase<DerivedE2> & E2,
|
||||
Eigen::PlainObjectBase<DerivedEM2> & EM2)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
assert( (VM.size() == 0 || V.rows() == VM.size()) &&
|
||||
assert( (VM.size() == 0 || V.rows() == VM.size()) &&
|
||||
"Vertex markers must be empty or same size as V");
|
||||
assert( (EM.size() == 0 || E.rows() == EM.size()) &&
|
||||
assert( (EM.size() == 0 || E.rows() == EM.size()) &&
|
||||
"Segment markers must be empty or same size as E");
|
||||
assert(V.cols() == 2);
|
||||
assert(E.size() == 0 || E.cols() == 2);
|
||||
@@ -149,6 +119,7 @@ IGL_INLINE void igl::triangle::triangulate(
|
||||
// Return the mesh
|
||||
V2 = MapXdr(out.pointlist,out.numberofpoints,2).cast<typename DerivedV2::Scalar>();
|
||||
F2 = MapXir(out.trianglelist,out.numberoftriangles,3).cast<typename DerivedF2::Scalar>();
|
||||
E2 = MapXir(out.segmentlist,out.numberofsegments,2).cast<typename DerivedE2::Scalar>();
|
||||
if(VM.size())
|
||||
{
|
||||
VM2 = MapXir(out.pointmarkerlist,out.numberofpoints,1).cast<typename DerivedVM2::Scalar>();
|
||||
@@ -175,7 +146,7 @@ IGL_INLINE void igl::triangle::triangulate(
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::triangle::triangulate<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<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<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> >&);
|
||||
template void igl::triangle::triangulate<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::triangle::triangulate<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<double, -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&, 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> >&);
|
||||
#endif
|
||||
|
||||
@@ -16,17 +16,43 @@ namespace igl
|
||||
{
|
||||
namespace triangle
|
||||
{
|
||||
// Triangulate the interior of a polygon using the triangle library.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 2 list of 2D vertex positions
|
||||
// E #E by 2 list of vertex ids forming unoriented edges of the boundary of the polygon
|
||||
// H #H by 2 coordinates of points contained inside holes of the polygon
|
||||
// flags string of options pass to triangle (see triangle documentation)
|
||||
// Outputs:
|
||||
// V2 #V2 by 2 coordinates of the vertives of the generated triangulation
|
||||
// F2 #F2 by 3 list of indices forming the faces of the generated triangulation
|
||||
//
|
||||
/// Triangulate the interior of a polygon using the triangle library.
|
||||
///
|
||||
/// @param[in] V #V by 2 list of 2D vertex positions
|
||||
/// @param[in] E #E by 2 list of vertex ids forming unoriented edges of the boundary of the polygon
|
||||
/// @param[in] H #H by 2 coordinates of points contained inside holes of the polygon
|
||||
/// @param[in] VM #V list of markers for input vertices
|
||||
/// @param[in] EM #E list of markers for input edges
|
||||
/// @param[in] flags string of options pass to triangle (see triangle documentation)
|
||||
/// @param[out] V2 #V2 by 2 coordinates of the vertives of the generated triangulation
|
||||
/// @param[out] F2 #F2 by 3 list of indices forming the faces of the generated triangulation
|
||||
/// @param[out] VM2 #V2 list of markers for output vertices
|
||||
/// @param[out] E2 #E2 by 2 list of output edges
|
||||
/// @param[out] EM2 #E2 list of markers for output edges
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedE,
|
||||
typename DerivedH,
|
||||
typename DerivedVM,
|
||||
typename DerivedEM,
|
||||
typename DerivedV2,
|
||||
typename DerivedF2,
|
||||
typename DerivedVM2,
|
||||
typename DerivedE2,
|
||||
typename DerivedEM2>
|
||||
IGL_INLINE void triangulate(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedE> & E,
|
||||
const Eigen::MatrixBase<DerivedH> & H,
|
||||
const Eigen::MatrixBase<DerivedVM> & VM,
|
||||
const Eigen::MatrixBase<DerivedEM> & EM,
|
||||
const std::string flags,
|
||||
Eigen::PlainObjectBase<DerivedV2> & V2,
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2,
|
||||
Eigen::PlainObjectBase<DerivedVM2> & VM2,
|
||||
Eigen::PlainObjectBase<DerivedE2> & E2,
|
||||
Eigen::PlainObjectBase<DerivedEM2> & EM2);
|
||||
/// \overload
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedE,
|
||||
@@ -40,43 +66,6 @@ namespace igl
|
||||
const std::string flags,
|
||||
Eigen::PlainObjectBase<DerivedV2> & V2,
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2);
|
||||
|
||||
// Triangulate the interior of a polygon using the triangle library.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 2 list of 2D vertex positions
|
||||
// E #E by 2 list of vertex ids forming unoriented edges of the boundary of the polygon
|
||||
// H #H by 2 coordinates of points contained inside holes of the polygon
|
||||
// M #V list of markers for input vertices
|
||||
// flags string of options pass to triangle (see triangle documentation)
|
||||
// Outputs:
|
||||
// V2 #V2 by 2 coordinates of the vertives of the generated triangulation
|
||||
// F2 #F2 by 3 list of indices forming the faces of the generated triangulation
|
||||
// M2 #V2 list of markers for output vertices
|
||||
//
|
||||
// TODO: expose the option to prevent Steiner points on the boundary
|
||||
//
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedE,
|
||||
typename DerivedH,
|
||||
typename DerivedVM,
|
||||
typename DerivedEM,
|
||||
typename DerivedV2,
|
||||
typename DerivedF2,
|
||||
typename DerivedVM2,
|
||||
typename DerivedEM2>
|
||||
IGL_INLINE void triangulate(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedE> & E,
|
||||
const Eigen::MatrixBase<DerivedH> & H,
|
||||
const Eigen::MatrixBase<DerivedVM> & VM,
|
||||
const Eigen::MatrixBase<DerivedEM> & EM,
|
||||
const std::string flags,
|
||||
Eigen::PlainObjectBase<DerivedV2> & V2,
|
||||
Eigen::PlainObjectBase<DerivedF2> & F2,
|
||||
Eigen::PlainObjectBase<DerivedVM2> & VM2,
|
||||
Eigen::PlainObjectBase<DerivedEM2> & EM2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user