CGAL 6.2 - 3D Surface Mesh Generation

Loading...
Searching...
No Matches
Surface_mesher/mesh_an_implicit_function.cpp
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#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>
#include <CGAL/IO/facets_in_complex_2_to_triangle_mesh.h>
#include <CGAL/Surface_mesh.h>
#include <fstream>
// default triangulation for Surface_mesher
typedef CGAL::Surface_mesh_default_triangulation_3 Tr;
// 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);
typedef CGAL::Implicit_surface_3<GT, Function> Surface_3;
typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
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());
Surface_mesh sm;
CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, sm);
std::ofstream out("sphere.off");
out << sm << std::endl;
std::cout << "Final number of points: " << tr.number_of_vertices() << "\n";
}
CGAL::Implicit_surface_3
The class Implicit_surface_3 implements a surface described as the zero level set of a function .
Definition: Implicit_surface_3.h:39
CGAL::Surface_mesh_default_criteria_3
The class Surface_mesh_default_criteria_3 implements the most commonly used combination of meshing cr...
Definition: Surface_mesh_default_criteria_3.h:36
CGAL::Surface_mesh_default_triangulation_3
The class Surface_mesh_default_triangulation_3 is a model of the concept SurfaceMeshTriangulation_3,...
Definition: Surface_mesh_default_triangulation_3.h:20
Surface_3
The concept Surface_3 describes the types of surfaces to be meshed. The surface types are required to...
Definition: Surface_3.h:21
CGAL::facets_in_complex_2_to_triangle_mesh
void facets_in_complex_2_to_triangle_mesh(const C2T3 &c2t3, TriangleMesh &graph)
converts a manifold surface reconstructed by make_surface_mesh() to a TriangleMesh.
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::ORIGIN
const CGAL::Origin ORIGIN
CGAL::Non_manifold_tag