Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
igl::slim Namespace Reference

Functions

IGL_INLINE void compute_surface_gradient_matrix (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &F1, const Eigen::MatrixXd &F2, Eigen::SparseMatrix< double > &D1, Eigen::SparseMatrix< double > &D2)
 
IGL_INLINE void buildA (igl::SLIMData &s, std::vector< Eigen::Triplet< double > > &IJV)
 
IGL_INLINE void buildRhs (igl::SLIMData &s, const Eigen::SparseMatrix< double > &A)
 
IGL_INLINE void add_soft_constraints (igl::SLIMData &s, Eigen::SparseMatrix< double > &L)
 
IGL_INLINE double compute_energy (igl::SLIMData &s, Eigen::MatrixXd &V_new)
 
IGL_INLINE double compute_soft_const_energy (igl::SLIMData &s, const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, Eigen::MatrixXd &V_o)
 
IGL_INLINE double compute_energy_with_jacobians (igl::SLIMData &s, const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &Ji, Eigen::MatrixXd &uv, Eigen::VectorXd &areas)
 
IGL_INLINE void solve_weighted_arap (igl::SLIMData &s, const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, Eigen::MatrixXd &uv, Eigen::VectorXi &soft_b_p, Eigen::MatrixXd &soft_bc_p)
 
IGL_INLINE void update_weights_and_closest_rotations (igl::SLIMData &s, const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, Eigen::MatrixXd &uv)
 
IGL_INLINE void compute_jacobians (igl::SLIMData &s, const Eigen::MatrixXd &uv)
 
IGL_INLINE void build_linear_system (igl::SLIMData &s, Eigen::SparseMatrix< double > &L)
 
IGL_INLINE void pre_calc (igl::SLIMData &s)
 

Function Documentation

◆ add_soft_constraints()

IGL_INLINE void igl::slim::add_soft_constraints ( igl::SLIMData s,
Eigen::SparseMatrix< double > &  L 
)
561 {
562 int v_n = s.v_num;
563 for (int d = 0; d < s.dim; d++)
564 {
565 for (int i = 0; i < s.b.rows(); i++)
566 {
567 int v_idx = s.b(i);
568 s.rhs(d * v_n + v_idx) += s.soft_const_p * s.bc(i, d); // rhs
569 L.coeffRef(d * v_n + v_idx, d * v_n + v_idx) += s.soft_const_p; // diagonal of matrix
570 }
571 }
572 }
#define L(s)
Definition I18N.hpp:18
Eigen::VectorXd rhs
Definition slim.h:65
int v_num
Definition slim.h:60
Eigen::MatrixXd bc
Definition slim.h:46
double soft_const_p
Definition slim.h:47
int dim
Definition slim.h:74
Eigen::VectorXi b
Definition slim.h:45

References igl::SLIMData::b, igl::SLIMData::bc, igl::SLIMData::dim, L, igl::SLIMData::rhs, igl::SLIMData::soft_const_p, and igl::SLIMData::v_num.

Referenced by build_linear_system().

+ Here is the caller graph for this function:

◆ build_linear_system()

IGL_INLINE void igl::slim::build_linear_system ( igl::SLIMData s,
Eigen::SparseMatrix< double > &  L 
)
499 {
500 // formula (35) in paper
501 std::vector<Eigen::Triplet<double> > IJV;
502
503 #ifdef SLIM_CACHED
504 buildA(s,IJV);
505 if (s.A.rows() == 0)
506 {
507 s.A = Eigen::SparseMatrix<double>(s.dim * s.dim * s.f_n, s.dim * s.v_n);
509 }
510 else
511 igl::sparse_cached(IJV,s.A_data,s.A);
512 #else
513 Eigen::SparseMatrix<double> A(s.dim * s.dim * s.f_n, s.dim * s.v_n);
514 buildA(s,IJV);
515 A.setFromTriplets(IJV.begin(),IJV.end());
516 A.makeCompressed();
517 #endif
518
519 #ifdef SLIM_CACHED
520 #else
522 At.makeCompressed();
523 #endif
524
525 #ifdef SLIM_CACHED
526 Eigen::SparseMatrix<double> id_m(s.A.cols(), s.A.cols());
527 #else
528 Eigen::SparseMatrix<double> id_m(A.cols(), A.cols());
529 #endif
530
531 id_m.setIdentity();
532
533 // add proximal penalty
534 #ifdef SLIM_CACHED
535 s.AtA_data.W = s.WGL_M;
536 if (s.AtA.rows() == 0)
538 else
540
541 L = s.AtA + s.proximal_p * id_m; //add also a proximal
542 L.makeCompressed();
543
544 #else
545 L = At * s.WGL_M.asDiagonal() * A + s.proximal_p * id_m; //add also a proximal term
546 L.makeCompressed();
547 #endif
548
549 #ifdef SLIM_CACHED
550 buildRhs(s, s.A);
551 #else
552 buildRhs(s, A);
553 #endif
554
556 add_soft_constraints(s,L);
557 L.makeCompressed();
558 }
TransposeReturnType transpose()
Definition SparseMatrixBase.h:349
A versatible sparse matrix representation.
Definition SparseMatrix.h:98
void makeCompressed()
Definition SparseMatrix.h:464
Index rows() const
Definition SparseMatrix.h:136
Index cols() const
Definition SparseMatrix.h:138
IGL_INLINE void buildA(igl::SLIMData &s, std::vector< Eigen::Triplet< double > > &IJV)
Definition slim.cpp:720
IGL_INLINE void sparse_cached_precompute(const Eigen::MatrixBase< DerivedI > &I, const Eigen::MatrixBase< DerivedI > &J, Eigen::VectorXi &data, Eigen::SparseMatrix< Scalar > &X)
Definition sparse_cached.cpp:18
IGL_INLINE void AtA_cached(const Eigen::SparseMatrix< Scalar > &A, const AtA_cached_data &data, Eigen::SparseMatrix< Scalar > &AtA)
Definition AtA_cached.cpp:113
IGL_INLINE void sparse_cached(const std::vector< Eigen::Triplet< Scalar > > &triplets, const Eigen::VectorXi &data, Eigen::SparseMatrix< Scalar > &X)
Definition sparse_cached.cpp:85
IGL_INLINE void AtA_cached_precompute(const Eigen::SparseMatrix< Scalar > &A, AtA_cached_data &data, Eigen::SparseMatrix< Scalar > &AtA)
Definition AtA_cached.cpp:15
Eigen::VectorXd W
Definition AtA_cached.h:19
igl::AtA_cached_data AtA_data
Definition slim.h:80
double proximal_p
Definition slim.h:62
int v_n
Definition slim.h:71
Eigen::VectorXd WGL_M
Definition slim.h:64
int f_n
Definition slim.h:71
Eigen::SparseMatrix< double > A
Definition slim.h:77
Eigen::SparseMatrix< double > AtA
Definition slim.h:79
Eigen::VectorXi A_data
Definition slim.h:78

