int main( int argc, char** argv ) { Surface_mesh surface_mesh; std::ifstream is(argc > 1 ? argv[1] : "data/fold.off"); is >> surface_mesh; // This is a stop predicate (defines when the algorithm terminates). // In this example, the simplification stops when the number of undirected edges // left in the surface mesh drops below the specified number (1000) SMS::Count_stop_predicate<Surface_mesh> stop(num_halfedges(surface_mesh)/2 - 1); typedef SMS::Bounded_normal_change_placement<SMS::LindstromTurk_placement<Surface_mesh> > Placement; // This the actual call to the simplification algorithm. // The surface mesh and stop conditions are mandatory arguments. // The index maps are needed because the vertices and edges // of this surface mesh lack an "id()" field. SMS::edge_collapse( surface_mesh, stop, CGAL::parameters::get_cost (SMS::LindstromTurk_cost<Surface_mesh>()) .get_placement(Placement()) ); std::ofstream os( argc > 2 ? argv[2] : "out.off" ); os.precision(17); os << surface_mesh; return EXIT_SUCCESS; }
void split_face_test() { Surface_fixture_6<T> f; CGAL::Euler::split_face(f.h1, f.h2,f.m); assert(num_vertices(f.m) == 4); assert(num_faces(f.m) == 2); assert(num_halfedges(f.m) == 10); }
void make_hole_test() { Surface_fixture_7<T> f; std::size_t nv = num_vertices(f.m); std::size_t nf = num_faces(f.m); std::size_t nh = num_halfedges(f.m); CGAL::Euler::make_hole(f.h, f.m); assert(CGAL::internal::exact_num_vertices(f.m) == nv); assert(CGAL::internal::exact_num_faces(f.m) == nf-1 ); assert(CGAL::internal::exact_num_halfedges(f.m) == nh); }
void remove_center_vertex_test() { Surface_fixture_7<T> f; std::size_t nv = num_vertices(f.m); std::size_t nf = num_faces(f.m); std::size_t nh = num_halfedges(f.m); typename boost::graph_traits<T>::degree_size_type deg = degree(target(f.h,f.m),f.m); CGAL::Euler::remove_center_vertex(f.h,f.m); assert(CGAL::internal::exact_num_vertices(f.m) == nv-1); assert(CGAL::internal::exact_num_faces(f.m) == (nf-deg)+1); assert(CGAL::internal::exact_num_halfedges(f.m) == nh-(2*deg)); }
int main(int,char*[]) { Triangulation t; t.insert(Point(0.1,0,1)); t.insert(Point(1,0,1)); t.insert(Point(0.2,0.2, 2)); t.insert(Point(0,1,2)); t.insert(Point(0,2,3)); vertex_iterator vit, ve; // Associate indices to the vertices int index = 0; // boost::tie assigns the first and second element of the std::pair // returned by boost::vertices to the variables vit and ve for(boost::tie(vit,ve) = vertices(t); vit!=ve; ++vit ){ vertex_descriptor vd = *vit; if(! t.is_infinite(vd)){ vertex_id_map[vd]= index++; } } std::cerr << index << " vertices" << std::endl; index = 0; face_iterator fit,fe; for(boost::tie(fit,fe) = faces(t); fit!= fe; ++fit){ face_descriptor fd = *fit; halfedge_descriptor hd = halfedge(fd,t); halfedge_descriptor n = next(hd,t); halfedge_descriptor nn = next(n,t); if(next(nn,t) != hd){ std::cerr << "the face is not a triangle" << std::endl; } ++index; } std::cerr << index << " faces" << std::endl; index = 0; edge_iterator eit,ee; for(boost::tie(eit,ee) = edges(t); eit!= ee; ++eit){ edge_descriptor ed = *eit; vertex_descriptor vd = source(ed,t); CGAL_USE(vd); ++index; } std::cerr << index << " edges" << std::endl; index = 0; halfedge_iterator hit,he; for(boost::tie(hit,he) = halfedges(t); hit!= he; ++hit){ halfedge_descriptor hd = *hit; vertex_descriptor vd = source(hd,t); CGAL_USE(vd); ++index; } std::cerr << index << " halfedges" << std::endl; std::cerr << num_vertices(t) << " " << num_edges(t) << " " << num_halfedges(t) << " " << num_faces(t) << std::endl; typedef boost::property_map<Triangulation, boost::vertex_point_t>::type Ppmap; Ppmap ppmap = get(boost::vertex_point, t); for(vertex_descriptor vd : vertices_around_target(*vertices(t).first, t)){ std::cout << ppmap[vd] << std::endl; } ppmap[*(++vertices(t).first)] = Point(78,1,2); std::cout << " changed point of vertex " << ppmap[*(++vertices(t).first)] << std::endl; return 0; }