SemiDiscreteOT 1.0
Semi-Discrete Optimal Transport Library
Loading...
Searching...
No Matches
PointCloudHierarchy.h
Go to the documentation of this file.
1#ifndef POINT_CLOUD_HIERARCHY_H
2#define POINT_CLOUD_HIERARCHY_H
3
4#include <deal.II/base/point.h>
5#include <vector>
6#include <array>
7#include <string>
8#include <memory>
9#include <unordered_map>
13
14using namespace dealii;
15
17
24public:
30 PointCloudHierarchyManager(int min_points = 100, int max_points = 1000);
31
40 template <int spacedim>
42 const std::vector<Point<spacedim>>& input_points,
43 const std::vector<double>& input_density,
44 const std::string& output_dir);
45
49 void setMaxPoints(int max_points);
50
54 void setMinPoints(int min_points);
55
59 int getNumLevels() const;
60
64 int getPointCount(int level) const;
65
69 int getPointsForLevel(int base_points, int level) const;
70
76 const std::vector<std::vector<size_t>>& getParentIndices(int level) const;
77
83 const std::vector<std::vector<size_t>>& getChildIndices(int level) const;
84
85private:
89 std::vector<int> level_point_counts_;
90
91 // parent_indices_[L] stores the relationships between level L and level L+1
92 // For each point at level L, parent_indices_[L][point_idx] contains indices of its parents at level L+1
93 std::vector<std::vector<std::vector<size_t>>> parent_indices_;
94
95 // child_indices_[L] stores the relationships between level L+1 and level L
96 // For each point at level L+1, child_indices_[L][point_idx] contains indices of its children at level L
97 std::vector<std::vector<std::vector<size_t>>> child_indices_;
98
102 void ensureDirectoryExists(const std::string& path) const;
103
114 template <int spacedim>
115 std::tuple<std::vector<std::array<double, spacedim>>, std::vector<double>, std::vector<int>>
117 const std::vector<std::array<double, spacedim>>& points,
118 const std::vector<double>& densities,
119 size_t k);
120};
121
122} // namespace PointCloudHierarchy
123
124#endif // POINT_CLOUD_HIERARCHY_H
Class to manage a hierarchy of point clouds with different resolutions The hierarchy is organized wit...
std::vector< std::vector< std::vector< size_t > > > parent_indices_
int getPointCount(int level) const
Get the number of points at a specific level.
const std::vector< std::vector< size_t > > & getParentIndices(int level) const
Get the parent indices for points at level L-1.
int getNumLevels() const
Get the number of levels in the last generated hierarchy.
void setMaxPoints(int max_points)
Set the maximum number of points for level 1.
std::tuple< std::vector< std::array< double, spacedim > >, std::vector< double >, std::vector< int > > kmeansClustering(const std::vector< std::array< double, spacedim > > &points, const std::vector< double > &densities, size_t k)
Performs parallel k-means clustering on a set of points with parent-child tracking.
int getPointsForLevel(int base_points, int level) const
Calculate number of points for a given level.
int generateHierarchy(const std::vector< Point< spacedim > > &input_points, const std::vector< double > &input_density, const std::string &output_dir)
Generate hierarchy of point clouds from input points.
const std::vector< std::vector< size_t > > & getChildIndices(int level) const
Get the child indices for points at level L.
void ensureDirectoryExists(const std::string &path) const
Ensure directory exists, create if it doesn't.
void setMinPoints(int min_points)
Set the minimum number of points for coarsest level.
std::vector< std::vector< std::vector< size_t > > > child_indices_