References igl::SLIMData::A, igl::SLIMData::A_data, add_soft_constraints(), igl::SLIMData::AtA, igl::AtA_cached(), igl::AtA_cached_precompute(), igl::SLIMData::AtA_data, buildA(), buildRhs(), Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::cols(), igl::SLIMData::dim, igl::SLIMData::f_n, L, Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::makeCompressed(), igl::SLIMData::proximal_p, Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::rows(), Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::setFromTriplets(), Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::setIdentity(), igl::sparse_cached(), igl::sparse_cached_precompute(), Eigen::SparseMatrixBase< Derived >::transpose(), igl::SLIMData::v_n, igl::AtA_cached_data::W, and igl::SLIMData::WGL_M.

Referenced by solve_weighted_arap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildA()

IGL_INLINE void igl::slim::buildA ( igl::SLIMData s,
std::vector< Eigen::Triplet< double > > &  IJV 
)
721 {
722 // formula (35) in paper
723 if (s.dim == 2)
724 {
725 IJV.reserve(4 * (s.Dx.outerSize() + s.Dy.outerSize()));
726
727 /*A = [W11*Dx, W12*Dx;
728 W11*Dy, W12*Dy;
729 W21*Dx, W22*Dx;
730 W21*Dy, W22*Dy];*/
731 for (int k = 0; k < s.Dx.outerSize(); ++k)
732 {
733 for (Eigen::SparseMatrix<double>::InnerIterator it(s.Dx, k); it; ++it)
734 {
735 int dx_r = it.row();
736 int dx_c = it.col();
737 double val = it.value();
738
739 IJV.push_back(Eigen::Triplet<double>(dx_r, dx_c, val * s.W_11(dx_r)));
740 IJV.push_back(Eigen::Triplet<double>(dx_r, s.v_n + dx_c, val * s.W_12(dx_r)));
741
742 IJV.push_back(Eigen::Triplet<double>(2 * s.f_n + dx_r, dx_c, val * s.W_21(dx_r)));
743 IJV.push_back(Eigen::Triplet<double>(2 * s.f_n + dx_r, s.v_n + dx_c, val * s.W_22(dx_r)));
744 }
745 }
746
747 for (int k = 0; k < s.Dy.outerSize(); ++k)
748 {
749 for (Eigen::SparseMatrix<double>::InnerIterator it(s.Dy, k); it; ++it)
750 {
751 int dy_r = it.row();
752 int dy_c = it.col();
753 double val = it.value();
754
755 IJV.push_back(Eigen::Triplet<double>(s.f_n + dy_r, dy_c, val * s.W_11(dy_r)));
756 IJV.push_back(Eigen::Triplet<double>(s.f_n + dy_r, s.v_n + dy_c, val * s.W_12(dy_r)));
757
758 IJV.push_back(Eigen::Triplet<double>(3 * s.f_n + dy_r, dy_c, val * s.W_21(dy_r)));
759 IJV.push_back(Eigen::Triplet<double>(3 * s.f_n + dy_r, s.v_n + dy_c, val * s.W_22(dy_r)));
760 }
761 }
762 }
763 else
764 {
765
766 /*A = [W11*Dx, W12*Dx, W13*Dx;
767 W11*Dy, W12*Dy, W13*Dy;
768 W11*Dz, W12*Dz, W13*Dz;
769 W21*Dx, W22*Dx, W23*Dx;
770 W21*Dy, W22*Dy, W23*Dy;
771 W21*Dz, W22*Dz, W23*Dz;
772 W31*Dx, W32*Dx, W33*Dx;
773 W31*Dy, W32*Dy, W33*Dy;
774 W31*Dz, W32*Dz, W33*Dz;];*/
775 IJV.reserve(9 * (s.Dx.outerSize() + s.Dy.outerSize() + s.Dz.outerSize()));
776 for (int k = 0; k < s.Dx.outerSize(); k++)
777 {
778 for (Eigen::SparseMatrix<double>::InnerIterator it(s.Dx, k); it; ++it)
779 {
780 int dx_r = it.row();
781 int dx_c = it.col();
782 double val = it.value();
783
784 IJV.push_back(Eigen::Triplet<double>(dx_r, dx_c, val * s.W_11(dx_r)));
785 IJV.push_back(Eigen::Triplet<double>(dx_r, s.v_n + dx_c, val * s.W_12(dx_r)));
786 IJV.push_back(Eigen::Triplet<double>(dx_r, 2 * s.v_n + dx_c, val * s.W_13(dx_r)));
787
788 IJV.push_back(Eigen::Triplet<double>(3 * s.f_n + dx_r, dx_c, val * s.W_21(dx_r)));
789 IJV.push_back(Eigen::Triplet<double>(3 * s.f_n + dx_r, s.v_n + dx_c, val * s.W_22(dx_r)));
790 IJV.push_back(Eigen::Triplet<double>(3 * s.f_n + dx_r, 2 * s.v_n + dx_c, val * s.W_23(dx_r)));
791
792 IJV.push_back(Eigen::Triplet<double>(6 * s.f_n + dx_r, dx_c, val * s.W_31(dx_r)));
793 IJV.push_back(Eigen::Triplet<double>(6 * s.f_n + dx_r, s.v_n + dx_c, val * s.W_32(dx_r)));
794 IJV.push_back(Eigen::Triplet<double>(6 * s.f_n + dx_r, 2 * s.v_n + dx_c, val * s.W_33(dx_r)));
795 }
796 }
797
798 for (int k = 0; k < s.Dy.outerSize(); k++)
799 {
800 for (Eigen::SparseMatrix<double>::InnerIterator it(s.Dy, k); it; ++it)
801 {
802 int dy_r = it.row();
803 int dy_c = it.col();
804 double val = it.value();
805
806 IJV.push_back(Eigen::Triplet<double>(s.f_n + dy_r, dy_c, val * s.W_11(dy_r)));
807 IJV.push_back(Eigen::Triplet<double>(s.f_n + dy_r, s.v_n + dy_c, val * s.W_12(dy_r)));
808 IJV.push_back(Eigen::Triplet<double>(s.f_n + dy_r, 2 * s.v_n + dy_c, val * s.W_13(dy_r)));
809
810 IJV.push_back(Eigen::Triplet<double>(4 * s.f_n + dy_r, dy_c, val * s.W_21(dy_r)));
811 IJV.push_back(Eigen::Triplet<double>(4 * s.f_n + dy_r, s.v_n + dy_c, val * s.W_22(dy_r)));
812 IJV.push_back(Eigen::Triplet<double>(4 * s.f_n + dy_r, 2 * s.v_n + dy_c, val * s.W_23(dy_r)));
813
814 IJV.push_back(Eigen::Triplet<double>(7 * s.f_n + dy_r, dy_c, val * s.W_31(dy_r)));
815 IJV.push_back(Eigen::Triplet<double>(7 * s.f_n + dy_r, s.v_n + dy_c, val * s.W_32(dy_r)));
816 IJV.push_back(Eigen::Triplet<double>(7 * s.f_n + dy_r, 2 * s.v_n + dy_c, val * s.W_33(dy_r)));
817 }
818 }
819
820 for (int k = 0; k < s.Dz.outerSize(); k++)
821 {
822 for (Eigen::SparseMatrix<double>::InnerIterator it(s.Dz, k); it; ++it)
823 {
824 int dz_r = it.row();
825 int dz_c = it.col();
826 double val = it.value();
827
828 IJV.push_back(Eigen::Triplet<double>(2 * s.f_n + dz_r, dz_c, val * s.W_11(dz_r)));
829 IJV.push_back(Eigen::Triplet<double>(2 * s.f_n + dz_r, s.v_n + dz_c, val * s.W_12(dz_r)));
830 IJV.push_back(Eigen::Triplet<double>(2 * s.f_n + dz_r, 2 * s.v_n + dz_c, val * s.W_13(dz_r)));
831
832 IJV.push_back(Eigen::Triplet<double>(5 * s.f_n + dz_r, dz_c, val * s.W_21(dz_r)));
833 IJV.push_back(Eigen::Triplet<double>(5 * s.f_n + dz_r, s.v_n + dz_c, val * s.W_22(dz_r)));
834 IJV.push_back(Eigen::Triplet<double>(5 * s.f_n + dz_r, 2 * s.v_n + dz_c, val * s.W_23(dz_r)));
835
836 IJV.push_back(Eigen::Triplet<double>(8 * s.f_n + dz_r, dz_c, val * s.W_31(dz_r)));
837 IJV.push_back(Eigen::Triplet<double>(8 * s.f_n + dz_r, s.v_n + dz_c, val * s.W_32(dz_r)));
838 IJV.push_back(Eigen::Triplet<double>(8 * s.f_n + dz_r, 2 * s.v_n + dz_c, val * s.W_33(dz_r)));
839 }
840 }
841 }
842 }
Definition SparseCompressedBase.h:137
Index outerSize() const
Definition SparseMatrix.h:143
A small structure to hold a non zero as a triplet (i,j,value).
Definition SparseUtil.h:155
Eigen::VectorXd W_12
Definition slim.h:67
Eigen::VectorXd W_33
Definition slim.h:69
Eigen::VectorXd W_32
Definition slim.h:69
Eigen::SparseMatrix< double > Dx
Definition slim.h:70
Eigen::VectorXd W_31
Definition slim.h:69
Eigen::VectorXd W_13
Definition slim.h:67
Eigen::SparseMatrix< double > Dz
Definition slim.h:70
Eigen::VectorXd W_22
Definition slim.h:68
Eigen::SparseMatrix< double > Dy
Definition slim.h:70
Eigen::VectorXd W_11
Definition slim.h:67
Eigen::VectorXd W_23
Definition slim.h:68
Eigen::VectorXd W_21
Definition slim.h:68

