#include <include/Curve.h>
Public Member Functions | |
Curve () | |
Curve (const char *filename) | |
Curve (istream &in) | |
Curve (const Curve< Vector > &curve) | |
Curve & | operator= (const Curve< Vector > &c) |
~Curve () | |
biarc_ref | operator[] (int c) |
biarc_constref | operator[] (int c) const |
void | push (const Biarc< Vector > &b) |
void | push (const Vector &p, const Vector &t) |
void | append (const Biarc< Vector > &b) |
void | append (const Vector &p, const Vector &t) |
void | insert (int loc, const Biarc< Vector > &b) |
void | insert (int loc, const Vector &p, const Vector &t) |
void | remove (int loc) |
void | remove (biarc_it b) |
void | flush_all () |
biarc_constref | getNext (int i) const |
biarc_constref | getPrevious (int i) |
void | setNext (int i, const Biarc< Vector > &b) |
void | setPrevious (int i, const Biarc< Vector > &b) |
biarc_it | begin () |
biarc_it | end () |
int | isClosed () const |
void | link () |
void | unlink () |
void | changeDirection () |
void | make (float f) |
void | makeMidpointRule () |
void | make (int from_N, int to_N, float f) |
void | make (Biarc< Vector > *from, Biarc< Vector > *to, float f) |
void | makeMidpointRule (int from_N, int to_N) |
void | makeMidpointRule (Biarc< Vector > *from, Biarc< Vector > *to) |
void | resample (int NewNoNodes) |
void | refine (int from_N, int to_N, int NewNoNodes) |
void | refine (biarc_it from, biarc_it to, int NewNoNodes) |
float | radius_pt (int from, int to) |
float | radius_pt (biarc_it from, biarc_it to) |
float | radius_pt (const Biarc< Vector > &from, const Biarc< Vector > &to) |
float | radius_pt (const Vector &p0, const Vector &t0, const Vector &p1) const |
float | radius_pt (const float s, const float t) const |
float | pp (int from, int to) const |
float | pp (float s, float t) const |
float | radius_global (Biarc< Vector > &at) |
float | thickness_fast () |
float | thickness (Vector *from=NULL, Vector *to=NULL) |
void | get_hint (int *i, int *j) const |
void | set_hint (const int i, const int j) |
float | minSegDistance () |
float | maxSegDistance () |
float | span () const |
float | distEnergy () |
float | curvature (int n) |
float | curvature (biarc_it b) |
Vector | normalVector (int n) |
Vector | normalVector (biarc_it b) |
float | torsion (int n, int a) |
float | torsion2 (int n) |
void | inertiaTensor (Matrix3 &mat) |
void | principalAxis (Matrix3 &mat) |
void | computeTangents () |
void | polygonalToArcs () |
void | arcsToPolygonal () |
int | nodes () const |
float | length () const |
Vector | pointAt (float s) const |
Vector | tangentAt (float s) const |
biarc_it | biarcAt (float s) |
int | biarcPos (float s) |
Curve & | rotAroundAxis (float angle, Vector axis) |
Curve & | operator+= (const Vector &v) |
Curve & | operator-= (const Vector &v) |
Curve | operator+ (const Curve &c) const |
Curve | operator- (const Curve &c) const |
Curve | operator* (const float s) const |
Curve & | apply (Matrix3 &m) |
Vector | getCenter () |
void | center () |
void | normalize () |
void | scale (float s) |
void | check_tangents () |
int | readPKF (const char *filename) |
int | readPKF (istream &in) |
int | writePKF (const char *filename, int Header=1) |
int | writePKF (ostream &out, int Header=1) |
int | readXYZ (const char *filename) |
int | readXYZ (istream &in) |
int | readData (const char *filename, const char *delimiter) |
int | readData (istream &in, const char *delimiter) |
int | writeData (const char *filename, const char *delimiter, int tangents_flag) |
int | writeData (ostream &out, const char *delimiter, int tangents_flag) |
Protected Member Functions | |
biarc_constit | accessBiarc (int i) const |
biarc_it | accessBiarc (int i) |
int | readSinglePKF (istream &in) |
ostream & | writeSinglePKF (ostream &out) |
int | readSingleData (istream &in, const char *delimiter) |
ostream & | writeSingleData (ostream &out, const char *delimiter, int tangents_flag) |
int | readSingleXYZ (istream &in) |
Protected Attributes | |
vector< Biarc< Vector > > | _Biarcs |
int | _Closed |
This class is used to store and manipulate a set of point/tangent data. This data can be interpolated to a biarc curve. The class is for open and closed curves, but this must be specified (how to do that is explained later in this text).
The space-curve is a linked-list of Biarc elements. Every biarc element in the "curve list" has two neighbours. If the point is the start or endpoint of an open curve, then it will only have a single neighbour.
In order to change data in a curve, the functions push(), pop(), append(), insert() or remove() can be used.
Here comes an example that reads in a PKF file describing a closed curve, interpolates the curve and resamples it :
#include "../include/Curve.h" int main(int argc,char** argv) { // Read the data Curve c("data.pkf"); // Close the curve c.link(); // Interpolate the curve by biarcs c.make_default(); // Resample the curve with 100 points. c.resample(100); // Write new curve to a file c.writePKF("resampled.pkf"); return 0; }
The next example illustrates how to build a circle with radius one and 10 data points :
#include "../include/Curve.h" int main(int argc,char** argv) { // Init empty curve Curve<Vector3> circle; // Point and Tangent Vector3 p,t; // Construct PKF header circle.header("Circle","Author","",""); // Build the circle with 10 nodes for (float i=0;i<10;i+=1.0) { // Compute point and tangent of the circle p = Vector3(sin(i*M_PI/5.0), cos(i*M_PI/5.0),0); t = Vector3(cos(i*M_PI/5.0),-sin(i*M_PI/5.0),0); // Normalize the tangent t.normalize(); // Add point to the curve circle.append(p,t); } ... return 0; }
Constructs an empty curve and sets the header to "No name","","",""
Constructs a curve by reading it from the istream in.
References Curve< Vector >::readPKF().
Read the curve data from a stream in. Does not read a PKF header. Call the readHeader() method for that purpose.
References Curve< Vector >::readSinglePKF().
Copy constructor.
Destructor. Flushes all the elements of the curve object.
References Curve< Vector >::flush_all().
biarc_constit Curve< Vector >::accessBiarc | ( | int | i | ) | const [inline, protected] |
Private access function to the biarcs in the curve. Returns an STL iterator to a biarc
Referenced by Curve< Vector >::curvature(), Curve< Vector >::normalVector(), and Curve< Vector >::refine().
biarc_it Curve< Vector >::accessBiarc | ( | int | i | ) | [inline, protected] |
Private access function to the biarcs in the curve. Returns an STL iterator to a biarc
int Curve< Vector >::readSinglePKF | ( | istream & | in | ) | [inline, protected] |
Read in only the curve data, this is from the COMP tag to the curve's END tag!
References Curve< Vector >::append().
Referenced by Curve< Vector >::Curve(), and Curve< Vector >::readPKF().
ostream & Curve< Vector >::writeSinglePKF | ( | ostream & | out | ) | [inline, protected] |
Write the current curve object to a stream out. Start with sending "COMP \#C" to the stream, where #C are the number of nodes currently stored in the Curve object. Then follow the NODE tags with the data point coordinates.
References Curve< Vector >::nodes().
Referenced by Curve< Vector >::writePKF().
int Curve< Vector >::readSingleData | ( | istream & | in, | |
const char * | delimiter | |||
) | [inline, protected] |
Read in the curve data for a single curve given in VECT format! Only one component is supported. Skips the first two lines. Reads the number of vertices from the 2nd column of line three. Skips 3 more lines and reads in the coordinates.
References Curve< Vector >::append().
Referenced by Curve< Vector >::readData().
ostream & Curve< Vector >::writeSingleData | ( | ostream & | out, | |
const char * | delimiter, | |||
int | tangents_flag | |||
) | [inline, protected] |
Writes the current curve to a a stream. A custom delimiter may be specified and the tangents are also written or not depending on the value of the tangents_flag. 1 = please write the tangents to the file, 0 = please don't.
References Curve< Vector >::nodes().
Referenced by Curve< Vector >::writeData().
int Curve< Vector >::readSingleXYZ | ( | istream & | in | ) | [inline, protected] |
Read in xyz data. First line is the number of data points. Then the x y z coordinates. Tangents are interpolated using these points.
References Curve< Vector >::append(), and Curve< Vector >::computeTangents().
Referenced by Curve< Vector >::readXYZ().
Curve< Vector > & Curve< Vector >::operator= | ( | const Curve< Vector > & | c | ) | [inline] |
Assign operator. Copies all the point/tangent data. Closes the curve if c is closed.
References Curve< Vector >::_Biarcs, Curve< Vector >::_hint_i, Curve< Vector >::_hint_j, Curve< Vector >::begin(), Curve< Vector >::end(), Curve< Vector >::flush_all(), Curve< Vector >::isClosed(), Curve< Vector >::link(), and Curve< Vector >::nodes().
biarc_ref Curve< Vector >::operator[] | ( | int | c | ) | [inline] |
Returns biarc number c of the curve. Index starts off with zero (C style).
biarc_constref Curve< Vector >::operator[] | ( | int | c | ) | const [inline] |
Returns biarc number c of the curve. Index starts off with zero (C style).
Adds a point/tangent data stored in biarc b at the front of the curve.
Referenced by Curve< Vector >::push().
void Curve< Vector >::push | ( | const Vector & | p, | |
const Vector & | t | |||
) | [inline] |
Adds a point/tangent data stored in biarc b at the end of the curve.
Referenced by Curve< Vector >::append(), Curve< Vector >::arcsToPolygonal(), TrefoilTorusAnneal::energy(), Curve< Vector >::operator+(), Curve< Vector >::operator-(), Curve< Vector >::polygonalToArcs(), Curve< Vector >::readSingleData(), Curve< Vector >::readSinglePKF(), Curve< Vector >::readSingleXYZ(), CurveBundle< Vector >::readVECT(), and Curve< Vector >::resample().
void Curve< Vector >::append | ( | const Vector & | p, | |
const Vector & | t | |||
) | [inline] |
Insert a biarc b at position loc on the curve and push all the elements after loc one position to the right. The index starts with zero. If loc = nodes on the current curve, then the new element is added at the end of the curve.
Referenced by Curve< Vector >::insert().
void Curve< Vector >::insert | ( | int | loc, | |
const Vector & | p, | |||
const Vector & | t | |||
) | [inline] |
Insert a point p, tangent t data at position loc on the curve and push all the elements after loc one position to the right. The index starts with zero. If loc = nodes on the current curve, then the new element is added at the end of the curve.
References Curve< Vector >::insert().
void Curve< Vector >::remove | ( | int | loc | ) | [inline] |
Remove biarc at position loc
Referenced by Curve< Vector >::resample().
void Curve< Vector >::remove | ( | biarc_it | b | ) | [inline] |
Remove biarc at position loc
void Curve< Vector >::flush_all | ( | ) | [inline] |
Remove all the nodes on the curve.
Referenced by Tube< Vector >::operator=(), Curve< Vector >::operator=(), CurveBundle< Vector >::readVECT(), and Curve< Vector >::~Curve().
biarc_constref Curve< Vector >::getNext | ( | int | i | ) | const [inline] |
Get a reference to the Biarc at position i+1 No check is made wheter i+1 exists! However it wraps around for closed curves!
References Curve< Vector >::_Closed, and Curve< Vector >::nodes().
biarc_constref Curve< Vector >::getPrevious | ( | int | i | ) | [inline] |
Get a reference to the Biarc at position i-1 No check is made wheter i-1 exists for open curves! However it wraps around for closed curves!
References Curve< Vector >::_Closed.
Set the Biarc at position i+1 to be Biarc b
References Curve< Vector >::_Closed, and Curve< Vector >::nodes().
void Curve< Vector >::setPrevious | ( | int | i, | |
const Biarc< Vector > & | b | |||
) | [inline] |
Set the Biarc at position i-1 to be Biarc b
References Curve< Vector >::_Closed, and Curve< Vector >::nodes().
biarc_it Curve< Vector >::begin | ( | ) | [inline] |
Return a STL iterator pointing to the first biarc
Referenced by Curve< Vector >::changeDirection(), Curve< Vector >::check_tangents(), Curve< Vector >::curvature(), Curve< Vector >::distEnergy(), Curve< Vector >::inertiaTensor(), Tube< Vector >::makeMesh(), Curve< Vector >::maxSegDistance(), Curve< Vector >::minSegDistance(), Curve< Vector >::normalVector(), Tube< Vector >::operator=(), Curve< Vector >::operator=(), Curve< Vector >::radius_global(), Curve< Vector >::refine(), Tube< Vector >::scaleTubeRadius(), Curve< Vector >::thickness(), and Curve< Vector >::thickness_fast().
biarc_it Curve< Vector >::end | ( | ) | [inline] |
Return a STL iterator pointing to the last biarc
Referenced by Curve< Vector >::changeDirection(), Curve< Vector >::check_tangents(), Curve< Vector >::curvature(), Curve< Vector >::distEnergy(), Curve< Vector >::inertiaTensor(), Curve< Vector >::maxSegDistance(), Curve< Vector >::minSegDistance(), Curve< Vector >::normalVector(), Tube< Vector >::operator=(), Curve< Vector >::operator=(), Curve< Vector >::refine(), Tube< Vector >::scaleTubeRadius(), Curve< Vector >::thickness(), and Curve< Vector >::thickness_fast().
int Curve< Vector >::isClosed | ( | ) | const [inline] |
Returns 1 if the curve is closed (i.e. the link() function had been used), and 0 otherwise.
References Curve< Vector >::_Closed.
Referenced by Curve< Vector >::biarcAt(), SoKnot::generatePrimitives(), SoKnot::GLRender(), Tube< Vector >::operator=(), Curve< Vector >::operator=(), Curve< Vector >::pointAt(), Curve< Vector >::polygonalToArcs(), Curve< Vector >::resample(), and Curve< Vector >::tangentAt().
void Curve< Vector >::link | ( | ) | [inline] |
This is the way to close a curve. It links the last element in the list to the first. If the curve is already linked, nothing happens.
References Curve< Vector >::_Closed.
Referenced by TrefoilTorusAnneal::energy(), Tube< Vector >::makeMesh(), Tube< Vector >::operator=(), Curve< Vector >::operator=(), CurveBundle< Vector >::readVECT(), and Curve< Vector >::resample().
void Curve< Vector >::unlink | ( | ) | [inline] |
Opens a closed curve. This cancels the link between the last and the first element in the curve. If the curve is already open, nothing happens.
References Curve< Vector >::_Closed.
Referenced by Tube< Vector >::makeMesh().
void Curve< Vector >::changeDirection | ( | ) | [inline] |
Change the direction of the curve. This flips the tangents and reorders the points, so that we run through the curve in the opposite direction.
References Curve< Vector >::begin(), Curve< Vector >::end(), and Curve< Vector >::nodes().
void Curve< Vector >::make | ( | float | f | ) | [inline] |
Interpolate the point/tangent data actually stored in this Curve object. This computes all the matching points along the curve for a given value of f in [0,1].
A "good" matching rule is still a unknown, usually f=0.5 seems not to be a good guess. Some people use the matching point that is equidistant between the two data points to be interpolated.
References Curve< Vector >::_Closed.
void Curve< Vector >::makeMidpointRule | ( | ) | [inline] |
Interpolate the point/tangent data actually stored in this Curve object. The computed matching points will be equidistant from their neighboring data points. The correct formulas are kindly provided by Antonio Trovato.
References Curve< Vector >::_Closed, and Curve< Vector >::nodes().
void Curve< Vector >::make | ( | int | from_N, | |
int | to_N, | |||
float | f | |||
) | [inline] |
TODO DOC
void Curve< Vector >::make | ( | Biarc< Vector > * | from, | |
Biarc< Vector > * | to, | |||
float | f | |||
) | [inline] |
TODO DOC
void Curve< Vector >::makeMidpointRule | ( | int | from_N, | |
int | to_N | |||
) | [inline] |
TODO DOC
void Curve< Vector >::makeMidpointRule | ( | Biarc< Vector > * | from, | |
Biarc< Vector > * | to | |||
) | [inline] |
TODO DOC
void Curve< Vector >::resample | ( | int | NewNoNodes | ) | [inline] |
This function resamples the current Curve object with NewNoNodes nodes on the curve. The whole curve is given as a sequence of biarcs and resampling by biarcs is therefore straightforward.
The resampling can only be done if the curve is biarc interpolated (meaning a call to one of the make() methods).
References Curve< Vector >::_Closed, Curve< Vector >::append(), Curve< Vector >::isClosed(), Curve< Vector >::length(), Curve< Vector >::link(), Curve< Vector >::nodes(), and Curve< Vector >::remove().
Referenced by Tube< Vector >::makeMesh().
void Curve< Vector >::refine | ( | int | from_N, | |
int | to_N, | |||
int | NewNoNodes | |||
) | [inline] |
This function puts NewNoNodes nodes between curve node from_N and node to_N. The count of the number of new nodes includes start and endpoint of that part of the curve.
The resampling can only be done if the curve is biarc interpolated (meaning a call to one of the make() methods).
So Far, periodic refinement is not yet implemented. I.e. it is not possible to refine the curve between node 'nodes-5' and node '10' !!!!
References Curve< Vector >::accessBiarc().
void Curve< Vector >::refine | ( | biarc_it | from, | |
biarc_it | to, | |||
int | NewNoNodes | |||
) | [inline] |
This function puts NewNoNodes nodes between pointer Biarc* from and Biarc* to. The count of the number of new nodes includes start and endpoint of that part of the curve.
The resampling can only be done if the curve is biarc interpolated (meaning a call to one of the make() methods).
So Far, periodic refinement is not yet implemented. I.e. it is not possible to refine the curve between node 'nodes-5' and node '10' !!!! We do not know which new node is the "start" of the new curve, that's why!
References Curve< Vector >::_Closed, Curve< Vector >::begin(), Curve< Vector >::end(), and Curve< Vector >::normalize().
float Curve< Vector >::radius_pt | ( | int | from, | |
int | to | |||
) | [inline] |
This function returns the radius of a circle that goes through point from and is tangent to the curve at point to. This function is commonly called . The arguments are the positions of the datapoints.
Referenced by Curve< Vector >::radius_global(), Curve< Vector >::radius_pt(), and Curve< Vector >::thickness_fast().
float Curve< Vector >::radius_pt | ( | biarc_it | from, | |
biarc_it | to | |||
) | [inline] |
This function returns the radius of a circle that goes through point from and is tangent to the curve at point to. This function is commonly called . The arguments are two pointers to biarcs.
References Curve< Vector >::radius_pt().
float Curve< Vector >::radius_pt | ( | const Biarc< Vector > & | from, | |
const Biarc< Vector > & | to | |||
) | [inline] |
This function returns the radius of a circle that goes through point from and is tangent to the curve at point to. This function is commonly called . The arguments are two pointers to biarcs.
References Biarc< Vector >::getPoint(), Biarc< Vector >::getTangent(), and Curve< Vector >::radius_pt().
float Curve< Vector >::radius_pt | ( | const Vector & | p0, | |
const Vector & | t0, | |||
const Vector & | p1 | |||
) | const [inline] |
This function returns the radius of a circle that goes through point p0 and its tangent t0 to the curve at point p1. This function is commonly called . The arguments are thre Vectors p0,t0,p1.
float Curve< Vector >::radius_pt | ( | const float | s, | |
const float | t | |||
) | const [inline] |
This function returns the radius of a circle that goes through point curve(s) and is tangent to the curve at point curve(t). This function is commonly called . The arguments s and t are arclength parameters.
References Curve< Vector >::pointAt(), Curve< Vector >::radius_pt(), and Curve< Vector >::tangentAt().
float Curve< Vector >::pp | ( | int | from, | |
int | to | |||
) | const [inline] |
Compute the pp (euclidean distance) function between two nodes
float Curve< Vector >::pp | ( | float | s, | |
float | t | |||
) | const [inline] |
Compute the pp (euclidean distance) function between and
References Curve< Vector >::pointAt().
This function returns the radius of a circle that goes through the 3 points x,y,z. This function is commonly called .
References Curve< Vector >::begin(), and Curve< Vector >::radius_pt().
float Curve< Vector >::thickness_fast | ( | ) | [inline] |
Returns the diameter of the fattest possible tube around the biarc curve. This is the inaccurate/fast version where we only look for the smallest local radius of curvature or the smallest rho_pt.
References Curve< Vector >::_Closed, Curve< Vector >::begin(), Curve< Vector >::end(), and Curve< Vector >::radius_pt().
float Curve< Vector >::thickness | ( | Vector * | from = NULL , |
|
Vector * | to = NULL | |||
) | [inline] |
Returns the diameter of the thickest possible tube around the biarc curve without self intersection or crossing. This function implements the subdivision scheme as proposed in the thesis of Jana Smutny.
The arguments from and to give the exact position of the contact corresponding to thickness (if not NULL).
References Curve< Vector >::begin(), and Curve< Vector >::end().
Referenced by TrefoilTorusAnneal::energy().
void Curve< Vector >::get_hint | ( | int * | i, | |
int * | j | |||
) | const [inline] |
Get the thickness hint. This can speed up the thickness computation if executed several times with changing only a little the curve. As for example in annealing.
void Curve< Vector >::set_hint | ( | const int | i, | |
const int | j | |||
) | [inline] |
Set the thickness hint. This can speed up the thickness computation if executed several times with changing only a little the curve. As for example in annealing.
float Curve< Vector >::minSegDistance | ( | ) | [inline] |
Returns the length of the smallest biarc in the current curve.
References Curve< Vector >::_Closed, Curve< Vector >::begin(), and Curve< Vector >::end().
float Curve< Vector >::maxSegDistance | ( | ) | [inline] |
Returns the length of the longest biarc in the current curve.
References Curve< Vector >::_Closed, Curve< Vector >::begin(), and Curve< Vector >::end().
float Curve< Vector >::span | ( | ) | const [inline] |
Return distance between the 2 most distant points.
float Curve< Vector >::distEnergy | ( | ) | [inline] |
Returns the Distance Energy in the current curve.
References Curve< Vector >::_Closed, Curve< Vector >::begin(), Curve< Vector >::end(), Curve< Vector >::length(), and Curve< Vector >::nodes().
float Curve< Vector >::curvature | ( | int | n | ) | [inline] |
Computes the curvature at biarc number n.
This curvature function is independant of the interpolation it takes only data points/tangents and computes the curvature approximation as given in Smutny's Thesis pp.60
Caution : No inflection points test, so far.
References Curve< Vector >::accessBiarc().
float Curve< Vector >::curvature | ( | biarc_it | b | ) | [inline] |
Computes the curvature at biarc b.
This curvature function is independant of the interpolation it takes only data points/tangents and computes the curvature approximation as given in Smutny's Thesis pp.60
Caution : No inflection points test, so far.
References Curve< Vector >::_Closed, Curve< Vector >::begin(), and Curve< Vector >::end().
Vector Curve< Vector >::normalVector | ( | int | n | ) | [inline] |
Returns the normal vector at biarc number n.
References Curve< Vector >::accessBiarc().
Vector Curve< Vector >::normalVector | ( | biarc_it | b | ) | [inline] |
Returns the normal vector at biarc b.
References Curve< Vector >::begin(), Vector3::dot(), and Curve< Vector >::end().
float Curve< Vector >::torsion | ( | int | n, | |
int | a | |||
) | [inline] |
Returns the 3 sin(angle)/arclength, where angle is the angle between the planes in which 2 consequent arcs lie.
Parameter a is 0 for arc 1 and 1 for the second arc
The torsion computation as given in Smutny's Thesis p.64 it is also only based on point/tangent data.
Caution : No inflection points test, so far.
References Curve< Vector >::_Closed, and Curve< Vector >::nodes().
float Curve< Vector >::torsion2 | ( | int | n | ) | [inline] |
Returns the torsion at biarc number n.
Slightly modified version of the torsion() computation. This time we consider a biarc's previous and next midpoint to compute the torsion at the current biarc.
Interpolated biarcs are necessary!
Caution : No inflection points test, so far. The torsion at the beginning and the end of an open curve is clamped to zero.
References Curve< Vector >::_Closed, and Curve< Vector >::nodes().
Compute the inertia tensor of this curve. We consider uniform density along the knot centerline.
Returns a Matrix3 object.
References Curve< Vector >::begin(), Curve< Vector >::end(), and Matrix3::zero().
Referenced by Curve< Vector >::principalAxis().
Compute the principal axis of the curve. Return them as colons of a Matrix3
References Matrix3::id(), and Curve< Vector >::inertiaTensor().
void Curve< Vector >::computeTangents | ( | ) | [inline] |
Computes the tangents for a set of points only. The tangent at the point is set to
If the curve is open the first and the last point get the tangent
References Curve< Vector >::_Closed.
Referenced by TrefoilTorusAnneal::energy(), Curve< Vector >::readSingleXYZ(), and CurveBundle< Vector >::readVECT().
void Curve< Vector >::polygonalToArcs | ( | ) | [inline] |
This function converts a polygonal curve into a curve made of arcs of circles.
The current data points (supposed to describe a polygonal curve) stored in Curve c are transformed in the following way
the corresponding tangents at each of these points if given by
References Curve< Vector >::append(), and Curve< Vector >::isClosed().
void Curve< Vector >::arcsToPolygonal | ( | ) | [inline] |
This function converts a biarc curve into a polygonal curve.
The vertices for the polygonal curve are the Bezier control points of the biarc interpolated curve, by taking only the control point at the tip of the triangle.
The tangent data for the polygonal knot are set to <0,1,0>.
Caution : a curve with N biarcs yields a polygonal curve with 2N vertices. This is true for an open and for a closed curve, since for an open curve the endpoints of the original biarc curve are also included.
References Curve< Vector >::_Closed, Curve< Vector >::append(), and Curve< Vector >::nodes().
int Curve< Vector >::nodes | ( | ) | const [inline] |
Returns the number of nodes on the curve. A node is a point/tangent data.
Referenced by Curve< Vector >::arcsToPolygonal(), Curve< Vector >::changeDirection(), Curve< Vector >::distEnergy(), TrefoilTorusAnneal::energy(), Curve< Vector >::getCenter(), Curve< Vector >::getNext(), SoKnot::GLRender(), Tube< Vector >::makeMesh(), Curve< Vector >::makeMidpointRule(), Curve< Vector >::operator+(), Curve< Vector >::operator-(), Tube< Vector >::operator=(), Curve< Vector >::operator=(), Curve< Vector >::resample(), Tube< Vector >::scaleTubeRadius(), SoKnot::setKnot(), Curve< Vector >::setNext(), Curve< Vector >::setPrevious(), Curve< Vector >::torsion(), Curve< Vector >::torsion2(), SoKnot::updateMesh(), Curve< Vector >::writeSingleData(), and Curve< Vector >::writeSinglePKF().
float Curve< Vector >::length | ( | ) | const [inline] |
Returns the arc-length of the whole curve, making the correct difference between an open or a closed curve.
References Curve< Vector >::_Closed.
Referenced by Curve< Vector >::biarcAt(), Curve< Vector >::distEnergy(), TrefoilTorusAnneal::energy(), Curve< Vector >::normalize(), Curve< Vector >::pointAt(), Curve< Vector >::resample(), and Curve< Vector >::tangentAt().
Vector Curve< Vector >::pointAt | ( | float | s | ) | const [inline] |
Return Point at Curve position Curve(s), where s is in [0,curvelength]
References Curve< Vector >::isClosed(), and Curve< Vector >::length().
Referenced by Curve< Vector >::pp(), and Curve< Vector >::radius_pt().
Vector Curve< Vector >::tangentAt | ( | float | s | ) | const [inline] |
Return Tangent at Curve position Curve(s), where s is in [0,curvelength]
References Curve< Vector >::isClosed(), and Curve< Vector >::length().
Referenced by Curve< Vector >::radius_pt().
biarc_it Curve< Vector >::biarcAt | ( | float | s | ) | [inline] |
Returns an STL iterator to the biarc on which the point Curve(s) is. s is in [0,curvelength]
References Curve< Vector >::isClosed(), and Curve< Vector >::length().
Referenced by Curve< Vector >::biarcPos().
int Curve< Vector >::biarcPos | ( | float | s | ) | [inline] |
Returns the position number of the biarc at Curve(s). s is in [0,curvelength]
References Curve< Vector >::biarcAt().
Curve< Vector > & Curve< Vector >::rotAroundAxis | ( | float | angle, | |
Vector | axis | |||
) | [inline] |
Rotate curve about some given axis. The rotation angle is given in radians!!!
References Curve< Vector >::apply().
Referenced by TrefoilTorusAnneal::energy().
Translates all the curve points by v.
Redo the interpolation after this operation if the initial curve was biarc interpolated, since the matching points and bezier points are no longer correct.
Translates all the curve points by -v.
Redo the interpolation after this operation if the initial curve was biarc interpolated, since the matching points and bezier points are no longer correct.
Curve< Vector > Curve< Vector >::operator+ | ( | const Curve< Vector > & | c | ) | const [inline] |
Add a curve to another. Checks wheter the two curves have the same number of nodes.
References Curve< Vector >::_Biarcs, Curve< Vector >::append(), PKFmanip::getCite(), PKFmanip::getEtic(), PKFmanip::getHistory(), PKFmanip::getName(), PKFmanip::header(), and Curve< Vector >::nodes().
Curve< Vector > Curve< Vector >::operator- | ( | const Curve< Vector > & | c | ) | const [inline] |
Remove a curve from another. Checks wheter the two curves have the same number of nodes.
References Curve< Vector >::_Biarcs, Curve< Vector >::append(), PKFmanip::getCite(), PKFmanip::getEtic(), PKFmanip::getHistory(), PKFmanip::getName(), PKFmanip::header(), and Curve< Vector >::nodes().
Returns a copy of the curve scaled by a factor of s.
References Curve< Vector >::scale().
Applies the rotation specified by a rotation matrix m to the curve. No check is done for m, the user must know what matrix he wants to apply.
This is not the standart 4x4 transformation matrix approach known from homogeneous coordinates stuff.
Referenced by Curve< Vector >::rotAroundAxis().
Vector Curve< Vector >::getCenter | ( | ) | [inline] |
Returns the curve's center of mass.
Reimplemented in Tube< Vector >, and Tube< Vector3 >.
References Curve< Vector >::nodes().
Referenced by Curve< Vector >::center().
void Curve< Vector >::center | ( | ) | [inline] |
Centers the curve's mass center to <0,0,0>.
References Curve< Vector >::getCenter().
void Curve< Vector >::normalize | ( | ) | [inline] |
Normalize the length of the curve. The resulting curve will have arclenth one.
An interpolated curve is necessary to compute the length of it.
References Curve< Vector >::length(), and Curve< Vector >::scale().
Referenced by Curve< Vector >::refine().
void Curve< Vector >::scale | ( | float | s | ) | [inline] |
Scales the length of the curve by s. The curve needs not to be interpolated, since only the data points are changed.
Referenced by Curve< Vector >::normalize(), and Curve< Vector >::operator*().
void Curve< Vector >::check_tangents | ( | ) | [inline] |
Prints Biarc and Tangent norm, if abs(norm-1)>1e-4
References Curve< Vector >::begin(), and Curve< Vector >::end().
int Curve< Vector >::readPKF | ( | const char * | filename | ) | [inline] |
Read a PKF curve from the file filename.
Referenced by Curve< Vector >::Curve().
int Curve< Vector >::readPKF | ( | istream & | in | ) | [inline] |
This function reads the curve data from a file filename, known as a portable knot format file (PKF). The PKF comes from the links-knots library written by Ben Laurie and Myk Soar.
An initial header gives details about the knot or link, such as the number of components (curves), the name of the current knot and more. The tags ETIC,CITE and HIST store a string for copyright purpose. The same tags ended with *L give the length of the string. The header manipulation is done in the PKFmanip class.
Each curve centerline is given as a list of point/tangent data.
The Curve class can only handle a single curve. If the number of components in the file is larger than 1, a warning message is posted to the output, saying that a CurveBundle object is necessary to process all the curves in the file.
It follows an example of a PKF file :
PKF 0.2 BIARC_KNOT "Knot Name" ETICL 14 ETIC "Please cite me" END CITEL 14 CITE "I have to cite" END HISTL 7 HIST "Remarks" END NCMP <Number of components> COMP <Number of nodes for component 1> NODE px py pz tx ty tz NODE 1.1363 0.2903 0.1548 0.2936 1.2251 0.2837 NODE 0.7187 0.8510 0.0271 -0.6460 0.7450 0.1103 ... END COMP <Number of nodes for component 2> ... END
Returns 1 if all went well, zero otherwise.
References PKFmanip::readHeader(), and Curve< Vector >::readSinglePKF().
int Curve< Vector >::writePKF | ( | const char * | filename, | |
int | Header = 1 | |||
) | [inline] |
Writes the current curve object to a portable PKF file filename. For more than 1 component use the CurveBundle class.
Returns 1 if all went well, zero otherwise.
Referenced by TrefoilTorusAnneal::energy().
int Curve< Vector >::writePKF | ( | ostream & | out, | |
int | Header = 1 | |||
) | [inline] |
Writes the current curve object to a stream out. For more than 1 component use the CurveBundle class.
Returns 1 if all went well, zero otherwise.
References PKFmanip::writeHeader(), and Curve< Vector >::writeSinglePKF().
int Curve< Vector >::readXYZ | ( | const char * | filename | ) | [inline] |
Read the curve data (only x,y,z coordinates) from a file filename, where the delimiter can be any char*. The delimiter is a space.
Referenced by TubeBundle< Vector >::readXYZ(), and CurveBundle< Vector >::readXYZ().
int Curve< Vector >::readXYZ | ( | istream & | in | ) | [inline] |
This function reads the curve data from a file infile. The file structure is a list of x,y,z coordinates. Delimiter is space " "
Returns 1 if all went well, zero otherwise.
References Curve< Vector >::readSingleXYZ().
int Curve< Vector >::readData | ( | const char * | filename, | |
const char * | delimiter | |||
) | [inline] |
Read the curve data (only x,y,z coordinates) from a file filename, where the delimiter can be any char*. The default delimiter is a space.
Referenced by TubeBundle< Vector >::readData(), and CurveBundle< Vector >::readData().
int Curve< Vector >::readData | ( | istream & | in, | |
const char * | delimiter | |||
) | [inline] |
This function reads the curve data from a file infile. The file structure is a list of x,y,z coordinates. The default for the delimiter is " ", but can be changed with the second argument of the function.
The first line gives the number of nodes in the following format {nodes}. Then the coordinates are read in. The delimiter argument is any string that separates the coordinate values from each other, the default value is a space ' ' delimiter.
Returns 1 if all went well, zero otherwise.
References Curve< Vector >::readSingleData().
int Curve< Vector >::writeData | ( | const char * | filename, | |
const char * | delimiter, | |||
int | tangents_flag | |||
) | [inline] |
Write the curve to a file. The format is : the number of curves at the first line, then the number of data points (the format is {#N}) and then the list of x,y,z coordinates for each data point.
References Curve< Vector >::writeSingleData().
int Curve< Vector >::writeData | ( | ostream & | out, | |
const char * | delimiter, | |||
int | tangents_flag | |||
) | [inline] |
Writes the curve to a data file. First line is the number of points and then follows a list of x,y,z coordinates. If the tangents_flag is set to 1, the tangents of the points are also dropped (Default is 0).
In fact we call only the readSingleData() function.
References Curve< Vector >::writeSingleData().
Flag is set to 1 if the curve is closed, 0 otherwise.
Referenced by Curve< Vector >::arcsToPolygonal(), Curve< Vector >::computeTangents(), Curve< Vector >::curvature(), Curve< Vector >::distEnergy(), Curve< Vector >::getNext(), Curve< Vector >::getPrevious(), Curve< Vector >::isClosed(), Curve< Vector >::length(), Curve< Vector >::link(), Curve< Vector >::make(), Tube< Vector >::makeMesh(), Curve< Vector >::makeMidpointRule(), Curve< Vector >::maxSegDistance(), Curve< Vector >::minSegDistance(), Curve< Vector >::refine(), Curve< Vector >::resample(), Tube< Vector >::scaleTubeRadius(), Curve< Vector >::setNext(), Curve< Vector >::setPrevious(), Curve< Vector >::thickness_fast(), Curve< Vector >::torsion(), Curve< Vector >::torsion2(), and Curve< Vector >::unlink().