Skip to content

Commit

Permalink
Merge pull request #8248 from sloriot/CGAL-deprecate_Surface_mesher
Browse files Browse the repository at this point in the history
deprecate Surface_mesher package
  • Loading branch information
lrineau committed Jun 12, 2024
2 parents 32893b9 + bc31d6f commit 1b534cd
Show file tree
Hide file tree
Showing 84 changed files with 1,735 additions and 225 deletions.
4 changes: 2 additions & 2 deletions Documentation/doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 3.12...3.29)
project(Documentation NONE)

# Minimal version of CMake:

# Check whether this cmake script is the top level one
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
# decide if this is a branch build
Expand Down Expand Up @@ -79,6 +77,7 @@ function(configure_doxygen_package CGAL_PACKAGE_NAME)
if(NOT EXISTS ${CGAL_PACKAGE_DOC_DIR}/Doxyfile.in)
return()
endif()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CGAL_PACKAGE_DOC_DIR}/Doxyfile.in)

set(CGAL_DOC_PACKAGE_DEFAULTS
${CGAL_DOC_DXY_DIR}/${CGAL_PACKAGE_NAME}_defaults.dxy)
Expand Down Expand Up @@ -166,6 +165,7 @@ function(configure_doxygen_package CGAL_PACKAGE_NAME)
endforeach()
else()
if(EXISTS ${CGAL_PACKAGE_DOC_DIR}/dependencies)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CGAL_PACKAGE_DOC_DIR}/dependencies)
file(STRINGS ${CGAL_PACKAGE_DOC_DIR}/dependencies DEPENDENCIES)
endif()
endif()
Expand Down
5 changes: 5 additions & 0 deletions Installation/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ Release date: June 2024
- **Breaking change**: Removed the class templates `CGAL::Gray_image_mesh_domain_3`, `CGAL::Implicit_mesh_domain_3`,
and `CGAL::Labeled_image_mesh_domain_3`, which were deprecated since CGAL-4.13.

### [3D Surface Mesh Generation](https://doc.cgal.org/6.0/Manual/packages.html#PkgSurfaceMesher3)

