Change domain members to shared_ptr

This commit is contained in:
Julian Stahl 2022-11-03 19:11:53 +01:00
parent 2b22009983
commit 777a39c65a
21 changed files with 240 additions and 384 deletions

View File

@ -1,6 +1,6 @@
#include <CGAL/Cartesian_grid_3.h> #include <CGAL/Cartesian_grid_3.h>
#include <CGAL/Dual_contouring_3.h> #include <CGAL/Dual_contouring_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Explicit_cartesian_grid_domain.h>
#include <CGAL/Marching_cubes_3.h> #include <CGAL/Marching_cubes_3.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>

View File

@ -1,7 +1,7 @@
#include <CGAL/Cartesian_grid_3.h> #include <CGAL/Cartesian_grid_3.h>
#include <CGAL/Default_gradients.h> #include <CGAL/Default_gradients.h>
#include <CGAL/Dual_contouring_3.h> #include <CGAL/Dual_contouring_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Explicit_cartesian_grid_domain.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>

View File

@ -1,6 +1,6 @@
#include <CGAL/Bbox_3.h> #include <CGAL/Bbox_3.h>
#include <CGAL/Dual_contouring_3.h> #include <CGAL/Dual_contouring_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Implicit_cartesian_grid_domain.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>

View File

@ -3,7 +3,7 @@
#include <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/Bbox_3.h> #include <CGAL/Bbox_3.h>
#include <CGAL/Dual_contouring_3.h> #include <CGAL/Dual_contouring_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Implicit_cartesian_grid_domain.h>
#include <CGAL/Side_of_triangle_mesh.h> #include <CGAL/Side_of_triangle_mesh.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h> #include <CGAL/Surface_mesh.h>

View File

@ -1,5 +1,5 @@
#include <CGAL/Dual_contouring_3.h> #include <CGAL/Dual_contouring_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Implicit_octree_domain.h>
#include <CGAL/Octree_wrapper.h> #include <CGAL/Octree_wrapper.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>

View File

@ -1,6 +1,6 @@
#include <CGAL/Cartesian_grid_3.h> #include <CGAL/Cartesian_grid_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Explicit_cartesian_grid_domain.h>
#include <CGAL/Marching_cubes_3.h> #include <CGAL/Marching_cubes_3.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>

View File

@ -1,6 +1,6 @@
#include <CGAL/Bbox_3.h> #include <CGAL/Bbox_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Implicit_cartesian_grid_domain.h>
#include <CGAL/Marching_cubes_3.h> #include <CGAL/Marching_cubes_3.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>
@ -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()); }; 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 // create a domain with bounding box [-1, 1]^3 and grid spacing 0.02
auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain<Kernel>(bbox, spacing, sphere_function); auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain<Kernel>(bbox, spacing, std::move(sphere_function));
// prepare collections for the result // prepare collections for the result
Point_range points; Point_range points;

View File

@ -1,5 +1,5 @@
#include <CGAL/Cartesian_grid_3.h> #include <CGAL/Cartesian_grid_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Explicit_cartesian_grid_domain.h>
#include <CGAL/Marching_cubes_3.h> #include <CGAL/Marching_cubes_3.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/IO/OFF.h> #include <CGAL/boost/graph/IO/OFF.h>

View File

@ -2,7 +2,7 @@
#include <CGAL/AABB_traits.h> #include <CGAL/AABB_traits.h>
#include <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/Cartesian_grid_3.h> #include <CGAL/Cartesian_grid_3.h>
#include <CGAL/Isosurfacing_domains.h> #include <CGAL/Explicit_cartesian_grid_domain.h>
#include <CGAL/Marching_cubes_3.h> #include <CGAL/Marching_cubes_3.h>
#include <CGAL/Side_of_triangle_mesh.h> #include <CGAL/Side_of_triangle_mesh.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>

View File

