Changed InitialPointsGenerator concept :

The points' dimensions are also outputed by the initialisation.
This commit is contained in:
ange-clement 2023-10-31 15:34:42 +01:00
parent 9d22242b63
commit d7f110e428
8 changed files with 38 additions and 29 deletions

View File

@ -25,11 +25,14 @@ public:
/*! /*!
Output a set of (`n`) surface points to the Output a set of (`n`) surface points to the
output iterator `pts`, as objects of type `std::pair<Point_3, output iterator `pts`, as objects of type
%Index>`. `std::tuple<Point_3, int, Index>` where
`Point_3` is the point's position,
`int` is the point's dimension and
`Index` is the point's index.
@tparam OutputIterator an `OutputIterator` of points of type @tparam OutputIterator an `OutputIterator` of points of type
`std::pair<MeshDomain::Point_3, MeshDomain::Index>` `std::tuple<MeshDomain::Point_3, int, MeshDomain::Index>`
@tparam MeshDomain a model of `MeshDomain_3` @tparam MeshDomain a model of `MeshDomain_3`
@tparam C3t3 a model of `MeshComplex_3InTriangulation_3` @tparam C3t3 a model of `MeshComplex_3InTriangulation_3`
@ -39,12 +42,16 @@ OutputIterator operator()(OutputIterator pts, const MeshDomain& domain, const C3
/*! /*!
Output a set of surface points to the Output a set of surface points to the
output iterator `pts`, as objects of type `std::pair<Point_3, output iterator `pts`, as objects of type
%Index>`. As `n` is not given, the functor must provide enough `std::tuple<Point_3, int, Index>` where
`Point_3` is the point's position,
`int` is the point's dimension and
`Index` is the point's index.
As `n` is not given, the functor must provide enough
points to initialize the mesh generation process. points to initialize the mesh generation process.
@tparam OutputIterator an `OutputIterator` of points of type @tparam OutputIterator an `OutputIterator` of points of type
`std::pair<MeshDomain::Point_3, MeshDomain::Index>` `std::tuple<MeshDomain::Point_3, int, MeshDomain::Index>`
@tparam MeshDomain a model of `MeshDomain_3` @tparam MeshDomain a model of `MeshDomain_3`
@tparam C3t3 a model of `MeshComplex_3InTriangulation_3` @tparam C3t3 a model of `MeshComplex_3InTriangulation_3`

View File

@ -819,7 +819,7 @@ points in the `%c3t3` object, with the calls to
`MeshVertexBase_3::set_dimension()` and `MeshVertexBase_3::set_dimension()` and
`MeshVertexBase_3::set_index()`. `MeshVertexBase_3::set_index()`.
\snippet CGAL/Mesh_3/mesh_3D_image_with_custom_initialization.cpp insert initial points \snippet Mesh_3/mesh_3D_image_with_custom_initialization.cpp insert initial points
The value of `index` must be consistent with the possible values of The value of `index` must be consistent with the possible values of
`Mesh_domain::Index`. `Mesh_domain::Index`.

View File

@ -47,7 +47,7 @@ void initialize_triangulation_from_gray_image(C3T3& c3t3,
typedef typename MeshDomain::Point_3 Point_3; typedef typename MeshDomain::Point_3 Point_3;
typedef typename MeshDomain::Index Index; typedef typename MeshDomain::Index Index;
typedef typename std::pair<Point_3, Index> ConstructedPoint; typedef typename std::tuple<Point_3, int, Index> ConstructedPoint;
Tr& tr = c3t3.triangulation(); Tr& tr = c3t3.triangulation();
@ -63,8 +63,9 @@ void initialize_triangulation_from_gray_image(C3T3& c3t3,
for (const ConstructedPoint & constructedPoint : constructedPoints) for (const ConstructedPoint & constructedPoint : constructedPoints)
{ {
const Point_3& point = constructedPoint.first; const Point_3& point = std::get<0>(constructedPoint);
const Index& index = constructedPoint.second; const int& dimension = std::get<1>(constructedPoint);
const Index& index = std::get<2>(constructedPoint);
Weighted_point pi = cwp(point); Weighted_point pi = cwp(point);
@ -73,7 +74,7 @@ void initialize_triangulation_from_gray_image(C3T3& c3t3,
Vertex_handle v = tr.insert(pi); Vertex_handle v = tr.insert(pi);
// `v` could be null if `pi` is hidden by other vertices of `tr`. // `v` could be null if `pi` is hidden by other vertices of `tr`.
CGAL_assertion(v != Vertex_handle()); CGAL_assertion(v != Vertex_handle());
c3t3.set_dimension(v, 2); // by construction, points are on surface c3t3.set_dimension(v, dimension);
c3t3.set_index(v, index); c3t3.set_index(v, index);
/// [insert initial points] /// [insert initial points]
} }

View File

@ -45,7 +45,7 @@ void initialize_triangulation_from_labeled_image(C3T3& c3t3,
typedef typename MeshDomain::Point_3 Point_3; typedef typename MeshDomain::Point_3 Point_3;
typedef typename MeshDomain::Index Index; typedef typename MeshDomain::Index Index;
typedef typename std::pair<Point_3, Index> ConstructedPoint; typedef typename std::tuple<Point_3, int, Index> ConstructedPoint;
Tr& tr = c3t3.triangulation(); Tr& tr = c3t3.triangulation();
@ -61,8 +61,9 @@ void initialize_triangulation_from_labeled_image(C3T3& c3t3,
for (const ConstructedPoint & constructedPoint : constructedPoints) for (const ConstructedPoint & constructedPoint : constructedPoints)
{ {
const Point_3& point = constructedPoint.first; const Point_3& point = std::get<0>(constructedPoint);
const Index& index = constructedPoint.second; const int& dimension = std::get<1>(constructedPoint);
const Index& index = std::get<2>(constructedPoint);
Weighted_point pi = cwp(point); Weighted_point pi = cwp(point);
@ -71,7 +72,7 @@ void initialize_triangulation_from_labeled_image(C3T3& c3t3,
Vertex_handle v = tr.insert(pi); Vertex_handle v = tr.insert(pi);
// `v` could be null if `pi` is hidden by other vertices of `tr`. // `v` could be null if `pi` is hidden by other vertices of `tr`.
CGAL_assertion(v != Vertex_handle()); CGAL_assertion(v != Vertex_handle());
c3t3.set_dimension(v, 2); // by construction, points are on surface c3t3.set_dimension(v, dimension);
c3t3.set_index(v, index); c3t3.set_index(v, index);
/// [insert initial points] /// [insert initial points]
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) 20XX,20XX GeometryFactory // Copyright (c) 2015,2016 GeometryFactory
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -8,7 +8,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s) : Laurent Rineau and Ange Clement // Author(s) : Laurent Rineau, Jane Tournois and Ange Clement
#ifndef CGAL_MESH_3_CONSTRUCT_INITIAL_POINTS_GRAY_IMAGE_H #ifndef CGAL_MESH_3_CONSTRUCT_INITIAL_POINTS_GRAY_IMAGE_H
#define CGAL_MESH_3_CONSTRUCT_INITIAL_POINTS_GRAY_IMAGE_H #define CGAL_MESH_3_CONSTRUCT_INITIAL_POINTS_GRAY_IMAGE_H
@ -54,7 +54,7 @@ struct Construct_initial_points_gray_image
* \brief Constructs the initial points using the gray image. * \brief Constructs the initial points using the gray image.
* *
* @tparam OutputIterator an `OutputIterator` of points of type * @tparam OutputIterator an `OutputIterator` of points of type
* `std::pair<MeshDomain::Point_3, MeshDomain::Index>` * `std::tuple<MeshDomain::Point_3, int, MeshDomain::Index>`
* @tparam MeshDomain a model of `MeshDomain_3` * @tparam MeshDomain a model of `MeshDomain_3`
* @tparam C3t3 a model of `MeshComplex_3InTriangulation_3` * @tparam C3t3 a model of `MeshComplex_3InTriangulation_3`
*/ */

