109 Cloud(
const std::vector<float> &x,
110 const std::vector<float> &y,
111 float default_value = 0.f);
121 Cloud(
const std::vector<float> &x,
122 const std::vector<float> &y,
123 const std::vector<float> &v);
135 Cloud(
const std::vector<glm::ivec2> &indices,
136 const glm::ivec2 &shape,
142 Cloud(
const std::vector<glm::vec3> &xyv);
208 std::vector<float>
get_x()
const;
220 std::vector<float>
get_xy()
const;
227 std::vector<float>
get_y()
const;
250 void set_points(
const std::vector<float> &x,
const std::vector<float> &y);
256 void set_values(
const std::vector<float> &new_values);
297 const BBox2D &bbox = BBox2D{});
343 Point &
at(
size_t index);
348 const Point &
at(
size_t index)
const;
358 const Point &
back()
const;
363 std::vector<Point>::iterator
begin() noexcept;
368 std::vector<Point>::const_iterator
begin() const noexcept;
379 std::vector<Point>::const_iterator
cbegin() const noexcept;
384 std::vector<Point>::const_iterator
cend() const noexcept;
394 Point *
data() noexcept;
399 const Point *
data() const noexcept;
415 std::vector<Point>::iterator
end() noexcept;
420 std::vector<Point>::const_iterator
end() const noexcept;
425 std::vector<Point>::iterator
erase(std::vector<Point>::const_iterator pos);
430 std::vector<Point>::iterator
erase(std::vector<Point>::const_iterator first,
431 std::vector<Point>::const_iterator last);
441 const Point &
front() const;
446 std::vector<Point>::iterator
insert(std::vector<Point>::const_iterator pos,
452 std::vector<Point>::iterator
insert(std::vector<Point>::const_iterator pos,
458 template <typename InputIt>
463 return this->
points.insert(pos, first, last);
528 void shuffle(
float dx,
float dy, std::uint32_t seed,
float dv = 0.f);
542 float tolerance_ratio = 1.f);
567 bool from_csv(
const std::string &fname);
582 void to_array(Array &array,
const BBox2D &bbox = BBox2D{})
const;
585 Array
to_array(glm::ivec2 shape,
const BBox2D &bbox)
const;
615 const BBox2D &bbox = BBox2D{},
618 const Array *p_noise_x =
nullptr,
619 const Array *p_noise_y =
nullptr,
620 const BBox2D &bbox_array = BBox2D{})
const;
626 void to_csv(
const std::string &fname)
const;
650 void to_png(
const std::string &fname,
652 const BBox2D &bbox = BBox2D{},
654 glm::ivec2 shape = {512, 512})
const;
660 std::vector<glm::vec3>
to_vec3()
const;
683 const Array *p_noise_x =
nullptr,
684 const Array *p_noise_y =
nullptr);
694bool has_duplicates(
const Cloud &cloud,
float eps = 1e-9f,
bool xy_only =
true);
723Cloud
merge_cloud(
const Cloud &cloud1,
const Cloud &cloud2);
757 const BBox2D &bbox = BBox2D{});
783 const Array &density,
800 const Array &density,
858 const Array &density,
950 const glm::vec2 &jitter_amount,
951 const glm::vec2 &stagger_ratio,
970 const Array &density_mask,
990 glm::vec2 center = {0.5f, 0.5f});
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:61
void pop_back()
Removes the last point.
Definition cloud.cpp:658
Point & back()
Access the last point.
Definition cloud.cpp:551
std::vector< Point >::iterator end() noexcept
Returns an iterator to the end.
Definition cloud.cpp:611
size_t capacity() const noexcept
Returns the number of points that can be held in currently allocated storage.
Definition cloud.cpp:571
void clear()
Clear all data from the cloud.
Definition cloud.cpp:586
std::vector< Point >::const_iterator cend() const noexcept
Returns a const iterator to the end.
Definition cloud.cpp:581
Point get_center() const
Calculates the centroid of a set of points.
Definition cloud.cpp:188
void remap_values(float vmin, float vmax)
Remap the values of the cloud points to a target range.
Definition cloud.cpp:335
void print() const
Print information about the cloud's points.
Definition cloud.cpp:300
std::vector< Point >::iterator begin() noexcept
Returns an iterator to the first point.
Definition cloud.cpp:561
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:731
bool from_csv(const std::string &fname)
Loads point data from a CSV file into the Cloud object.
Definition cloud.cpp:109
Point * data() noexcept
Direct pointer to the underlying point array.
Definition cloud.cpp:591
std::vector< float > get_values() const
Get the values assigned to the points in the cloud.
Definition cloud.cpp:219
void to_png(const std::string &fname, int cmap, const BBox2D &bbox=BBox2D{}, int depth=0, glm::ivec2 shape={512, 512}) const
Saves the current data as a PNG image file.
Definition cloud.cpp:840
void set_values(const std::vector< float > &new_values)
Set new values for the cloud points.
Definition cloud.cpp:363
std::vector< glm::vec3 > to_vec3() const
Convert path points to a vector of 3D positions.
Definition cloud.cpp:853
void reserve(size_t new_cap)
Reserves storage for at least the specified number of points.
Definition cloud.cpp:673
std::vector< Point >::iterator insert(std::vector< Point >::const_iterator pos, const Point &value)
Inserts a point before pos.
Definition cloud.cpp:644
void set_points(const std::vector< float > &x, const std::vector< float > &y)
Set points of the using x, y coordinates.
Definition cloud.cpp:351
Cloud()
Default constructor for the Cloud class.
BBox2D get_bbox() const
Get the bounding box of the cloud.
Definition cloud.cpp:168
void to_array_interp(Array &array, const BBox2D &bbox=BBox2D{}, InterpolationMethod2D interpolation_method=InterpolationMethod2D::ITP2D_DELAUNAY, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const BBox2D &bbox_array=BBox2D{}) const
Interpolate the values of an array using the cloud points.
Definition cloud.cpp:777
Point & at(size_t index)
Access point with bounds checking.
Definition cloud.cpp:541
bool empty() const
Check whether the cloud has no points.
Definition cloud.cpp:606
Point & front()
Access the first point.
Definition cloud.cpp:634
float get_values_min() const
Get the minimum value among the points in the cloud.
Definition cloud.cpp:239
void to_array(Array &array, const BBox2D &bbox=BBox2D{}) const
Project the cloud points onto an array.
Definition cloud.cpp:744
void randomize(std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Randomize the positions and values of the cloud points.
Definition cloud.cpp:324
std::vector< float > get_x() const
Get the x coordinates of the points in the cloud.
Definition cloud.cpp:250
Graph to_graph_delaunay() const
Convert the cloud to a graph using Delaunay triangulation.
Definition cloud.cpp:822
std::vector< Point > points
Points of the cloud.
Definition cloud.hpp:663
std::vector< float > get_xy() const
Get the concatenated x and y coordinates of the points in the cloud.
Definition cloud.cpp:259
Point & operator[](size_t index)
Access point by index.
Definition cloud.cpp:531
float get_values_max() const
Get the maximum value among the points in the cloud.
Definition cloud.cpp:228
std::vector< float > get_y() const
Get the y coordinates of the points in the cloud.
Definition cloud.cpp:271
void set_values_from_array(const Array &array, const BBox2D &bbox=BBox2D{})
Set the values of the cloud points using values from an underlying array.
Definition cloud.cpp:378
void push_back(const Point &p)
Appends a point.
Definition cloud.cpp:663
size_t nearest_point(const glm::vec2 &xy) const
Find the index of the nearest point in the cloud.
Definition cloud.cpp:280
void set_values_from_min_distance()
Sets point values based on the distance to their nearest neighbor.
Definition cloud.cpp:504
std::vector< Point >::const_iterator cbegin() const noexcept
Returns a const iterator to the first point.
Definition cloud.cpp:576
size_t size() const
Get the number of points in the cloud.
Definition cloud.cpp:678
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:482
void snap_points_to_bounding_box(const BBox2D &bbox=BBox2D{}, float tolerance_ratio=1.f)
Snap points to the bounding box edges and corners.
Definition cloud.cpp:683
void to_csv(const std::string &fname) const
Export the cloud data to a CSV file.
Definition cloud.cpp:808
void set_values_from_border_distance(const BBox2D &bbox=BBox2D{})
Sets point values based on their distance to the bounding box border.
Definition cloud.cpp:471
void emplace_back(float x, float y, float v=0.f)
Appends a new point in-place.
Definition cloud.cpp:601
std::vector< Point >::iterator erase(std::vector< Point >::const_iterator pos)
Erases the point at the specified position.
Definition cloud.cpp:621
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:198
A class to represent and manipulate 2D points that can carry a value.
Definition point.hpp:26
Header file for 2D interpolation methods.
Cloud random_cloud_jittered(size_t count, const glm::vec2 &jitter_amount, const glm::vec2 &stagger_ratio, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Generates a jittered grid cloud of points.
Definition cloud.cpp:971
bool has_duplicates(const Cloud &cloud, float eps=1e-9f, bool xy_only=true)
Checks whether the point cloud contains duplicate points.
Definition cloud_functions.cpp:65
Cloud random_cloud_distance_weibull(float dist_min, float lambda, float k, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Generates a random cloud of points with distances drawn from a Weibull distribution.
Definition cloud.cpp:960
ArraySampling
Strategy used to extract a point value from an array.
Definition cloud.hpp:39
@ AS_MEAN
Average of the array values within a radius.
Definition cloud.hpp:43
@ AS_MIN
Minimum of the array values within a radius.
Definition cloud.hpp:41
@ AS_MAX
Maximum of the array values within a radius.
Definition cloud.hpp:42
@ AS_POINT
Array value at the point (interpolated).
Definition cloud.hpp:40
Cloud random_cloud_distance(float min_dist, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Generates a random cloud of points separated by at least a given minimum distance.
Definition cloud.cpp:923
InterpolationMethod2D
Enumeration of 2D interpolation methods.
Definition interpolate2d.hpp:43
@ ITP2D_DELAUNAY
Delaunay triangulation method for 2D interpolation.
Definition interpolate2d.hpp:44
Cloud random_cloud_inverse_sampling(size_t count, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Generates a random cloud of points using inverse transform sampling on a 2D density array.
Definition cloud.cpp:911
Cloud scale(const Cloud &cloud, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f})
Scales the point coordinates in a cloud relative to a center point.
Definition cloud_functions.cpp:163
Cloud random_cloud(size_t count, std::uint32_t seed, const PointSamplingMethod &method=PointSamplingMethod::RND_LHS, const BBox2D &bbox=BBox2D{})
Generates a random cloud of points within a bounding box.
Definition cloud.cpp:889
PointSamplingMethod
Enumeration of point sampling methods.
Definition point_sampling.hpp:34
@ RND_LHS
Latin Hypercube Sampling.
Definition point_sampling.hpp:38
Cloud merge_cloud(const Cloud &cloud1, const Cloud &cloud2)
Merges two point clouds into one.
Definition cloud.cpp:864
std::vector< float > interpolate_values_from_array(const Cloud &cloud, const Array &array, const BBox2D &bbox)
Interpolate values from an array at the points' (x, y) locations.
Definition cloud_functions.cpp:98
void rejection_filter_density(Cloud &cloud, const Array &density_mask, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Filter a point cloud using rejection sampling based on a density mask.
Definition cloud_functions.cpp:141
Array cloud_sdf_to_array(const Cloud &cloud, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), 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
Cloud random_cloud_distance_power_law(float dist_min, float dist_max, float alpha, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Generates a random cloud of points with distances drawn from a power-law distribution.
Definition cloud.cpp:945
Cloud random_cloud_density(size_t count, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{})
Generates a random cloud of points based on a spatial density map.
Definition cloud.cpp:899
Cloud merge_clouds(const std::vector< Cloud > &clouds)
Merges multiple point clouds into a single cloud.
Definition cloud.cpp:873
Axis-aligned 2D bounding box in world coordinates.
Definition bbox2d.hpp:25
static constexpr BBox2D unit()
Definition bbox2d.hpp:39