@ -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 <CGAL/Cartesian_grid_3.h>
#include <CGAL/Default_gradients.h>
#include <CGAL/Isosurfacing_3/internal/Base_domain.h>
#include <CGAL/Isosurfacing_3/internal/Cartesian_grid_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Grid_topology.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename Gradient_>
using Explicit_cartesian_grid_domain = Base_domain<GeomTraits, Grid_topology, Cartesian_grid_geometry<GeomTraits>,
Cartesian_grid_3<GeomTraits>, Gradient_>;
template <class GeomTraits, typename Gradient_ = Zero_gradient<GeomTraits>>
Explicit_cartesian_grid_domain<GeomTraits, Gradient_> create_explicit_cartesian_grid_domain(
const Cartesian_grid_3<GeomTraits>& grid, const Gradient_& gradient = Gradient_()) {
typedef Explicit_cartesian_grid_domain<GeomTraits, Gradient_> 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<Topology::element_type>(size_i, size_j, size_k);
const Geometry geom = std::make_shared<Geometry::element_type>(offset, spacing);
const Function func = std::make_shared<Function::element_type>(grid);
const Gradient grad = std::make_shared<Gradient::element_type>(gradient);
return Domain(topo, geom, func, grad);
}
} // namespace Isosurfacing
} // namespace CGAL
#endif // CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H

View File

@ -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 <CGAL/Default_gradients.h>
#include <CGAL/Isosurfacing_3/internal/Base_domain.h>
#include <CGAL/Isosurfacing_3/internal/Cartesian_grid_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Grid_topology.h>
#include <CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename PointFunction, typename Gradient_>
using Implicit_cartesian_grid_domain =
Base_domain<GeomTraits, Grid_topology, Cartesian_grid_geometry<GeomTraits>,
Implicit_function_with_geometry<GeomTraits, Cartesian_grid_geometry<GeomTraits>, PointFunction>,
Gradient_>;
template <class GeomTraits, typename PointFunction, typename Gradient_ = Zero_gradient<GeomTraits>>
Implicit_cartesian_grid_domain<GeomTraits, PointFunction, Gradient_> 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<GeomTraits, PointFunction, Gradient_> 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<Topology::element_type>(size_i, size_j, size_k);
const Geometry geom = std::make_shared<Geometry::element_type>(offset, spacing);
const Point_function point_func = std::make_shared<Point_function::element_type>(point_function);
const Function func = std::make_shared<Function::element_type>(geom, point_func);
const Gradient grad = std::make_shared<Gradient::element_type>(gradient);
return Domain(topo, geom, func, grad);
}
} // namespace Isosurfacing
} // namespace CGAL
#endif // CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H

View File

@ -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 <CGAL/Default_gradients.h>
#include <CGAL/Isosurfacing_3/internal/Base_domain.h>
#include <CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Octree_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Octree_topology.h>
#include <CGAL/Octree_wrapper.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename PointFunction, typename Gradient_>
using Implicit_octree_domain =
Base_domain<GeomTraits, Octree_topology<GeomTraits>, Octree_geometry<GeomTraits>,
Implicit_function_with_geometry<GeomTraits, Octree_geometry<GeomTraits>, PointFunction>, Gradient_>;
template <class GeomTraits, typename PointFunction, typename Gradient_ = Zero_gradient<GeomTraits>>
Implicit_octree_domain<GeomTraits, PointFunction, Gradient_> create_implicit_octree_domain(
const Octree_wrapper<GeomTraits>& octree, const PointFunction& point_function,
const Gradient_& gradient = Gradient_()) {
typedef Implicit_octree_domain<GeomTraits, PointFunction, Gradient_> 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::element_type>(octree);
const Topology topo = std::make_shared<Topology::element_type>(oct);
const Geometry geom = std::make_shared<Geometry::element_type>(oct);
const Point_function point_func = std::make_shared<Point_function::element_type>(point_function);
const Function func = std::make_shared<Function::element_type>(geom, point_func);
const Gradient grad = std::make_shared<Gradient::element_type>(gradient);
return Domain(topo, geom, func, grad);
}
} // namespace Isosurfacing
} // namespace CGAL
#endif // CGAL_IMPLICIT_OCTREE_DOMAIN_H

View File