View File

@ -1,4 +1,4 @@
// Copyright (c) 20XX,20XX GeometryFactory // Copyright (c) 2015,2016 GeometryFactory
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org). // This file is part of CGAL (www.cgal.org).
@ -102,7 +102,7 @@ struct Construct_initial_points_labeled_image
* \snippet this get construct intersection * \snippet this get construct intersection
* *
* @tparam OutputIterator an `OutputIterator` of points of type * @tparam OutputIterator an `OutputIterator` of points of type
* `std::pair<MeshDomain::Point_3, MeshDomain::Index>` * `std::tuple<MeshDomain::Point_3, int, MeshDomain::Index>`
* @tparam MeshDomain a model of `MeshDomain_3` * @tparam MeshDomain a model of `MeshDomain_3`
* @tparam C3t3 a model of `MeshComplex_3InTriangulation_3` * @tparam C3t3 a model of `MeshComplex_3InTriangulation_3`
*/ */
@ -117,7 +117,7 @@ struct Construct_initial_points_labeled_image
* \brief Same as above, but a `TransformOperator` is used * \brief Same as above, but a `TransformOperator` is used
* *
* @tparam OutputIterator an `OutputIterator` of points of type * @tparam OutputIterator an `OutputIterator` of points of type
* `std::pair<MeshDomain::Point_3, MeshDomain::Index>` * `std::tuple<MeshDomain::Point_3, int, MeshDomain::Index>`
* @tparam MeshDomain a model of `MeshDomain_3` * @tparam MeshDomain a model of `MeshDomain_3`
* @tparam TransformOperator a functor to transform values of the image. * @tparam TransformOperator a functor to transform values of the image.
* It must provides the following type:<br> * It must provides the following type:<br>
@ -293,7 +293,7 @@ struct Construct_initial_points_labeled_image
if (pi_inside_protecting_sphere) if (pi_inside_protecting_sphere)
continue; continue;
*pts++ = std::make_pair(intersect_point, intersect_index); *pts++ = std::make_tuple(intersect_point, 2, intersect_index); // dimension 2 by construction, points are on surface
} }
} }
} }

