![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/Spline.h>
Uniform Catmull-Rom spline. More...
Uniform Catmull-Rom spline.
Public Member Functions | |
Spline (const std::vector< vec3 > &points) | |
void | addPoint (const vec3 &p, int position=-1) |
Add control point. | |
void | removePoint (int index) |
Remove control point. | |
void | setPoints (const std::vector< vec3 > &points) |
Set control points. | |
void | getPoints (std::vector< vec3 > &points) const |
Get control points. | |
const std::vector< vec3 > & | points () const |
Get control points. | |
void | evaluate (double t, vec3 &res) const |
Evaluates spline. | |
void | evaluateTangent (double t, vec3 &res) const |
Evaluates spline tangent. | |
void | evaluateNormal (double t, int axis, vec3 &res) const |
Evaluates spline normal orthogonal to the tangent and the specified axis. | |
void | evaluateNormal (double t, const vec3 &dir, vec3 &res) const |
Evaluates spline normal orthogonal to the tangent and the specified direction. | |
double | getCurveLength (double t1=0.0, double t2=1.0) const |
Computes the length of the spline between t1 and t2. | |
double | getProjectedCurveLength (int axis, double t1=0.0, double t2=1.0) const |
Computes the length of the spline between t1 and t2 when projected onto an axis plane. | |
double | getProjectedCurveLength (const vec3 &normal, double t1=0.0, double t2=1.0) const |
Computes the length of the spline between t1 and t2 when projected onto a plane. | |
void | getUniformSamples (int n, std::vector< std::pair< double, vec3 > > &samples) const |
Returns sort-of uniformly spaced sample points on the spline (in terms of distance). | |
std::vector< vec3 > | getParametricUniformSamples (int n) const |
Returns t-uniformly-spaced sample points on the spline. | |
void | getUniformSamplesX (int n, std::vector< vec3 > &samples) const |
Sample spline uniformly along x-axis. | |
void | getUniformSamples (int n, std::vector< vec3 > &samples, double eps=1e-10) const |
Returns uniformly spaced sample points on the spline (in terms of arc length). | |
void | getProjectedUniformSamples (int n, int axis, std::vector< std::pair< double, vec3 > > &samples) const |
Returns uniformly spaced points on the spline (in terms of distance on the given axis plane) | |
void | getProjectedUniformSamples (int n, const vec3 &normal, std::vector< std::pair< double, vec3 > > &samples) const |
Returns uniformly spaced points on the spline (in terms of distance on the given plane) | |
double | arcLengthToSplineCoord (double pos) const |
Converts a position on the spline given in arc length parameterization (in world units) to the corresponding position in the spline parameterization. | |
double | splineCoordToArcLength (double t) const |
Converts a position on the spline given in spline parameterization to the corresponding position in arc length parameterization (in world units) | |
void | convertToLabelMap (unsigned char *buffer, int width, int height, const vec3 &spacing, unsigned char inValue=1, unsigned char outValue=0, bool skipInterpolation=false) const |
Fills a label map from the spline with inside/outside values. | |
void | setClosed (bool v) |
bool | closed () const |
double | calculateNearestPointArcLength (const Eigen::Vector3d &pos, const std::vector< Eigen::Vector3d > pointsApproximation=std::vector< Eigen::Vector3d >(), Eigen::Vector3d *nearestPoint=nullptr, bool *outsideCurve=nullptr) const |
Calculates the arc length of the point nearest to pos. | |
std::unique_ptr< Spline > | getApproximateSpline (double eps) const |
Get a spline that approximates the current spline up to an error eps. | |
std::unique_ptr< Spline > | getApproximateClosedSpline (int skipFactor, bool optimizePositions) const |
Get a closed spline that approximates the current closed spline. | |
void | evaluateLoop (double t_, vec3 &res) const |
This version of evaluate scraps the padding points at each end and cycles around instead to produce a closed loop. | |
void evaluate | ( | double | t, |
vec3 & | res ) const |
Evaluates spline.
The spline is parametrized in the range t = [0;1]
t | spline parameter |
res | position at t (output parameter) |
void evaluateTangent | ( | double | t, |
vec3 & | res ) const |
Evaluates spline tangent.
The spline is parametrized in the range t = [0;1]
t | spline parameter |
res | tangent at t (output parameter) |
void evaluateNormal | ( | double | t, |
int | axis, | ||
vec3 & | res ) const |
Evaluates spline normal orthogonal to the tangent and the specified axis.
The spline is parametrized in the range t = [0;1]
t | spline parameter |
res | normal at t (output parameter) |
void evaluateNormal | ( | double | t, |
const vec3 & | dir, | ||
vec3 & | res ) const |
Evaluates spline normal orthogonal to the tangent and the specified direction.
The spline is parametrized in the range t = [0;1]
t | spline parameter |
dir | orthogonal direction |
res | normal at t (output parameter) |
double getCurveLength | ( | double | t1 = 0.0, |
double | t2 = 1.0 ) const |
Computes the length of the spline between t1 and t2.
Does not consider and thus does not work with closed splines!
t1 | start parameter |
t2 | stop parameter |
double getProjectedCurveLength | ( | int | axis, |
double | t1 = 0.0, | ||
double | t2 = 1.0 ) const |
Computes the length of the spline between t1 and t2 when projected onto an axis plane.
axis | axis (0 = z, 1 = y, 2 = x) |
t1 | start parameter |
t2 | stop parameter |
double getProjectedCurveLength | ( | const vec3 & | normal, |
double | t1 = 0.0, | ||
double | t2 = 1.0 ) const |
Computes the length of the spline between t1 and t2 when projected onto a plane.
normal | plane normal |
t1 | start parameter |
t2 | stop parameter |
void getUniformSamples | ( | int | n, |
std::vector< std::pair< double, vec3 > > & | samples ) const |
Returns sort-of uniformly spaced sample points on the spline (in terms of distance).
Works for open splines only.
n | upper bound for number of sample points |
samples | spline samples (output parameter) |
std::vector< vec3 > getParametricUniformSamples | ( | int | n | ) | const |
Returns t-uniformly-spaced sample points on the spline.
The curve parameter t is uniformly sampled. This gives the guarantee of an equal number of samples within segments (in-between control points) which are sort-of uniformly sampled within a segment. Works for closed and open splines.
n | number of sample points |
void getUniformSamplesX | ( | int | n, |
std::vector< vec3 > & | samples ) const |
Sample spline uniformly along x-axis.
Assumes that spline is a graph in the xy-plane.
void getUniformSamples | ( | int | n, |
std::vector< vec3 > & | samples, | ||
double | eps = 1e-10 ) const |
Returns uniformly spaced sample points on the spline (in terms of arc length).
Doesn't work with closed splines
n | number of sample points |
samples | spline samples (output parameter) |
eps | threshold on max deviation of the sample's arc length |
void getProjectedUniformSamples | ( | int | n, |
int | axis, | ||
std::vector< std::pair< double, vec3 > > & | samples ) const |
Returns uniformly spaced points on the spline (in terms of distance on the given axis plane)
n | number of sample points |
samples | spline samples (output parameter) |
void getProjectedUniformSamples | ( | int | n, |
const vec3 & | normal, | ||
std::vector< std::pair< double, vec3 > > & | samples ) const |
Returns uniformly spaced points on the spline (in terms of distance on the given plane)
n | number of sample points |
normal | plane normal |
samples | spline samples (output parameter) |
double arcLengthToSplineCoord | ( | double | pos | ) | const |
Converts a position on the spline given in arc length parameterization (in world units) to the corresponding position in the spline parameterization.
pos | arc length position |
|
inline |
Converts a position on the spline given in spline parameterization to the corresponding position in arc length parameterization (in world units)
t | spline parameterization position |
double calculateNearestPointArcLength | ( | const Eigen::Vector3d & | pos, |
const std::vector< Eigen::Vector3d > | pointsApproximation = std::vector< Eigen::Vector3d >(), | ||
Eigen::Vector3d * | nearestPoint = nullptr, | ||
bool * | outsideCurve = nullptr ) const |
Calculates the arc length of the point nearest to pos.
First the nearest point to pos on the spline is determined and the arc length from the start of the spline to this point returned. The calculation pretends that the first and last segment of the spline extend to infinity. This means that the returned arc length can be negative (before the first point) or larger than the overall arc length (after the last point).
pos | worldspace position of a point on the view |
optional | list of approximated points used intead of the control points |
optional | nearestPoint world position of the nearest point on the spline |
std::unique_ptr< Spline > getApproximateClosedSpline | ( | int | skipFactor, |
bool | optimizePositions ) const |
Get a closed spline that approximates the current closed spline.
skipFactor | The factor by which to skip points in the approximation. A skipFactor of 1 will result in the same number of points as the original spline. |
optimizePositions | Whether or not to run a post optimization after the skipping step |
void evaluateLoop | ( | double | t_, |
vec3 & | res ) const |
This version of evaluate scraps the padding points at each end and cycles around instead to produce a closed loop.
It is called in evaluate
when the spline is set to be closed.