80 Cloud(
int npoints,
uint seed, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
97 Cloud(
const std::vector<float> &x,
98 const std::vector<float> &y,
99 float default_value = 0.f);
109 Cloud(
const std::vector<float> &x,
110 const std::vector<float> &y,
111 const std::vector<float> &v);
123 Cloud(
const std::vector<glm::ivec2> &indices,
124 const glm::ivec2 &shape,
125 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
130 Cloud(
const std::vector<glm::vec3> &xyv);
209 std::vector<float>
get_x()
const;
221 std::vector<float>
get_xy()
const;
228 std::vector<float>
get_y()
const;
251 void set_points(
const std::vector<float> &x,
const std::vector<float> &y);
257 void set_values(
const std::vector<float> &new_values);
281 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
293 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
337 void randomize(
uint seed, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
358 void shuffle(
float dx,
float dy,
uint seed,
float dv = 0.f);
372 float tolerance_ratio = 1.f);
397 bool from_csv(
const std::string &fname);
412 void to_array(Array &array, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f})
const;
415 Array
to_array(glm::ivec2 shape, glm::vec4 bbox)
const;
445 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
448 Array *p_noise_x =
nullptr,
449 Array *p_noise_y =
nullptr,
450 glm::vec4 bbox_array = {0.f, 1.f, 0.f, 1.f})
const;
456 void to_csv(
const std::string &fname)
const;
480 void to_png(
const std::string &fname,
482 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
484 glm::ivec2 shape = {512, 512});
490 std::vector<glm::vec3>
to_vec3()
const;
509 glm::vec4 bbox_array = {0.f, 1.f, 0.f, 1.f},
510 const Array *p_noise_x =
nullptr,
511 const Array *p_noise_y =
nullptr);
540Cloud
merge_cloud(
const Cloud &cloud1,
const Cloud &cloud2);
574 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
600 const Array &density,
602 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
629 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
658 const Array &density,
660 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
692 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
724 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
751 const glm::vec2 &jitter_amount,
752 const glm::vec2 &stagger_ratio,
754 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
771 const Array &density_mask,
773 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
unsigned int uint
Definition array.hpp:14
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:54
void clear()
Clear all data from the cloud.
Definition cloud.cpp:90
Point get_center() const
Calculates the centroid of a set of points.
Definition cloud.cpp:174
void remap_values(float vmin, float vmax)
Remap the values of the cloud points to a target range.
Definition cloud.cpp:310
void to_array(Array &array, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}) const
Project the cloud points onto an array.
Definition cloud.cpp:487
void set_values_from_border_distance(const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Sets point values based on their distance to the bounding box border.
Definition cloud.cpp:362
bool from_csv(const std::string &fname)
Loads point data from a CSV file into the Cloud object.
Definition cloud.cpp:95
void randomize(uint seed, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Randomize the positions and values of the cloud points.
Definition cloud.cpp:299
std::vector< float > get_values() const
Get the values assigned to the points in the cloud.
Definition cloud.cpp:200
void set_values_from_array(const Array &array, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Set the values of the cloud points using values from an underlying array.
Definition cloud.cpp:356
void set_values(const std::vector< float > &new_values)
Set new values for the cloud points.
Definition cloud.cpp:341
std::vector< glm::vec3 > to_vec3() const
Convert path points to a vector of 3D positions.
Definition cloud.cpp:584
void set_points(const std::vector< float > &x, const std::vector< float > &y)
Set points of the using x, y coordinates.
Definition cloud.cpp:329
Cloud()
Default constructor for the Cloud class.
Definition cloud.hpp:67
Cloud(const std::vector< Point > &points)
Constructs a new Cloud object based on a list of existing points.
Definition cloud.hpp:87
void snap_points_to_bounding_box(const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f}, float tolerance_ratio=1.f)
Snap points to the bounding box edges and corners.
Definition cloud.cpp:409
float get_values_min() const
Get the minimum value among the points in the cloud.
Definition cloud.cpp:217
std::vector< float > get_x() const
Get the x coordinates of the points in the cloud.
Definition cloud.cpp:225
std::vector< Point > points
Points of the cloud.
Definition cloud.hpp:56
std::vector< float > get_xy() const
Get the concatenated x and y coordinates of the points in the cloud.
Definition cloud.cpp:234
void add_point(const Point &p)
Add a new point to the cloud.
Definition cloud.cpp:85
float get_values_max() const
Get the maximum value among the points in the cloud.
Definition cloud.cpp:209
std::vector< float > get_y() const
Get the y coordinates of the points in the cloud.
Definition cloud.cpp:246
void to_array_interp(Array &array, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}, InterpolationMethod2D interpolation_method=InterpolationMethod2D::ITP2D_DELAUNAY, Array *p_noise_x=nullptr, Array *p_noise_y=nullptr, glm::vec4 bbox_array={0.f, 1.f, 0.f, 1.f}) const
Interpolate the values of an array using the cloud points.
Definition cloud.cpp:512
size_t nearest_point(const glm::vec2 &xy) const
Find the index of the nearest point in the cloud.
Definition cloud.cpp:255
void set_values_from_min_distance()
Sets point values based on the distance to their nearest neighbor.
Definition cloud.cpp:392
void to_png(const std::string &fname, int cmap, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}, int depth=CV_8U, glm::ivec2 shape={512, 512})
Saves the current data as a PNG image file.
Definition cloud.cpp:573
size_t size() const
Get the number of points in the cloud.
Definition cloud.cpp:404
Graph to_graph_delaunay()
Convert the cloud to a graph using Delaunay triangulation.
Definition cloud.cpp:555
void set_values_from_chull_distance()
Set the values of the cloud points based on the distance to the convex hull of the cloud.
Definition cloud.cpp:373
glm::vec4 get_bbox() const
Get the bounding box of the cloud.
Definition cloud.cpp:157
void to_csv(const std::string &fname) const
Export the cloud data to a CSV file.
Definition cloud.cpp:541
void print()
Print information about the cloud's points.
Definition cloud.cpp:275
void shuffle(float dx, float dy, uint seed, float dv=0.f)
Randomly perturbs the positions and values of all points in the cloud.
Definition cloud.cpp:474
void remove_point(int point_idx)
Remove a point from the cloud.
Definition cloud.cpp:324
std::vector< int > get_convex_hull() const
Computes the indices of the points that form the convex hull of a set of points.
Definition cloud.cpp:184
Header file for 2D interpolation methods.
Definition algebra.hpp:23
Cloud random_cloud_distance(float min_dist, uint seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a random cloud of points separated by at least a given minimum distance.
Definition cloud.cpp:661
Cloud random_cloud_density(size_t count, const Array &density, uint seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a random cloud of points based on a spatial density map.
Definition cloud.cpp:651
Cloud random_cloud_jittered(size_t count, const glm::vec2 &jitter_amount, const glm::vec2 &stagger_ratio, uint seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a jittered grid cloud of points.
Definition cloud.cpp:705
Cloud random_cloud_distance_power_law(float dist_min, float dist_max, float alpha, uint seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a random cloud of points with distances drawn from a power-law distribution.
Definition cloud.cpp:679
InterpolationMethod2D
Enumeration of 2D interpolation methods.
Definition interpolate2d.hpp:45
@ ITP2D_DELAUNAY
Delaunay triangulation method for 2D interpolation.
Definition interpolate2d.hpp:46
Cloud random_cloud(size_t count, uint seed, const PointSamplingMethod &method=PointSamplingMethod::RND_LHS, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a random cloud of points within a bounding box.
Definition cloud.cpp:641
Array cloud_sdf_to_array(const Cloud &cloud, glm::ivec2 shape, glm::vec4 bbox_array={0.f, 1.f, 0.f, 1.f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr)
Compute a distance field from a point cloud.
Definition cloud_functions.cpp:14
std::vector< float > interpolate_values_from_array(const Cloud &cloud, const Array &array, glm::vec4 bbox)
Interpolate values from an array at the points' (x, y) locations.
Definition cloud_functions.cpp:59
Cloud random_cloud_distance_weibull(float dist_min, float lambda, float k, uint seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a random cloud of points with distances drawn from a Weibull distribution.
Definition cloud.cpp:694
PointSamplingMethod
Enumeration of point sampling methods.
Definition point_sampling.hpp:31
@ RND_LHS
Latin Hypercube Sampling.
Definition point_sampling.hpp:35
Cloud merge_cloud(const Cloud &cloud1, const Cloud &cloud2)
Merges two point clouds into one.
Definition cloud.cpp:595
void rejection_filter_density(Cloud &cloud, const Array &density_mask, uint seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Filter a point cloud using rejection sampling based on a density mask.
Definition cloud_functions.cpp:100
Cloud merge_clouds(const std::vector< Cloud > &clouds)
Merges multiple point clouds into a single cloud.
Definition cloud.cpp:612