mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 10:32:20 +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:
@@ -11,6 +11,7 @@
|
||||
#include "sortrows.h"
|
||||
#include "slice.h"
|
||||
#include "round.h"
|
||||
#include "placeholders.h"
|
||||
#include "colon.h"
|
||||
|
||||
#include <iostream>
|
||||
@@ -23,10 +24,10 @@ template <
|
||||
typename DerivedFF,
|
||||
typename DerivedI>
|
||||
IGL_INLINE void igl::sort_triangles(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedMV> & MV,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedMV> & MV,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
Eigen::PlainObjectBase<DerivedFF> & FF,
|
||||
Eigen::PlainObjectBase<DerivedI> & I)
|
||||
{
|
||||
@@ -34,465 +35,25 @@ IGL_INLINE void igl::sort_triangles(
|
||||
using namespace std;
|
||||
|
||||
|
||||
typedef typename DerivedV::Scalar Scalar;
|
||||
// Barycenter, centroid
|
||||
Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,1> D,sD;
|
||||
Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,4> BC,PBC;
|
||||
Eigen::Matrix<Scalar, DerivedF::RowsAtCompileTime,1> D,sD;
|
||||
Eigen::Matrix<Scalar, DerivedF::RowsAtCompileTime,3> BC;
|
||||
barycenter(V,F,BC);
|
||||
D = BC*(MV.transpose()*P.transpose().eval().col(2));
|
||||
Eigen::Matrix<Scalar, DerivedF::RowsAtCompileTime,4> BC4(BC.rows(),4);
|
||||
BC4.leftCols(3) = BC;
|
||||
BC4.col(3).setConstant(1);
|
||||
D = BC4*(
|
||||
MV.template cast<Scalar>().transpose()*
|
||||
P.template cast<Scalar>().transpose().eval().col(2));
|
||||
sort(D,1,false,sD,I);
|
||||
|
||||
//// Closest corner
|
||||
//Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,1> D,sD;
|
||||
//D.setConstant(F.rows(),1,-1e26);
|
||||
//for(int c = 0;c<3;c++)
|
||||
//{
|
||||
// Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,4> C;
|
||||
// Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,1> DC;
|
||||
// C.resize(F.rows(),4);
|
||||
// for(int f = 0;f<F.rows();f++)
|
||||
// {
|
||||
// C(f,0) = V(F(f,c),0);
|
||||
// C(f,1) = V(F(f,c),1);
|
||||
// C(f,2) = V(F(f,c),2);
|
||||
// C(f,3) = 1;
|
||||
// }
|
||||
// DC = C*(MV.transpose()*P.transpose().eval().col(2));
|
||||
// D = (DC.array()>D.array()).select(DC,D).eval();
|
||||
//}
|
||||
//sort(D,1,false,sD,I);
|
||||
|
||||
//// Closest corner with tie breaks
|
||||
//Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,3> D,sD,ssD;
|
||||
//D.resize(F.rows(),3);
|
||||
//for(int c = 0;c<3;c++)
|
||||
//{
|
||||
// Eigen::Matrix<typename DerivedV::Scalar, DerivedF::RowsAtCompileTime,4> C;
|
||||
// C.resize(F.rows(),4);
|
||||
// for(int f = 0;f<F.rows();f++)
|
||||
// {
|
||||
// C(f,0) = V(F(f,c),0);
|
||||
// C(f,1) = V(F(f,c),1);
|
||||
// C(f,2) = V(F(f,c),2);
|
||||
// C(f,3) = 1;
|
||||
// }
|
||||
// D.col(c) = C*(MV.transpose()*P.transpose().eval().col(2));
|
||||
//}
|
||||
//VectorXi _;
|
||||
//sort(D,2,false,sD,_);
|
||||
//sortrows(sD,false,ssD,I);
|
||||
|
||||
|
||||
slice(F,I,1,FF);
|
||||
FF = F(I.derived(),igl::placeholders::all);
|
||||
}
|
||||
|
||||
//#include "EPS.h"
|
||||
//#include <functional>
|
||||
//#include <algorithm>
|
||||
//
|
||||
//static int tough_count = 0;
|
||||
//template <typename Vec3>
|
||||
//class Triangle
|
||||
//{
|
||||
// public:
|
||||
// static inline bool z_comp(const Vec3 & A, const Vec3 & B)
|
||||
// {
|
||||
// return A(2) > B(2);
|
||||
// }
|
||||
// static typename Vec3::Scalar ZERO()
|
||||
// {
|
||||
// return igl::EPS<typename Vec3::Scalar>();
|
||||
// return 0;
|
||||
// }
|
||||
// public:
|
||||
// int id;
|
||||
// // Sorted projected coners: c[0] has smallest z value
|
||||
// Vec3 c[3];
|
||||
// Vec3 n;
|
||||
// public:
|
||||
// Triangle():id(-1) { };
|
||||
// Triangle(int id, const Vec3 c0, const Vec3 c1, const Vec3 c2):
|
||||
// id(id)
|
||||
// {
|
||||
// using namespace std;
|
||||
// c[0] = c0;
|
||||
// c[1] = c1;
|
||||
// c[2] = c2;
|
||||
// sort(c,c+3,Triangle<Vec3>::z_comp);
|
||||
// // normal pointed toward viewpoint
|
||||
// n = (c0-c1).cross(c2-c0);
|
||||
// if(n(2) < 0)
|
||||
// {
|
||||
// n *= -1.0;
|
||||
// }
|
||||
// // Avoid NaNs
|
||||
// typename Vec3::Scalar len = n.norm();
|
||||
// if(len == 0)
|
||||
// {
|
||||
// cout<<"avoid NaN"<<endl;
|
||||
// assert(false);
|
||||
// len = 1;
|
||||
// }
|
||||
// n /= len;
|
||||
// };
|
||||
//
|
||||
// typename Vec3::Scalar project(const Vec3 & r) const
|
||||
// {
|
||||
// //return n.dot(r-c[2]);
|
||||
// int closest = -1;
|
||||
// typename Vec3::Scalar min_dist = 1e26;
|
||||
// for(int ci = 0;ci<3;ci++)
|
||||
// {
|
||||
// typename Vec3::Scalar dist = (c[ci]-r).norm();
|
||||
// if(dist < min_dist)
|
||||
// {
|
||||
// min_dist = dist;
|
||||
// closest = ci;
|
||||
// }
|
||||
// }
|
||||
// assert(closest>=0);
|
||||
// return n.dot(r-c[closest]);
|
||||
// }
|
||||
//
|
||||
// // Z-values of this are < z-values of that
|
||||
// bool is_completely_behind(const Triangle & that) const
|
||||
// {
|
||||
// const typename Vec3::Scalar ac0 = that.c[0](2);
|
||||
// const typename Vec3::Scalar ac1 = that.c[1](2);
|
||||
// const typename Vec3::Scalar ac2 = that.c[2](2);
|
||||
// const typename Vec3::Scalar ic0 = this->c[0](2);
|
||||
// const typename Vec3::Scalar ic1 = this->c[1](2);
|
||||
// const typename Vec3::Scalar ic2 = this->c[2](2);
|
||||
// return
|
||||
// (ic0 < ac2 && ic1 <= ac2 && ic2 <= ac2) ||
|
||||
// (ic0 <= ac2 && ic1 < ac2 && ic2 <= ac2) ||
|
||||
// (ic0 <= ac2 && ic1 <= ac2 && ic2 < ac2);
|
||||
// }
|
||||
//
|
||||
// bool is_behind_plane(const Triangle &that) const
|
||||
// {
|
||||
// using namespace std;
|
||||
// const typename Vec3::Scalar apc0 = that.project(this->c[0]);
|
||||
// const typename Vec3::Scalar apc1 = that.project(this->c[1]);
|
||||
// const typename Vec3::Scalar apc2 = that.project(this->c[2]);
|
||||
// cout<<" "<<
|
||||
// apc0<<", "<<
|
||||
// apc1<<", "<<
|
||||
// apc2<<", "<<endl;
|
||||
// return (apc0 < ZERO() && apc1 < ZERO() && apc2 < ZERO());
|
||||
// }
|
||||
//
|
||||
// bool is_in_front_of_plane(const Triangle &that) const
|
||||
// {
|
||||
// using namespace std;
|
||||
// const typename Vec3::Scalar apc0 = that.project(this->c[0]);
|
||||
// const typename Vec3::Scalar apc1 = that.project(this->c[1]);
|
||||
// const typename Vec3::Scalar apc2 = that.project(this->c[2]);
|
||||
// cout<<" "<<
|
||||
// apc0<<", "<<
|
||||
// apc1<<", "<<
|
||||
// apc2<<", "<<endl;
|
||||
// return (apc0 > ZERO() && apc1 > ZERO() && apc2 > ZERO());
|
||||
// }
|
||||
//
|
||||
// bool is_coplanar(const Triangle &that) const
|
||||
// {
|
||||
// using namespace std;
|
||||
// const typename Vec3::Scalar apc0 = that.project(this->c[0]);
|
||||
// const typename Vec3::Scalar apc1 = that.project(this->c[1]);
|
||||
// const typename Vec3::Scalar apc2 = that.project(this->c[2]);
|
||||
// return (fabs(apc0)<=ZERO() && fabs(apc1)<=ZERO() && fabs(apc2)<=ZERO());
|
||||
// }
|
||||
//
|
||||
// // http://stackoverflow.com/a/14561664/148668
|
||||
// // a1 is line1 start, a2 is line1 end, b1 is line2 start, b2 is line2 end
|
||||
// static bool seg_seg_intersect(const Vec3 & a1, const Vec3 & a2, const Vec3 & b1, const Vec3 & b2)
|
||||
// {
|
||||
// Vec3 b = a2-a1;
|
||||
// Vec3 d = b2-b1;
|
||||
// typename Vec3::Scalar bDotDPerp = b(0) * d(1) - b(1) * d(0);
|
||||
//
|
||||
// // if b dot d == 0, it means the lines are parallel so have infinite intersection points
|
||||
// if (bDotDPerp == 0)
|
||||
// return false;
|
||||
//
|
||||
// Vec3 c = b1-a1;
|
||||
// typename Vec3::Scalar t = (c(0) * d(1) - c(1) * d(0)) / bDotDPerp;
|
||||
// if (t < 0 || t > 1)
|
||||
// return false;
|
||||
//
|
||||
// typename Vec3::Scalar u = (c(0) * b(1) - c(1) * b(0)) / bDotDPerp;
|
||||
// if (u < 0 || u > 1)
|
||||
// return false;
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// bool has_corner_inside(const Triangle & that) const
|
||||
// {
|
||||
// // http://www.blackpawn.com/texts/pointinpoly/
|
||||
// // Compute vectors
|
||||
// Vec3 A = that.c[0];
|
||||
// Vec3 B = that.c[1];
|
||||
// Vec3 C = that.c[2];
|
||||
// A(2) = B(2) = C(2) = 0;
|
||||
// for(int ci = 0;ci<3;ci++)
|
||||
// {
|
||||
// Vec3 P = this->c[ci];
|
||||
// P(2) = 0;
|
||||
//
|
||||
// Vec3 v0 = C - A;
|
||||
// Vec3 v1 = B - A;
|
||||
// Vec3 v2 = P - A;
|
||||
//
|
||||
// // Compute dot products
|
||||
// typename Vec3::Scalar dot00 = v0.dot(v0);
|
||||
// typename Vec3::Scalar dot01 = v0.dot(v1);
|
||||
// typename Vec3::Scalar dot02 = v0.dot(v2);
|
||||
// typename Vec3::Scalar dot11 = v1.dot(v1);
|
||||
// typename Vec3::Scalar dot12 = v1.dot(v2);
|
||||
//
|
||||
// // Compute barycentric coordinates
|
||||
// typename Vec3::Scalar invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
|
||||
// typename Vec3::Scalar u = (dot11 * dot02 - dot01 * dot12) * invDenom;
|
||||
// typename Vec3::Scalar v = (dot00 * dot12 - dot01 * dot02) * invDenom;
|
||||
//
|
||||
// // Check if point is in triangle
|
||||
// if((u >= 0) && (v >= 0) && (u + v < 1))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// bool overlaps(const Triangle &that) const
|
||||
// {
|
||||
// // Edges cross
|
||||
// for(int e = 0;e<3;e++)
|
||||
// {
|
||||
// for(int f = 0;f<3;f++)
|
||||
// {
|
||||
// if(seg_seg_intersect(
|
||||
// this->c[e],this->c[(e+1)%3],
|
||||
// that.c[e],that.c[(e+1)%3]))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // This could be entirely inside that
|
||||
// if(this->has_corner_inside(that))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// // vice versa
|
||||
// if(that.has_corner_inside(*this))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// bool operator< (const Triangle &that) const
|
||||
// {
|
||||
// // THIS < THAT if "depth" of THIS < "depth" of THAT
|
||||
// // " if THIS should be draw before THAT
|
||||
// using namespace std;
|
||||
// bool ret = false;
|
||||
// // Self compare
|
||||
// if(that.id == this->id)
|
||||
// {
|
||||
// ret = false;
|
||||
// }
|
||||
// if(this->is_completely_behind(that))
|
||||
// {
|
||||
// cout<<" "<<this->id<<" completely behind "<<that.id<<endl;
|
||||
// ret = false;
|
||||
// }else if(that.is_completely_behind(*this))
|
||||
// {
|
||||
// cout<<" "<<that.id<<" completely behind "<<this->id<<endl;
|
||||
// ret = true;
|
||||
// }else
|
||||
// {
|
||||
// if(!this->overlaps(that))
|
||||
// {
|
||||
// assert(!that.overlaps(*this));
|
||||
// cout<<" THIS does not overlap THAT"<<endl;
|
||||
// // No overlap use barycenter
|
||||
// return
|
||||
// 1./3.*(this->c[0](2) + this->c[1](2) + this->c[2](2)) >
|
||||
// 1./3.*(that.c[0](2) + that.c[1](2) + that.c[2](2));
|
||||
// }else
|
||||
// {
|
||||
// if(this->is_coplanar(that) || that.is_coplanar(*this))
|
||||
// {
|
||||
// cout<<" coplanar"<<endl;
|
||||
// // co-planar: decide based on barycenter depth
|
||||
// ret =
|
||||
// 1./3.*(this->c[0](2) + this->c[1](2) + this->c[2](2)) >
|
||||
// 1./3.*(that.c[0](2) + that.c[1](2) + that.c[2](2));
|
||||
// }else if(this->is_behind_plane(that))
|
||||
// {
|
||||
// cout<<" THIS behind plane of THAT"<<endl;
|
||||
// ret = true;
|
||||
// }else if(that.is_behind_plane(*this))
|
||||
// {
|
||||
// cout<<" THAT behind of plane of THIS"<<endl;
|
||||
// ret = false;
|
||||
// // THAT is in front of plane of THIS
|
||||
// }else if(that.is_in_front_of_plane(*this))
|
||||
// {
|
||||
// cout<<" THAT in front of plane of THIS"<<endl;
|
||||
// ret = true;
|
||||
// // THIS is in front of plane of THAT
|
||||
// }else if(this->is_in_front_of_plane(that))
|
||||
// {
|
||||
// cout<<" THIS in front plane of THAT"<<endl;
|
||||
// ret = false;
|
||||
// }else
|
||||
// {
|
||||
// cout<<" compare bary"<<endl;
|
||||
// ret =
|
||||
// 1./3.*(this->c[0](2) + this->c[1](2) + this->c[2](2)) >
|
||||
// 1./3.*(that.c[0](2) + that.c[1](2) + that.c[2](2));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(ret)
|
||||
// {
|
||||
// // THIS < THAT so better not be THAT < THIS
|
||||
// cout<<this->id<<" < "<<that.id<<endl;
|
||||
// assert(!(that < *this));
|
||||
// }else
|
||||
// {
|
||||
// // THIS >= THAT so could be THAT < THIS or THAT == THIS
|
||||
// }
|
||||
// return ret;
|
||||
// }
|
||||
//};
|
||||
//#include <igl/matlab/MatlabWorkspace.h>
|
||||
//
|
||||
//template <
|
||||
// typename DerivedV,
|
||||
// typename DerivedF,
|
||||
// typename DerivedMV,
|
||||
// typename DerivedP,
|
||||
// typename DerivedFF,
|
||||
// typename DerivedI>
|
||||
//IGL_INLINE void igl::sort_triangles_robust(
|
||||
// const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
// const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
// const Eigen::PlainObjectBase<DerivedMV> & MV,
|
||||
// const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
// Eigen::PlainObjectBase<DerivedFF> & FF,
|
||||
// Eigen::PlainObjectBase<DerivedI> & I)
|
||||
//{
|
||||
// assert(false &&
|
||||
// "THIS WILL NEVER WORK because depth sorting is not a numerical sort where"
|
||||
// "pairwise comparisons of triangles are transitive. Rather it is a"
|
||||
// "topological sort on a dependency graph. Dependency encodes 'This triangle"
|
||||
// "must be drawn before that one'");
|
||||
// using namespace std;
|
||||
// using namespace Eigen;
|
||||
// typedef Matrix<typename DerivedV::Scalar,3,1> Vec3;
|
||||
// assert(V.cols() == 4);
|
||||
// Matrix<typename DerivedV::Scalar, DerivedV::RowsAtCompileTime,3> VMVP =
|
||||
// V*(MV.transpose()*P.transpose().eval().block(0,0,4,3));
|
||||
//
|
||||
// MatrixXd projV(V.rows(),3);
|
||||
// for(int v = 0;v<V.rows();v++)
|
||||
// {
|
||||
// Vector3d vv;
|
||||
// vv(0) = V(v,0);
|
||||
// vv(1) = V(v,1);
|
||||
// vv(2) = V(v,2);
|
||||
// Vector3d p;
|
||||
// project(vv,p);
|
||||
// projV.row(v) = p;
|
||||
// }
|
||||
//
|
||||
// vector<Triangle<Vec3> > vF(F.rows());
|
||||
// MatrixXd N(F.rows(),3);
|
||||
// MatrixXd C(F.rows()*3,3);
|
||||
// for(int f = 0;f<F.rows();f++)
|
||||
// {
|
||||
// vF[f] =
|
||||
// //Triangle<Vec3>(f,VMVP.row(F(f,0)),VMVP.row(F(f,1)),VMVP.row(F(f,2)));
|
||||
// Triangle<Vec3>(f,projV.row(F(f,0)),projV.row(F(f,1)),projV.row(F(f,2)));
|
||||
// N.row(f) = vF[f].n;
|
||||
// for(int c = 0;c<3;c++)
|
||||
// for(int d = 0;d<3;d++)
|
||||
// C(f*3+c,d) = vF[f].c[c](d);
|
||||
// }
|
||||
// MatlabWorkspace mw;
|
||||
// mw.save_index(F,"F");
|
||||
// mw.save(V,"V");
|
||||
// mw.save(MV,"MV");
|
||||
// mw.save(P,"P");
|
||||
// Vector4i VP;
|
||||
// glGetIntegerv(GL_VIEWPORT, VP.data());
|
||||
// mw.save(projV,"projV");
|
||||
// mw.save(VP,"VP");
|
||||
// mw.save(VMVP,"VMVP");
|
||||
// mw.save(N,"N");
|
||||
// mw.save(C,"C");
|
||||
// mw.write("ao.mat");
|
||||
// sort(vF.begin(),vF.end());
|
||||
//
|
||||
// // check
|
||||
// for(int f = 0;f<F.rows();f++)
|
||||
// {
|
||||
// for(int g = f+1;g<F.rows();g++)
|
||||
// {
|
||||
// assert(!(vF[g] < vF[f])); // should never happen
|
||||
// }
|
||||
// }
|
||||
// FF.resize(F.rows(),3);
|
||||
// I.resize(F.rows(),1);
|
||||
// for(int f = 0;f<F.rows();f++)
|
||||
// {
|
||||
// FF.row(f) = F.row(vF[f].id);
|
||||
// I(f) = vF[f].id;
|
||||
// }
|
||||
//
|
||||
// mw.save_index(FF,"FF");
|
||||
// mw.save_index(I,"I");
|
||||
// mw.write("ao.mat");
|
||||
//}
|
||||
|
||||
//template <
|
||||
// typename DerivedV,
|
||||
// typename DerivedF,
|
||||
// typename DerivedFF,
|
||||
// typename DerivedI>
|
||||
//IGL_INLINE void igl::sort_triangles_robust(
|
||||
// const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
// const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
// Eigen::PlainObjectBase<DerivedFF> & FF,
|
||||
// Eigen::PlainObjectBase<DerivedI> & I)
|
||||
//{
|
||||
// using namespace Eigen;
|
||||
// using namespace std;
|
||||
// // Put model, projection, and viewport matrices into double arrays
|
||||
// Matrix4d MV;
|
||||
// Matrix4d P;
|
||||
// glGetDoublev(GL_MODELVIEW_MATRIX, MV.data());
|
||||
// glGetDoublev(GL_PROJECTION_MATRIX, P.data());
|
||||
// if(V.cols() == 3)
|
||||
// {
|
||||
// Matrix<typename DerivedV::Scalar, DerivedV::RowsAtCompileTime,4> hV;
|
||||
// hV.resize(V.rows(),4);
|
||||
// hV.block(0,0,V.rows(),V.cols()) = V;
|
||||
// hV.col(3).setConstant(1);
|
||||
// return sort_triangles_robust(hV,F,MV,P,FF,I);
|
||||
// }else
|
||||
// {
|
||||
// return sort_triangles_robust(V,F,MV,P,FF,I);
|
||||
// }
|
||||
//}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::sort_triangles<Eigen::Matrix<double, -1, 4, 0, -1, 4>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 4, 0, -1, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::sort_triangles<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, 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<double, 4, 4, 0, 4, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> > const&, 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 void igl::sort_triangles<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<float, 4, 4, 0, 4, 4>, Eigen::Matrix<float, 4, 4, 0, 4, 4>, 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<float, 4, 4, 0, 4, 4> > const&, Eigen::MatrixBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::sort_triangles<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, Eigen::Matrix<double, 4, 4, 0, 4, 4>, 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, 4, 4, 0, 4, 4> > const&, Eigen::MatrixBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user