Curve< Vector > Class Template Reference
[libbiarc]

The Curve class for storing and manipulating a single biarc curve in $\mathcal{R}^3$. More...

#include <include/Curve.h>

Inheritance diagram for Curve< Vector >:

PKFmanip Tube< Vector >

List of all members.

Public Member Functions

 Curve ()
 Curve (const char *filename)
 Curve (istream &in)
 Curve (const Curve< Vector > &curve)
Curveoperator= (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)
CurverotAroundAxis (float angle, Vector axis)
Curveoperator+= (const Vector &v)
Curveoperator-= (const Vector &v)
Curve operator+ (const Curve &c) const
Curve operator- (const Curve &c) const
Curve operator* (const float s) const
Curveapply (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


Detailed Description

template<class Vector>
class Curve< Vector >

The Curve class for storing and manipulating a single biarc curve in $\mathcal{R}^3$.

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;
  
  }

See also:
Biarc

Constructor & Destructor Documentation

template<class Vector>
Curve< Vector >::Curve (  )  [inline]

Constructs an empty curve and sets the header to "No name","","",""

template<class Vector>
Curve< Vector >::Curve ( const char *  filename  )  [inline]

Constructs a curve by reading it from the istream in.

References Curve< Vector >::readPKF().

template<class Vector>
Curve< Vector >::Curve ( istream &  in  )  [inline]

Read the curve data from a stream in. Does not read a PKF header. Call the readHeader() method for that purpose.

See also:
PKFmanip

References Curve< Vector >::readSinglePKF().

template<class Vector>
Curve< Vector >::Curve ( const Curve< Vector > &  curve  )  [inline]

Copy constructor.

See also:
operator=

template<class Vector>
Curve< Vector >::~Curve (  )  [inline]

Destructor. Flushes all the elements of the curve object.

References Curve< Vector >::flush_all().


Member Function Documentation

template<class Vector>
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().

template<class Vector>
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

template<class Vector>
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!

See also:
readPKF()

References Curve< Vector >::append().

Referenced by Curve< Vector >::Curve(), and Curve< Vector >::readPKF().

template<class Vector>
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.

See also:
writePKF()

References Curve< Vector >::nodes().

Referenced by Curve< Vector >::writePKF().

template<class Vector>
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.

See also:
readData()

References Curve< Vector >::append().

Referenced by Curve< Vector >::readData().

template<class Vector>
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.

See also:
writeData()

References Curve< Vector >::nodes().

Referenced by Curve< Vector >::writeData().

template<class Vector>
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.

See also:
readPKF(), readData()

References Curve< Vector >::append(), and Curve< Vector >::computeTangents().

Referenced by Curve< Vector >::readXYZ().

template<class Vector>
Curve< Vector > & Curve< Vector >::operator= ( const Curve< Vector > &  c  )  [inline]

template<class Vector>
biarc_ref Curve< Vector >::operator[] ( int  c  )  [inline]

Returns biarc number c of the curve. Index starts off with zero (C style).

template<class Vector>
biarc_constref Curve< Vector >::operator[] ( int  c  )  const [inline]

Returns biarc number c of the curve. Index starts off with zero (C style).

template<class Vector>
void Curve< Vector >::push ( const Biarc< Vector > &  b  )  [inline]

Adds a point/tangent data stored in biarc b at the front of the curve.

See also:
append(),insert(),pop(),remove()

Referenced by Curve< Vector >::push().

template<class Vector>
void Curve< Vector >::push ( const Vector &  p,
const Vector &  t 
) [inline]

Adds a point p, tangent t data at the front of the curve.

See also:
append(),insert(),pop(),remove()

References Curve< Vector >::push().

template<class Vector>
void Curve< Vector >::append ( const Biarc< Vector > &  b  )  [inline]

template<class Vector>
void Curve< Vector >::append ( const Vector &  p,
const Vector &  t 
) [inline]

Adds a point p, tangent t data at the end of the curve.

See also:
push(),insert(),pop(),remove()

References Curve< Vector >::append().

