#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef std::vector > RotationList; const Eigen::RowVector3d sea_green(70./255.,252./255.,167./255.); Eigen::MatrixXd V,U; Eigen::MatrixXi F; Eigen::VectorXi S,b; Eigen::RowVector3d mid; double anim_t = 0.0; double anim_t_dir = 0.03; igl::ARAPData arap_data; bool pre_draw(igl::opengl::glfw::Viewer & viewer) { using namespace Eigen; using namespace std; MatrixXd bc(b.size(),V.cols()); for(int i = 0;i(0,V.rows()-1,b); b.conservativeResize(stable_partition( b.data(), b.data()+b.size(), [](int i)->bool{return S(i)>=0;})-b.data()); // Centroid mid = 0.5*(V.colwise().maxCoeff() + V.colwise().minCoeff()); // Precomputation arap_data.max_iter = 100; igl::arap_precomputation(V,F,V.cols(),b,arap_data); // Set color based on selection MatrixXd C(F.rows(),3); RowVector3d purple(80.0/255.0,64.0/255.0,255.0/255.0); RowVector3d gold(255.0/255.0,228.0/255.0,58.0/255.0); for(int f = 0;f=0 && S(F(f,1))>=0 && S(F(f,2))>=0) { C.row(f) = purple; }else { C.row(f) = gold; } } // Plot the mesh with pseudocolors igl::opengl::glfw::Viewer viewer; viewer.data().set_mesh(U, F); viewer.data().set_colors(C); viewer.callback_pre_draw = &pre_draw; viewer.callback_key_down = &key_down; viewer.core().is_animating = false; viewer.core().animation_max_fps = 30.; cout<< "Press [space] to toggle animation"<