|
@@ -11,6 +11,7 @@
|
|
|
#include "doublearea.h"
|
|
|
#include "harmonic.h"
|
|
|
//#include "matlab/MatlabWorkspace.h"
|
|
|
+#include <iostream>
|
|
|
|
|
|
template <
|
|
|
typename DerivedV,
|
|
@@ -24,13 +25,31 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
|
|
|
const Eigen::MatrixBase<Derivedb> & b,
|
|
|
const Eigen::MatrixBase<Derivedbc> & bc,
|
|
|
Eigen::PlainObjectBase<DerivedU> & U)
|
|
|
+{
|
|
|
+ return bijective_composite_harmonic_mapping(V,F,b,bc,1,200,20,true,U);
|
|
|
+}
|
|
|
+
|
|
|
+template <
|
|
|
+ typename DerivedV,
|
|
|
+ typename DerivedF,
|
|
|
+ typename Derivedb,
|
|
|
+ typename Derivedbc,
|
|
|
+ typename DerivedU>
|
|
|
+IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
|
|
|
+ const Eigen::MatrixBase<DerivedV> & V,
|
|
|
+ const Eigen::MatrixBase<DerivedF> & F,
|
|
|
+ const Eigen::MatrixBase<Derivedb> & b,
|
|
|
+ const Eigen::MatrixBase<Derivedbc> & bc,
|
|
|
+ const int min_steps,
|
|
|
+ const int max_steps,
|
|
|
+ const int num_inner_iters,
|
|
|
+ const bool test_for_flips,
|
|
|
+ Eigen::PlainObjectBase<DerivedU> & U)
|
|
|
{
|
|
|
typedef typename Derivedbc::Scalar Scalar;
|
|
|
assert(V.cols() == 2 && bc.cols() == 2 && "Input should be 2D");
|
|
|
assert(F.cols() == 3 && "F should contain triangles");
|
|
|
int tries = 0;
|
|
|
- const int min_steps = 1;
|
|
|
- const int max_steps = 64;
|
|
|
int nsteps = min_steps;
|
|
|
Derivedbc bc0;
|
|
|
slice(V,b,1,bc0);
|
|
@@ -54,8 +73,7 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
|
|
|
// components.
|
|
|
Derivedbc bct = bc0 + t*(bc - bc0);
|
|
|
// Compute dsicrete harmonic map using metric of previous step
|
|
|
- const int ninnersteps = 8;
|
|
|
- for(int iter = 0;iter<8;iter++)
|
|
|
+ for(int iter = 0;iter<num_inner_iters;iter++)
|
|
|
{
|
|
|
//std::cout<<nsteps<<" t: "<<t<<" iter: "<<iter;
|
|
|
//igl::matlab::MatlabWorkspace mw;
|
|
@@ -65,13 +83,16 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
|
|
|
//mw.save(bct,"bct");
|
|
|
//mw.write("numerical.mat");
|
|
|
harmonic(DerivedU(U),F,b,bct,1,U);
|
|
|
- Eigen::Matrix<Scalar,Eigen::Dynamic,1> A;
|
|
|
- doublearea(U,F,A);
|
|
|
- flipped = (A.array() < 0 ).count();
|
|
|
- //std::cout<<" "<<flipped<<" nan? "<<(U.array() != U.array()).any()<<std::endl;
|
|
|
- nans = (U.array() != U.array()).count();
|
|
|
- if(flipped == 0 && nans == 0) break;
|
|
|
igl::slice(U,b,1,bct);
|
|
|
+ nans = (U.array() != U.array()).count();
|
|
|
+ if(test_for_flips)
|
|
|
+ {
|
|
|
+ Eigen::Matrix<Scalar,Eigen::Dynamic,1> A;
|
|
|
+ doublearea(U,F,A);
|
|
|
+ flipped = (A.array() < 0 ).count();
|
|
|
+ //std::cout<<" "<<flipped<<" nan? "<<(U.array() != U.array()).any()<<std::endl;
|
|
|
+ if(flipped == 0 && nans == 0) break;
|
|
|
+ }
|
|
|
}
|
|
|
if(flipped > 0 || nans>0) break;
|
|
|
}
|
|
@@ -81,6 +102,7 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
|
|
|
}
|
|
|
nsteps *= 2;
|
|
|
}
|
|
|
+ //std::cout<<"failed to finish in "<<nsteps<<"..."<<std::endl;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -88,4 +110,6 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
|
|
|
// Explicit template instantiation
|
|
|
// generated by autoexplicit.sh
|
|
|
template bool igl::bijective_composite_harmonic_mapping<Eigen::Matrix<double, -1, -1, 1, -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, 1, -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<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&);
|
|
|
+// generated by autoexplicit.sh
|
|
|
+template bool igl::bijective_composite_harmonic_mapping<Eigen::Matrix<double, -1, -1, 1, -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, 1, -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<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, int, int, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&);
|
|
|
#endif
|