CGAL 5.1 - 3D Surface Mesh Generation
Surface_mesher/mesh_an_implicit_function.cpp
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/Complex_2_in_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>
// default triangulation for Surface_mesher
// c2t3
typedef CGAL::Complex_2_in_triangulation_3<Tr> C2t3;
typedef Tr::Geom_traits GT;
typedef GT::Sphere_3 Sphere_3;
typedef GT::Point_3 Point_3;
typedef GT::FT FT;
typedef FT (*Function)(Point_3);
FT sphere_function (Point_3 p) {
const FT x2=p.x()*p.x(), y2=p.y()*p.y(), z2=p.z()*p.z();
return x2+y2+z2-1;
}
int main() {
Tr tr; // 3D-Delaunay triangulation
C2t3 c2t3 (tr); // 2D-complex in 3D-Delaunay triangulation
// defining the surface
Surface_3 surface(sphere_function, // pointer to function
Sphere_3(CGAL::ORIGIN, 2.)); // bounding sphere
// Note that "2." above is the *squared* radius of the bounding sphere!
// defining meshing criteria
CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30., // angular bound
0.1, // radius bound
0.1); // distance bound
// meshing surface
CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag());
std::cout << "Final number of points: " << tr.number_of_vertices() << "\n";
}
CGAL::make_surface_mesh
void make_surface_mesh(SurfaceMeshC2T3 &c2t3, Surface surface, FacetsCriteria criteria, Tag tag, int initial_number_of_points=20)
In the first overloaded version of of make_surface_mesh(), the surface type is given as template para...
CGAL::Surface_mesh_default_triangulation_3
Definition: Surface_mesh_default_triangulation_3.h:20
CGAL::Implicit_surface_3
Definition: Implicit_surface_3.h:39
Surface_3
The concept Surface_3 describes the types of surfaces to be meshed. The surface types are required to...
Definition: Surface_3.h:19
CGAL::ORIGIN
const CGAL::Origin ORIGIN
CGAL::Non_manifold_tag
Definition: make_surface_mesh.h:205
CGAL::Surface_mesh_default_criteria_3
Definition: Surface_mesh_default_criteria_3.h:36