References igl::SLIMData::dim, igl::SLIMData::Dx, igl::SLIMData::Dy, igl::SLIMData::Dz, igl::SLIMData::f_n, Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::outerSize(), igl::SLIMData::v_n, igl::SLIMData::W_11, igl::SLIMData::W_12, igl::SLIMData::W_13, igl::SLIMData::W_21, igl::SLIMData::W_22, igl::SLIMData::W_23, igl::SLIMData::W_31, igl::SLIMData::W_32, and igl::SLIMData::W_33.

Referenced by build_linear_system().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildRhs()

IGL_INLINE void igl::slim::buildRhs ( igl::SLIMData s,
const Eigen::SparseMatrix< double > &  A 
)
845 {
846 Eigen::VectorXd f_rhs(s.dim * s.dim * s.f_n);
847 f_rhs.setZero();
848 if (s.dim == 2)
849 {
850 /*b = [W11*R11 + W12*R21; (formula (36))
851 W11*R12 + W12*R22;
852 W21*R11 + W22*R21;
853 W21*R12 + W22*R22];*/
854 for (int i = 0; i < s.f_n; i++)
855 {
856 f_rhs(i + 0 * s.f_n) = s.W_11(i) * s.Ri(i, 0) + s.W_12(i) * s.Ri(i, 1);
857 f_rhs(i + 1 * s.f_n) = s.W_11(i) * s.Ri(i, 2) + s.W_12(i) * s.Ri(i, 3);
858 f_rhs(i + 2 * s.f_n) = s.W_21(i) * s.Ri(i, 0) + s.W_22(i) * s.Ri(i, 1);
859 f_rhs(i + 3 * s.f_n) = s.W_21(i) * s.Ri(i, 2) + s.W_22(i) * s.Ri(i, 3);
860 }
861 }
862 else
863 {
864 /*b = [W11*R11 + W12*R21 + W13*R31;
865 W11*R12 + W12*R22 + W13*R32;
866 W11*R13 + W12*R23 + W13*R33;
867 W21*R11 + W22*R21 + W23*R31;
868 W21*R12 + W22*R22 + W23*R32;
869 W21*R13 + W22*R23 + W23*R33;
870 W31*R11 + W32*R21 + W33*R31;
871 W31*R12 + W32*R22 + W33*R32;
872 W31*R13 + W32*R23 + W33*R33;];*/
873 for (int i = 0; i < s.f_n; i++)
874 {
875 f_rhs(i + 0 * s.f_n) = s.W_11(i) * s.Ri(i, 0) + s.W_12(i) * s.Ri(i, 1) + s.W_13(i) * s.Ri(i, 2);
876 f_rhs(i + 1 * s.f_n) = s.W_11(i) * s.Ri(i, 3) + s.W_12(i) * s.Ri(i, 4) + s.W_13(i) * s.Ri(i, 5);
877 f_rhs(i + 2 * s.f_n) = s.W_11(i) * s.Ri(i, 6) + s.W_12(i) * s.Ri(i, 7) + s.W_13(i) * s.Ri(i, 8);
878 f_rhs(i + 3 * s.f_n) = s.W_21(i) * s.Ri(i, 0) + s.W_22(i) * s.Ri(i, 1) + s.W_23(i) * s.Ri(i, 2);
879 f_rhs(i + 4 * s.f_n) = s.W_21(i) * s.Ri(i, 3) + s.W_22(i) * s.Ri(i, 4) + s.W_23(i) * s.Ri(i, 5);
880 f_rhs(i + 5 * s.f_n) = s.W_21(i) * s.Ri(i, 6) + s.W_22(i) * s.Ri(i, 7) + s.W_23(i) * s.Ri(i, 8);
881 f_rhs(i + 6 * s.f_n) = s.W_31(i) * s.Ri(i, 0) + s.W_32(i) * s.Ri(i, 1) + s.W_33(i) * s.Ri(i, 2);
882 f_rhs(i + 7 * s.f_n) = s.W_31(i) * s.Ri(i, 3) + s.W_32(i) * s.Ri(i, 4) + s.W_33(i) * s.Ri(i, 5);
883 f_rhs(i + 8 * s.f_n) = s.W_31(i) * s.Ri(i, 6) + s.W_32(i) * s.Ri(i, 7) + s.W_33(i) * s.Ri(i, 8);
884 }
885 }
886 Eigen::VectorXd uv_flat(s.dim *s.v_n);
887 for (int i = 0; i < s.dim; i++)
888 for (int j = 0; j < s.v_n; j++)
889 uv_flat(s.v_n * i + j) = s.V_o(j, i);
890
891 s.rhs = (f_rhs.transpose() * s.WGL_M.asDiagonal() * A).transpose() + s.proximal_p * uv_flat;
892 }
Eigen::MatrixXd Ri
Definition slim.h:66
Eigen::MatrixXd V_o
Definition slim.h:53