- This package is deprecated and the package [3D Mesh Generation](https://doc.cgal.org/6.0/Manual/packages.html#PkgMesh3) should
be used instead.

### [Surface Mesh Parameterization](https://doc.cgal.org/6.0/Manual/packages.html#PkgSurfaceMeshParameterization)

- **Breaking change**: The method [`CGAL::Surface_mesh_parameterization::LSCM_parameterizer_3`](https://doc.cgal.org/6.0/Surface_mesh_parameterization/classCGAL_1_1Surface__mesh__parameterization_1_1LSCM__parameterizer__3.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
#include <CGAL/AABB_tree.h> // must be included before kernel
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Timer.h>
#include <CGAL/Surface_mesh_default_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/Poisson_reconstruction_function.h>
#include <CGAL/compute_average_spacing.h>

#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/facets_in_complex_3_to_triangle_mesh.h>

#include <CGAL/Eigen_solver_traits.h>

#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>

#include <math.h>
#include <CGAL/Timer.h>

#include "Kernel_type.h"
#include "SMesh_type.h"
Expand Down Expand Up @@ -179,10 +183,11 @@ SMesh* poisson_reconstruct(Point_set& points,
// Poisson implicit function
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;

// Surface mesher
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
// Mesh_3
typedef CGAL::Labeled_mesh_domain_3<Kernel> Mesh_domain;
typedef typename CGAL::Mesh_triangulation_3<Mesh_domain, CGAL::Default, Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;

// AABB tree
typedef CGAL::AABB_face_graph_triangle_primitive<SMesh> Primitive;
Expand Down Expand Up @@ -273,7 +278,7 @@ SMesh* poisson_reconstruct(Point_set& points,
else
{
//***************************************
// Surface mesh generation
// Surface mesh generation using Mesh_3
//***************************************

std::cerr << "Surface meshing...\n";
Expand Down Expand Up @@ -301,45 +306,43 @@ SMesh* poisson_reconstruct(Point_set& points,
// conservative bounding sphere centered at inner point.
Kernel::FT sm_sphere_radius = 5.0 * radius;
Kernel::FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy error must be << sm_distance
Surface_3 surface(function,
Kernel::Sphere_3(inner_point,sm_sphere_radius*sm_sphere_radius),
sm_dichotomy_error/sm_sphere_radius);

// Defines surface mesh generation criteria
CGAL::Surface_mesh_default_criteria_3<STr> criteria(sm_angle, // Min triangle angle (degrees)
sm_radius*average_spacing, // Max triangle size
sm_distance*average_spacing); // Approximation error

CGAL_TRACE_STREAM << " make_surface_mesh(sphere center=("<<inner_point << "),\n"
<< " sphere radius="<<sm_sphere_radius<<",\n"
<< " angle="<<sm_angle << " degrees,\n"
<< " triangle size="<<sm_radius<<" * average spacing="<<sm_radius*average_spacing<<",\n"
<< " distance="<<sm_distance<<" * average spacing="<<sm_distance*average_spacing<<",\n"
<< " dichotomy error=distance/"<<sm_distance*average_spacing/sm_dichotomy_error<<",\n"
<< " Manifold_with_boundary_tag)\n";

// Generates surface mesh with manifold option
STr tr; // 3D Delaunay triangulation for surface mesh generation
C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation
CGAL::make_surface_mesh(c2t3, // reconstructed mesh
surface, // implicit surface
criteria, // meshing criteria
CGAL::Manifold_with_boundary_tag()); // require manifold mesh
Mesh_criteria criteria(CGAL::parameters::facet_angle = sm_angle,
CGAL::parameters::facet_size = sm_radius*average_spacing,
CGAL::parameters::facet_distance = sm_distance*average_spacing);

CGAL_TRACE_STREAM << " make_mesh_3 with\n"
<< " \t sphere center = ("<<inner_point << "), \n"
<< " \t sphere radius="<<sm_sphere_radius<<",\n"
<< " \t angle="<<sm_angle << " degrees,\n"
<< " \t triangle size="<<sm_radius<<" * average spacing="<<sm_radius*average_spacing<<",\n"
<< " \t distance="<<sm_distance<<" * average spacing="<<sm_distance*average_spacing<<",\n"
<< " \t dichotomy error=distance/"<<sm_distance*average_spacing/sm_dichotomy_error<<",\n"
<< " \t Manifold_with_boundary_tag\n";

Mesh_domain domain = Mesh_domain::create_implicit_mesh_domain(function, bsphere,
CGAL::parameters::relative_error_bound(sm_dichotomy_error / sm_sphere_radius));

// Generates mesh with manifold option
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
CGAL::parameters::no_exude().no_perturb()
.manifold_with_boundary());

// Prints status
std::cerr << "Surface meshing: " << task_timer.time() << " seconds, "
<< tr.number_of_vertices() << " output vertices"
<< c3t3.triangulation().number_of_vertices() << " output vertices"
<< std::endl;
task_timer.reset();

if(tr.number_of_vertices() == 0)
if(c3t3.triangulation().number_of_vertices() == 0)
{
delete mesh;
return nullptr;
}

// Converts to polyhedron
CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, *mesh);
CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, *mesh);

// Prints total reconstruction duration
std::cerr << "Total reconstruction (implicit function + meshing): " << reconstruction_timer.time() << " seconds\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Timer.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Poisson_implicit_surface_3.h>
#include <CGAL/IO/facets_in_complex_2_to_triangle_mesh.h>

#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/facets_in_complex_3_to_triangle_mesh.h>

#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>

#include <CGAL/Timer.h>

#include <deque>
#include <cstdlib>
#include <fstream>
Expand All @@ -50,10 +55,11 @@ typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
// Poisson implicit function
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;

// Surface mesher
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Poisson_implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
// Mesh_3
typedef CGAL::Labeled_mesh_domain_3<Kernel> Mesh_domain;
typedef typename CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;

// AABB tree
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
Expand Down Expand Up @@ -304,36 +310,33 @@ int main(int argc, char * argv[])
Sphere bsphere = function.bounding_sphere();
FT radius = std::sqrt(bsphere.squared_radius());

// Defines the implicit surface: requires defining a
// conservative bounding sphere centered at inner point.
FT sm_sphere_radius = 5.0 * radius;
FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy error must be << sm_distance
Surface_3 surface(function,
Sphere(inner_point,sm_sphere_radius*sm_sphere_radius),
sm_dichotomy_error/sm_sphere_radius);

// Defines surface mesh generation criteria
CGAL::Surface_mesh_default_criteria_3<STr> criteria(sm_angle, // Min triangle angle (degrees)
sm_radius*average_spacing, // Max triangle size
sm_distance*average_spacing); // Approximation error
// Defines generation criteria
Mesh_criteria criteria(CGAL::parameters::facet_angle = sm_angle,
CGAL::parameters::facet_size = sm_radius*average_spacing,
CGAL::parameters::facet_distance = sm_distance*average_spacing);

std::cerr << " make_surface_mesh(sphere center=("<<inner_point << "),\n"
std::cerr << " make_mesh_3 with sphere center=("<<inner_point << "),\n"
<< " sphere radius="<<sm_sphere_radius<<",\n"
<< " angle="<<sm_angle << " degrees,\n"
<< " triangle size="<<sm_radius<<" * average spacing="<<sm_radius*average_spacing<<",\n"
<< " distance="<<sm_distance<<" * average spacing="<<sm_distance*average_spacing<<",\n"
<< " dichotomy error=distance/"<<sm_distance*average_spacing/sm_dichotomy_error<<",\n"
<< " Manifold_with_boundary_tag)\n";
<< " manifold_with_boundary()\n";

// Defines mesh domain
Mesh_domain domain = Mesh_domain::create_implicit_mesh_domain(function, bsphere,
CGAL::parameters::relative_error_bound(sm_dichotomy_error / sm_sphere_radius));

// Generates surface mesh with manifold option
STr tr; // 3D Delaunay triangulation for surface mesh generation
C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation
CGAL::make_surface_mesh(c2t3, // reconstructed mesh
surface, // implicit surface
criteria, // meshing criteria
CGAL::Manifold_with_boundary_tag()); // require manifold mesh
// Generates mesh with manifold option
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
CGAL::parameters::no_exude().no_perturb()
.manifold_with_boundary());

// Prints status
const Tr& tr = c3t3.triangulation();
std::cerr << "Surface meshing: " << task_timer.time() << " seconds, "
<< tr.number_of_vertices() << " output vertices"
<< std::endl;
Expand All @@ -344,7 +347,7 @@ int main(int argc, char * argv[])

// Converts to polyhedron
Polyhedron output_mesh;
CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, output_mesh);
CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, output_mesh);

