Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
voronoi.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2025 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Matteo Caldana <matteo.caldana@polimi.it>
22
23#ifndef VULPES_GEOMETRY_VORONOI_HPP_
24#define VULPES_GEOMETRY_VORONOI_HPP_
25
26#include <array>
27#include <cstdint>
28#include <functional>
29#include <vector>
30
31#include <voro++.hh>
32#include <voro++_2d.hh>
33
35
36namespace vulpes {
37namespace geometry {
38
57void voronoi2D(
58 const std::array<Point<double, 2>, 2>& bbox,
59 const std::vector<Point<double, 2>>& points,
60 const std::function<void(voro::voronoicell_neighbor_2d& cell, int32_t id)>&
61 cell_callback);
62
80void voronoi3D(
81 const std::array<Point<double, 3>, 2>& bbox,
82 const std::vector<Point<double, 3>>& points,
83 const std::function<void(voro::voronoicell_neighbor& cell, int32_t id)>&
84 cell_callback);
85
98template <int32_t Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
99using VoronoiCell = std::conditional_t<
100 Dim == 2,
101 voro::voronoicell_neighbor_2d,
102 voro::voronoicell_neighbor>;
103
122template <int32_t Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
124 const std::array<Point<double, Dim>, 2>& bbox,
125 std::vector<Point<double, Dim>>& points,
126 const std::function<void(VoronoiCell<Dim>& cell, int32_t id)>&
127 cell_callback) {
128 if constexpr (Dim == 2) {
129 voronoi2D(bbox, points, cell_callback);
130 } else {
131 voronoi3D(bbox, points, cell_callback);
132 }
133}
134
135} // namespace geometry
136} // namespace vulpes
137
138#endif // VULPES_GEOMETRY_VORONOI_HPP_
Definition abs_agg_model.cpp:40
Eigen::Matrix< DataType, Dim, 1, Eigen::ColMajor > Point
Definition traits.hpp:34
std::conditional_t< Dim==2, voro::voronoicell_neighbor_2d, voro::voronoicell_neighbor > VoronoiCell
Alias for the Voronoi cell type based on the dimensionality (2D or 3D).
Definition voronoi.hpp:99
void voronoi(const std::array< Point< double, Dim >, 2 > &bbox, std::vector< Point< double, Dim > > &points, const std::function< void(VoronoiCell< Dim > &cell, int32_t id)> &cell_callback)
Computes a Voronoi tessellation in either 2D or 3D space.
Definition voronoi.hpp:123
void voronoi2D(const std::array< Point< double, 2 >, 2 > &bbox, const std::vector< Point< double, 2 > > &points, const std::function< void(voro::voronoicell_neighbor_2d &cell, int32_t id)> &cell_callback)
Computes a 2D Voronoi tessellation for a given set of points within a bounding box.
Definition voronoi.cpp:44
void voronoi3D(const std::array< Point< double, 3 >, 2 > &bbox, const std::vector< Point< double, 3 > > &points, const std::function< void(voro::voronoicell_neighbor &cell, int32_t id)> &cell_callback)
Computes a 3D Voronoi tessellation for a given set of points within a bounding box.
Definition voronoi.cpp:72
Definition cell_manager.hpp:38