References igl::SLIMData::dim, igl::SLIMData::f_n, igl::SLIMData::proximal_p, igl::SLIMData::rhs, igl::SLIMData::Ri, igl::SLIMData::v_n, igl::SLIMData::V_o, igl::SLIMData::W_11, igl::SLIMData::W_12, igl::SLIMData::W_13, igl::SLIMData::W_21, igl::SLIMData::W_22, igl::SLIMData::W_23, igl::SLIMData::W_31, igl::SLIMData::W_32, igl::SLIMData::W_33, and igl::SLIMData::WGL_M.

Referenced by build_linear_system().

+ Here is the caller graph for this function:

◆ compute_energy()

IGL_INLINE double igl::slim::compute_energy ( igl::SLIMData s,
Eigen::MatrixXd &  V_new 
)
575 {
576 compute_jacobians(s,V_new);
577 return compute_energy_with_jacobians(s, s.V, s.F, s.Ji, V_new, s.M) +
578 compute_soft_const_energy(s, s.V, s.F, V_new);
579 }
IGL_INLINE double compute_energy_with_jacobians(igl::SLIMData &s, const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &Ji, Eigen::MatrixXd &uv, Eigen::VectorXd &areas)
Definition slim.cpp:594
IGL_INLINE double compute_soft_const_energy(igl::SLIMData &s, const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, Eigen::MatrixXd &V_o)
Definition slim.cpp:581
IGL_INLINE void compute_jacobians(igl::SLIMData &s, const Eigen::MatrixXd &uv)
Definition slim.cpp:95
Eigen::VectorXd M
Definition slim.h:57
Eigen::MatrixXd Ji
Definition slim.h:66
Eigen::MatrixXd V
Definition slim.h:30
Eigen::MatrixXi F
Definition slim.h:31

References compute_energy_with_jacobians(), compute_jacobians(), compute_soft_const_energy(), igl::SLIMData::F, igl::SLIMData::Ji, igl::SLIMData::M, and igl::SLIMData::V.

Referenced by igl::slim_precompute(), and igl::slim_solve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_energy_with_jacobians()

