#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; Eigen::MatrixXd PQS0, PQS1, PQS2, PQS3; // Quad mesh generated from conjugate field Eigen::MatrixXd VQC; Eigen::MatrixXi FQC; Eigen::MatrixXi FQCtri; Eigen::MatrixXd VQCplan; Eigen::MatrixXd PQC0, PQC1, PQC2, PQC3; Eigen::MatrixXd PQCp0, PQCp1, PQCp2, PQCp3; // 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; bool key_down(igl::Viewer& viewer, unsigned char key, int modifier) { using namespace std; using namespace Eigen; if (key <'1' || key >'3') return false; viewer.data.lines.resize(0,9); // 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; // Optimize the field int conjIter = 20; int totalConjIter = 0; double lambdaOrtho = .1; double lambdaInit = 100; double lambdaMultFactor = 1.01; bool doHardConstraints = true; double lambdaOut; igl::conjugate_frame_fields(*csdata, isConstrained, conjugate_pvf, conjugate_pvf, conjIter, lambdaOrtho, lambdaInit, lambdaMultFactor, doHardConstraints, &lambdaOut); // Launch the viewer igl::Viewer viewer; viewer.core.invert_normals = true; viewer.core.show_lines = false; viewer.core.show_texture = false; viewer.set_mesh(V, F); viewer.callback_key_down = &key_down; key_down(viewer,'3',0); viewer.launch(); }