Also rework the Octree domain to avoid aliases

This commit is contained in:
Mael Rouxel-Labbé 2024-01-22 15:16:52 +01:00
parent 449a5dc111
commit b2a98cbb7b
4 changed files with 60 additions and 58 deletions

View File

@ -31,7 +31,7 @@ namespace Isosurfacing {
* \brief A domain that represents an explicitly stored %Cartesian grid. * \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 * \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 * \tparam Grid must be a `CGAL::Isosurfacing::Cartesian_grid_3` whose `GeomTraits` template parameter
* is a model of `IsosurfacingTraits_3`. * 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 * \tparam Grid must be a `CGAL::Isosurfacing::Cartesian_grid_3` whose `GeomTraits` template parameter
* is a model of `IsosurfacingTraits_3`. * is a model of `IsosurfacingTraits_3`.
* \tparam Gradient the type of the gradient functor. It must be a model of `CopyConstructible` * \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 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 * \param gradient a function giving the value of the gradient of the implicit function at each discretization point

View File

@ -31,7 +31,10 @@ namespace Isosurfacing {
* *
* \brief A domain that represents an octree that discretizes an implicit function. * \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<GeomTraits>`.
* \tparam ImplicitFunction the type of the implicit function. It must be a model of CopyConstructible implement * \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`. * `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 * \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 Octree, template <typename Octree,
typename ImplicitFunction, typename ImplicitFunction,
typename Gradient = Zero_gradient, typename Gradient = Zero_gradient
typename Topology = internal::Octree_topology<Octree>, #ifndef DOXYGEN_RUNNING // Do not document Topology, Geometry, Function
typename Geometry = internal::Octree_geometry<Octree> > , typename Topology = internal::Octree_topology<Octree>
using Implicit_octree_domain = , typename Geometry = internal::Octree_geometry<Octree>
internal::Isosurfacing_domain_3<typename Octree::Geom_traits, , typename Function = internal::Implicit_function_with_geometry<Geometry, ImplicitFunction>
Topology, #endif
Geometry, >
internal::Implicit_function_with_geometry<Geometry, ImplicitFunction>, class Implicit_octree_domain
Gradient>; #ifndef DOXYGEN_RUNNING
: public internal::Isosurfacing_domain_3<typename Octree::Geom_traits,
Topology, Geometry, Function, Gradient>
#endif
{
using Base = internal::Isosurfacing_domain_3<typename Octree::Geom_traits,
Topology, Geometry, Function, Gradient>;
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 * \ingroup IS_Domains_grp
* *
* \brief creates a domain from an octree that can be used as input for isosurfacing algorithms. * \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 Octree must be a `CGAL::Octree<GeomTraits>`.
* \tparam ImplicitFunction the type of the implicit function. It must be a model of `CopyConstructible` and implement * \tparam ImplicitFunction the type of the implicit function. It must be a model of `CopyConstructible`
* `GeomTraits::FT operator()(const GeomTraits::Point_3& point) const`. * 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 * \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 octree an octree
* \param point_function the function with a point as argument * \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` * \return a new `CGAL::Implicit_octree_domain`
*/ */
#ifdef DOXYGEN_RUNNING // allow more than the Octree_wrapper
template <typename GeomTraits,
typename ImplicitFunction,
typename Gradient = Zero_gradient>
auto create_implicit_octree_domain(const internal::Octree_wrapper<Octree<GeomTraits> >& octree,
const ImplicitFunction& point_func,
const Gradient& grad = Gradient())
{
using Octree = internal::Octree_wrapper<Octree<GeomTraits> >;
#else
template <typename Octree, template <typename Octree,
typename ImplicitFunction, typename ImplicitFunction,
typename Gradient = Zero_gradient> typename Gradient = Zero_gradient>
auto create_implicit_octree_domain(const Octree& octree, Implicit_octree_domain<Octree, ImplicitFunction, Gradient>
const ImplicitFunction& point_func, create_implicit_octree_domain(const Octree& octree,
const Gradient& gradient = Gradient()) const ImplicitFunction& point_function,
const Gradient& gradient = Gradient())
{ {
#endif return { octree, point_function, gradient };
using Domain = Implicit_octree_domain<Octree, ImplicitFunction, Gradient>;
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() };
} }
} // namespace Isosurfacing } // namespace Isosurfacing

View File

@ -28,16 +28,16 @@ class Octree_geometry
public: public:
Octree_geometry(const Octree& octree) Octree_geometry(const Octree& octree)
: octree(octree) : m_octree(octree)
{ } { }
decltype(auto) /*Point_3*/ operator()(const Vertex_descriptor& v) const decltype(auto) /*Point_3*/ operator()(const Vertex_descriptor& v) const
{ {
return octree.point(v); return m_octree.point(v);
} }
private: private:
const Octree& octree; const Octree& m_octree;
}; };
} // namespace internal } // namespace internal

View File

@ -46,47 +46,47 @@ public:
public: public:
Octree_topology(const Octree& octree) Octree_topology(const Octree& octree)
: octree(octree) : m_octree(octree)
{ } { }
Vertices_incident_to_edge incident_vertices(const Edge_descriptor& e) const 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 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 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 Cell_edges cell_edges(const Cell_descriptor& c) const
{ {
return octree.voxel_edges(c); return m_octree.voxel_edges(c);
} }
template <typename Functor> template <typename Functor>
void for_each_vertex(Functor& f, Sequential_tag) const 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); f(v);
} }
template <typename Functor> template <typename Functor>
void for_each_edge(Functor& f, Sequential_tag) const 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); f(e);
} }
template <typename Functor> template <typename Functor>
void for_each_cell(Functor& f, Sequential_tag) const 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); f(v);
} }
@ -94,7 +94,7 @@ public:
template <typename Functor> template <typename Functor>
void for_each_vertex(Functor& f, Parallel_tag) const 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<std::size_t>& r) auto iterator = [&](const tbb::blocked_range<std::size_t>& r)
{ {
@ -108,7 +108,7 @@ public:
template <typename Functor> template <typename Functor>
void for_each_edge(Functor& f, Parallel_tag) const 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<std::size_t>& r) auto iterator = [&](const tbb::blocked_range<std::size_t>& r)
{ {
@ -122,7 +122,7 @@ public:
template <typename Functor> template <typename Functor>
void for_each_cell(Functor& f, Parallel_tag) const 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<std::size_t>& r) auto iterator = [&](const tbb::blocked_range<std::size_t>& r)
{ {
@ -135,7 +135,7 @@ public:
#endif // CGAL_LINKED_WITH_TBB #endif // CGAL_LINKED_WITH_TBB
private: private:
const Octree& octree; const Octree& m_octree;
}; };
} // namespace internal } // namespace internal