IGL_INLINE double igl::slim::compute_energy_with_jacobians ( igl::SLIMData s,
const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::MatrixXd &  Ji,
Eigen::MatrixXd &  uv,
Eigen::VectorXd &  areas 
)
598 {
599
600 double energy = 0;
601 if (s.dim == 2)
602 {
604 for (int i = 0; i < s.f_n; i++)
605 {
606 ji(0, 0) = Ji(i, 0);
607 ji(0, 1) = Ji(i, 1);
608 ji(1, 0) = Ji(i, 2);
609 ji(1, 1) = Ji(i, 3);
610
611 typedef Eigen::Matrix<double, 2, 2> Mat2;
612 typedef Eigen::Matrix<double, 2, 1> Vec2;
613 Mat2 ri, ti, ui, vi;
614 Vec2 sing;
615 igl::polar_svd(ji, ri, ti, ui, sing, vi);
616 double s1 = sing(0);
617 double s2 = sing(1);
618
619 switch (s.slim_energy)
620 {
622 {
623 energy += areas(i) * (pow(s1 - 1, 2) + pow(s2 - 1, 2));
624 break;
625 }
627 {
628 energy += areas(i) * (pow(s1, 2) + pow(s1, -2) + pow(s2, 2) + pow(s2, -2));
629 break;
630 }
632 {
633 energy += areas(i) * exp(s.exp_factor * (pow(s1, 2) + pow(s1, -2) + pow(s2, 2) + pow(s2, -2)));
634 break;
635 }
637 {
638 energy += areas(i) * (pow(log(s1), 2) + pow(log(s2), 2));
639 break;
640 }
642 {
643 energy += areas(i) * ((pow(s1, 2) + pow(s2, 2)) / (2 * s1 * s2));
644 break;
645 }
647 {
648 energy += areas(i) * exp(s.exp_factor * ((pow(s1, 2) + pow(s2, 2)) / (2 * s1 * s2)));
649 break;
650 }
651
652 }
653
654 }
655 }
656 else
657 {
659 for (int i = 0; i < s.f_n; i++)
660 {
661 ji(0, 0) = Ji(i, 0);
662 ji(0, 1) = Ji(i, 1);
663 ji(0, 2) = Ji(i, 2);
664 ji(1, 0) = Ji(i, 3);
665 ji(1, 1) = Ji(i, 4);
666 ji(1, 2) = Ji(i, 5);
667 ji(2, 0) = Ji(i, 6);
668 ji(2, 1) = Ji(i, 7);
669 ji(2, 2) = Ji(i, 8);
670
671 typedef Eigen::Matrix<double, 3, 3> Mat3;
672 typedef Eigen::Matrix<double, 3, 1> Vec3;
673 Mat3 ri, ti, ui, vi;
674 Vec3 sing;
675 igl::polar_svd(ji, ri, ti, ui, sing, vi);
676 double s1 = sing(0);
677 double s2 = sing(1);
678 double s3 = sing(2);
679
680 switch (s.slim_energy)
681 {
683 {
684 energy += areas(i) * (pow(s1 - 1, 2) + pow(s2 - 1, 2) + pow(s3 - 1, 2));
685 break;
686 }
688 {
689 energy += areas(i) * (pow(s1, 2) + pow(s1, -2) + pow(s2, 2) + pow(s2, -2) + pow(s3, 2) + pow(s3, -2));
690 break;
691 }
693 {
694 energy += areas(i) * exp(s.exp_factor *
695 (pow(s1, 2) + pow(s1, -2) + pow(s2, 2) + pow(s2, -2) + pow(s3, 2) + pow(s3, -2)));
696 break;
697 }
699 {
700 energy += areas(i) * (pow(log(s1), 2) + pow(log(std::abs(s2)), 2) + pow(log(std::abs(s3)), 2));
701 break;
702 }
704 {
705 energy += areas(i) * ((pow(s1, 2) + pow(s2, 2) + pow(s3, 2)) / (3 * pow(s1 * s2 * s3, 2. / 3.)));
706 break;
707 }
709 {
710 energy += areas(i) * exp((pow(s1, 2) + pow(s2, 2) + pow(s3, 2)) / (3 * pow(s1 * s2 * s3, 2. / 3.)));
711 break;
712 }
713 }
714 }
715 }
716
717 return energy;
718 }
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
Definition ArrayCwiseUnaryOps.h:88
EIGEN_DEVICE_FUNC const LogReturnType log() const
Definition ArrayCwiseUnaryOps.h:105
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half &a, const half &b)
Definition Half.h:477
IGL_INLINE void polar_svd(const Eigen::PlainObjectBase< DerivedA > &A, Eigen::PlainObjectBase< DerivedR > &R, Eigen::PlainObjectBase< DerivedT > &T, Eigen::PlainObjectBase< DerivedU > &U, Eigen::PlainObjectBase< DerivedS > &S, Eigen::PlainObjectBase< DerivedV > &V)
Definition polar_svd.cpp:36
double exp_factor
Definition slim.h:49
@ ARAP
Definition slim.h:34
@ EXP_CONFORMAL
Definition slim.h:38
@ LOG_ARAP
Definition slim.h:35
@ CONFORMAL
Definition slim.h:37
@ EXP_SYMMETRIC_DIRICHLET
Definition slim.h:39
@ SYMMETRIC_DIRICHLET
Definition slim.h:36
SLIM_ENERGY slim_energy
Definition slim.h:41

References igl::SLIMData::ARAP, igl::SLIMData::CONFORMAL, igl::SLIMData::dim, exp(), igl::SLIMData::EXP_CONFORMAL, igl::SLIMData::exp_factor, igl::SLIMData::EXP_SYMMETRIC_DIRICHLET, igl::SLIMData::f_n, log(), igl::SLIMData::LOG_ARAP, igl::polar_svd(), igl::SLIMData::slim_energy, and igl::SLIMData::SYMMETRIC_DIRICHLET.

Referenced by compute_energy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_jacobians()

IGL_INLINE void igl::slim::compute_jacobians ( igl::SLIMData s,
const Eigen::MatrixXd &  uv 
)
96 {
97 if (s.F.cols() == 3)
98 {
99 // Ji=[D1*u,D2*u,D1*v,D2*v];
100 s.Ji.col(0) = s.Dx * uv.col(0);
101 s.Ji.col(1) = s.Dy * uv.col(0);
102 s.Ji.col(2) = s.Dx * uv.col(1);
103 s.Ji.col(3) = s.Dy * uv.col(1);
104 }
105 else /*tet mesh*/{
106 // Ji=[D1*u,D2*u,D3*u, D1*v,D2*v, D3*v, D1*w,D2*w,D3*w];
107 s.Ji.col(0) = s.Dx * uv.col(0);
108 s.Ji.col(1) = s.Dy * uv.col(0);
109 s.Ji.col(2) = s.Dz * uv.col(0);
110 s.Ji.col(3) = s.Dx * uv.col(1);
111 s.Ji.col(4) = s.Dy * uv.col(1);
112 s.Ji.col(5) = s.Dz * uv.col(1);
113 s.Ji.col(6) = s.Dx * uv.col(2);
114 s.Ji.col(7) = s.Dy * uv.col(2);
115 s.Ji.col(8) = s.Dz * uv.col(2);
116 }
117 }

References igl::SLIMData::Dx, igl::SLIMData::Dy, igl::SLIMData::Dz, igl::SLIMData::F, and igl::SLIMData::Ji.

Referenced by compute_energy(), and update_weights_and_closest_rotations().

+ Here is the caller graph for this function:

◆ compute_soft_const_energy()

IGL_INLINE double igl::slim::compute_soft_const_energy ( igl::SLIMData s,
const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
Eigen::MatrixXd &  V_o 
)
585 {
586 double e = 0;
587 for (int i = 0; i < s.b.rows(); i++)
588 {
589 e += s.soft_const_p * (s.bc.row(i) - V_o.row(s.b(i))).squaredNorm();
590 }
591 return e;
592 }

References igl::SLIMData::b, igl::SLIMData::bc, and igl::SLIMData::soft_const_p.

Referenced by compute_energy().

+ Here is the caller graph for this function:

◆ compute_surface_gradient_matrix()

IGL_INLINE void igl::slim::compute_surface_gradient_matrix ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::MatrixXd &  F1,
const Eigen::MatrixXd &  F2,
Eigen::SparseMatrix< double > &  D1,
Eigen::SparseMatrix< double > &  D2 
)
83 {
84
86 igl::grad(V, F, G);
87 Eigen::SparseMatrix<double> Dx = G.block(0, 0, F.rows(), V.rows());
88 Eigen::SparseMatrix<double> Dy = G.block(F.rows(), 0, F.rows(), V.rows());
89 Eigen::SparseMatrix<double> Dz = G.block(2 * F.rows(), 0, F.rows(), V.rows());
90
91 D1 = F1.col(0).asDiagonal() * Dx + F1.col(1).asDiagonal() * Dy + F1.col(2).asDiagonal() * Dz;
92 D2 = F2.col(0).asDiagonal() * Dx + F2.col(1).asDiagonal() * Dy + F2.col(2).asDiagonal() * Dz;
93 }
IGL_INLINE void grad(const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, Eigen::SparseMatrix< typename DerivedV::Scalar > &G, bool uniform=false)
Definition grad.cpp:227

