From b2a98cbb7b0a6c7aa17e2efc3c196deb4adb3668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 22 Jan 2024 15:16:52 +0100 Subject: [PATCH] Also rework the Octree domain to avoid aliases --- .../Explicit_Cartesian_grid_domain_3.h | 4 +- .../Isosurfacing_3/Implicit_octree_domain.h | 84 ++++++++++--------- .../Isosurfacing_3/internal/Octree_geometry.h | 6 +- .../Isosurfacing_3/internal/Octree_topology.h | 24 +++--- 4 files changed, 60 insertions(+), 58 deletions(-) diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/Explicit_Cartesian_grid_domain_3.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/Explicit_Cartesian_grid_domain_3.h index f8438cc2003..e5ba25932ea 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/Explicit_Cartesian_grid_domain_3.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/Explicit_Cartesian_grid_domain_3.h @@ -31,7 +31,7 @@ namespace Isosurfacing { * \brief A domain that represents an explicitly stored %Cartesian grid. * * \warning The domain keeps a pointer to the `grid` object, hence users must ensure that - * the lifetime of the `grid` object exceeds that of the object returned by this function. + * the lifetime of the `grid` object exceeds that of this object. * * \tparam Grid must be a `CGAL::Isosurfacing::Cartesian_grid_3` whose `GeomTraits` template parameter * is a model of `IsosurfacingTraits_3`. @@ -87,7 +87,7 @@ public: * \tparam Grid must be a `CGAL::Isosurfacing::Cartesian_grid_3` whose `GeomTraits` template parameter * is a model of `IsosurfacingTraits_3`. * \tparam Gradient the type of the gradient functor. It must be a model of `CopyConstructible` - * and implement `%Grid::Geom_traits::Vector_3 operator()(const GeomTraits::Point_3& point) const + * and implement `%Grid::Geom_traits::Vector_3 operator()(const GeomTraits::Point_3& point) const`. * * \param grid the %Cartesian grid containing input data * \param gradient a function giving the value of the gradient of the implicit function at each discretization point diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/Implicit_octree_domain.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/Implicit_octree_domain.h index b765811d207..e7e9a0273ec 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/Implicit_octree_domain.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/Implicit_octree_domain.h @@ -31,7 +31,10 @@ namespace Isosurfacing { * * \brief A domain that represents an octree that discretizes an implicit function. * - * \tparam Octree must be a model of `...`. + * \warning The domain keeps a pointer to the `octree` object, hence users must ensure that + * the lifetime of the `octree` object exceeds that of this object. + * + * \tparam Octree must be a `CGAL::Octree`. * \tparam ImplicitFunction the type of the implicit function. It must be a model of CopyConstructible implement * `GeomTraits::FT operator()(const GeomTraits::Point_3& point) const`. * \tparam Gradient the type of the gradient functor. It must be a model of `CopyConstructible` and implement @@ -39,28 +42,48 @@ namespace Isosurfacing { */ template , - typename Geometry = internal::Octree_geometry > -using Implicit_octree_domain = - internal::Isosurfacing_domain_3, - Gradient>; + typename Gradient = Zero_gradient +#ifndef DOXYGEN_RUNNING // Do not document Topology, Geometry, Function + , typename Topology = internal::Octree_topology + , typename Geometry = internal::Octree_geometry + , typename Function = internal::Implicit_function_with_geometry +#endif + > +class Implicit_octree_domain +#ifndef DOXYGEN_RUNNING + : public internal::Isosurfacing_domain_3 +#endif +{ + using Base = internal::Isosurfacing_domain_3; + +public: + Implicit_octree_domain(const Octree& octree, + const ImplicitFunction& point_function, + const Gradient& gradient = Gradient()) + : Base(Topology { octree }, + Geometry { octree }, + Function { Geometry { octree }, point_function }, + gradient, + octree.geom_traits()) + { + } +}; /* * \ingroup IS_Domains_grp * * \brief creates a domain from an octree that can be used as input for isosurfacing algorithms. * - * \details The implicit function will be evaluated on the octree vertices. + * \warning The domain keeps a pointer to the `octree` object, hence users must ensure that + * the lifetime of the `octree` object exceeds that of the object returned by this function. * - * \tparam GeomTraits must be a model of `Kernel`. - * \tparam ImplicitFunction the type of the implicit function. It must be a model of `CopyConstructible` and implement - * `GeomTraits::FT operator()(const GeomTraits::Point_3& point) const`. + * \tparam Octree must be a `CGAL::Octree`. + * \tparam ImplicitFunction the type of the implicit function. It must be a model of `CopyConstructible` + * and implement `GeomTraits::FT operator()(const GeomTraits::Point_3& point) const`. * \tparam Gradient the type of the gradient functor. It must be a model of `CopyConstructible` and implement - * `GeomTraits::Vector_3 operator()(const GeomTraits::Point_3& point) const`. + * `Octree::GeomTraits::Vector_3 operator()(const GeomTraits::Point_3& point) const`. * * \param octree an octree * \param point_function the function with a point as argument @@ -68,36 +91,15 @@ using Implicit_octree_domain = * * \return a new `CGAL::Implicit_octree_domain` */ -#ifdef DOXYGEN_RUNNING // allow more than the Octree_wrapper -template -auto create_implicit_octree_domain(const internal::Octree_wrapper >& octree, - const ImplicitFunction& point_func, - const Gradient& grad = Gradient()) -{ - using Octree = internal::Octree_wrapper >; -#else template -auto create_implicit_octree_domain(const Octree& octree, - const ImplicitFunction& point_func, - const Gradient& gradient = Gradient()) +Implicit_octree_domain +create_implicit_octree_domain(const Octree& octree, + const ImplicitFunction& point_function, + const Gradient& gradient = Gradient()) { -#endif - using Domain = Implicit_octree_domain; - - using Topology = typename Domain::Topology; - using Geometry = typename Domain::Geometry; - using Function = typename Domain::Function; - - const Topology topo { octree }; - const Geometry geom { octree }; - const Function func { geom, point_func }; - - // @fixme Octree_wrapper's geom_traits() isn't octree's geom_traits()... - return Domain{ topo, geom, func, gradient, octree.geom_traits() }; + return { octree, point_function, gradient }; } } // namespace Isosurfacing diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_geometry.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_geometry.h index aa50566964e..51bb87365f4 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_geometry.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_geometry.h @@ -28,16 +28,16 @@ class Octree_geometry public: Octree_geometry(const Octree& octree) - : octree(octree) + : m_octree(octree) { } decltype(auto) /*Point_3*/ operator()(const Vertex_descriptor& v) const { - return octree.point(v); + return m_octree.point(v); } private: - const Octree& octree; + const Octree& m_octree; }; } // namespace internal diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_topology.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_topology.h index 50c91bd1459..90e82c0a4d9 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_topology.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_topology.h @@ -46,47 +46,47 @@ public: public: Octree_topology(const Octree& octree) - : octree(octree) + : m_octree(octree) { } Vertices_incident_to_edge incident_vertices(const Edge_descriptor& e) const { - return octree.edge_vertices(e); + return m_octree.edge_vertices(e); } Cells_incident_to_edge incident_cells(const Edge_descriptor& e) const { - return octree.edge_voxels(e); + return m_octree.edge_voxels(e); } Cell_vertices cell_vertices(const Cell_descriptor& c) const { - return octree.voxel_vertices(c); + return m_octree.voxel_vertices(c); } Cell_edges cell_edges(const Cell_descriptor& c) const { - return octree.voxel_edges(c); + return m_octree.voxel_edges(c); } template void for_each_vertex(Functor& f, Sequential_tag) const { - for(const Vertex_descriptor& v : octree.leaf_vertices()) + for(const Vertex_descriptor& v : m_octree.leaf_vertices()) f(v); } template void for_each_edge(Functor& f, Sequential_tag) const { - for(const Edge_descriptor& e : octree.leaf_edges()) + for(const Edge_descriptor& e : m_octree.leaf_edges()) f(e); } template void for_each_cell(Functor& f, Sequential_tag) const { - for(const Cell_descriptor& v : octree.leaf_voxels()) + for(const Cell_descriptor& v : m_octree.leaf_voxels()) f(v); } @@ -94,7 +94,7 @@ public: template void for_each_vertex(Functor& f, Parallel_tag) const { - const auto& vertices = octree.leaf_vertices(); + const auto& vertices = m_octree.leaf_vertices(); auto iterator = [&](const tbb::blocked_range& r) { @@ -108,7 +108,7 @@ public: template void for_each_edge(Functor& f, Parallel_tag) const { - const auto& edges = octree.leaf_edges(); + const auto& edges = m_octree.leaf_edges(); auto iterator = [&](const tbb::blocked_range& r) { @@ -122,7 +122,7 @@ public: template void for_each_cell(Functor& f, Parallel_tag) const { - const auto& cells = octree.leaf_voxels(); + const auto& cells = m_octree.leaf_voxels(); auto iterator = [&](const tbb::blocked_range& r) { @@ -135,7 +135,7 @@ public: #endif // CGAL_LINKED_WITH_TBB private: - const Octree& octree; + const Octree& m_octree; }; } // namespace internal