template<class Vector>
void Curve< Vector >::insert ( int  loc,
const Biarc< Vector > &  b 
) [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.

See also:
push(),append(),pop(),remove()

Referenced by Curve< Vector >::insert().

template<class Vector>
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.

See also:
push(),append(),pop(),remove()

References Curve< Vector >::insert().

template<class Vector>
void Curve< Vector >::remove ( int  loc  )  [inline]

Remove biarc at position loc

Referenced by Curve< Vector >::resample().

template<class Vector>
void Curve< Vector >::remove ( biarc_it  b  )  [inline]

Remove biarc at position loc

template<class Vector>
void Curve< Vector >::flush_all (  )  [inline]

template<class Vector>
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().

template<class Vector>
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.

template<class Vector>
void Curve< Vector >::setNext ( 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().

template<class Vector>
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().

template<class Vector>
biarc_it Curve< Vector >::begin (  )  [inline]

template<class Vector>
biarc_it Curve< Vector >::end (  )  [inline]

template<class Vector>
int Curve< Vector >::isClosed (  )  const [inline]

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
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.

See also:
Biarc::make(),CurveBundle::make()

References Curve< Vector >::_Closed.

template<class Vector>
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.

See also:
make(), CurveBundle::makeMidpointRule()

References Curve< Vector >::_Closed, and Curve< Vector >::nodes().

template<class Vector>
void Curve< Vector >::make ( int  from_N,
int  to_N,
float  f 
) [inline]

TODO DOC

template<class Vector>
void Curve< Vector >::make ( Biarc< Vector > *  from,
Biarc< Vector > *  to,
float  f 
) [inline]

TODO DOC

template<class Vector>
void Curve< Vector >::makeMidpointRule ( int  from_N,
int  to_N 
) [inline]

TODO DOC

template<class Vector>
void Curve< Vector >::makeMidpointRule ( Biarc< Vector > *  from,
Biarc< Vector > *  to 
) [inline]

TODO DOC

template<class Vector>
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).

See also:
refine(),make(),CurveBundle::resample()

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().

template<class Vector>
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' !!!!

See also:
resample(),make().

References Curve< Vector >::accessBiarc().

template<class Vector>
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!

See also:
resample(),make().

References Curve< Vector >::_Closed, Curve< Vector >::begin(), Curve< Vector >::end(), and Curve< Vector >::normalize().

template<class Vector>
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 $\rho_{pt}(s,t)$. The arguments are the positions of the datapoints.

See also:
thickness(), thickness_fast()

Referenced by Curve< Vector >::radius_global(), Curve< Vector >::radius_pt(), and Curve< Vector >::thickness_fast().

template<class Vector>
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 $\rho_{pt}(s,t)$. The arguments are two pointers to biarcs.

See also:
thickness(), thickness_fast()

References Curve< Vector >::radius_pt().

template<class Vector>
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 $\rho_{pt}(s,t)$. The arguments are two pointers to biarcs.

See also:
thickness(), thickness_fast()

References Biarc< Vector >::getPoint(), Biarc< Vector >::getTangent(), and Curve< Vector >::radius_pt().

template<class Vector>
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 $\rho_{pt}(s,t)$. The arguments are thre Vectors p0,t0,p1.

See also:
thickness(), thickness_fast()

template<class Vector>
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 $\rho_{pt}(s,t)$. The arguments s and t are arclength parameters.

See also:
thickness(), thickness_fast()

References Curve< Vector >::pointAt(), Curve< Vector >::radius_pt(), and Curve< Vector >::tangentAt().

template<class Vector>
float Curve< Vector >::pp ( int  from,
int  to 
) const [inline]

Compute the pp (euclidean distance) function between two nodes

template<class Vector>
float Curve< Vector >::pp ( float  s,
float  t 
) const [inline]

Compute the pp (euclidean distance) function between $\gamma(s)$ and $\gamma(t)$

References Curve< Vector >::pointAt().

template<class Vector>
float Curve< Vector >::radius_global ( Biarc< Vector > &  at  )  [inline]

This function returns the radius of a circle that goes through the 3 points x,y,z. This function is commonly called $\rho_{ppp}(s,t)$.

See also:
thickness(), thickness_fast()

References Curve< Vector >::begin(), and Curve< Vector >::radius_pt().

template<class Vector>
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.

See also:
radius_pt()

References Curve< Vector >::_Closed, Curve< Vector >::begin(), Curve< Vector >::end(), and Curve< Vector >::radius_pt().

template<class Vector>
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).

See also:
radius_pt(), thickness_fast()

References Curve< Vector >::begin(), and Curve< Vector >::end().

Referenced by TrefoilTorusAnneal::energy().

template<class Vector>
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.

See also:
set_hint()

template<class Vector>
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.

See also:
get_hint()

template<class Vector>
float Curve< Vector >::minSegDistance (  )  [inline]

Returns the length of the smallest biarc in the current curve.

See also:
maxSegDistance()

References Curve< Vector >::_Closed, Curve< Vector >::begin(), and Curve< Vector >::end().

template<class Vector>
float Curve< Vector >::maxSegDistance (  )  [inline]

Returns the length of the longest biarc in the current curve.

See also:
minSegDistance()

References Curve< Vector >::_Closed, Curve< Vector >::begin(), and Curve< Vector >::end().

template<class Vector>
float Curve< Vector >::span (  )  const [inline]

Return distance between the 2 most distant points.

template<class Vector>
float Curve< Vector >::distEnergy (  )  [inline]

template<class Vector>
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.

See also:
torsion(),torsion2()

References Curve< Vector >::accessBiarc().

template<class Vector>
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.

See also:
torsion(),torsion2()

References Curve< Vector >::_Closed, Curve< Vector >::begin(), and Curve< Vector >::end().

template<class Vector>
Vector Curve< Vector >::normalVector ( int  n  )  [inline]

Returns the normal vector at biarc number n.

References Curve< Vector >::accessBiarc().

template<class Vector>
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().