References igl::grad().

Referenced by pre_calc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pre_calc()

IGL_INLINE void igl::slim::pre_calc ( igl::SLIMData s)
440 {
441 if (!s.has_pre_calc)
442 {
443 s.v_n = s.v_num;
444 s.f_n = s.f_num;
445
446 if (s.F.cols() == 3)
447 {
448 s.dim = 2;
449 Eigen::MatrixXd F1, F2, F3;
450 igl::local_basis(s.V, s.F, F1, F2, F3);
451 compute_surface_gradient_matrix(s.V, s.F, F1, F2, s.Dx, s.Dy);
452
453 s.W_11.resize(s.f_n);
454 s.W_12.resize(s.f_n);
455 s.W_21.resize(s.f_n);
456 s.W_22.resize(s.f_n);
457 }
458 else
459 {
460 s.dim = 3;
462 igl::grad(s.V, s.F, G,
463 s.mesh_improvement_3d /*use normal gradient, or one from a "regular" tet*/);
464 s.Dx = G.block(0, 0, s.F.rows(), s.V.rows());
465 s.Dy = G.block(s.F.rows(), 0, s.F.rows(), s.V.rows());
466 s.Dz = G.block(2 * s.F.rows(), 0, s.F.rows(), s.V.rows());
467
468
469 s.W_11.resize(s.f_n);
470 s.W_12.resize(s.f_n);
471 s.W_13.resize(s.f_n);
472 s.W_21.resize(s.f_n);
473 s.W_22.resize(s.f_n);
474 s.W_23.resize(s.f_n);
475 s.W_31.resize(s.f_n);
476 s.W_32.resize(s.f_n);
477 s.W_33.resize(s.f_n);
478 }
479
480 s.Dx.makeCompressed();
481 s.Dy.makeCompressed();
482 s.Dz.makeCompressed();
483 s.Ri.resize(s.f_n, s.dim * s.dim);
484 s.Ji.resize(s.f_n, s.dim * s.dim);
485 s.rhs.resize(s.dim * s.v_num);
486
487 // flattened weight matrix
488 s.WGL_M.resize(s.dim * s.dim * s.f_n);
489 for (int i = 0; i < s.dim * s.dim; i++)
490 for (int j = 0; j < s.f_n; j++)
491 s.WGL_M(i * s.f_n + j) = s.M(j);
492
493 s.first_solve = true;
494 s.has_pre_calc = true;
495 }
496 }
IGL_INLINE void compute_surface_gradient_matrix(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &F1, const Eigen::MatrixXd &F2, Eigen::SparseMatrix< double > &D1, Eigen::SparseMatrix< double > &D2)
Definition slim.cpp:80
IGL_INLINE void local_basis(const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedV > &B1, Eigen::PlainObjectBase< DerivedV > &B2, Eigen::PlainObjectBase< DerivedV > &B3)
Definition local_basis.cpp:19
int f_num
Definition slim.h:61
bool mesh_improvement_3d
Definition slim.h:50
bool has_pre_calc
Definition slim.h:73
bool first_solve
Definition slim.h:72

References compute_surface_gradient_matrix(), igl::SLIMData::dim, igl::SLIMData::Dx, igl::SLIMData::Dy, igl::SLIMData::Dz, igl::SLIMData::F, igl::SLIMData::f_n, igl::SLIMData::f_num, igl::SLIMData::first_solve, igl::grad(), igl::SLIMData::has_pre_calc, igl::SLIMData::Ji, igl::local_basis(), igl::SLIMData::M, Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >::makeCompressed(), igl::SLIMData::mesh_improvement_3d, igl::SLIMData::rhs, igl::SLIMData::Ri, igl::SLIMData::V, igl::SLIMData::v_n, igl::SLIMData::v_num, igl::SLIMData::W_11, igl::SLIMData::W_12, igl::SLIMData::W_13, igl::SLIMData::W_21, igl::SLIMData::W_22, igl::SLIMData::W_23, igl::SLIMData::W_31, igl::SLIMData::W_32, igl::SLIMData::W_33, and igl::SLIMData::WGL_M.

Referenced by igl::slim_precompute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ solve_weighted_arap()

IGL_INLINE void igl::slim::solve_weighted_arap ( igl::SLIMData s,
const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
Eigen::MatrixXd &  uv,
Eigen::VectorXi &  soft_b_p,
Eigen::MatrixXd &  soft_bc_p 
)
400 {
401 using namespace Eigen;
402
405
406 igl::Timer t;
407
408 //t.start();
409 // solve
410 Eigen::VectorXd Uc;
411#ifndef CHOLMOD
412 if (s.dim == 2)
413 {
415 Uc = solver.compute(L).solve(s.rhs);
416 }
417 else
418 { // seems like CG performs much worse for 2D and way better for 3D
419 Eigen::VectorXd guess(uv.rows() * s.dim);
420 for (int i = 0; i < s.v_num; i++) for (int j = 0; j < s.dim; j++) guess(uv.rows() * j + i) = uv(i, j); // flatten vector
422 cg.setTolerance(1e-8);
423 cg.compute(L);
424 Uc = cg.solveWithGuess(s.rhs, guess);
425 }
426#else
428 Uc = solver.compute(L).solve(s.rhs);
429#endif
430 for (int i = 0; i < s.dim; i++)
431 uv.col(i) = Uc.block(i * s.v_n, 0, s.v_n, 1);
432
433 // t.stop();
434 // std::cerr << "solve: " << t.getElapsedTime() << std::endl;
435
436 }
Derived & compute(const MatrixType &matrix)
Definition CholmodSupport.h:232
A simplicial direct Cholesky (LDLT) factorization and solver based on Cholmod.
Definition CholmodSupport.h:486
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition ConjugateGradient.h:159
A direct sparse LDLT Cholesky factorizations without square root.
Definition SimplicialCholesky.h:422
SimplicialLDLT & compute(const MatrixType &matrix)
Definition SimplicialCholesky.h:461
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition SparseSolverBase.h:88
Definition Timer.h:29
Definition LDLT.h:16
IGL_INLINE void build_linear_system(igl::SLIMData &s, Eigen::SparseMatrix< double > &L)
Definition slim.cpp:498

