|
@@ -24,6 +24,7 @@
|
|
|
#include "slice.h"
|
|
|
#include "sum.h"
|
|
|
#include "find.h"
|
|
|
+#include <iostream>
|
|
|
|
|
|
template <
|
|
|
typename DerivedV,
|
|
@@ -123,6 +124,7 @@ IGL_INLINE void igl::straighten_seams(
|
|
|
// boundary in the 3D mesh but is a boundary in the texture-mesh AND is not
|
|
|
// "cut cleanly" (the vertex is mapped to exactly 2 locations)
|
|
|
Array<bool,Dynamic,1> SV = Array<bool,Dynamic,1>::Zero(VT.rows(),1);
|
|
|
+ //std::cout<<"#SV: "<<SV.count()<<std::endl;
|
|
|
assert(BTF.size() == OT.rows());
|
|
|
for(int h = 0;h<BTF.size();h++)
|
|
|
{
|
|
@@ -132,6 +134,7 @@ IGL_INLINE void igl::straighten_seams(
|
|
|
SV(OT(h,1)) = true;
|
|
|
}
|
|
|
}
|
|
|
+ //std::cout<<"#SV: "<<SV.count()<<std::endl;
|
|
|
Array<bool,Dynamic,1> CL = DT.array()==2;
|
|
|
SparseMatrix<bool> VTOT;
|
|
|
{
|
|
@@ -148,34 +151,45 @@ IGL_INLINE void igl::straighten_seams(
|
|
|
count( (VTOT*OEQ).eval(), 2, cuts);
|
|
|
CL = (CL && (cuts.array() == 2)).eval();
|
|
|
}
|
|
|
+ //std::cout<<"#CL: "<<CL.count()<<std::endl;
|
|
|
assert(CL.size() == SV.size());
|
|
|
for(int c = 0;c<CL.size();c++) if(CL(c)) SV(c) = false;
|
|
|
- // vertices at the corner of ears are declared to be sharp. This is
|
|
|
- // conservative: for example, if the ear is strictly convex and stays strictly
|
|
|
- // convex then the ear won't be flipped.
|
|
|
- VectorXi ear,ear_opp;
|
|
|
- ears(FT,ear,ear_opp);
|
|
|
- // There might be an ear on one copy, so mark vertices on other copies, too
|
|
|
- // ears as they live on the 3D mesh
|
|
|
- VectorXi earTi(ear.size());
|
|
|
- for(int e = 0;e<ear.size();e++) earTi(e) = FT(ear(e),ear_opp(e));
|
|
|
- SparseMatrix<bool> V2VTearTi,V2VTearFi;
|
|
|
- slice(V2VT,earTi,2,V2VTearTi);
|
|
|
- VectorXi earFi;
|
|
|
- Array<bool,Dynamic,1> earFb;
|
|
|
- any(V2VTearTi,2,earFb);
|
|
|
- find(earFb,earFi);
|
|
|
- slice(V2VT,earFi,1,V2VTearFi);
|
|
|
- Array<bool,Dynamic,1> earT;
|
|
|
- any(V2VTearFi,1,earT);
|
|
|
- // Even if ear-vertices are marked as sharp if it changes, e.g., from convex
|
|
|
- // to concave then it will _force_ a flip of the ear triangle. So, declare
|
|
|
- // that neighbors of ears are also sharp.
|
|
|
- SparseMatrix<bool> A;
|
|
|
- adjacency_matrix(FT,A);
|
|
|
- earT = (earT || (A*earT.matrix()).array()).eval();
|
|
|
- assert(earT.size() == SV.size());
|
|
|
- for(int e = 0;e<earT.size();e++) if(earT(e)) SV(e) = true;
|
|
|
+ {}
|
|
|
+ //std::cout<<"#SV: "<<SV.count()<<std::endl;
|
|
|
+
|
|
|
+ {
|
|
|
+ // vertices at the corner of ears are declared to be sharp. This is
|
|
|
+ // conservative: for example, if the ear is strictly convex and stays
|
|
|
+ // strictly convex then the ear won't be flipped.
|
|
|
+ VectorXi ear,ear_opp;
|
|
|
+ ears(FT,ear,ear_opp);
|
|
|
+ //std::cout<<"#ear: "<<ear.size()<<std::endl;
|
|
|
+ // There might be an ear on one copy, so mark vertices on other copies, too
|
|
|
+ // ears as they live on the 3D mesh
|
|
|
+ Array<bool,Dynamic,1> earT = Array<bool,Dynamic,1>::Zero(VT.rows(),1);
|
|
|
+ for(int e = 0;e<ear.size();e++) earT(FT(ear(e),ear_opp(e))) = 1;
|
|
|
+ //std::cout<<"#earT: "<<earT.count()<<std::endl;
|
|
|
+ // Even if ear-vertices are marked as sharp if it changes, e.g., from
|
|
|
+ // convex to concave then it will _force_ a flip of the ear triangle. So,
|
|
|
+ // declare that neighbors of ears are also sharp.
|
|
|
+ SparseMatrix<bool> A;
|
|
|
+ adjacency_matrix(FT,A);
|
|
|
+ earT = (earT || (A*earT.matrix()).array()).eval();
|
|
|
+ //std::cout<<"#earT: "<<earT.count()<<std::endl;
|
|
|
+ assert(earT.size() == SV.size());
|
|
|
+ for(int e = 0;e<earT.size();e++) if(earT(e)) SV(e) = true;
|
|
|
+ //std::cout<<"#SV: "<<SV.count()<<std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ SparseMatrix<bool> V2VTSV,V2VTC;
|
|
|
+ slice_mask(V2VT,SV,2,V2VTSV);
|
|
|
+ Array<bool,Dynamic,1> Cb;
|
|
|
+ any(V2VTSV,2,Cb);
|
|
|
+ slice_mask(V2VT,Cb,1,V2VTC);
|
|
|
+ any(V2VTC,1,SV);
|
|
|
+ }
|
|
|
+ //std::cout<<"#SV: "<<SV.count()<<std::endl;
|
|
|
|
|
|
SparseMatrix<bool> OTVT = VTOT.transpose();
|
|
|
int nc;
|
|
@@ -346,7 +360,7 @@ IGL_INLINE void igl::straighten_seams(
|
|
|
}
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
-// Explicit template specialization
|
|
|
+// Explicit template instantiation
|
|
|
// generated by autoexplicit.sh
|
|
|
template void igl::straighten_seams<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double, Eigen::Matrix<int, -1, -1, 0, -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, 0, -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&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, double, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
#endif
|