#include #include #include #include #include #include #include #include #include #include // Input mesh Eigen::MatrixXd V; Eigen::MatrixXi F; // Face barycenters Eigen::MatrixXd B; // Scale for visualizing the fields double global_scale; // Input frame field constraints Eigen::VectorXi b; Eigen::MatrixXd bc1; Eigen::MatrixXd bc2; // Interpolated frame field Eigen::MatrixXd FF1, FF2; // Singularities od the frame field Eigen::VectorXd S; // Deformed mesh Eigen::MatrixXd V_deformed; Eigen::MatrixXd B_deformed; // Frame field on deformed Eigen::MatrixXd FF1_deformed; Eigen::MatrixXd FF2_deformed; // Cross field on deformed Eigen::MatrixXd X1_deformed; Eigen::MatrixXd X2_deformed; // Quad mesh on deformed Eigen::MatrixXd V_quad_deformed; Eigen::MatrixXi F_quad_deformed; // Quad mesh Eigen::MatrixXd V_quad; Eigen::MatrixXi F_quad; 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 == '1') { // Frame field constraints viewer.set_mesh(V, F); MatrixXd F1_t = MatrixXd::Zero(FF1.rows(),FF1.cols()); MatrixXd F2_t = MatrixXd::Zero(FF2.rows(),FF2.cols()); // Highlight in red the constrained faces MatrixXd C = MatrixXd::Constant(F.rows(),3,1); for (unsigned i=0; i(); bc1 = temp.block(0,1,temp.rows(),3); bc2 = temp.block(0,4,temp.rows(),3); // Interpolate the frame field igl::frame_field(V, F, b, bc1, bc2, FF1, FF2, S); // Deform the mesh to transform the frame field in a cross field igl::frame_field_deformer(V,F,FF1,FF2,V_deformed,FF1_deformed,FF2_deformed); // Compute face barycenters deformed mesh igl::barycenter(V_deformed, F, B_deformed); 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(); }