int main(int argc, char*argv[]) { const char* fname = (argc>1)?argv[1]:"data/elephant.off"; // Create and fill polyhedron Polyhedron polyhedron; std::ifstream input(fname); input >> polyhedron; if(input.bad()){ std::cerr << "Error: Cannot read file " << fname << std::endl; return EXIT_FAILURE; } input.close(); // Implicit function built by AABB_tree projection queries Polyhedral_wrapper polyhedral_wrapper(polyhedron, 3, 0.01, -0.01); Mesh_domain domain(polyhedral_wrapper, polyhedral_wrapper.bounding_sphere(), 1e-4); // Set mesh criteria Facet_criteria facet_criteria(20, 5, 0.002); // angle, size, approximation Cell_criteria cell_criteria(4, 0.05); // radius-edge ratio, size Mesh_criteria criteria(facet_criteria, cell_criteria); // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria); // Output std::ofstream medit_file("out.mesh"); CGAL::output_to_medit(medit_file, c3t3); return 0; }
void operator()() const { typedef CGAL::Mesh_3::Robust_intersection_traits_3<K> Gt; typedef CGAL::Polyhedral_mesh_domain_with_features_3<Gt> Mesh_domain; typedef typename CGAL::Mesh_triangulation_3< Mesh_domain, typename CGAL::Kernel_traits<Mesh_domain>::Kernel, Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 < Tr, typename Mesh_domain::Corner_index, typename Mesh_domain::Curve_segment_index > C3t3; typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria; typedef typename Mesh_criteria::Edge_criteria Edge_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; //------------------------------------------------------- // Data generation //------------------------------------------------------- std::cout << "\tSeed is\t" << CGAL::default_random.get_seed() << std::endl; Mesh_domain domain("data/cube.off", &CGAL::default_random); domain.detect_features(); // Set mesh criteria Edge_criteria edge_criteria(0.2); Facet_criteria facet_criteria(30, 0.2, 0.02); Cell_criteria cell_criteria(3, 0.2); Mesh_criteria criteria(edge_criteria, facet_criteria, cell_criteria); // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, CGAL::parameters::no_exude(), CGAL::parameters::no_perturb()); CGAL::remove_far_points_in_mesh_3(c3t3); // Verify this->verify(c3t3,domain,criteria, Polyhedral_tag()); //, 1099, 1099, 1158, 1158, 4902, 4902); std::ofstream out_medit("test-medit.mesh"); CGAL::output_to_medit(out_medit, c3t3); CGAL::output_to_tetgen("test-tetgen", c3t3); std::ofstream out_binary("test-binary.mesh.cgal", std::ios_base::out|std::ios_base::binary); CGAL::Mesh_3::save_binary_file(out_binary, c3t3); out_binary.close(); C3t3 c3t3_bis; std::ifstream in_binary("test-binary.mesh.cgal", std::ios_base::in|std::ios_base::binary); CGAL::Mesh_3::load_binary_file(in_binary, c3t3_bis); assert(c3t3_bis.triangulation() == c3t3.triangulation()); }
void image() const { typedef CGAL::Image_3 Image; typedef CGAL::Labeled_image_mesh_domain_3<Image, K_e_i> Mesh_domain; typedef typename CGAL::Mesh_triangulation_3< Mesh_domain, CGAL::Kernel_traits<Mesh_domain>::Kernel, Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3; typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; //------------------------------------------------------- // Data generation //------------------------------------------------------- Image image; image.read("data/liver.inr.gz"); std::cout << "\tSeed is\t" << CGAL::get_default_random().get_seed() << std::endl; Mesh_domain domain(image, 1e-9, &CGAL::get_default_random()); // Set mesh criteria Facet_criteria facet_criteria(25, 20*image.vx(), 5*image.vx()); Cell_criteria cell_criteria(4, 25*image.vx()); Mesh_criteria criteria(facet_criteria, cell_criteria); // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, CGAL::parameters::no_exude(), CGAL::parameters::no_perturb()); // Verify this->verify_c3t3_volume(c3t3, 1772330*0.95, 1772330*1.05); this->verify(c3t3,domain,criteria, Bissection_tag()); typedef typename Mesh_domain::Surface_patch_index Patch_id; CGAL_static_assertion(CGAL::Output_rep<Patch_id>::is_specialized); CGAL_USE_TYPE(Patch_id); }