75 Cloud(
int npoints, std::uint32_t seed, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
92 Cloud(
const std::vector<float> &x,
93 const std::vector<float> &y,
94 float default_value = 0.f);
104 Cloud(
const std::vector<float> &x,
105 const std::vector<float> &y,
106 const std::vector<float> &v);
118 Cloud(
const std::vector<glm::ivec2> &indices,
119 const glm::ivec2 &shape,
120 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
125 Cloud(
const std::vector<glm::vec3> &xyv);
204 std::vector<float>
get_x()
const;
216 std::vector<float>
get_xy()
const;
223 std::vector<float>
get_y()
const;
246 void set_points(
const std::vector<float> &x,
const std::vector<float> &y);
252 void set_values(
const std::vector<float> &new_values);
276 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
288 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
332 void randomize(std::uint32_t seed, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
353 void shuffle(
float dx,
float dy, std::uint32_t seed,
float dv = 0.f);
367 float tolerance_ratio = 1.f);
392 bool from_csv(
const std::string &fname);
407 void to_array(Array &array, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f})
const;
410 Array
to_array(glm::ivec2 shape, glm::vec4 bbox)
const;
440 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
443 Array *p_noise_x =
nullptr,
444 Array *p_noise_y =
nullptr,
445 glm::vec4 bbox_array = {0.f, 1.f, 0.f, 1.f})
const;
451 void to_csv(
const std::string &fname)
const;
475 void to_png(
const std::string &fname,
477 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
479 glm::ivec2 shape = {512, 512});
485 std::vector<glm::vec3>
to_vec3()
const;
504 glm::vec4 bbox_array = {0.f, 1.f, 0.f, 1.f},
505 const Array *p_noise_x =
nullptr,
506 const Array *p_noise_y =
nullptr);
535Cloud
merge_cloud(
const Cloud &cloud1,
const Cloud &cloud2);
569 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
595 const Array &density,
597 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
624 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
653 const Array &density,
655 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
687 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
719 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
746 const glm::vec2 &jitter_amount,
747 const glm::vec2 &stagger_ratio,
749 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
766 const Array &density_mask,
768 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 ...
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:49
void clear()
Clear all data from the cloud.
Definition cloud.cpp:102
Point get_center() const
Calculates the centroid of a set of points.
Definition cloud.cpp:186
void remap_values(float vmin, float vmax)
Remap the values of the cloud points to a target range.
Definition cloud.cpp:322
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:499
void shuffle(float dx, float dy, std::uint32_t seed, float dv=0.f)
Randomly perturbs the positions and values of all points in the cloud.
Definition cloud.cpp:486
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:374
bool from_csv(const std::string &fname)
Loads point data from a CSV file into the Cloud object.
Definition cloud.cpp:107
std::vector< float > get_values() const
Get the values assigned to the points in the cloud.
Definition cloud.cpp:212
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:368
void set_values(const std::vector< float > &new_values)
Set new values for the cloud points.
Definition cloud.cpp:353
std::vector< glm::vec3 > to_vec3() const
Convert path points to a vector of 3D positions.
Definition cloud.cpp:596
void set_points(const std::vector< float > &x, const std::vector< float > &y)
Set points of the using x, y coordinates.
Definition cloud.cpp:341
Cloud()
Default constructor for the Cloud class.
Definition cloud.hpp:62
Cloud(const std::vector< Point > &points)
Constructs a new Cloud object based on a list of existing points.
Definition cloud.hpp:82
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:421
float get_values_min() const
Get the minimum value among the points in the cloud.
Definition cloud.cpp:229
void randomize(std::uint32_t seed, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Randomize the positions and values of the cloud points.
Definition cloud.cpp:311
std::vector< float > get_x() const
Get the x coordinates of the points in the cloud.
Definition cloud.cpp:237
std::vector< Point > points
Points of the cloud.
Definition cloud.hpp:51
std::vector< float > get_xy() const
Get the concatenated x and y coordinates of the points in the cloud.
Definition cloud.cpp:246
void add_point(const Point &p)
Add a new point to the cloud.
Definition cloud.cpp:97
float get_values_max() const
Get the maximum value among the points in the cloud.
Definition cloud.cpp:221
std::vector< float > get_y() const
Get the y coordinates of the points in the cloud.
Definition cloud.cpp:258
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:524
size_t nearest_point(const glm::vec2 &xy) const
Find the index of the nearest point in the cloud.
Definition cloud.cpp:267
void set_values_from_min_distance()
Sets point values based on the distance to their nearest neighbor.
Definition cloud.cpp:404
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:585
size_t size() const
Get the number of points in the cloud.
Definition cloud.cpp:416
Graph to_graph_delaunay()
Convert the cloud to a graph using Delaunay triangulation.
Definition cloud.cpp:567
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:385
glm::vec4 get_bbox() const
Get the bounding box of the cloud.
Definition cloud.cpp:169
void to_csv(const std::string &fname) const
Export the cloud data to a CSV file.
Definition cloud.cpp:553
void print()
Print information about the cloud's points.
Definition cloud.cpp:287
void remove_point(int point_idx)
Remove a point from the cloud.
Definition cloud.cpp:336
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:196
Header file for 2D interpolation methods.
Definition algebra.hpp:23
InterpolationMethod2D
Enumeration of 2D interpolation methods.
Definition interpolate2d.hpp:47
@ ITP2D_DELAUNAY
Delaunay triangulation method for 2D interpolation.
Definition interpolate2d.hpp:48
Cloud random_cloud_distance_weibull(float dist_min, float lambda, float k, std::uint32_t 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:708
Cloud random_cloud_distance_power_law(float dist_min, float dist_max, float alpha, std::uint32_t 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:693
void rejection_filter_density(Cloud &cloud, const Array &density_mask, std::uint32_t 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:108
Cloud random_cloud_jittered(size_t count, const glm::vec2 &jitter_amount, const glm::vec2 &stagger_ratio, std::uint32_t seed, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a jittered grid cloud of points.
Definition cloud.cpp:719
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:22
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:67
Cloud random_cloud_distance(float min_dist, std::uint32_t 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:673
PointSamplingMethod
Enumeration of point sampling methods.
Definition point_sampling.hpp:32
@ RND_LHS
Latin Hypercube Sampling.
Definition point_sampling.hpp:36
Cloud merge_cloud(const Cloud &cloud1, const Cloud &cloud2)
Merges two point clouds into one.
Definition cloud.cpp:607
Cloud random_cloud(size_t count, std::uint32_t 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:653
Cloud random_cloud_density(size_t count, const Array &density, std::uint32_t 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:663
Cloud merge_clouds(const std::vector< Cloud > &clouds)
Merges multiple point clouds into a single cloud.
Definition cloud.cpp:624