#undef IGL_STATIC_LIBRARY #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 PQC0, PQC1, PQC2, PQC3; // Scale for visualizing the fields double global_scale; // Input constraints Eigen::VectorXi isConstrained; Eigen::MatrixXd constraints; Eigen::MatrixXd smooth_pvf; Eigen::MatrixXd angle_bound_pvf; igl::AngleBoundFFSolverData *csdata; int conjIter = 2; int totalConjIter = 0; double lambdaOrtho = .1; double lambdaInit = 100; double lambdaMultFactor = 1.5; bool doHardConstraints = false; bool showAngles = true; int curr_key = 0; void computeAngles(const Eigen::MatrixXd &ff, Eigen::VectorXd &angles) { angles.resize(ff.rows(),1); int num =0; for (int i =0; i'5') { return false; } viewer.clear(); viewer.core.show_lines = false; viewer.core.show_texture = false; if (key == '1') { viewer.set_mesh(V, F); viewer.set_colors(CC); // Frame field constraints MatrixXd F1_t = MatrixXd::Zero(F.rows(),3); MatrixXd F2_t = MatrixXd::Zero(F.rows(),3); 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::AngleBoundFFSolverData(V,F); angle_bound_pvf = smooth_pvf; // Load quad mesh generated by smooth field igl::readOBJ("../shared/teddy_smooth_remeshed.obj", 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::readOBJ("../shared/teddy_angle_bound_remeshed.obj", 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::slice( VQS, FQS.col(0), 1, PQS0); igl::slice( VQS, FQS.col(1), 1, PQS1); igl::slice( VQS, FQS.col(2), 1, PQS2); igl::slice( VQS, FQS.col(3), 1, PQS3); igl::slice( VQC, FQC.col(0), 1, PQC0); igl::slice( VQC, FQC.col(1), 1, PQC1); igl::slice( VQC, FQC.col(2), 1, PQC2); igl::slice( VQC, FQC.col(3), 1, PQC3); 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(); }