Skip to content

Commit

Permalink
Merge pull request CGAL#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 5, 2024
2 parents 67d4e4a + 6e6c103 commit b5b0399
Show file tree
Hide file tree
Showing 76 changed files with 923 additions and 148 deletions.
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
@@ -1,3 +1,4 @@
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
// poisson_reconstruction.cpp

//----------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// @TODO: change the usage from Surface_mesher to Mesh_3
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2006-2007, 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Laurent Rineau, Jane Tournois

#ifndef CGAL_MESH_3_POISSON_MESH_TRAITS_GENERATOR_3_H
#define CGAL_MESH_3_POISSON_MESH_TRAITS_GENERATOR_3_H

#include <CGAL/license/Poisson_surface_reconstruction_3.h>


#include <CGAL/Surface_mesher/Poisson_sphere_oracle_3.h>

namespace CGAL {

template <class K>
class Sphere_3;

/** Default traits class.
* Partial specialization will be in other headers
*/
template <typename Surface>
struct Poisson_mesh_traits_generator_3
{
typedef typename Surface::Surface_mesher_traits_3 Type;
typedef Type type; // for Boost compatibility (meta-programming)
};

// specialization for Kernel::Sphere_3
template <typename Kernel>
struct Poisson_mesh_traits_generator_3<CGAL::Sphere_3<Kernel> >
{
typedef Surface_mesher::Poisson_sphere_oracle_3<Kernel> Type;
typedef Type type; // for Boost compatibility (meta-programming)
};

} // end namespace CGAL

#endif // CGAL_MESH_3_POISSON_MESH_TRAITS_GENERATOR_3_H
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2003-2007 INRIA Sophia-Antipolis (France).
// Copyright (c) 2008,2011 GeometryFactory Sarl (France)
// Copyright (c) 2008,2011,2024 GeometryFactory Sarl (France)
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
Expand All @@ -17,9 +17,8 @@
#include <CGAL/license/Poisson_surface_reconstruction_3.h>


#include <CGAL/Surface_mesher/Null_oracle_visitor.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/Surface_mesher/Sphere_oracle_3.h>
#include <CGAL/Surface_mesher/Poisson_sphere_oracle_3.h>
#include <CGAL/Surface_mesher/Implicit_surface_oracle_3.h>
#include <CGAL/Real_embeddable_traits.h>
#include <CGAL/squared_distance_3.h>
Expand Down Expand Up @@ -56,7 +55,7 @@ namespace CGAL {
Return_min<typename Transform_functor_::result_type>,
class Point_creator = Creator_uniform_3<typename GT::FT,
typename GT::Point_3>,
class Visitor = Null_oracle_visitor
class Visitor = Poisson_null_oracle_visitor
>
class Poisson_implicit_surface_oracle_3
{
Expand All @@ -68,7 +67,7 @@ namespace CGAL {
Point_creator,
Visitor> Self;

typedef Sphere_oracle_3<GT, Point_creator> Sphere_oracle;
typedef Poisson_sphere_oracle_3<GT, Point_creator> Sphere_oracle;

typedef typename GT::Point_3 Point;

Expand Down
Loading

0 comments on commit b5b0399

Please sign in to comment.