template<class Vector>
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.

See also:
torsion2(),curvature()

References Curve< Vector >::_Closed, and Curve< Vector >::nodes().

template<class Vector>
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.

See also:
torsion(),curvature()

References Curve< Vector >::_Closed, and Curve< Vector >::nodes().

template<class Vector>
void Curve< Vector >::inertiaTensor ( Matrix3 mat  )  [inline]

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().

template<class Vector>
void Curve< Vector >::principalAxis ( Matrix3 mat  )  [inline]

Compute the principal axis of the curve. Return them as colons of a Matrix3

References Matrix3::id(), and Curve< Vector >::inertiaTensor().

template<class Vector>
void Curve< Vector >::computeTangents (  )  [inline]

Computes the tangents for a set of points only. The tangent $t_i$ at the point $p_i$ is set to

$t_i=\frac{p_{i+1}-p_{i-1}}{|p_{i+1}-p_{i-1}|}$

If the curve is open the first and the last point get the tangent

$t_0=\frac{p_1-p_0}{|p_1-p_0|}$ $t_{N-1}=\frac{p_{N-1}-p_{N-2}}{|p_{N-1}-p_{N-2}|}$

References Curve< Vector >::_Closed.

Referenced by TrefoilTorusAnneal::energy(), Curve< Vector >::readSingleXYZ(), and CurveBundle< Vector >::readVECT().

template<class Vector>
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

$p_i^{new}=\frac{p_i^{old}+ p_{i+1}^{old}}{2}$

the corresponding tangents at each of these points $p_i$ if given by

$t_i= \frac{p_i^{old} + p_{i+1}^{old}}{2\,|p_i^{old}-p_{i+1}^{old}| }$

See also:
arcsTolPolygonal()

References Curve< Vector >::append(), and Curve< Vector >::isClosed().

template<class Vector>
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.

See also:
arcsToPolygonal()

References Curve< Vector >::_Closed, Curve< Vector >::append(), and Curve< Vector >::nodes().

template<class Vector>
int Curve< Vector >::nodes (  )  const [inline]

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
Curve< Vector > & Curve< Vector >::operator+= ( const Vector &  v  )  [inline]

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.

See also:
center().

template<class Vector>
Curve< Vector > & Curve< Vector >::operator-= ( const Vector &  v  )  [inline]

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.

See also:
center().

template<class Vector>
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().

template<class Vector>
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().

template<class Vector>
Curve< Vector > Curve< Vector >::operator* ( const float  s  )  const [inline]

Returns a copy of the curve scaled by a factor of s.

References Curve< Vector >::scale().

template<class Vector>
Curve< Vector > & Curve< Vector >::apply ( Matrix3 m  )  [inline]

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().

template<class Vector>
Vector Curve< Vector >::getCenter (  )  [inline]

Returns the curve's center of mass.

See also:
center()

Reimplemented in Tube< Vector >, and Tube< Vector3 >.

References Curve< Vector >::nodes().

Referenced by Curve< Vector >::center().

template<class Vector>
void Curve< Vector >::center (  )  [inline]

Centers the curve's mass center to <0,0,0>.

See also:
getCenter()

References Curve< Vector >::getCenter().

template<class Vector>
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.

See also:
scale(),CurveBundle::normalize()

References Curve< Vector >::length(), and Curve< Vector >::scale().

Referenced by Curve< Vector >::refine().

template<class Vector>
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.

See also:
normalize(),CurveBundle::scale()

Referenced by Curve< Vector >::normalize(), and Curve< Vector >::operator*().

template<class Vector>
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().

template<class Vector>
int Curve< Vector >::readPKF ( const char *  filename  )  [inline]

Read a PKF curve from the file filename.

See also:
writePKF()

Referenced by Curve< Vector >::Curve().

template<class Vector>
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.

See also:
writePKF(),CurveBundle,PKFmanip

References PKFmanip::readHeader(), and Curve< Vector >::readSinglePKF().

template<class Vector>
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.

See also:
readPKF(),CurveBundle

Referenced by TrefoilTorusAnneal::energy().

template<class Vector>
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.

See also:
readPKF(),CurveBundle

References PKFmanip::writeHeader(), and Curve< Vector >::writeSinglePKF().

template<class Vector>
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().

template<class Vector>
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.

See also:
readPKF(), readData()

References Curve< Vector >::readSingleXYZ().

template<class Vector>
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().

template<class Vector>
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.

See also:
computeTangents(),polygonalToArcs(),arcsToPolygonal()

References Curve< Vector >::readSingleData().

template<class Vector>
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.

See also:
writeSingleData(),readData()

References Curve< Vector >::writeSingleData().

template<class Vector>
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.

See also:
writeSingleData(),readData()

References Curve< Vector >::writeSingleData().


Member Data Documentation

template<class Vector>
int Curve< Vector >::_Closed [protected]


The documentation for this class was generated from the following files:

Generated on Mon Feb 8 17:22:36 2010 for libbiarc by  doxygen 1.5.6