diff --git a/Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp b/Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp index 3e84bdd8cb6..6b8acc85efa 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp index f969fafa1ab..b5da6966425 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp index f4afc2ee134..87d648191d8 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp index c1be67c248a..b2bfccf3653 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp index 45cf7fedda4..d1b5734b9fe 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp index d428e11aecb..e640c5131f2 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_implicit_sphere.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_implicit_sphere.cpp index 15028d014f5..64bb6372f43 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_implicit_sphere.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_implicit_sphere.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ int main() { auto sphere_function = [&](const Point& p) { return std::sqrt(p.x() * p.x() + p.y() * p.y() + p.z() * p.z()); }; // create a domain with bounding box [-1, 1]^3 and grid spacing 0.02 - auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain(bbox, spacing, sphere_function); + auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain(bbox, spacing, std::move(sphere_function)); // prepare collections for the result Point_range points; diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp index ffb0d09e332..8564ef7dd7f 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_mesh_offset.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_mesh_offset.cpp index 931fd1ddb10..1deb39ecff0 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_mesh_offset.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_mesh_offset.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Isosurfacing_3/include/CGAL/Cartesian_grid_3.h b/Isosurfacing_3/include/CGAL/Cartesian_grid_3.h index 5e7ffd188c0..9dcbdb56bfa 100644 --- a/Isosurfacing_3/include/CGAL/Cartesian_grid_3.h +++ b/Isosurfacing_3/include/CGAL/Cartesian_grid_3.h @@ -30,7 +30,7 @@ public: typedef typename Geom_traits::Vector_3 Vector; public: - Cartesian_grid_3(const std::size_t xdim, const std::size_t ydim, const std::size_t zdim, const Bbox_3 &bbox) + Cartesian_grid_3(const std::size_t xdim, const std::size_t ydim, const std::size_t zdim, const Bbox_3& bbox) : sizes{xdim, ydim, zdim}, bbox(bbox) { values.resize(xdim * ydim * zdim); @@ -42,11 +42,11 @@ public: spacing = Vector(d_x, d_y, d_z); } - Cartesian_grid_3(const Image_3 &image) { + Cartesian_grid_3(const Image_3& image) { from_image(image); } - FT operator()(const std::array &idx) const { + FT operator()(const std::array& idx) const { return values[linear_index(idx[0], idx[1], idx[2])]; } @@ -54,7 +54,7 @@ public: return values[linear_index(x, y, z)]; } - FT &value(const std::size_t x, const std::size_t y, const std::size_t z) { + FT& value(const std::size_t x, const std::size_t y, const std::size_t z) { return values[linear_index(x, y, z)]; } @@ -62,7 +62,7 @@ public: return gradients[linear_index(x, y, z)]; } - Vector &gradient(const std::size_t x, const std::size_t y, const std::size_t z) { + Vector& gradient(const std::size_t x, const std::size_t y, const std::size_t z) { return gradients[linear_index(x, y, z)]; } @@ -76,11 +76,11 @@ public: return sizes[2]; } - const Bbox_3 &get_bbox() const { + const Bbox_3& get_bbox() const { return bbox; } - const Vector &get_spacing() const { + const Vector& get_spacing() const { return spacing; } @@ -89,7 +89,7 @@ private: return (z * ydim() + y) * xdim() + x; } - void from_image(const Image_3 &image); + void from_image(const Image_3& image); Image_3 to_image() const; private: @@ -103,7 +103,7 @@ private: }; template -void Cartesian_grid_3::from_image(const Image_3 &image) { +void Cartesian_grid_3::from_image(const Image_3& image) { const FT max_x = image.tx() + (image.xdim() - 1) * image.vx(); const FT max_y = image.ty() + (image.ydim() - 1) * image.vy(); const FT max_z = image.tz() + (image.zdim() - 1) * image.vz(); @@ -147,7 +147,7 @@ Image_3 Cartesian_grid_3::to_image() const { const double vy = bbox.y_span() / (ydim() - 1); const double vz = bbox.z_span() / (zdim() - 1); - _image *im = _createImage(xdim(), ydim(), zdim(), + _image* im = _createImage(xdim(), ydim(), zdim(), 1, // vectorial dimension vx, vy, vz, // voxel size sizeof(FT), // image word size in bytes @@ -162,7 +162,7 @@ Image_3 Cartesian_grid_3::to_image() const { im->ty = bbox.ymin(); im->tz = bbox.zmin(); - FT *data = (FT *)im->data; + FT* data = (FT*)im->data; for (std::size_t x = 0; x < xdim(); x++) { for (std::size_t y = 0; y < ydim(); y++) { for (std::size_t z = 0; z < zdim(); z++) { diff --git a/Isosurfacing_3/include/CGAL/Explicit_cartesian_grid_domain.h b/Isosurfacing_3/include/CGAL/Explicit_cartesian_grid_domain.h new file mode 100644 index 00000000000..e868268ffb8 --- /dev/null +++ b/Isosurfacing_3/include/CGAL/Explicit_cartesian_grid_domain.h @@ -0,0 +1,58 @@ +// Copyright (c) 2022 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) : Julian Stahl + +#ifndef CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H +#define CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H + +#include +#include +#include +#include +#include +#include + +namespace CGAL { +namespace Isosurfacing { + +template +using Explicit_cartesian_grid_domain = Base_domain, + Cartesian_grid_3, Gradient_>; + +template > +Explicit_cartesian_grid_domain create_explicit_cartesian_grid_domain( + const Cartesian_grid_3& grid, const Gradient_& gradient = Gradient_()) { + + typedef Explicit_cartesian_grid_domain Domain; + typedef typename Domain::Topology Topology; + typedef typename Domain::Geometry Geometry; + typedef typename Domain::Function Function; + typedef typename Domain::Gradient Gradient; + + const std::size_t size_i = grid.xdim(); + const std::size_t size_j = grid.ydim(); + const std::size_t size_k = grid.zdim(); + + const Bbox_3& bbox = grid.get_bbox(); + const typename GeomTraits::Vector_3 offset(bbox.xmin(), bbox.ymin(), bbox.zmin()); + const typename GeomTraits::Vector_3 spacing = grid.get_spacing(); + + const Topology topo = std::make_shared(size_i, size_j, size_k); + const Geometry geom = std::make_shared(offset, spacing); + const Function func = std::make_shared(grid); + const Gradient grad = std::make_shared(gradient); + + return Domain(topo, geom, func, grad); +} + +} // namespace Isosurfacing +} // namespace CGAL + +#endif // CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H diff --git a/Isosurfacing_3/include/CGAL/Implicit_cartesian_grid_domain.h b/Isosurfacing_3/include/CGAL/Implicit_cartesian_grid_domain.h new file mode 100644 index 00000000000..b0f9681ae21 --- /dev/null +++ b/Isosurfacing_3/include/CGAL/Implicit_cartesian_grid_domain.h @@ -0,0 +1,61 @@ +// Copyright (c) 2022 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) : Julian Stahl + +#ifndef CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H +#define CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H + +#include +#include +#include +#include +#include +#include + +namespace CGAL { +namespace Isosurfacing { + +template +using Implicit_cartesian_grid_domain = + Base_domain, + Implicit_function_with_geometry, PointFunction>, + Gradient_>; + +template > +Implicit_cartesian_grid_domain create_implicit_cartesian_grid_domain( + const Bbox_3& bbox, const typename GeomTraits::Vector_3& spacing, const PointFunction& point_function, + const Gradient_& gradient = Gradient_()) { + + typedef Implicit_cartesian_grid_domain Domain; + typedef typename Domain::Topology Topology; + typedef typename Domain::Geometry Geometry; + typedef typename Domain::Function Function; + typedef typename Domain::Gradient Gradient; + typedef typename Function::element_type::Point_function Point_function; + + const std::size_t size_i = std::ceil(bbox.x_span() / spacing.x()) + 1; + const std::size_t size_j = std::ceil(bbox.y_span() / spacing.y()) + 1; + const std::size_t size_k = std::ceil(bbox.z_span() / spacing.z()) + 1; + + const typename GeomTraits::Vector_3 offset(bbox.xmin(), bbox.ymin(), bbox.zmin()); + + const Topology topo = std::make_shared(size_i, size_j, size_k); + const Geometry geom = std::make_shared(offset, spacing); + const Point_function point_func = std::make_shared(point_function); + const Function func = std::make_shared(geom, point_func); + const Gradient grad = std::make_shared(gradient); + + return Domain(topo, geom, func, grad); +} + +} // namespace Isosurfacing +} // namespace CGAL + +#endif // CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H diff --git a/Isosurfacing_3/include/CGAL/Implicit_octree_domain.h b/Isosurfacing_3/include/CGAL/Implicit_octree_domain.h new file mode 100644 index 00000000000..2ecced0e35f --- /dev/null +++ b/Isosurfacing_3/include/CGAL/Implicit_octree_domain.h @@ -0,0 +1,58 @@ +// Copyright (c) 2022 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) : Julian Stahl + +#ifndef CGAL_IMPLICIT_OCTREE_DOMAIN_H +#define CGAL_IMPLICIT_OCTREE_DOMAIN_H + +#include +#include +#include +#include +#include +#include +#include + +namespace CGAL { +namespace Isosurfacing { + + +template +using Implicit_octree_domain = + Base_domain, Octree_geometry, + Implicit_function_with_geometry, PointFunction>, Gradient_>; + +template > +Implicit_octree_domain create_implicit_octree_domain( + const Octree_wrapper& octree, const PointFunction& point_function, + const Gradient_& gradient = Gradient_()) { + + typedef Implicit_octree_domain Domain; + typedef typename Domain::Topology Topology; + typedef typename Domain::Geometry Geometry; + typedef typename Domain::Function Function; + typedef typename Domain::Gradient Gradient; + typedef typename Function::element_type::Point_function Point_function; + typedef typename Topology::element_type::Octree Octree; + + const Octree oct = std::make_shared(octree); + const Topology topo = std::make_shared(oct); + const Geometry geom = std::make_shared(oct); + const Point_function point_func = std::make_shared(point_function); + const Function func = std::make_shared(geom, point_func); + const Gradient grad = std::make_shared(gradient); + + return Domain(topo, geom, func, grad); +} + +} // namespace Isosurfacing +} // namespace CGAL + +#endif // CGAL_IMPLICIT_OCTREE_DOMAIN_H diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Base_domain.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Base_domain.h index 5af83d6cf1c..03bbd7b1a85 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Base_domain.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Base_domain.h @@ -15,6 +15,8 @@ #include #include +#include + namespace CGAL { namespace Isosurfacing { @@ -26,27 +28,27 @@ public: typedef typename Geom_traits::Point_3 Point; typedef typename Geom_traits::Vector_3 Vector; - typedef Topology_ Topology; - typedef typename Topology::Vertex_descriptor Vertex_descriptor; - typedef typename Topology::Edge_descriptor Edge_descriptor; - typedef typename Topology::Cell_descriptor Cell_descriptor; + typedef std::shared_ptr Topology; + typedef typename Topology_::Vertex_descriptor Vertex_descriptor; + typedef typename Topology_::Edge_descriptor Edge_descriptor; + typedef typename Topology_::Cell_descriptor Cell_descriptor; - static constexpr Cell_type CELL_TYPE = Topology::CELL_TYPE; - static constexpr std::size_t VERTICES_PER_CELL = Topology::VERTICES_PER_CELL; - static constexpr std::size_t EDGES_PER_CELL = Topology::EDGES_PER_CELL; + static constexpr Cell_type CELL_TYPE = Topology_::CELL_TYPE; + static constexpr std::size_t VERTICES_PER_CELL = Topology_::VERTICES_PER_CELL; + static constexpr std::size_t EDGES_PER_CELL = Topology_::EDGES_PER_CELL; - typedef typename Topology::Vertices_incident_to_edge Vertices_incident_to_edge; - typedef typename Topology::Cells_incident_to_edge Cells_incident_to_edge; - typedef typename Topology::Cell_vertices Cell_vertices; - typedef typename Topology::Cell_edges Cell_edges; + typedef typename Topology_::Vertices_incident_to_edge Vertices_incident_to_edge; + typedef typename Topology_::Cells_incident_to_edge Cells_incident_to_edge; + typedef typename Topology_::Cell_vertices Cell_vertices; + typedef typename Topology_::Cell_edges Cell_edges; - typedef Geometry_ Geometry; - typedef Function_ Function; - typedef Gradient_ Gradient; + typedef std::shared_ptr Geometry; + typedef std::shared_ptr Function; + typedef std::shared_ptr Gradient; public: Base_domain(const Topology& topo, const Geometry& geom, const Function& func, const Gradient& grad) - : topo(&topo), geom(&geom), func(&func), grad(&grad) {} + : topo(topo), geom(geom), func(func), grad(grad) {} Point position(const Vertex_descriptor& v) const { return geom->operator()(v); @@ -92,10 +94,10 @@ public: } private: - const Topology* topo; - const Geometry* geom; - const Function* func; - const Gradient* grad; + const Topology topo; + const Geometry geom; + const Function func; + const Gradient grad; }; } // namespace Isosurfacing diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Explicit_cartesian_grid_domain.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Explicit_cartesian_grid_domain.h deleted file mode 100644 index 8df7b0159cb..00000000000 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Explicit_cartesian_grid_domain.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2022 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) : Julian Stahl - -#ifndef CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H -#define CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H - -#include -#include -#include -#include -#include -#include - -namespace CGAL { -namespace Isosurfacing { - -template -class Explicit_cartesian_grid_domain_with_gradient - : public Base_domain, Cartesian_grid_3, - Gradient_> { -public: - typedef GeomTraits Geom_traits; - typedef typename Geom_traits::Vector_3 Vector; - - typedef Grid_topology Topology; - typedef Cartesian_grid_geometry Geometry; - typedef Cartesian_grid_3 Function; - typedef Gradient_ Gradient; - - typedef Base_domain Base; - -public: - Explicit_cartesian_grid_domain_with_gradient(const std::size_t size_i, const std::size_t size_j, - const std::size_t size_k, const Vector& offset, const Vector& spacing, - const Function& grid, const Gradient& grad) - : topo(size_i, size_j, size_k), geom(offset, spacing), Base(topo, geom, grid, grad) {} - -private: - Topology topo; - Geometry geom; -}; - -template -class Explicit_cartesian_grid_domain - : public Explicit_cartesian_grid_domain_with_gradient> { -public: - typedef GeomTraits Geom_traits; - typedef typename Geom_traits::Vector_3 Vector; - - typedef Cartesian_grid_3 Function; - typedef Zero_gradient Gradient; - - typedef Explicit_cartesian_grid_domain_with_gradient Base; - -public: - Explicit_cartesian_grid_domain(const std::size_t size_i, const std::size_t size_j, const std::size_t size_k, - const Vector& offset, const Vector& spacing, const Function& grid) - : Base(size_i, size_j, size_k, offset, spacing, grid, grad) {} - -private: - Gradient grad; -}; - -} // namespace Isosurfacing -} // namespace CGAL - -#endif // CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_cartesian_grid_domain.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_cartesian_grid_domain.h deleted file mode 100644 index 7095b56d01b..00000000000 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_cartesian_grid_domain.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2022 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) : Julian Stahl - -#ifndef CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H -#define CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H - -#include -#include -#include -#include -#include -#include - -namespace CGAL { -namespace Isosurfacing { - -template -class Implicit_cartesian_grid_domain_with_gradient - : public Base_domain, - Implicit_function_with_geometry, Function_>, - Gradient_> { -public: - typedef GeomTraits Geom_traits; - typedef typename Geom_traits::Vector_3 Vector; - - typedef Grid_topology Topology; - typedef Cartesian_grid_geometry Geometry; - typedef Function_ Function_with_point; - typedef Implicit_function_with_geometry Function; - typedef Gradient_ Gradient; - - typedef Base_domain Base; - -public: - Implicit_cartesian_grid_domain_with_gradient(const std::size_t size_i, const std::size_t size_j, - const std::size_t size_k, const Vector& offset, const Vector& spacing, - const Function_with_point& func_with_point, const Gradient& grad) - : topo(size_i, size_j, size_k), - geom(offset, spacing), - func(geom, func_with_point), - Base(topo, geom, func, grad) {} - -private: - Topology topo; - Geometry geom; - Function func; -}; - -template -class Implicit_cartesian_grid_domain - : public Implicit_cartesian_grid_domain_with_gradient> { -public: - typedef GeomTraits Geom_traits; - typedef typename Geom_traits::Vector_3 Vector; - - typedef Function_ Function_with_point; - typedef Zero_gradient Gradient; - - typedef Implicit_cartesian_grid_domain_with_gradient Base; - -public: - Implicit_cartesian_grid_domain(const std::size_t size_i, const std::size_t size_j, const std::size_t size_k, - const Vector& offset, const Vector& spacing, const Function_with_point& func) - : Base(size_i, size_j, size_k, offset, spacing, func, grad) {} - -private: - Gradient grad; -}; - -} // namespace Isosurfacing -} // namespace CGAL - -#endif // CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h index 74266c41dfa..f080c393abb 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h @@ -14,17 +14,22 @@ #include +#include + namespace CGAL { namespace Isosurfacing { -template +template class Implicit_function_with_geometry { public: typedef GeomTraits Geom_traits; typedef typename Geom_traits::FT FT; + typedef std::shared_ptr Geometry; + typedef std::shared_ptr Point_function; + public: - Implicit_function_with_geometry(const Geometry& geom, const Function& func) : geom(&geom), func(&func) {} + Implicit_function_with_geometry(const Geometry& geom, const Point_function& func) : geom(geom), func(func) {} template FT operator()(const VertexDescriptor& v) const { @@ -32,8 +37,8 @@ public: } private: - const Geometry* geom; - const Function* func; + const Geometry geom; + const Point_function func; }; } // namespace Isosurfacing diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_octree_domain.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_octree_domain.h deleted file mode 100644 index 829f3f9e652..00000000000 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Implicit_octree_domain.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2022 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) : Julian Stahl - -#ifndef CGAL_IMPLICIT_OCTREE_DOMAIN_H -#define CGAL_IMPLICIT_OCTREE_DOMAIN_H - -#include -#include -#include -#include -#include -#include -#include - -namespace CGAL { -namespace Isosurfacing { - -template -class Implicit_octree_domain_with_gradient - : public Base_domain, Octree_geometry, - Implicit_function_with_geometry, Function_>, - Gradient_> { -public: - typedef GeomTraits Geom_traits; - - typedef Octree_wrapper Octree; - - typedef Octree_topology Topology; - typedef Octree_geometry Geometry; - typedef Function_ Function_with_point; - typedef Implicit_function_with_geometry Function; - typedef Gradient_ Gradient; - - typedef Base_domain Base; - -public: - Implicit_octree_domain_with_gradient(const Octree& octree, const Function_with_point& func_with_point, - const Gradient& grad) - : topo(octree), geom(octree), func(geom, func_with_point), Base(topo, geom, func, grad) {} - -private: - Topology topo; - Geometry geom; - Function func; -}; - -template -class Implicit_octree_domain - : public Implicit_octree_domain_with_gradient> { -public: - typedef GeomTraits Geom_traits; - typedef Octree_wrapper Octree; - typedef Function_ Function_with_point; - typedef Zero_gradient Gradient; - - typedef Implicit_octree_domain_with_gradient Base; - -public: - Implicit_octree_domain(const Octree& octree, const Function_with_point& func) : Base(octree, func, grad) {} - -private: - Gradient grad; -}; - -} // namespace Isosurfacing -} // namespace CGAL - -#endif // CGAL_IMPLICIT_OCTREE_DOMAIN_H 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 66ce190b961..45e4c5f5c6e 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_geometry.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_geometry.h @@ -16,6 +16,8 @@ #include #include +#include + namespace CGAL { namespace Isosurfacing { @@ -25,19 +27,19 @@ public: typedef GeomTraits Geom_traits; typedef typename Geom_traits::Point_3 Point; - typedef Octree_wrapper Octree; + typedef std::shared_ptr> Octree; typedef typename Octree_topology::Vertex_descriptor Vertex_descriptor; public: - Octree_geometry(const Octree& octree) : octree(&octree) {} + Octree_geometry(const Octree& octree) : octree(octree) {} Point operator()(const Vertex_descriptor& v) const { return octree->point(v); } private: - const Octree* octree; + const Octree octree; }; } // namespace Isosurfacing 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 b8ee9e6347f..5e4214bfdef 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_topology.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/Octree_topology.h @@ -28,10 +28,11 @@ template // TODO: should not be necessary class Octree_topology { public: typedef GeomTraits Geom_traits; - typedef Octree_wrapper Octree; - typedef typename Octree::Vertex_handle Vertex_descriptor; - typedef typename Octree::Edge_handle Edge_descriptor; - typedef typename Octree::Voxel_handle Cell_descriptor; + typedef Octree_wrapper Octree_; + typedef std::shared_ptr> Octree; + typedef typename Octree_::Vertex_handle Vertex_descriptor; + typedef typename Octree_::Edge_handle Edge_descriptor; + typedef typename Octree_::Voxel_handle Cell_descriptor; static constexpr Cell_type CELL_TYPE = CUBICAL_CELL; static constexpr std::size_t VERTICES_PER_CELL = 8; @@ -43,7 +44,7 @@ public: typedef std::array Cell_edges; public: - Octree_topology(const Octree& octree) : octree(&octree) {} + Octree_topology(const Octree& octree) : octree(octree) {} Vertices_incident_to_edge edge_vertices(const Edge_descriptor& e) const { return octree->edge_vertices(e); @@ -124,7 +125,7 @@ public: #endif // CGAL_LINKED_WITH_TBB private: - const Octree* octree; + const Octree octree; }; } // namespace Isosurfacing diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_domains.h b/Isosurfacing_3/include/CGAL/Isosurfacing_domains.h deleted file mode 100644 index 01364e2b86b..00000000000 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_domains.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2022 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) : Julian Stahl - -#ifndef CGAL_ISOSURFACING_DOMAINS_H -#define CGAL_ISOSURFACING_DOMAINS_H - -#include -#include -#include -#include -#include -#include -#include - -namespace CGAL { -namespace Isosurfacing { - -template -Implicit_cartesian_grid_domain_with_gradient create_implicit_cartesian_grid_domain( - const Bbox_3& bbox, const typename GeomTraits::Vector_3& spacing, const Function& func, const Gradient& grad) { - - const std::size_t size_i = std::ceil(bbox.x_span() / spacing.x()) + 1; - const std::size_t size_j = std::ceil(bbox.y_span() / spacing.y()) + 1; - const std::size_t size_k = std::ceil(bbox.z_span() / spacing.z()) + 1; - - const typename GeomTraits::Vector_3 offset(bbox.xmin(), bbox.ymin(), bbox.zmin()); - - return {size_i, size_j, size_k, offset, spacing, func, grad}; -} - -template -Implicit_cartesian_grid_domain create_implicit_cartesian_grid_domain( - const Bbox_3& bbox, const typename GeomTraits::Vector_3& spacing, const Function& func) { - - const std::size_t size_i = std::ceil(bbox.x_span() / spacing.x()) + 1; - const std::size_t size_j = std::ceil(bbox.y_span() / spacing.y()) + 1; - const std::size_t size_k = std::ceil(bbox.z_span() / spacing.z()) + 1; - - const typename GeomTraits::Vector_3 offset(bbox.xmin(), bbox.ymin(), bbox.zmin()); - - return {size_i, size_j, size_k, offset, spacing, func}; -} - -template -Explicit_cartesian_grid_domain_with_gradient create_explicit_cartesian_grid_domain( - const Cartesian_grid_3& grid, const Gradient& grad) { - - const std::size_t size_i = grid.xdim(); - const std::size_t size_j = grid.ydim(); - const std::size_t size_k = grid.zdim(); - - const Bbox_3& bbox = grid.get_bbox(); - const typename GeomTraits::Vector_3 offset(bbox.xmin(), bbox.ymin(), bbox.zmin()); - const typename GeomTraits::Vector_3 spacing = grid.get_spacing(); - - return {size_i, size_j, size_k, offset, spacing, grid, grad}; -} - -template -Explicit_cartesian_grid_domain create_explicit_cartesian_grid_domain( - const Cartesian_grid_3& grid) { - - const std::size_t size_i = grid.xdim(); - const std::size_t size_j = grid.ydim(); - const std::size_t size_k = grid.zdim(); - - const Bbox_3& bbox = grid.get_bbox(); - const typename GeomTraits::Vector_3 offset(bbox.xmin(), bbox.ymin(), bbox.zmin()); - const typename GeomTraits::Vector_3 spacing = grid.get_spacing(); - - return {size_i, size_j, size_k, offset, spacing, grid}; -} - -template -Implicit_octree_domain_with_gradient create_implicit_octree_domain( - const Octree_wrapper& octree, const Function& func, const Gradient& grad) { - - return {octree, func, grad}; -} - -template -Implicit_octree_domain create_implicit_octree_domain(const Octree_wrapper& octree, - const Function& func) { - - return {octree, func}; -} - -} // namespace Isosurfacing -} // namespace CGAL - -#endif // CGAL_ISOSURFACING_DOMAINS_H