// Prints total reconstruction duration
std::cerr << "Total reconstruction (implicit function + meshing): " << reconstruction_timer.time() << " seconds\n";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh_default_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/Poisson_reconstruction_function.h>

#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/facets_in_complex_3_to_triangle_mesh.h>

#include <CGAL/property_map.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/compute_average_spacing.h>
Expand All @@ -28,9 +32,10 @@ typedef Kernel::Sphere_3 Sphere;
typedef std::vector<Point_with_normal> PointList;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
typedef CGAL::Labeled_mesh_domain_3<Kernel> Mesh_domain;
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;

int main(void)
{
Expand Down Expand Up @@ -67,40 +72,35 @@ int main(void)
(points, 6 /* knn = 1 ring */,
CGAL::parameters::point_map (Point_map()));

// Gets one point inside the implicit surface
// and computes implicit function bounding sphere radius.
Point inner_point = function.get_inner_point();
//Computes implicit function bounding sphere radius.
Sphere bsphere = function.bounding_sphere();
FT radius = std::sqrt(bsphere.squared_radius());

// Defines the implicit surface: requires defining a
// conservative bounding sphere centered at inner point.
FT sm_sphere_radius = 5.0 * radius;
FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy error must be << sm_distance
Surface_3 surface(function,
Sphere(inner_point,sm_sphere_radius*sm_sphere_radius),
sm_dichotomy_error/sm_sphere_radius);

// Defines surface mesh generation criteria
CGAL::Surface_mesh_default_criteria_3<STr> criteria(sm_angle, // Min triangle angle (degrees)
sm_radius*average_spacing, // Max triangle size
sm_distance*average_spacing); // Approximation error

// Generates surface mesh with manifold option
STr tr; // 3D Delaunay triangulation for surface mesh generation
C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation
CGAL::make_surface_mesh(c2t3, // reconstructed mesh
surface, // implicit surface
criteria, // meshing criteria
CGAL::Manifold_with_boundary_tag()); // require manifold mesh
Mesh_criteria criteria(CGAL::parameters::facet_angle = sm_angle,
CGAL::parameters::facet_size = sm_radius*average_spacing,
CGAL::parameters::facet_distance = sm_distance*average_spacing);

// Defines mesh domain
Mesh_domain domain = Mesh_domain::create_implicit_mesh_domain(function, bsphere,
CGAL::parameters::relative_error_bound(sm_dichotomy_error / sm_sphere_radius));

// Generates mesh with manifold option
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
CGAL::parameters::no_exude().no_perturb()
.manifold_with_boundary());

const Tr& tr = c3t3.triangulation();
if(tr.number_of_vertices() == 0)
return EXIT_FAILURE;

// saves reconstructed surface mesh
std::ofstream out("kitten_poisson-20-30-0.375.off");
Polyhedron output_mesh;
CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, output_mesh);
CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, output_mesh);
out << output_mesh;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ namespace CGAL {
return surface(f, sphere, error_bound);
}

// template <typename GT, typename Function>
// struct Surface_mesh_traits_generator_3<Poisson_implicit_surface_3<GT, Function> >
// {
// typedef Poisson_implicit_surface_3<GT, Function> Surface_type;
// typedef typename Surface_mesher::Poisson_implicit_surface_oracle_3<GT,
// Surface_type> Type;
// typedef Type type; // Boost meta-programming compatibility
// };

// non documented class
template <typename FT, typename Point>
class Poisson_implicit_function_wrapper : public CGAL::cpp98::unary_function<Point, FT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ class Poisson_reconstruction_function

Cell_handle get() const
{
return Triangulation_data_structure::Cell_range::s_iterator_to(*m_cell);
if(m_cell == nullptr)
return {};
else
return Triangulation_data_structure::Cell_range::s_iterator_to(*m_cell);
}
void set (Cell_handle ch) { m_cell = ch.operator->(); }
};
Expand Down
Loading

0 comments on commit 1b534cd

Please sign in to comment.