View File

@ -46,7 +46,7 @@ init_c3t3(C3T3& c3t3, const MeshDomain& domain, const MeshCriteria&,
{ {
typedef typename MeshDomain::Point_3 Point_3; typedef typename MeshDomain::Point_3 Point_3;
typedef typename MeshDomain::Index Index; typedef typename MeshDomain::Index Index;
typedef std::vector<std::pair<Point_3, Index> > Initial_points_vector; typedef std::vector<std::tuple<Point_3, int, Index> > Initial_points_vector;
typedef typename Initial_points_vector::iterator Ipv_iterator; typedef typename Initial_points_vector::iterator Ipv_iterator;
typedef typename C3T3::Vertex_handle Vertex_handle; typedef typename C3T3::Vertex_handle Vertex_handle;
@ -66,13 +66,13 @@ init_c3t3(C3T3& c3t3, const MeshDomain& domain, const MeshCriteria&,
it != initial_points.end() ; it != initial_points.end() ;
++it ) ++it )
{ {
Vertex_handle v = c3t3.triangulation().insert(cwp(it->first)); Vertex_handle v = c3t3.triangulation().insert(cwp(std::get<0>(*it)));
// v could be null if point is hidden // v could be null if point is hidden
if ( v != Vertex_handle() ) if ( v != Vertex_handle() )
{ {
c3t3.set_dimension(v,2); // by construction, points are on surface c3t3.set_dimension(v,std::get<1>(*it));
c3t3.set_index(v,it->second); c3t3.set_index(v,std::get<2>(*it));
} }
} }
} }
@ -523,7 +523,7 @@ void make_mesh_3_impl(C3T3& c3t3,
C3T3, C3T3,
MeshDomain, MeshDomain,
MeshCriteria, MeshCriteria,
::CGAL::internal::has_Has_features<MeshDomain>::value >() (c3t3, ::CGAL::internal::has_Has_features<MeshDomain>::value > () (c3t3,
domain, domain,
criteria, criteria,
with_features, with_features,

View File

@ -193,7 +193,7 @@ struct Initial_points_generator_options_holder<nullptr_t>
template <typename MeshDomain, typename C3t3> template <typename MeshDomain, typename C3t3>
struct Initial_points_generator_options struct Initial_points_generator_options
{ {
typedef typename std::back_insert_iterator<std::vector<std::pair<typename MeshDomain::Point_3, typename MeshDomain::Index>>> OutputIterator; typedef typename std::back_insert_iterator<std::vector<std::tuple<typename MeshDomain::Point_3, int, typename MeshDomain::Index>>> OutputIterator;
template <typename Initial_points_generator> template <typename Initial_points_generator>
Initial_points_generator_options(const Initial_points_generator& generator) Initial_points_generator_options(const Initial_points_generator& generator)
@ -263,7 +263,7 @@ struct Domain_features_generator< MeshDomain, true >
template <typename MeshDomain, typename C3t3> template <typename MeshDomain, typename C3t3>
struct Initial_points_generator_generator struct Initial_points_generator_generator
{ {
typedef typename std::back_insert_iterator<std::vector<std::pair<typename MeshDomain::Point_3, typename MeshDomain::Index>>> OutputIterator; typedef typename std::back_insert_iterator<std::vector<std::tuple<typename MeshDomain::Point_3, int, typename MeshDomain::Index>>> OutputIterator;
typedef typename CGAL::parameters::internal::Initial_points_generator_options<MeshDomain, C3t3> Initial_points_generator_options; typedef typename CGAL::parameters::internal::Initial_points_generator_options<MeshDomain, C3t3> Initial_points_generator_options;