4#include <deal.II/base/point.h>
5#include <deal.II/grid/tria.h>
6#include <deal.II/grid/tria_accessor.h>
7#include <deal.II/grid/tria_iterator.h>
8#include <deal.II/base/geometry_info.h>
9#include <deal.II/numerics/data_out.h>
12#include <deal.II/lac/vector.h>
14#include <geogram/basic/smart_pointer.h>
15#include <geogram/delaunay/delaunay.h>
16#include <geogram/voronoi/RVD.h>
28using namespace dealii;
39template <
int dim,
int spacedim=dim>
50 const Vector<double> &potentials) = 0;
61 virtual void output_vtu(
const std::string& filename)
const = 0;
89template <
int dim,
int spacedim=dim>
104 const Vector<double> &potentials)
override;
111 const std::function<
double(
const Point<spacedim>&,
const Point<spacedim>&)>& dist)
123 const unsigned int generator_idx)
const;
134 void output_vtu(
const std::string& filename)
const override;
174template <
int dim,
int spacedim = dim>
190 const Vector<double> &potentials)
override;
201 void output_vtu(
const std::string& filename)
const override;
225 GEO::RestrictedVoronoiDiagram_var
RVD;
242template <
int dim,
int spacedim>
244 const std::string& implementation_type,
245 const Triangulation<dim, spacedim>* dealii_mesh =
nullptr,
246 const std::string& geogram_mesh_file =
"") {
248 if (implementation_type ==
"dealii" && dealii_mesh !=
nullptr) {
249 return std::make_unique<DealIIPowerDiagram<dim, spacedim>>(*dealii_mesh);
250 }
else if (implementation_type ==
"geogram" && !geogram_mesh_file.empty()) {
251 if constexpr (dim==3 && dim==spacedim)
254 throw std::runtime_error(
"Geogram power diagram is only available for dim==spacedim");
256 throw std::runtime_error(
"Invalid power diagram implementation type or missing required parameters");
A class for computing power diagrams using deal.II.
void output_vtu(const std::string &filename) const override
Outputs the power diagram to a VTU file.
unsigned int get_cell_assignment(const unsigned int cell_index) const
Returns the assignment of a cell to a generator.
const Triangulation< dim, spacedim > * source_triangulation
The source triangulation.
void compute_cell_centroids() override
Computes the centroids of the power cells.
void set_generators(const std::vector< Point< spacedim > > &points, const Vector< double > &potentials) override
Sets the generator points and their potentials.
void set_distance_function(const std::function< double(const Point< spacedim > &, const Point< spacedim > &)> &dist)
Sets the distance function to be used.
std::vector< unsigned int > cell_assignments
The assignments of cells to generators.
void save_centroids_to_file(const std::string &filename) const override
Saves the centroids of the power cells to a file.
std::function< double(const Point< spacedim > &, const Point< spacedim > &)> distance_function
The distance function.
double power_distance(const Point< spacedim > &point, const unsigned int generator_idx) const
Computes the power distance between a point and a generator.
const std::vector< unsigned int > & get_cell_assignments() const
Returns the assignments of all cells to generators.
void compute_power_diagram() override
Computes the power diagram.
const std::vector< Point< spacedim > > & get_cell_centroids() const override
Returns the centroids of the power cells.
A class for computing power diagrams using Geogram.
bool save_morph
A flag to indicate whether to save the morphed mesh.
void output_vtu(const std::string &filename) const override
Outputs the power diagram to a VTU file.
const std::vector< Point< spacedim > > & get_cell_centroids() const override
Returns the centroids of the power cells.
std::vector< double > points_mesh_target_lifted
The lifted target points.
void compute_cell_centroids() override
Computes the centroids of the power cells.
void init_power_diagram()
void compute_power_diagram() override
Computes the power diagram.
void set_generators(const std::vector< Point< spacedim > > &points, const Vector< double > &potentials) override
Sets the generator points and their potentials.
std::vector< double > points_mesh_target
The target points.
void save_centroids_to_file(const std::string &filename) const override
Saves the centroids of the power cells to a file.
bool save_RVD
A flag to indicate whether to save the restricted Voronoi diagram.
std::unique_ptr< GEO::Mesh > source_mesh
The source mesh.
GEO::RestrictedVoronoiDiagram_var RVD
The restricted Voronoi diagram.
bool load_volume_mesh(const std::string &filename, GEO::Mesh &mesh)
int dimension_voronoi
The dimension of the Voronoi diagram.
std::unique_ptr< GEO::Mesh > RVD_mesh
The restricted Voronoi diagram mesh.
GEO::Delaunay_var delaunay
The Delaunay triangulation.
A base class for power diagrams.
virtual ~PowerDiagramBase()=default
std::vector< double > generator_potentials
The potentials of the generator points.
virtual void compute_power_diagram()=0
Computes the power diagram.
virtual const std::vector< Point< spacedim > > & get_cell_centroids() const =0
Returns the centroids of the power cells.
virtual void output_vtu(const std::string &filename) const =0
Outputs the power diagram to a VTU file.
std::vector< Point< spacedim > > generator_points
The generator points.
virtual void set_generators(const std::vector< Point< spacedim > > &points, const Vector< double > &potentials)=0
Sets the generator points and their potentials.
virtual void compute_cell_centroids()=0
Computes the centroids of the power cells.
virtual void save_centroids_to_file(const std::string &filename) const =0
Saves the centroids of the power cells to a file.
std::vector< Point< spacedim > > cell_centroids
The centroids of the power cells.
std::unique_ptr< PowerDiagramBase< dim, spacedim > > create_power_diagram(const std::string &implementation_type, const Triangulation< dim, spacedim > *dealii_mesh=nullptr, const std::string &geogram_mesh_file="")
A factory function to create a power diagram.