References build_linear_system(), Eigen::CholmodBase< _MatrixType, _UpLo, Derived >::compute(), Eigen::SimplicialLDLT< _MatrixType, _UpLo, _Ordering >::compute(), igl::SLIMData::dim, L, igl::SLIMData::rhs, Eigen::SparseSolverBase< Derived >::solve(), igl::SLIMData::v_n, and igl::SLIMData::v_num.

Referenced by igl::slim_solve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_weights_and_closest_rotations()

IGL_INLINE void igl::slim::update_weights_and_closest_rotations ( igl::SLIMData s,
const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
Eigen::MatrixXd &  uv 
)
123 {
124 compute_jacobians(s, uv);
125
126 const double eps = 1e-8;
127 double exp_f = s.exp_factor;
128
129 if (s.dim == 2)
130 {
131 for (int i = 0; i < s.Ji.rows(); ++i)
132 {
133 typedef Eigen::Matrix<double, 2, 2> Mat2;
134 typedef Eigen::Matrix<double, 2, 1> Vec2;
135 Mat2 ji, ri, ti, ui, vi;
136 Vec2 sing;
137 Vec2 closest_sing_vec;
138 Mat2 mat_W;
139 Vec2 m_sing_new;
140 double s1, s2;
141
142 ji(0, 0) = s.Ji(i, 0);
143 ji(0, 1) = s.Ji(i, 1);
144 ji(1, 0) = s.Ji(i, 2);
145 ji(1, 1) = s.Ji(i, 3);
146
147 igl::polar_svd(ji, ri, ti, ui, sing, vi);
148
149 s1 = sing(0);
150 s2 = sing(1);
151
152 // Update Weights according to energy
153 switch (s.slim_energy)
154 {
156 {
157 m_sing_new << 1, 1;
158 break;
159 }
161 {
162 double s1_g = 2 * (s1 - pow(s1, -3));
163 double s2_g = 2 * (s2 - pow(s2, -3));
164 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1)));
165 break;
166 }
168 {
169 double s1_g = 2 * (log(s1) / s1);
170 double s2_g = 2 * (log(s2) / s2);
171 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1)));
172 break;
173 }
175 {
176 double s1_g = 1 / (2 * s2) - s2 / (2 * pow(s1, 2));
177 double s2_g = 1 / (2 * s1) - s1 / (2 * pow(s2, 2));
178
179 double geo_avg = sqrt(s1 * s2);
180 double s1_min = geo_avg;
181 double s2_min = geo_avg;
182
183 m_sing_new << sqrt(s1_g / (2 * (s1 - s1_min))), sqrt(s2_g / (2 * (s2 - s2_min)));
184
185 // change local step
186 closest_sing_vec << s1_min, s2_min;
187 ri = ui * closest_sing_vec.asDiagonal() * vi.transpose();
188 break;
189 }
191 {
192 double s1_g = 2 * (s1 - pow(s1, -3));
193 double s2_g = 2 * (s2 - pow(s2, -3));
194
195 double geo_avg = sqrt(s1 * s2);
196 double s1_min = geo_avg;
197 double s2_min = geo_avg;
198
199 double in_exp = exp_f * ((pow(s1, 2) + pow(s2, 2)) / (2 * s1 * s2));
200 double exp_thing = exp(in_exp);
201
202 s1_g *= exp_thing * exp_f;
203 s2_g *= exp_thing * exp_f;
204
205 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1)));
206 break;
207 }
209 {
210 double s1_g = 2 * (s1 - pow(s1, -3));
211 double s2_g = 2 * (s2 - pow(s2, -3));
212
213 double in_exp = exp_f * (pow(s1, 2) + pow(s1, -2) + pow(s2, 2) + pow(s2, -2));
214 double exp_thing = exp(in_exp);
215
216 s1_g *= exp_thing * exp_f;
217 s2_g *= exp_thing * exp_f;
218
219 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1)));
220 break;
221 }
222 }
223
224 if (std::abs(s1 - 1) < eps) m_sing_new(0) = 1;
225 if (std::abs(s2 - 1) < eps) m_sing_new(1) = 1;
226 mat_W = ui * m_sing_new.asDiagonal() * ui.transpose();
227
228 s.W_11(i) = mat_W(0, 0);
229 s.W_12(i) = mat_W(0, 1);
230 s.W_21(i) = mat_W(1, 0);
231 s.W_22(i) = mat_W(1, 1);
232
233 // 2) Update local step (doesn't have to be a rotation, for instance in case of conformal energy)
234 s.Ri(i, 0) = ri(0, 0);
235 s.Ri(i, 1) = ri(1, 0);
236 s.Ri(i, 2) = ri(0, 1);
237 s.Ri(i, 3) = ri(1, 1);
238 }
239 }
240 else
241 {
242 typedef Eigen::Matrix<double, 3, 1> Vec3;
243 typedef Eigen::Matrix<double, 3, 3> Mat3;
244 Mat3 ji;
245 Vec3 m_sing_new;
246 Vec3 closest_sing_vec;
247 const double sqrt_2 = sqrt(2);
248 for (int i = 0; i < s.Ji.rows(); ++i)
249 {
250 ji(0, 0) = s.Ji(i, 0);
251 ji(0, 1) = s.Ji(i, 1);
252 ji(0, 2) = s.Ji(i, 2);
253 ji(1, 0) = s.Ji(i, 3);
254 ji(1, 1) = s.Ji(i, 4);
255 ji(1, 2) = s.Ji(i, 5);
256 ji(2, 0) = s.Ji(i, 6);
257 ji(2, 1) = s.Ji(i, 7);
258 ji(2, 2) = s.Ji(i, 8);
259
260 Mat3 ri, ti, ui, vi;
261 Vec3 sing;
262 igl::polar_svd(ji, ri, ti, ui, sing, vi);
263
264 double s1 = sing(0);
265 double s2 = sing(1);
266 double s3 = sing(2);
267
268 // 1) Update Weights
269 switch (s.slim_energy)
270 {
272 {
273 m_sing_new << 1, 1, 1;
274 break;
275 }
277 {
278 double s1_g = 2 * (log(s1) / s1);
279 double s2_g = 2 * (log(s2) / s2);
280 double s3_g = 2 * (log(s3) / s3);
281 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1))), sqrt(s3_g / (2 * (s3 - 1)));
282 break;
283 }
285 {
286 double s1_g = 2 * (s1 - pow(s1, -3));
287 double s2_g = 2 * (s2 - pow(s2, -3));
288 double s3_g = 2 * (s3 - pow(s3, -3));
289 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1))), sqrt(s3_g / (2 * (s3 - 1)));
290 break;
291 }
293 {
294 double s1_g = 2 * (s1 - pow(s1, -3));
295 double s2_g = 2 * (s2 - pow(s2, -3));
296 double s3_g = 2 * (s3 - pow(s3, -3));
297 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1))), sqrt(s3_g / (2 * (s3 - 1)));
298
299 double in_exp = exp_f * (pow(s1, 2) + pow(s1, -2) + pow(s2, 2) + pow(s2, -2) + pow(s3, 2) + pow(s3, -2));
300 double exp_thing = exp(in_exp);
301
302 s1_g *= exp_thing * exp_f;
303 s2_g *= exp_thing * exp_f;
304 s3_g *= exp_thing * exp_f;
305
306 m_sing_new << sqrt(s1_g / (2 * (s1 - 1))), sqrt(s2_g / (2 * (s2 - 1))), sqrt(s3_g / (2 * (s3 - 1)));
307
308 break;
309 }
311 {
312 double common_div = 9 * (pow(s1 * s2 * s3, 5. / 3.));
313
314 double s1_g = (-2 * s2 * s3 * (pow(s2, 2) + pow(s3, 2) - 2 * pow(s1, 2))) / common_div;
315 double s2_g = (-2 * s1 * s3 * (pow(s1, 2) + pow(s3, 2) - 2 * pow(s2, 2))) / common_div;
316 double s3_g = (-2 * s1 * s2 * (pow(s1, 2) + pow(s2, 2) - 2 * pow(s3, 2))) / common_div;
317
318 double closest_s = sqrt(pow(s1, 2) + pow(s3, 2)) / sqrt_2;
319 double s1_min = closest_s;
320 double s2_min = closest_s;
321 double s3_min = closest_s;
322
323 m_sing_new << sqrt(s1_g / (2 * (s1 - s1_min))), sqrt(s2_g / (2 * (s2 - s2_min))), sqrt(
324 s3_g / (2 * (s3 - s3_min)));
325
326 // change local step
327 closest_sing_vec << s1_min, s2_min, s3_min;
328 ri = ui * closest_sing_vec.asDiagonal() * vi.transpose();
329 break;
330 }
332 {
333 // E_conf = (s1^2 + s2^2 + s3^2)/(3*(s1*s2*s3)^(2/3) )
334 // dE_conf/ds1 = (-2*(s2*s3)*(s2^2+s3^2 -2*s1^2) ) / (9*(s1*s2*s3)^(5/3))
335 // Argmin E_conf(s1): s1 = sqrt(s1^2+s2^2)/sqrt(2)
336 double common_div = 9 * (pow(s1 * s2 * s3, 5. / 3.));
337
338 double s1_g = (-2 * s2 * s3 * (pow(s2, 2) + pow(s3, 2) - 2 * pow(s1, 2))) / common_div;
339 double s2_g = (-2 * s1 * s3 * (pow(s1, 2) + pow(s3, 2) - 2 * pow(s2, 2))) / common_div;
340 double s3_g = (-2 * s1 * s2 * (pow(s1, 2) + pow(s2, 2) - 2 * pow(s3, 2))) / common_div;
341
342 double in_exp = exp_f * ((pow(s1, 2) + pow(s2, 2) + pow(s3, 2)) / (3 * pow((s1 * s2 * s3), 2. / 3)));;
343 double exp_thing = exp(in_exp);
344
345 double closest_s = sqrt(pow(s1, 2) + pow(s3, 2)) / sqrt_2;
346 double s1_min = closest_s;
347 double s2_min = closest_s;
348 double s3_min = closest_s;
349
350 s1_g *= exp_thing * exp_f;
351 s2_g *= exp_thing * exp_f;
352 s3_g *= exp_thing * exp_f;
353
354 m_sing_new << sqrt(s1_g / (2 * (s1 - s1_min))), sqrt(s2_g / (2 * (s2 - s2_min))), sqrt(
355 s3_g / (2 * (s3 - s3_min)));
356
357 // change local step
358 closest_sing_vec << s1_min, s2_min, s3_min;
359 ri = ui * closest_sing_vec.asDiagonal() * vi.transpose();
360 }
361 }
362 if (std::abs(s1 - 1) < eps) m_sing_new(0) = 1;
363 if (std::abs(s2 - 1) < eps) m_sing_new(1) = 1;
364 if (std::abs(s3 - 1) < eps) m_sing_new(2) = 1;
365 Mat3 mat_W;
366 mat_W = ui * m_sing_new.asDiagonal() * ui.transpose();
367
368 s.W_11(i) = mat_W(0, 0);
369 s.W_12(i) = mat_W(0, 1);
370 s.W_13(i) = mat_W(0, 2);
371 s.W_21(i) = mat_W(1, 0);
372 s.W_22(i) = mat_W(1, 1);
373 s.W_23(i) = mat_W(1, 2);
374 s.W_31(i) = mat_W(2, 0);
375 s.W_32(i) = mat_W(2, 1);
376 s.W_33(i) = mat_W(2, 2);
377
378 // 2) Update closest rotations (not rotations in case of conformal energy)
379 s.Ri(i, 0) = ri(0, 0);
380 s.Ri(i, 1) = ri(1, 0);
381 s.Ri(i, 2) = ri(2, 0);
382 s.Ri(i, 3) = ri(0, 1);
383 s.Ri(i, 4) = ri(1, 1);
384 s.Ri(i, 5) = ri(2, 1);
385 s.Ri(i, 6) = ri(0, 2);
386 s.Ri(i, 7) = ri(1, 2);
387 s.Ri(i, 8) = ri(2, 2);
388 } // for loop end
389
390 } // if dim end
391
392 }
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Definition ArrayCwiseUnaryOps.h:152

References igl::SLIMData::ARAP, compute_jacobians(), igl::SLIMData::CONFORMAL, igl::SLIMData::dim, exp(), igl::SLIMData::EXP_CONFORMAL, igl::SLIMData::exp_factor, igl::SLIMData::EXP_SYMMETRIC_DIRICHLET, igl::SLIMData::Ji, log(), igl::SLIMData::LOG_ARAP, igl::polar_svd(), igl::SLIMData::Ri, igl::SLIMData::slim_energy, sqrt(), igl::SLIMData::SYMMETRIC_DIRICHLET, igl::SLIMData::W_11, igl::SLIMData::W_12, igl::SLIMData::W_13, igl::SLIMData::W_21, igl::SLIMData::W_22, igl::SLIMData::W_23, igl::SLIMData::W_31, igl::SLIMData::W_32, and igl::SLIMData::W_33.

Referenced by igl::slim_solve().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: