#include "StdAfx.h" #include #include #include #include #include #include #include #include #include #include "Property_maps_for_edit_plugin.h" #include #define CGAL_SUPERLU_ENABLED #ifdef CGAL_SUPERLU_ENABLED #include typedef CGAL::Eigen_solver_traits::EigenType> > DefaultSolver; #else #include ///////////////////////////////////////////////// namespace CGAL { namespace internal { template struct Get_eigen_matrix< ::Eigen::SparseLU, FT> { typedef Eigen_sparse_matrix type; }; } // internal } // CGAL ///////////////////////////////////////////////// typedef CGAL::Eigen_solver_traits< Eigen::SparseLU< CGAL::Eigen_sparse_matrix::EigenType, Eigen::COLAMDOrdering > > DefaultSolver; #endif typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; typedef Polyhedron_vertex_deformation_index_map Vertex_index_map; typedef Polyhedron_edge_deformation_index_map Edge_index_map; typedef CGAL::Deform_mesh Deform_mesh; int main() { Polyhedron mesh; std::ifstream("data/square.off") >> mesh; Deform_mesh deform_mesh(mesh, Vertex_index_map(), Edge_index_map()); // load handles and roi from txt std::ifstream handle_stream("data/Symmetry_test_handle.txt"); std::ifstream non_roi_stream("data/Symmetry_test_non_roi.txt"); std::vector handles; std::vector non_rois; int id; while(handle_stream >> id) { handles.push_back(id); } while(non_roi_stream >> id) { non_rois.push_back(id); } std::cout << handles.size() << std::endl; std::cout << non_rois.size(); id = 0; Deform_mesh::Handle_group active_handle_group = deform_mesh.create_handle_group(); for(Polyhedron::Vertex_iterator it = mesh.vertices_begin(); it != mesh.vertices_end(); ++it, ++id) { // not efficient but small poly if(std::find(handles.begin(), handles.end(), id) != handles.end()) { deform_mesh.insert_handle(active_handle_group, it); } if(std::find(non_rois.begin(), non_rois.end(), id) == non_rois.end()) { deform_mesh.insert_roi(it); } } deform_mesh.preprocess(); Kernel::Vector_3 dif(-0.45, -0.65, 0); deform_mesh.translate(active_handle_group, dif); for(int i = 0; i < 50; ++i) { deform_mesh.deform(); } std::ofstream("data/square_deformed.off") << mesh; }