#include <include/TubeBundle.h>
Public Member Functions | |
void | clear_tb () |
TubeBundle () | |
TubeBundle (const char *filename) | |
TubeBundle (const TubeBundle< Vector > &tb) | |
TubeBundle (const CurveBundle< Vector > &cb) | |
TubeBundle< Vector > & | operator= (const TubeBundle< Vector > &tb) |
~TubeBundle () | |
int | tubes () const |
void | newTube (const Tube< Vector > &t) |
void | newTube (istream &in) |
Tube< Vector > & | operator[] (int c) |
void | makeMesh (int N, int S, float R, float Tol=-1.0) |
void | getBoundingBox (Vector &BBox_Min, Vector &BBox_Max) |
Vector & | getCenter () |
void | scaleTubeRadius (float NewRadius) |
int | readPKF (const char *infile) |
int | readXYZ (const char *infile) |
int | readPKF (istream &in) |
int | readData (const char *infile, const char *delimiter=" ") |
This class is used to store the points and normals of a tubular mesh around a space-curve.
The usage of TubeBundle objects are shown in the following example :
#include "../include/TubeBundle.h" main(int argc, char **argv) { // Read curve data from a file TubeBundle t("curve.pkf"); // Close the curve t.link(); // Number of nodes on the curve int N = t.nodes(); // We want 10 segments on the cross section int S = 10; // The radius is set to 1.0 float R = 1.0; // We match up the mesh with this tolerance value float Tol = 1e-3; // Generate mesh points and normals t.makeMesh(N,S,R,Tol); ... // Write the output to standart out cout << t << endl; ... return 0; }
TubeBundle< Vector >::TubeBundle | ( | ) | [inline] |
Default constructor. Creates an empty tube bundle.
TubeBundle< Vector >::TubeBundle | ( | const char * | filename | ) | [inline] |
Constructor reads the curves data from infile and stores it in a Tube container. No interpolation is done, and no mesh points are generated. A call to makeMesh() is necessary to generate the mesh points for all the curves.
References TubeBundle< Vector >::readPKF().
TubeBundle< Vector >::TubeBundle | ( | const TubeBundle< Vector > & | tb | ) | [inline] |
Constructor copies a TubeBundle object tube. Only the curve data points are copied and the curve is closed if necessary. No interpolation and no mesh generation is done in the new TubeBundle instance. To do that makeMesh() must be called.
Maybe this will be changed in the future to copy all the mesh points if the tube object has mesh points.
TubeBundle< Vector >::TubeBundle | ( | const CurveBundle< Vector > & | cb | ) | [inline] |
Constructor copies a Curve object curve. No interpolation and no mesh generation is done. To do that makeMesh() must be called.
References CurveBundle< Vector >::curves(), and TubeBundle< Vector >::newTube().
TubeBundle< Vector >::~TubeBundle | ( | ) | [inline] |
Destructor. Clears the memory used by the mesh points and normals.
TubeBundle< Vector > & TubeBundle< Vector >::operator= | ( | const TubeBundle< Vector > & | tb | ) | [inline] |
Assign operator. Copies the curve data and calls link() if TubeBundle c is closed.
References TubeBundle< Vector >::container, and TubeBundle< Vector >::tubes().
int TubeBundle< Vector >::tubes | ( | ) | const [inline] |
Returns the number of tubes int this bundle.
Referenced by TubeBundle< Vector >::makeMesh(), CurveInterface::makeMesh(), TubeBundle< Vector >::operator=(), and TubeBundle< Vector >::scaleTubeRadius().
void TubeBundle< Vector >::newTube | ( | const Tube< Vector > & | t | ) | [inline] |
Add a tube t to the bundle.
Referenced by CurveInterface::load(), TubeBundle< Vector >::newTube(), TubeBundle< Vector >::readData(), TubeBundle< Vector >::readPKF(), TubeBundle< Vector >::readXYZ(), and TubeBundle< Vector >::TubeBundle().
void TubeBundle< Vector >::newTube | ( | istream & | in | ) | [inline] |
Read the curve data from a stream in. The curve is converted into a Tube object and added to the TubeBundle.
References TubeBundle< Vector >::newTube().
Tube< Vector > & TubeBundle< Vector >::operator[] | ( | int | c | ) | [inline] |
Return a reference to the tube number c in the TubeBundle container.
void TubeBundle< Vector >::makeMesh | ( | int | N, | |
int | S, | |||
float | R, | |||
float | Tol = -1.0 | |||
) | [inline] |
Creates a tubular mesh with radius R around the curve with N nodes and S segments on each cross sectional circle. If the actually stored curve has not exactly N nodes, the Curve::resample() routine is called automatically.
The parameter Tol is the precision used to math up the mesh of a closed curve. Tol is the difference in radians of the angle between the first and the last normal of the sequence of curve frames.
Use Tol = -1 (default) for no torsion adjustment and open curves.
Computes also the mesh normals at each point where the normal is an average of the neighbouring face normals. (The normals are used for Gouraud shading in visualisation programs).
At the end the center of mass and the bounding box are computed.
The interpolation in case of a resampling is done with Gamma = 0.5.
References TubeBundle< Vector >::tubes().
Referenced by CurveInterface::makeMesh().
void TubeBundle< Vector >::getBoundingBox | ( | Vector & | BBox_Min, | |
Vector & | BBox_Max | |||
) | [inline] |
Puts the position of the minimum and the maximum corner of a box containing the whole tubular object into the vectors BBox_Min and BBox_Max.
Vector & TubeBundle< Vector >::getCenter | ( | ) | [inline] |
Returns the center of mass of the tubular mesh.
void TubeBundle< Vector >::scaleTubeRadius | ( | float | NewRadius | ) | [inline] |
Inflates or deflates the existing mesh according to the new radius given. All the cross sectional circles are changed to have radius NewRadius. This function drops an error message if there are no valid mesh points.
The bounding box values are updated at the end of the process.
References TubeBundle< Vector >::tubes().
int TubeBundle< Vector >::readPKF | ( | const char * | infile | ) | [inline] |
Read a PKF file with more than one curve from infile.
Referenced by CurveInterface::load(), and TubeBundle< Vector >::TubeBundle().
int TubeBundle< Vector >::readXYZ | ( | const char * | infile | ) | [inline] |
Read XYZ file.
References TubeBundle< Vector >::newTube(), and Curve< Vector >::readXYZ().
Referenced by CurveInterface::load().
int TubeBundle< Vector >::readPKF | ( | istream & | in | ) | [inline] |
Read a PKF file with more than one curve from istream in.
References TubeBundle< Vector >::newTube(), and PKFmanip::readHeader().
int TubeBundle< Vector >::readData | ( | const char * | infile, | |
const char * | delimiter = " " | |||
) | [inline] |
Read a data file. This routine has been used for different file formats. If needed, adapt it ;)
References TubeBundle< Vector >::newTube(), and Curve< Vector >::readData().