@ -15,6 +15,8 @@
#include <CGAL/Isosurfacing_3/internal/Cell_type.h> #include <CGAL/Isosurfacing_3/internal/Cell_type.h>
#include <CGAL/license/Isosurfacing_3.h> #include <CGAL/license/Isosurfacing_3.h>
#include <memory>
namespace CGAL { namespace CGAL {
namespace Isosurfacing { namespace Isosurfacing {
@ -26,27 +28,27 @@ public:
typedef typename Geom_traits::Point_3 Point; typedef typename Geom_traits::Point_3 Point;
typedef typename Geom_traits::Vector_3 Vector; typedef typename Geom_traits::Vector_3 Vector;
typedef Topology_ Topology; typedef std::shared_ptr<Topology_> Topology;
typedef typename Topology::Vertex_descriptor Vertex_descriptor; typedef typename Topology_::Vertex_descriptor Vertex_descriptor;
typedef typename Topology::Edge_descriptor Edge_descriptor; typedef typename Topology_::Edge_descriptor Edge_descriptor;
typedef typename Topology::Cell_descriptor Cell_descriptor; typedef typename Topology_::Cell_descriptor Cell_descriptor;
static constexpr Cell_type CELL_TYPE = Topology::CELL_TYPE; 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 VERTICES_PER_CELL = Topology_::VERTICES_PER_CELL;
static constexpr std::size_t EDGES_PER_CELL = Topology::EDGES_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_::Vertices_incident_to_edge Vertices_incident_to_edge;
typedef typename Topology::Cells_incident_to_edge Cells_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_vertices Cell_vertices;
typedef typename Topology::Cell_edges Cell_edges; typedef typename Topology_::Cell_edges Cell_edges;
typedef Geometry_ Geometry; typedef std::shared_ptr<Geometry_> Geometry;
typedef Function_ Function; typedef std::shared_ptr<Function_> Function;
typedef Gradient_ Gradient; typedef std::shared_ptr<Gradient_> Gradient;
public: public:
Base_domain(const Topology& topo, const Geometry& geom, const Function& func, const Gradient& grad) 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 { Point position(const Vertex_descriptor& v) const {
return geom->operator()(v); return geom->operator()(v);
@ -92,10 +94,10 @@ public:
} }
private: private:
const Topology* topo; const Topology topo;
const Geometry* geom; const Geometry geom;
const Function* func; const Function func;
const Gradient* grad; const Gradient grad;
}; };
} // namespace Isosurfacing } // namespace Isosurfacing

View File

@ -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 <CGAL/Cartesian_grid_3.h>
#include <CGAL/Default_gradients.h>
#include <CGAL/Isosurfacing_3/internal/Base_domain.h>
#include <CGAL/Isosurfacing_3/internal/Cartesian_grid_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Grid_topology.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename Gradient_>
class Explicit_cartesian_grid_domain_with_gradient
: public Base_domain<GeomTraits, Grid_topology, Cartesian_grid_geometry<GeomTraits>, Cartesian_grid_3<GeomTraits>,
Gradient_> {
public:
typedef GeomTraits Geom_traits;
typedef typename Geom_traits::Vector_3 Vector;
typedef Grid_topology Topology;
typedef Cartesian_grid_geometry<Geom_traits> Geometry;
typedef Cartesian_grid_3<Geom_traits> Function;
typedef Gradient_ Gradient;
typedef Base_domain<Geom_traits, Topology, Geometry, Function, Gradient> 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 GeomTraits>
class Explicit_cartesian_grid_domain
: public Explicit_cartesian_grid_domain_with_gradient<GeomTraits, Zero_gradient<GeomTraits>> {
public:
typedef GeomTraits Geom_traits;
typedef typename Geom_traits::Vector_3 Vector;
typedef Cartesian_grid_3<Geom_traits> Function;
typedef Zero_gradient<Geom_traits> Gradient;
typedef Explicit_cartesian_grid_domain_with_gradient<Geom_traits, 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

View File

@ -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 <CGAL/Default_gradients.h>
#include <CGAL/Isosurfacing_3/internal/Base_domain.h>
#include <CGAL/Isosurfacing_3/internal/Cartesian_grid_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Grid_topology.h>
#include <CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename Function_, typename Gradient_>
class Implicit_cartesian_grid_domain_with_gradient
: public Base_domain<GeomTraits, Grid_topology, Cartesian_grid_geometry<GeomTraits>,
Implicit_function_with_geometry<GeomTraits, Cartesian_grid_geometry<GeomTraits>, Function_>,
Gradient_> {
public:
typedef GeomTraits Geom_traits;
typedef typename Geom_traits::Vector_3 Vector;
typedef Grid_topology Topology;
typedef Cartesian_grid_geometry<Geom_traits> Geometry;
typedef Function_ Function_with_point;
typedef Implicit_function_with_geometry<Geom_traits, Geometry, Function_with_point> Function;
typedef Gradient_ Gradient;
typedef Base_domain<Geom_traits, Topology, Geometry, Function, Gradient> 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 GeomTraits, typename Function_>
class Implicit_cartesian_grid_domain
: public Implicit_cartesian_grid_domain_with_gradient<GeomTraits, Function_, Zero_gradient<GeomTraits>> {
public:
typedef GeomTraits Geom_traits;
typedef typename Geom_traits::Vector_3 Vector;
typedef Function_ Function_with_point;
typedef Zero_gradient<Geom_traits> Gradient;
typedef Implicit_cartesian_grid_domain_with_gradient<Geom_traits, Function_, 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

View File

@ -14,17 +14,22 @@
#include <CGAL/license/Isosurfacing_3.h> #include <CGAL/license/Isosurfacing_3.h>
#include <memory>
namespace CGAL { namespace CGAL {
namespace Isosurfacing { namespace Isosurfacing {
template <class GeomTraits, typename Geometry, typename Function> template <class GeomTraits, typename Geometry_, typename PointFunction>
class Implicit_function_with_geometry { class Implicit_function_with_geometry {
public: public:
typedef GeomTraits Geom_traits; typedef GeomTraits Geom_traits;
typedef typename Geom_traits::FT FT; typedef typename Geom_traits::FT FT;
typedef std::shared_ptr<Geometry_> Geometry;
typedef std::shared_ptr<PointFunction> Point_function;
public: 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 <typename VertexDescriptor> template <typename VertexDescriptor>
FT operator()(const VertexDescriptor& v) const { FT operator()(const VertexDescriptor& v) const {
@ -32,8 +37,8 @@ public:
} }
private: private:
const Geometry* geom; const Geometry geom;
const Function* func; const Point_function func;
}; };
} // namespace Isosurfacing } // namespace Isosurfacing

View File

@ -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 <CGAL/Default_gradients.h>
#include <CGAL/Isosurfacing_3/internal/Base_domain.h>
#include <CGAL/Isosurfacing_3/internal/Implicit_function_with_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Octree_geometry.h>
#include <CGAL/Isosurfacing_3/internal/Octree_topology.h>
#include <CGAL/Octree_wrapper.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename Function_, typename Gradient_>
class Implicit_octree_domain_with_gradient
: public Base_domain<GeomTraits, Octree_topology<GeomTraits>, Octree_geometry<GeomTraits>,
Implicit_function_with_geometry<GeomTraits, Octree_geometry<GeomTraits>, Function_>,
Gradient_> {
public:
typedef GeomTraits Geom_traits;
typedef Octree_wrapper<Geom_traits> Octree;
typedef Octree_topology<Geom_traits> Topology;
typedef Octree_geometry<Geom_traits> Geometry;
typedef Function_ Function_with_point;
typedef Implicit_function_with_geometry<Geom_traits, Geometry, Function_with_point> Function;
typedef Gradient_ Gradient;
typedef Base_domain<Geom_traits, Topology, Geometry, Function, Gradient> 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 GeomTraits, typename Function_>
class Implicit_octree_domain
: public Implicit_octree_domain_with_gradient<GeomTraits, Function_, Zero_gradient<GeomTraits>> {
public:
typedef GeomTraits Geom_traits;
typedef Octree_wrapper<Geom_traits> Octree;
typedef Function_ Function_with_point;
typedef Zero_gradient<Geom_traits> Gradient;
typedef Implicit_octree_domain_with_gradient<Geom_traits, Function_, 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

View File

@ -16,6 +16,8 @@
#include <CGAL/Octree_wrapper.h> #include <CGAL/Octree_wrapper.h>
#include <CGAL/license/Isosurfacing_3.h> #include <CGAL/license/Isosurfacing_3.h>
#include <memory>
namespace CGAL { namespace CGAL {
namespace Isosurfacing { namespace Isosurfacing {
@ -25,19 +27,19 @@ public:
typedef GeomTraits Geom_traits; typedef GeomTraits Geom_traits;
typedef typename Geom_traits::Point_3 Point; typedef typename Geom_traits::Point_3 Point;
typedef Octree_wrapper<Geom_traits> Octree; typedef std::shared_ptr<Octree_wrapper<Geom_traits>> Octree;
typedef typename Octree_topology<Geom_traits>::Vertex_descriptor Vertex_descriptor; typedef typename Octree_topology<Geom_traits>::Vertex_descriptor Vertex_descriptor;
public: public:
Octree_geometry(const Octree& octree) : octree(&octree) {} Octree_geometry(const Octree& octree) : octree(octree) {}
Point operator()(const Vertex_descriptor& v) const { Point operator()(const Vertex_descriptor& v) const {
return octree->point(v); return octree->point(v);
} }
private: private:
const Octree* octree; const Octree octree;
}; };
} // namespace Isosurfacing } // namespace Isosurfacing

View File

@ -28,10 +28,11 @@ template <class GeomTraits> // TODO: should not be necessary
class Octree_topology { class Octree_topology {
public: public:
typedef GeomTraits Geom_traits; typedef GeomTraits Geom_traits;
typedef Octree_wrapper<Geom_traits> Octree; typedef Octree_wrapper<Geom_traits> Octree_;
typedef typename Octree::Vertex_handle Vertex_descriptor; typedef std::shared_ptr<Octree_wrapper<Geom_traits>> Octree;
typedef typename Octree::Edge_handle Edge_descriptor; typedef typename Octree_::Vertex_handle Vertex_descriptor;
typedef typename Octree::Voxel_handle Cell_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 Cell_type CELL_TYPE = CUBICAL_CELL;
static constexpr std::size_t VERTICES_PER_CELL = 8; static constexpr std::size_t VERTICES_PER_CELL = 8;
@ -43,7 +44,7 @@ public:
typedef std::array<Edge_descriptor, 12> Cell_edges; typedef std::array<Edge_descriptor, 12> Cell_edges;
public: 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 { Vertices_incident_to_edge edge_vertices(const Edge_descriptor& e) const {
return octree->edge_vertices(e); return octree->edge_vertices(e);
@ -124,7 +125,7 @@ public:
#endif // CGAL_LINKED_WITH_TBB #endif // CGAL_LINKED_WITH_TBB
private: private:
const Octree* octree; const Octree octree;
}; };
} // namespace Isosurfacing } // namespace Isosurfacing

View File

@ -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 <CGAL/Bbox_3.h>
#include <CGAL/Cartesian_grid_3.h>
#include <CGAL/Isosurfacing_3/internal/Explicit_cartesian_grid_domain.h>
#include <CGAL/Isosurfacing_3/internal/Implicit_cartesian_grid_domain.h>
#include <CGAL/Isosurfacing_3/internal/Implicit_octree_domain.h>
#include <CGAL/Octree_wrapper.h>
#include <CGAL/license/Isosurfacing_3.h>
namespace CGAL {
namespace Isosurfacing {
template <class GeomTraits, typename Function, typename Gradient>
Implicit_cartesian_grid_domain_with_gradient<GeomTraits, Function, 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 <class GeomTraits, typename Function>
Implicit_cartesian_grid_domain<GeomTraits, Function> 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 <class GeomTraits, typename Gradient>
Explicit_cartesian_grid_domain_with_gradient<GeomTraits, Gradient> create_explicit_cartesian_grid_domain(
const Cartesian_grid_3<GeomTraits>& 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 <class GeomTraits>
Explicit_cartesian_grid_domain<GeomTraits> create_explicit_cartesian_grid_domain(
const Cartesian_grid_3<GeomTraits>& 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 <class GeomTraits, typename Function, typename Gradient>
Implicit_octree_domain_with_gradient<GeomTraits, Function, Gradient> create_implicit_octree_domain(
const Octree_wrapper<GeomTraits>& octree, const Function& func, const Gradient& grad) {
return {octree, func, grad};
}
template <class GeomTraits, typename Function>
Implicit_octree_domain<GeomTraits, Function> create_implicit_octree_domain(const Octree_wrapper<GeomTraits>& octree,
const Function& func) {
return {octree, func};
}
} // namespace Isosurfacing
} // namespace CGAL
#endif // CGAL_ISOSURFACING_DOMAINS_H