77 Path(
int npoints,
uint seed, glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f})
78 :
Cloud(npoints, seed, bbox){};
94 Path(std::vector<float> x, std::vector<float> y) :
Cloud(x, y){};
104 Path(std::vector<float> x, std::vector<float> y, std::vector<float> v)
118 Path(
const std::vector<glm::ivec2> &indices,
119 const glm::ivec2 &shape,
120 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f})
121 :
Cloud(indices, shape, bbox){};
164 std::vector<float>
get_curvature(
bool normalized =
false)
const;
208 std::vector<float>
get_x()
const;
221 std::vector<float>
get_xy()
const;
232 std::vector<float>
get_y()
const;
388 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
389 bool filled =
false)
const;
393 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
394 bool filled =
false)
const;
398 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
399 bool filled =
false)
const;
415 void to_png(std::string fname, glm::ivec2 shape = {512, 512});
418 enum class PathClosure :
int
422 } path_closure = PathClosure::PT_OPEN;
453Path
bezier(
const Path &path,
454 float curvature_ratio = 0.3f,
455 int edge_divisions = 10,
482 float curvature_ratio = 0.3f,
483 int edge_divisions = 10,
513 int edge_divisions = 10,
538 int edge_divisions = 10,
569 int edge_divisions = 10,
594Path
decimate_vw(
const Path &path,
int n_points_target = 3);
633 float persistence = 1.f,
634 Array *p_control_field =
nullptr,
635 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
655Path
inflate(
const Path &path,
float strength,
bool resample =
true);
688 float noise_ratio = 0.1f,
691 int edge_divisions = 10,
709 glm::vec4 bbox_array = {0.f, 1.f, 0.f, 1.f},
710 const Array *p_noise_x =
nullptr,
711 const Array *p_noise_y =
nullptr);
766Path
smooth(
const Path &path,
768 float averaging_intensity = 1.f,
769 float inertia = 0.f);
789 bool verbose =
false);
unsigned int uint
Definition array.hpp:14
Header file for boundary condition functions and utilities.
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:54
std::vector< Point > points
Points of the cloud.
Definition cloud.hpp:56
Represents an ordered set of points in 2D, forming a polyline (open or closed).
Definition path.hpp:51
Path(const std::vector< glm::ivec2 > &indices, const glm::ivec2 &shape, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Construct a point cloud from grid indices mapped to a bounding box.
Definition path.hpp:118
Path(std::vector< float > x, std::vector< float > y)
Construct a new Path object based on x and y coordinates. Initializes a path with the specified x and...
Definition path.hpp:94
std::vector< float > get_arc_length() const
Get the arc length of the path.
Definition path.cpp:76
std::vector< Point > get_edge_centers() const
Compute midpoints of path edges.
Definition path.cpp:126
std::vector< float > get_xy() const
Get the coordinates of the points as a single vector.
Definition path.cpp:194
void to_array_mask(Array &array, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}, bool filled=false) const
See hmap::to_array.
Definition path.cpp:428
Path()=default
Construct a new Path object with default properties. Initializes an empty path with the closed proper...
Path(int npoints, uint seed, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Construct a new Path object with random positions and values. Initializes a path with a specified num...
Definition path.hpp:77
bool is_closed() const
Check whether the path is closed.
Definition path.cpp:221
Path(std::vector< float > x, std::vector< float > y, std::vector< float > v)
Construct a new Path object based on x, y coordinates, and values. Initializes a path with the specif...
Definition path.hpp:104
void enforce_monotonic_values(bool decreasing=true)
Enforces monotonicity on the values of the points in the path.
Definition path.cpp:56
void to_array(Array &array, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}, bool filled=false) const
Project path points to an array.
Definition path.cpp:373
EdgeDivisionMode
Definition path.hpp:54
std::vector< float > get_values() const
Get the values assigned to the points on the path.
Definition path.cpp:174
void resample_by_spacing(float delta, InterpolationMethod1D itp_method=InterpolationMethod1D::LINEAR)
Resample the path to achieve an approximately constant distance between points.
Definition path.cpp:272
void resample_uniform(InterpolationMethod1D itp_method=InterpolationMethod1D::LINEAR)
Resample the path to achieve fairly uniform distance between consecutive points.
Definition path.cpp:321
void divide()
Divide the path by adding a point between each pair of consecutive points.
Definition path.cpp:31
void subsample(int step)
Subsample the path by keeping only every n-th point.
Definition path.cpp:357
std::vector< float > get_cumulative_distance() const
Get the cumulative distance of the path.
Definition path.cpp:85
void to_png(std::string fname, glm::ivec2 shape={512, 512})
Export path as PNG image file.
Definition path.cpp:435
std::vector< float > get_curvature(bool normalized=false) const
Computes the signed curvature at each point of the path.
Definition path.cpp:100
void reverse()
Reverse the order of points in the path.
Definition path.cpp:347
std::vector< float > get_y() const
Get the y coordinates of the points on the path.
Definition path.cpp:211
std::vector< float > get_x() const
Get the x coordinates of the points on the path.
Definition path.cpp:184
std::vector< glm::vec2 > get_normals() const
Computes unit normals at each point of the path.
Definition path.cpp:146
void reorder_nns(int start_index=0)
Reorder points using a nearest neighbor search.
Definition path.cpp:226
void clear()
Clear the path data.
Definition path.cpp:26
std::vector< glm::vec2 > get_tangents() const
Computes unit tangents at each point of the path.
Definition path.cpp:156
void set_closed(bool new_value)
Set whether the path is closed.
Definition path.cpp:352
Path(const std::vector< glm::vec3 > &xyv)
Constructs a new Path object from lists of xyz data as glm::vec3.
Definition path.hpp:126
Path(std::vector< Point > points)
Construct a new Path object based on a list of points. Initializes a path with the specified points a...
Definition path.hpp:85
void resample_interp(int npoints, InterpolationMethod1D itp_method=InterpolationMethod1D::CUBIC)
Resamples the path using cubic interpolation along arc length.
Definition path.cpp:282
Definition of the Cloud class for manipulating sets of 2D points.
Defines a 1D interpolation class using the GSL (GNU Scientific Library).
Definition algebra.hpp:23
Path bspline(const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
Smooth the path using B-Spline curves.
Definition path_functions.cpp:142
Array path_sdf_to_array(const Path &path, 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 path.
Definition path_functions.cpp:392
Path bezier_round(const Path &path, float curvature_ratio=0.3f, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
Smooth the path using Bezier curves (alternative method).
Definition path_functions.cpp:86
InterpolationMethod1D
Enumeration of the available 1D interpolation methods.
Definition interpolate1d.hpp:36
@ CUBIC
Cubic spline interpolation.
Definition interpolate1d.hpp:39
@ LINEAR
Linear interpolation.
Definition interpolate1d.hpp:41
bool assert_start_end_points(const Path &path1, const Path &path2, float tol=1e-6f, bool verbose=false)
Asserts that the start and end points of two paths are within a specified tolerance.
Definition path_verification.cpp:11
Path fractalize(const Path &path, int iterations, uint seed, float sigma=0.2f, int orientation=0, float persistence=1.f, Array *p_control_field=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Applies fractalization to the path by adding points and randomly displacing their positions.
Definition path_functions.cpp:234
Path remove_geometric_loops(const Path &path)
Removes geometric loops in a 2D path caused by self-intersections.
Definition path_functions.cpp:445
Path inflate(const Path &path, float strength, bool resample=true)
Inflate (offset) a path along its normals using curvature.
Definition path_functions.cpp:295
Array step(glm::ivec2 shape, float angle, float slope, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, glm::vec2 center={0.5f, 0.5f}, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Return a step function (Heaviside with an optional talus slope at the transition).
Definition primitives.cpp:372
Path decimate_vw(const Path &path, int n_points_target=3)
Simplifies the current path using the Visvalingam-Whyatt algorithm.
Definition path_functions.cpp:201
Path catmullrom(const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
Smooth the path using Catmull-Rom curves.
Definition path_functions.cpp:160
float chamfer_distance(const Path &a, const Path &b)
Calculate the chamfer distance between two paths.
Definition path_verification.cpp:37
Path bezier(const Path &path, float curvature_ratio=0.3f, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
Smooth the path using Bezier curves.
Definition path_functions.cpp:32
Path smooth(const Path &path, int navg=1, float averaging_intensity=1.f, float inertia=0.f)
Applies a smoothing operation to the path points using a moving average filter.
Definition path_functions.cpp:482
bool has_duplicates(const Path &path, float tol=1e-6f)
Check if a path contains duplicate points within a given tolerance.
Definition path_verification.cpp:55
Path meanderize(const Path &path, float ratio, float noise_ratio=0.1f, uint seed=1, int iterations=1, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
Add "meanders" to the path.
Definition path_functions.cpp:325
Path decasteljau(const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
Smooth the path using De Casteljau curves.
Definition path_functions.cpp:181