28 #include <CGAL/trace.h> 29 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 30 #include <CGAL/Polyhedron_3.h> 31 #include <CGAL/IO/Polyhedron_iostream.h> 32 #include <CGAL/Surface_mesh_default_triangulation_3.h> 33 #include <CGAL/make_surface_mesh.h> 34 #include <CGAL/Implicit_surface_3.h> 35 #include <CGAL/IO/output_surface_facets_to_polyhedron.h> 36 #include <CGAL/Poisson_reconstruction_function.h> 37 #include <CGAL/Point_with_normal_3.h> 38 #include <CGAL/property_map.h> 39 #include <CGAL/IO/read_xyz_points.h> 40 #include <CGAL/compute_average_spacing.h> 46 typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
47 typedef Kernel::FT FT;
48 typedef Kernel::Point_3 Point;
49 typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal;
50 typedef Kernel::Sphere_3 Sphere;
51 typedef std::vector<Point_with_normal> PointList;
52 typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
53 typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;
54 typedef CGAL::Surface_mesh_default_triangulation_3 STr;
55 typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
56 typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
65 FT sm_distance = 0.375;
72 std::ifstream stream(
"data/kitten.xyz");
74 !CGAL::read_xyz_points_and_normals(
76 std::back_inserter(points),
77 CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
79 std::cerr <<
"Error: cannot read file data/kitten.xyz" << std::endl;
87 Poisson_reconstruction_function
function(
88 points.begin(), points.end(),
89 CGAL::make_normal_of_point_with_normal_pmap(points.begin()));
93 if ( !
function.compute_implicit_function() )
97 FT average_spacing = CGAL::compute_average_spacing(points.begin(), points.end(),
102 Point inner_point =
function.get_inner_point();
103 Sphere bsphere =
function.bounding_sphere();
104 FT radius = std::sqrt(bsphere.squared_radius());
108 FT sm_sphere_radius = 5.0 * radius;
109 FT sm_dichotomy_error = sm_distance*average_spacing/1000.0;
110 Surface_3 surface(
function,
111 Sphere(inner_point,sm_sphere_radius*sm_sphere_radius),
112 sm_dichotomy_error/sm_sphere_radius);
115 CGAL::Surface_mesh_default_criteria_3<STr> criteria(sm_angle,
116 sm_radius*average_spacing,
117 sm_distance*average_spacing);
122 CGAL::make_surface_mesh(c2t3,
125 CGAL::Manifold_with_boundary_tag());
127 if(tr.number_of_vertices() == 0)
131 std::ofstream out(
"kitten_poisson-20-30-0.375.off");
132 Polyhedron output_mesh;
133 CGAL::output_surface_facets_to_polyhedron(c2t3, output_mesh);
140 printf(
"DefSurface without CGAL not implemented\n");
Draw provides the basic configuration of the openGL libraries used in every derived program...
void DefineSurf()
Find the covering surface for given points.