mirror of https://github.com/CGAL/cgal
Refactor domains to separate topology, geometry, function, gradient
This commit is contained in:
parent
dadc205da5
commit
a649221899
|
|
@ -1,151 +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_CARTESIAN_GRID_DOMAIN_H
|
|
||||||
#define CGAL_CARTESIAN_GRID_DOMAIN_H
|
|
||||||
|
|
||||||
#include <CGAL/license/Isosurfacing_3.h>
|
|
||||||
#include <CGAL/Cartesian_grid_3.h>
|
|
||||||
#include <CGAL/Cartesian_topology_base.h>
|
|
||||||
#include <CGAL/Default_gradients.h>
|
|
||||||
#include <CGAL/Isosurfacing_3/internal/Tables.h>
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
|
||||||
#include <tbb/parallel_for.h>
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
namespace Isosurfacing {
|
|
||||||
|
|
||||||
template <class GeomTraits, typename Gradient = Zero_gradient<GeomTraits>>
|
|
||||||
class Cartesian_grid_domain : public Cartesian_topology_base {
|
|
||||||
public:
|
|
||||||
typedef GeomTraits Geom_traits;
|
|
||||||
typedef typename Geom_traits::FT FT;
|
|
||||||
typedef typename Geom_traits::Point_3 Point;
|
|
||||||
typedef typename Geom_traits::Vector_3 Vector;
|
|
||||||
typedef typename Geom_traits::Vector_3 Grid_spacing;
|
|
||||||
typedef Cartesian_grid_3<Geom_traits> Grid;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Cartesian_grid_domain(const Grid& grid, const Gradient& grad = Gradient()) : grid(&grid), grad(&grad) {}
|
|
||||||
|
|
||||||
Point position(const Vertex_handle& v) const {
|
|
||||||
const Bbox_3& bbox = grid->get_bbox();
|
|
||||||
const Vector& spacing = grid->get_spacing();
|
|
||||||
|
|
||||||
return Point(v[0] * spacing.x() + bbox.xmin(), v[1] * spacing.y() + bbox.ymin(),
|
|
||||||
v[2] * spacing.z() + bbox.zmin());
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector gradient(const Point& p) const {
|
|
||||||
return grad->operator()(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
FT value(const Vertex_handle& v) const {
|
|
||||||
return grid->value(v[0], v[1], v[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices(Functor& f, Sequential_tag tag = Sequential_tag()) const {
|
|
||||||
iterate_vertices_base(f, tag, grid->xdim(), grid->ydim(), grid->zdim());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges(Functor& f, Sequential_tag tag = Sequential_tag()) const {
|
|
||||||
iterate_edges_base(f, tag, grid->xdim(), grid->ydim(), grid->zdim());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells(Functor& f, Sequential_tag tag = Sequential_tag()) const {
|
|
||||||
iterate_cells_base(f, tag, grid->xdim(), grid->ydim(), grid->zdim());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices(Functor& f, Parallel_tag) const {
|
|
||||||
const std::size_t size_x = grid->xdim();
|
|
||||||
const std::size_t size_y = grid->ydim();
|
|
||||||
const std::size_t size_z = grid->zdim();
|
|
||||||
|
|
||||||
auto iterator = [&f, size_x, size_y, size_z](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t x = r.begin(); x != r.end(); x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_x - 1), iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges(Functor& f, Parallel_tag) const {
|
|
||||||
const std::size_t size_x = grid->xdim();
|
|
||||||
const std::size_t size_y = grid->ydim();
|
|
||||||
const std::size_t size_z = grid->zdim();
|
|
||||||
|
|
||||||
auto iterator = [&f, size_x, size_y, size_z](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t x = r.begin(); x != r.end(); x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z, 0});
|
|
||||||
f({x, y, z, 1});
|
|
||||||
f({x, y, z, 2});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_x - 1), iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells(Functor& f, Parallel_tag) const {
|
|
||||||
const std::size_t size_x = grid->xdim();
|
|
||||||
const std::size_t size_y = grid->ydim();
|
|
||||||
const std::size_t size_z = grid->zdim();
|
|
||||||
|
|
||||||
//#pragma omp parallel for
|
|
||||||
// for (int x = 0; x < size_x - 1; x++) {
|
|
||||||
// for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
// for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
// f({(std::size_t)x, y, z});
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
auto iterator = [&f, size_x, size_y, size_z](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t x = r.begin(); x != r.end(); x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_x - 1), iterator);
|
|
||||||
}
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Grid* grid;
|
|
||||||
|
|
||||||
const Gradient* grad;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Isosurfacing
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
#endif // CGAL_CARTESIAN_GRID_DOMAIN_H
|
|
||||||
|
|
@ -1,129 +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_CARTESIAN_TOPOLOGY_BASE_H
|
|
||||||
#define CGAL_CARTESIAN_TOPOLOGY_BASE_H
|
|
||||||
|
|
||||||
#include <CGAL/license/Isosurfacing_3.h>
|
|
||||||
#include <CGAL/Cell_type.h>
|
|
||||||
#include <CGAL/Isosurfacing_3/internal/Tables.h>
|
|
||||||
#include <CGAL/tags.h>
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
namespace Isosurfacing {
|
|
||||||
|
|
||||||
class Cartesian_topology_base {
|
|
||||||
public:
|
|
||||||
typedef std::array<std::size_t, 3> Vertex_handle;
|
|
||||||
typedef std::array<std::size_t, 4> Edge_handle;
|
|
||||||
typedef std::array<std::size_t, 3> Cell_handle;
|
|
||||||
|
|
||||||
static constexpr Cell_type CELL_TYPE = CUBICAL_CELL;
|
|
||||||
static constexpr std::size_t VERTICES_PER_CELL = 8;
|
|
||||||
static constexpr std::size_t EDGES_PER_CELL = 12;
|
|
||||||
|
|
||||||
typedef std::array<Vertex_handle, 2> Edge_vertices;
|
|
||||||
typedef std::array<Cell_handle, 4> Cells_incident_to_edge;
|
|
||||||
typedef std::array<Vertex_handle, VERTICES_PER_CELL> Cell_vertices;
|
|
||||||
typedef std::array<Edge_handle, EDGES_PER_CELL> Cell_edges;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Edge_vertices edge_vertices(const Edge_handle& e) const {
|
|
||||||
Edge_vertices ev;
|
|
||||||
ev[0] = {e[0], e[1], e[2]};
|
|
||||||
ev[1] = {e[0], e[1], e[2]};
|
|
||||||
ev[1][e[3]] += 1;
|
|
||||||
return ev;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cells_incident_to_edge cells_incident_to_edge(const Edge_handle& e) const {
|
|
||||||
const int local = internal::Cube_table::edge_store_index[e[3]];
|
|
||||||
auto neighbors = internal::Cube_table::edge_to_voxel_neighbor[local];
|
|
||||||
|
|
||||||
Cells_incident_to_edge cite;
|
|
||||||
for (std::size_t i = 0; i < cite.size(); i++) {
|
|
||||||
for (std::size_t j = 0; j < cite[i].size(); j++) {
|
|
||||||
cite[i][j] = e[j] + neighbors[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cite;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell_vertices cell_vertices(const Cell_handle& v) const {
|
|
||||||
Cell_vertices cv;
|
|
||||||
for (std::size_t i = 0; i < cv.size(); i++) {
|
|
||||||
for (std::size_t j = 0; j < v.size(); j++) {
|
|
||||||
cv[i][j] = v[j] + internal::Cube_table::local_vertex_position[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cv;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell_edges cell_edges(const Cell_handle& v) const {
|
|
||||||
Cell_edges ce;
|
|
||||||
for (std::size_t i = 0; i < ce.size(); i++) {
|
|
||||||
for (std::size_t j = 0; j < v.size(); j++) {
|
|
||||||
ce[i][j] = v[j] + internal::Cube_table::global_edge_id[i][j];
|
|
||||||
}
|
|
||||||
ce[i][3] = internal::Cube_table::global_edge_id[i][3];
|
|
||||||
}
|
|
||||||
return ce;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices_base(Functor& f, Sequential_tag, const std::size_t size_x, const std::size_t size_y,
|
|
||||||
const std::size_t size_z) const {
|
|
||||||
|
|
||||||
for (std::size_t x = 0; x < size_x; x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z; z++) {
|
|
||||||
f({x, y, z});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges_base(Functor& f, Sequential_tag, const std::size_t size_x, const std::size_t size_y,
|
|
||||||
const std::size_t size_z) const {
|
|
||||||
|
|
||||||
for (std::size_t x = 0; x < size_x - 1; x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z, 0});
|
|
||||||
f({x, y, z, 1});
|
|
||||||
f({x, y, z, 2});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells_base(Functor& f, Sequential_tag, const std::size_t size_x, const std::size_t size_y,
|
|
||||||
const std::size_t size_z) const {
|
|
||||||
|
|
||||||
for (std::size_t x = 0; x < size_x - 1; x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Isosurfacing
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
#endif // CGAL_CARTESIAN_TOPOLOGY_BASE_H
|
|
||||||
|
|
@ -1,169 +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_DOMAIN_H
|
|
||||||
#define CGAL_IMPLICIT_DOMAIN_H
|
|
||||||
|
|
||||||
#include <CGAL/license/Isosurfacing_3.h>
|
|
||||||
#include <CGAL/Bbox_3.h>
|
|
||||||
#include <CGAL/Cartesian_topology_base.h>
|
|
||||||
#include <CGAL/Default_gradients.h>
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
|
||||||
#include <tbb/parallel_for.h>
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
namespace Isosurfacing {
|
|
||||||
|
|
||||||
template <class GeomTraits, typename Function, typename Gradient = Zero_gradient<GeomTraits>>
|
|
||||||
class Implicit_domain : public Cartesian_topology_base {
|
|
||||||
public:
|
|
||||||
typedef GeomTraits Geom_traits;
|
|
||||||
typedef typename Geom_traits::FT FT;
|
|
||||||
typedef typename Geom_traits::Point_3 Point;
|
|
||||||
typedef typename Geom_traits::Vector_3 Vector;
|
|
||||||
typedef typename Geom_traits::Vector_3 Grid_spacing;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Implicit_domain(const Bbox_3& bbox, const Grid_spacing& spacing, const Function& func,
|
|
||||||
const Gradient& grad = Gradient())
|
|
||||||
: bbox(bbox), spacing(spacing), func(&func), grad(&grad) {
|
|
||||||
|
|
||||||
sizes[0] = bbox.x_span() / spacing.x() + 1;
|
|
||||||
sizes[1] = bbox.y_span() / spacing.y() + 1;
|
|
||||||
sizes[2] = bbox.z_span() / spacing.z() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Point position(const Vertex_handle& v) const {
|
|
||||||
return Point(v[0] * spacing.x() + bbox.xmin(), v[1] * spacing.y() + bbox.ymin(),
|
|
||||||
v[2] * spacing.z() + bbox.zmin());
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector gradient(const Point& p) const {
|
|
||||||
return grad->operator()(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
FT value(const Vertex_handle& v) const {
|
|
||||||
return func->operator()(position(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices(Functor& f, Sequential_tag tag = Sequential_tag()) const {
|
|
||||||
iterate_vertices_base(f, tag, sizes[0], sizes[1], sizes[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges(Functor& f, Sequential_tag tag = Sequential_tag()) const {
|
|
||||||
iterate_edges_base(f, tag, sizes[0], sizes[1], sizes[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells(Functor& f, Sequential_tag tag = Sequential_tag()) const {
|
|
||||||
iterate_cells_base(f, tag, sizes[0], sizes[1], sizes[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices(Functor& f, Parallel_tag) const {
|
|
||||||
const std::size_t size_x = sizes[0];
|
|
||||||
const std::size_t size_y = sizes[1];
|
|
||||||
const std::size_t size_z = sizes[2];
|
|
||||||
|
|
||||||
auto iterator = [&f, size_x, size_y, size_z](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t x = r.begin(); x != r.end(); x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z; z++) {
|
|
||||||
f({x, y, z});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_x), iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges(Functor& f, Parallel_tag) const {
|
|
||||||
const std::size_t size_x = sizes[0];
|
|
||||||
const std::size_t size_y = sizes[1];
|
|
||||||
const std::size_t size_z = sizes[2];
|
|
||||||
|
|
||||||
auto iterator = [&f, size_x, size_y, size_z](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t x = r.begin(); x != r.end(); x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z, 0});
|
|
||||||
f({x, y, z, 1});
|
|
||||||
f({x, y, z, 2});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_x - 1), iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells(Functor& f, Parallel_tag) const {
|
|
||||||
const std::size_t size_x = sizes[0];
|
|
||||||
const std::size_t size_y = sizes[1];
|
|
||||||
const std::size_t size_z = sizes[2];
|
|
||||||
|
|
||||||
//#pragma omp parallel for
|
|
||||||
// for (int x = 0; x < size_x - 1; x++) {
|
|
||||||
// Cell_handle h;
|
|
||||||
// h[0] = x;
|
|
||||||
// for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
// h[1] = y;
|
|
||||||
// for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
// h[2] = z;
|
|
||||||
// f(h);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
auto iterator = [&f, size_x, size_y, size_z](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t x = r.begin(); x != r.end(); x++) {
|
|
||||||
for (std::size_t y = 0; y < size_y - 1; y++) {
|
|
||||||
for (std::size_t z = 0; z < size_z - 1; z++) {
|
|
||||||
f({x, y, z});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_x - 1), iterator);
|
|
||||||
}
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
|
||||||
|
|
||||||
private:
|
|
||||||
Bbox_3 bbox;
|
|
||||||
Grid_spacing spacing;
|
|
||||||
|
|
||||||
const Function* func;
|
|
||||||
const Gradient* grad;
|
|
||||||
|
|
||||||
std::array<std::size_t, 3> sizes;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <typename Function, typename Gradient, class GeomTraits = typename Function::Geom_traits>
|
|
||||||
Implicit_domain<GeomTraits, Function, Gradient> create_implicit_domain(const Bbox_3& domain,
|
|
||||||
const typename GeomTraits::Vector_3& spacing,
|
|
||||||
const Function& func, const Gradient& grad) {
|
|
||||||
return Implicit_domain<GeomTraits, Function, Gradient>(domain, spacing, func, grad);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Isosurfacing
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
#endif // CGAL_IMPLICIT_DOMAIN_H
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
// 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_BASE_DOMAIN_H
|
||||||
|
#define CGAL_BASE_DOMAIN_H
|
||||||
|
|
||||||
|
#include <CGAL/Isosurfacing_3/internal/Cell_type.h>
|
||||||
|
#include <CGAL/license/Isosurfacing_3.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
namespace Isosurfacing {
|
||||||
|
|
||||||
|
template <class GeomTraits, typename Topology_, typename Geometry_, typename Function_, typename Gradient_>
|
||||||
|
class Base_domain {
|
||||||
|
public:
|
||||||
|
typedef GeomTraits Geom_traits;
|
||||||
|
typedef typename Geom_traits::FT FT;
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 Geometry_ Geometry;
|
||||||
|
typedef Function_ Function;
|
||||||
|
typedef Gradient_ Gradient;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Base_domain(const Topology& topo, const Geometry& geom, const Function& func, const Gradient& grad)
|
||||||
|
: topo(&topo), geom(&geom), func(&func), grad(&grad) {}
|
||||||
|
|
||||||
|
Point position(const Vertex_descriptor& v) const {
|
||||||
|
return geom->operator()(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
FT value(const Vertex_descriptor& v) const {
|
||||||
|
return func->operator()(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector gradient(const Point& p) const {
|
||||||
|
return grad->operator()(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertices_incident_to_edge edge_vertices(const Edge_descriptor& e) const {
|
||||||
|
return topo->edge_vertices(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cells_incident_to_edge cells_incident_to_edge(const Edge_descriptor& e) const {
|
||||||
|
return topo->cells_incident_to_edge(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell_vertices cell_vertices(const Cell_descriptor& c) const {
|
||||||
|
return topo->cell_vertices(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell_edges cell_edges(const Cell_descriptor& c) const {
|
||||||
|
return topo->cell_edges(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Concurrency_tag, typename Functor>
|
||||||
|
void iterate_vertices(Functor& f) const {
|
||||||
|
topo->iterate_vertices(f, Concurrency_tag());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Concurrency_tag, typename Functor>
|
||||||
|
void iterate_edges(Functor& f) const {
|
||||||
|
topo->iterate_edges(f, Concurrency_tag());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Concurrency_tag, typename Functor>
|
||||||
|
void iterate_cells(Functor& f) const {
|
||||||
|
topo->iterate_cells(f, Concurrency_tag());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Topology* topo;
|
||||||
|
const Geometry* geom;
|
||||||
|
const Function* func;
|
||||||
|
const Gradient* grad;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_BASE_DOMAIN_H
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
// 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_CARTESIAN_GRID_GEOMETRY_H
|
||||||
|
#define CGAL_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>
|
||||||
|
class Cartesian_grid_geometry {
|
||||||
|
public:
|
||||||
|
typedef GeomTraits Geom_traits;
|
||||||
|
typedef typename Geom_traits::Point_3 Point;
|
||||||
|
typedef typename Geom_traits::Vector_3 Vector;
|
||||||
|
|
||||||
|
typedef typename Grid_topology::Vertex_descriptor Vertex_descriptor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Cartesian_grid_geometry(const Vector& offset, const Vector& spacing) : offset(offset), spacing(spacing) {}
|
||||||
|
|
||||||
|
Point operator()(const Vertex_descriptor& v) const {
|
||||||
|
return Point(v[0] * spacing[0], v[1] * spacing[1], v[2] * spacing[2]) + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector offset;
|
||||||
|
Vector spacing;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_CARTESIAN_GRID_GEOMETRY_H
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
// 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 Grid_topology Topology;
|
||||||
|
typedef Cartesian_grid_geometry<Geom_traits> Geometry;
|
||||||
|
typedef Cartesian_grid_3<Geom_traits> Function;
|
||||||
|
typedef Gradient_ Gradient;
|
||||||
|
|
||||||
|
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_domain(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:
|
||||||
|
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)
|
||||||
|
: Explicit_cartesian_grid_domain_with_gradient(size_i, size_j, size_k, offset, spacing, grid, grad) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Gradient grad;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_EXPLICIT_CARTESIAN_GRID_DOMAIN_H
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
// 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_GRID_TOPOLOGY_H
|
||||||
|
#define CGAL_GRID_TOPOLOGY_H
|
||||||
|
|
||||||
|
#include <CGAL/Isosurfacing_3/internal/Cell_type.h>
|
||||||
|
#include <CGAL/Isosurfacing_3/internal/Tables.h>
|
||||||
|
#include <CGAL/license/Isosurfacing_3.h>
|
||||||
|
#include <CGAL/tags.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
|
#include <tbb/parallel_for.h>
|
||||||
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
namespace Isosurfacing {
|
||||||
|
|
||||||
|
class Grid_topology {
|
||||||
|
public:
|
||||||
|
typedef std::array<std::size_t, 3> Vertex_descriptor;
|
||||||
|
typedef std::array<std::size_t, 4> Edge_descriptor;
|
||||||
|
typedef std::array<std::size_t, 3> Cell_descriptor;
|
||||||
|
|
||||||
|
static constexpr Cell_type CELL_TYPE = CUBICAL_CELL;
|
||||||
|
static constexpr std::size_t VERTICES_PER_CELL = 8;
|
||||||
|
static constexpr std::size_t EDGES_PER_CELL = 12;
|
||||||
|
|
||||||
|
typedef std::array<Vertex_descriptor, 2> Vertices_incident_to_edge;
|
||||||
|
typedef std::array<Cell_descriptor, 4> Cells_incident_to_edge;
|
||||||
|
typedef std::array<Vertex_descriptor, VERTICES_PER_CELL> Cell_vertices;
|
||||||
|
typedef std::array<Edge_descriptor, EDGES_PER_CELL> Cell_edges;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Grid_topology(const std::size_t size_i, const std::size_t size_j, const std::size_t size_k)
|
||||||
|
: size_i(size_i), size_j(size_j), size_k(size_k) {}
|
||||||
|
|
||||||
|
Vertices_incident_to_edge edge_vertices(const Edge_descriptor& e) const {
|
||||||
|
Vertices_incident_to_edge ev;
|
||||||
|
ev[0] = {e[0], e[1], e[2]};
|
||||||
|
ev[1] = {e[0], e[1], e[2]};
|
||||||
|
ev[1][e[3]] += 1;
|
||||||
|
return ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cells_incident_to_edge cells_incident_to_edge(const Edge_descriptor& e) const {
|
||||||
|
const int local = internal::Cube_table::edge_store_index[e[3]];
|
||||||
|
auto neighbors = internal::Cube_table::edge_to_voxel_neighbor[local];
|
||||||
|
|
||||||
|
Cells_incident_to_edge cite;
|
||||||
|
for (std::size_t i = 0; i < cite.size(); i++) {
|
||||||
|
for (std::size_t j = 0; j < cite[i].size(); j++) {
|
||||||
|
cite[i][j] = e[j] + neighbors[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cite;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell_vertices cell_vertices(const Cell_descriptor& c) const {
|
||||||
|
Cell_vertices cv;
|
||||||
|
for (std::size_t i = 0; i < cv.size(); i++) {
|
||||||
|
for (std::size_t j = 0; j < c.size(); j++) {
|
||||||
|
cv[i][j] = c[j] + internal::Cube_table::local_vertex_position[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cv;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell_edges cell_edges(const Cell_descriptor& c) const {
|
||||||
|
Cell_edges ce;
|
||||||
|
for (std::size_t i = 0; i < ce.size(); i++) {
|
||||||
|
for (std::size_t j = 0; j < c.size(); j++) {
|
||||||
|
ce[i][j] = c[j] + internal::Cube_table::global_edge_id[i][j];
|
||||||
|
}
|
||||||
|
ce[i][3] = internal::Cube_table::global_edge_id[i][3];
|
||||||
|
}
|
||||||
|
return ce;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_vertices(Functor& f, Sequential_tag) const {
|
||||||
|
for (std::size_t i = 0; i < size_i; i++) {
|
||||||
|
for (std::size_t j = 0; j < size_j; j++) {
|
||||||
|
for (std::size_t k = 0; k < size_k; k++) {
|
||||||
|
f({i, j, k});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_edges(Functor& f, Sequential_tag) const {
|
||||||
|
for (std::size_t i = 0; i < size_i - 1; i++) {
|
||||||
|
for (std::size_t j = 0; j < size_j - 1; j++) {
|
||||||
|
for (std::size_t k = 0; k < size_k - 1; k++) {
|
||||||
|
f({i, j, k, 0});
|
||||||
|
f({i, j, k, 1});
|
||||||
|
f({i, j, k, 2});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_cells(Functor& f, Sequential_tag) const {
|
||||||
|
for (std::size_t i = 0; i < size_i - 1; i++) {
|
||||||
|
for (std::size_t j = 0; j < size_j - 1; j++) {
|
||||||
|
for (std::size_t k = 0; k < size_k - 1; k++) {
|
||||||
|
f({i, j, k});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_vertices(Functor& f, Parallel_tag) const {
|
||||||
|
auto iterator = [&f, size_i, size_j, size_k](const tbb::blocked_range<std::size_t>& r) {
|
||||||
|
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
||||||
|
for (std::size_t j = 0; j < size_j; j++) {
|
||||||
|
for (std::size_t k = 0; k < size_k; k++) {
|
||||||
|
f({i, j, k});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_i), iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_edges(Functor& f, Parallel_tag) const {
|
||||||
|
auto iterator = [&f, size_i, size_j, size_k](const tbb::blocked_range<std::size_t>& r) {
|
||||||
|
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
||||||
|
for (std::size_t j = 0; j < size_j - 1; j++) {
|
||||||
|
for (std::size_t k = 0; k < size_k - 1; k++) {
|
||||||
|
f({i, j, k, 0});
|
||||||
|
f({i, j, k, 1});
|
||||||
|
f({i, j, k, 2});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_i - 1), iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_cells(Functor& f, Parallel_tag) const {
|
||||||
|
auto iterator = [&f, size_i, size_j, size_k](const tbb::blocked_range<std::size_t>& r) {
|
||||||
|
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
||||||
|
for (std::size_t j = 0; j < size_j - 1; j++) {
|
||||||
|
for (std::size_t k = 0; k < size_k - 1; k++) {
|
||||||
|
f({i, j, k});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, size_i - 1), iterator);
|
||||||
|
}
|
||||||
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::size_t size_i;
|
||||||
|
std::size_t size_j;
|
||||||
|
std::size_t size_k;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_GRID_TOPOLOGY_H
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
// 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 typename Topology::Vertex_descriptor Vertex_descriptor;
|
||||||
|
|
||||||
|
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_domain(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:
|
||||||
|
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)
|
||||||
|
: Implicit_cartesian_grid_domain_with_gradient(size_i, size_j, size_k, offset, spacing, func, grad) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Gradient grad;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_IMPLICIT_CARTESIAN_GRID_DOMAIN_H
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
// 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_FUNCTION_WITH_GEOMETRY_H
|
||||||
|
#define CGAL_IMPLICIT_FUNCTION_WITH_GEOMETRY_H
|
||||||
|
|
||||||
|
#include <CGAL/license/Isosurfacing_3.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
namespace Isosurfacing {
|
||||||
|
|
||||||
|
template <class GeomTraits, typename Geometry, typename Function>
|
||||||
|
class Implicit_function_with_geometry {
|
||||||
|
public:
|
||||||
|
typedef GeomTraits Geom_traits;
|
||||||
|
typedef typename Geom_traits::FT FT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Implicit_function_with_geometry(const Geometry& geom, const Function& func) : geom(&geom), func(&func) {}
|
||||||
|
|
||||||
|
template <typename VertexDescriptor>
|
||||||
|
FT operator()(const VertexDescriptor& v) const {
|
||||||
|
return func->operator()(geom->operator()(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Geometry* geom;
|
||||||
|
const Function* func;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_IMPLICIT_FUNCTION_WITH_GEOMETRY_H
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
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_domain(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:
|
||||||
|
Implicit_octree_domain(const Octree& octree, const Function_with_point& func)
|
||||||
|
: Implicit_cartesian_grid_domain_with_gradient(octree, func, grad) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Gradient grad;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_IMPLICIT_OCTREE_DOMAIN_H
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
// 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_OCTREE_GEOMETRY_H
|
||||||
|
#define CGAL_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>
|
||||||
|
class Octree_geometry {
|
||||||
|
public:
|
||||||
|
typedef GeomTraits Geom_traits;
|
||||||
|
typedef typename Geom_traits::Point_3 Point;
|
||||||
|
|
||||||
|
typedef Octree_wrapper<Geom_traits> Octree;
|
||||||
|
|
||||||
|
typedef typename Octree_topology<Geom_traits>::Vertex_descriptor Vertex_descriptor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Octree_geometry(const Octree& octree) : octree(&octree) {}
|
||||||
|
|
||||||
|
Point operator()(const Vertex_descriptor& v) const {
|
||||||
|
return octree->point(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Octree* octree;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_OCTREE_GEOMETRY_H
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
// 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_OCTREE_TOPOLOGY_H
|
||||||
|
#define CGAL_OCTREE_TOPOLOGY_H
|
||||||
|
|
||||||
|
#include <CGAL/Isosurfacing_3/internal/Cell_type.h>
|
||||||
|
#include <CGAL/Octree_wrapper.h>
|
||||||
|
#include <CGAL/license/Isosurfacing_3.h>
|
||||||
|
#include <CGAL/tags.h>
|
||||||
|
|
||||||
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
|
#include <tbb/parallel_for.h>
|
||||||
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
namespace Isosurfacing {
|
||||||
|
|
||||||
|
template <class GeomTraits> // TODO: should not be necessary
|
||||||
|
class Octree_topology {
|
||||||
|
public:
|
||||||
|
typedef GeomTraits Geom_traits;
|
||||||
|
typedef Octree_wrapper<Geom_traits> 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;
|
||||||
|
static constexpr std::size_t EDGES_PER_CELL = 12;
|
||||||
|
|
||||||
|
typedef std::array<Vertex_descriptor, 2> Vertices_incident_to_edge;
|
||||||
|
typedef std::array<Cell_descriptor, 4> Cells_incident_to_edge; // TODO: not always 4
|
||||||
|
typedef std::array<Vertex_descriptor, 8> Cell_vertices;
|
||||||
|
typedef std::array<Edge_descriptor, 12> Cell_edges;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Octree_topology(const Octree& octree) : octree(&octree) {}
|
||||||
|
|
||||||
|
Vertices_incident_to_edge edge_vertices(const Edge_descriptor& e) const {
|
||||||
|
return octree->edge_vertices(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cells_incident_to_edge cells_incident_to_edge(const Edge_descriptor& e) const {
|
||||||
|
return octree->edge_voxels(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell_vertices cell_vertices(const Cell_descriptor& c) const {
|
||||||
|
return octree->voxel_vertices(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell_edges cell_edges(const Cell_descriptor& c) const {
|
||||||
|
return octree->voxel_edges(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_vertices(Functor& f, Sequential_tag) const {
|
||||||
|
for (const Vertex_descriptor& v : octree->leaf_vertices()) {
|
||||||
|
f(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_edges(Functor& f, Sequential_tag) const {
|
||||||
|
for (const Edge_descriptor& e : octree->leaf_edges()) {
|
||||||
|
f(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_cells(Functor& f, Sequential_tag) const {
|
||||||
|
for (const Cell_descriptor& v : octree->leaf_voxels()) {
|
||||||
|
f(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_vertices(Functor& f, Parallel_tag) const {
|
||||||
|
const auto& vertices = octree->leaf_vertices();
|
||||||
|
|
||||||
|
auto iterator = [&](const tbb::blocked_range<std::size_t>& r) {
|
||||||
|
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
||||||
|
f(vertices[i]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, vertices.size()), iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_edges(Functor& f) const {
|
||||||
|
const auto& edges = octree->leaf_edges();
|
||||||
|
|
||||||
|
auto iterator = [&](const tbb::blocked_range<std::size_t>& r) {
|
||||||
|
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
||||||
|
f(edges[i]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, edges.size()), iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
void iterate_cells(Functor& f) const {
|
||||||
|
const auto& cells = octree->leaf_voxels();
|
||||||
|
|
||||||
|
auto iterator = [&](const tbb::blocked_range<std::size_t>& r) {
|
||||||
|
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
||||||
|
f(cells[i]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, cells.size()), iterator);
|
||||||
|
}
|
||||||
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Octree* octree;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Isosurfacing
|
||||||
|
} // namespace CGAL
|
||||||
|
|
||||||
|
#endif // CGAL_OCTREE_TOPOLOGY_H
|
||||||
|
|
@ -0,0 +1,99 @@
|
||||||
|
// 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
|
||||||
|
|
@ -1,153 +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_OCTREE_DOMAIN_H
|
|
||||||
#define CGAL_OCTREE_DOMAIN_H
|
|
||||||
|
|
||||||
#include <CGAL/license/Isosurfacing_3.h>
|
|
||||||
#include <CGAL/Cell_type.h>
|
|
||||||
#include <CGAL/Default_gradients.h>
|
|
||||||
#include <CGAL/Octree_wrapper.h>
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
|
||||||
#include <tbb/parallel_for.h>
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
namespace Isosurfacing {
|
|
||||||
|
|
||||||
template <typename GeomTraits, typename Gradient = Zero_gradient<GeomTraits>>
|
|
||||||
class Octree_domain {
|
|
||||||
public:
|
|
||||||
typedef GeomTraits Geom_traits;
|
|
||||||
typedef typename Geom_traits::FT FT;
|
|
||||||
typedef typename Geom_traits::Point_3 Point;
|
|
||||||
typedef typename Geom_traits::Vector_3 Vector;
|
|
||||||
|
|
||||||
typedef Octree_wrapper<Geom_traits> Octree;
|
|
||||||
typedef typename Octree::Vertex_handle Vertex_handle;
|
|
||||||
typedef typename Octree::Edge_handle Edge_handle;
|
|
||||||
typedef typename Octree::Voxel_handle Cell_handle;
|
|
||||||
|
|
||||||
static constexpr Cell_type CELL_TYPE = CUBICAL_CELL;
|
|
||||||
static constexpr std::size_t VERTICES_PER_CELL = 8;
|
|
||||||
static constexpr std::size_t EDGES_PER_CELL = 12;
|
|
||||||
|
|
||||||
typedef std::array<Vertex_handle, 2> Edge_vertices;
|
|
||||||
typedef std::array<Cell_handle, 4> Cells_incident_to_edge; // TODO: not alwayys 4
|
|
||||||
typedef std::array<Vertex_handle, 8> Cell_vertices;
|
|
||||||
typedef std::array<Edge_handle, 12> Cell_edges;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Octree_domain(const Octree& octree, const Gradient& grad = Gradient()) : octree_(&octree), grad(&grad) {}
|
|
||||||
|
|
||||||
Point position(const Vertex_handle& v) const {
|
|
||||||
return octree_->point(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector gradient(const Point& p) const {
|
|
||||||
return grad->operator()(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
FT value(const Vertex_handle& v) const {
|
|
||||||
return octree_->vertex_value(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
Edge_vertices edge_vertices(const Edge_handle& e_id) const {
|
|
||||||
return octree_->edge_vertices(e_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cells_incident_to_edge cells_incident_to_edge(const Edge_handle& e_id) const {
|
|
||||||
return octree_->edge_voxels(e_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell_vertices cell_vertices(const Cell_handle& vox) const {
|
|
||||||
return octree_->voxel_vertices(vox);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell_edges cell_edges(const Cell_handle& vox) const {
|
|
||||||
return octree_->voxel_edges(vox);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices(Functor& f, Sequential_tag = Sequential_tag()) const {
|
|
||||||
for (const Vertex_handle& v : octree_->leaf_vertices()) {
|
|
||||||
f(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges(Functor& f, Sequential_tag = Sequential_tag()) const {
|
|
||||||
for (const Edge_handle& e : octree_->leaf_edges()) {
|
|
||||||
f(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells(Functor& f, Sequential_tag = Sequential_tag()) const {
|
|
||||||
for (const Cell_handle& v : octree_->leaf_voxels()) {
|
|
||||||
f(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_vertices(Functor& f, Parallel_tag) const {
|
|
||||||
const auto& vertices = octree_->leaf_vertices();
|
|
||||||
|
|
||||||
auto iterator = [&](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
|
||||||
f(vertices[i]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, vertices.size()), iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_edges(Functor& f, Parallel_tag) const {
|
|
||||||
const auto& edges = octree_->leaf_edges();
|
|
||||||
|
|
||||||
auto iterator = [&](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
|
||||||
f(edges[i]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, edges.size()), iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
void iterate_cells(Functor& f, Parallel_tag) const {
|
|
||||||
const auto& cells = octree_->leaf_voxels();
|
|
||||||
|
|
||||||
auto iterator = [&](const tbb::blocked_range<std::size_t>& r) {
|
|
||||||
for (std::size_t i = r.begin(); i != r.end(); i++) {
|
|
||||||
f(cells[i]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, cells.size()), iterator);
|
|
||||||
}
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Octree* octree_;
|
|
||||||
|
|
||||||
const Gradient* grad;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Isosurfacing
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
#endif // CGAL_OCTREE_DOMAIN_H
|
|
||||||
Loading…
Reference in New Issue