#undef IGL_STATIC_LIBRARY #include #include #include #include #include #include #include #include #include #include #include #include #include // Input mesh Eigen::MatrixXd V; Eigen::MatrixXi F; // Face barycenters Eigen::MatrixXd B; // Quad mesh generated from smooth field Eigen::MatrixXd VQS; Eigen::MatrixXi FQS; Eigen::MatrixXi FQStri; // Quad mesh generated from conjugate field Eigen::MatrixXd VQC; Eigen::MatrixXi FQC; Eigen::MatrixXi FQCtri; Eigen::MatrixXd VQCplan; // Scale for visualizing the fields double global_scale; // Input constraints Eigen::VectorXi isConstrained; Eigen::MatrixXd constraints; Eigen::MatrixXd smooth_pvf; Eigen::MatrixXd conjugate_pvf; igl::ConjugateFFSolverData *csdata; int conjIter = 2; int totalConjIter = 0; double lambdaOrtho = .1; double lambdaInit = 100; double lambdaMultFactor = 1.01; bool doHardConstraints = true; bool key_down(igl::Viewer& viewer, unsigned char key, int modifier) { using namespace std; using namespace Eigen; if (key <'1' || key >'6') return false; viewer.clear_mesh(); viewer.options.show_lines = false; viewer.options.show_texture = false; if (key <= '3') { viewer.set_mesh(V, F); // Highlight in red the constrained faces MatrixXd C = MatrixXd::Constant(F.rows(),3,1); for (unsigned i=0; i(); constraints = temp.block(0,1,temp.rows(),temp.cols()-1); // Interpolate to get a smooth field igl::n_polyvector(V, F, isConstrained, constraints, smooth_pvf); // Initialize conjugate field with smooth field csdata = new igl::ConjugateFFSolverData(V,F); conjugate_pvf = smooth_pvf; // Load quad mesh generated by smooth field igl::readOFF("../shared/inspired_mesh_quads_Smooth.off", VQS, FQS); FQStri.resize(2*FQS.rows(), 3); FQStri << FQS.col(0),FQS.col(1),FQS.col(2), FQS.col(2),FQS.col(3),FQS.col(0); // Load quad mesh generated by conjugate field igl::readOFF("../shared/inspired_mesh_quads_Conjugate.off", VQC, FQC); FQCtri.resize(2*FQC.rows(), 3); FQCtri << FQC.col(0),FQC.col(1),FQC.col(2), FQC.col(2),FQC.col(3),FQC.col(0); igl::Viewer viewer; // Plot the original mesh with a texture parametrization key_down(viewer,'1',0); // Launch the viewer viewer.callback_key_down = &key_down; viewer.launch(); }