#include <include/Tube.h>
Public Member Functions | |
Tube () | |
Tube (istream &in) | |
Tube (const Curve< Vector > &curve) | |
Tube (const Tube< Vector > &tube) | |
Tube & | operator= (const Tube< Vector > &t) |
~Tube () | |
void | init () |
void | clear_tube () |
Vector & | meshPoint (int i) |
Vector & | meshNormal (int i) |
int | segments () |
float | radius () |
void | makeMesh (int N, int S, float R, float Tol=-1.0) |
void | getBoundingBox (Vector &BBox_BL, Vector &BBox_UR) |
Vector & | getCenter () |
void | scaleTubeRadius (float NewRadius) |
This class is used to store the points and normals of a tubular mesh around a space-curve.
The usage of Tube objects are shown in the following example :
#include "../include/Tube.h" main(int argc, char **argv) { // Read curve data from a file Tube 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; }
Default constructor. Creates an empty curve with no mesh points.
References Tube< Vector >::init().
Constructs a new Tube object, reading the curve data from a stream in. Header is automatically set to the default values and is NOT expected to on the stream!
References Tube< Vector >::init().
Constructor copies a Curve object curve. No interpolation and no mesh generation is done. To do that makeMesh() must be called.
References Tube< Vector >::init().
Constructor copies a Tube 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 Tube 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.
References Tube< Vector >::init().
Destructor. Clears the memory used by the mesh points and normals.
References Tube< Vector >::clear_tube().
Tube< Vector > & Tube< Vector >::operator= | ( | const Tube< Vector > & | c | ) | [inline] |
Assign operator. Copies the curve data and calls link() if Tube c is closed.
References Curve< Vector >::_Biarcs, Curve< Vector >::begin(), Curve< Vector >::end(), Curve< Vector >::flush_all(), Curve< Vector >::isClosed(), Curve< Vector >::link(), and Curve< Vector >::nodes().
void Tube< Vector >::init | ( | ) | [inline] |
Initialize Tube object. Number of segments and the radius are set to 0.0. The mesh point table and the mesh normal table are set to NULL.
Reimplemented from Curve< Vector >.
Referenced by Tube< Vector >::Tube().
void Tube< Vector >::clear_tube | ( | ) | [inline] |
Deletes the mesh points and the mesh normals.
Referenced by Tube< Vector >::makeMesh(), and Tube< Vector >::~Tube().
Vector & Tube< Vector >::meshPoint | ( | int | i | ) | [inline] |
Returns mesh point number i. There are a total of mesh points.
Referenced by SoKnot::generatePrimitives().
Vector & Tube< Vector >::meshNormal | ( | int | i | ) | [inline] |
Returns mesh normal number i. There are a total of mesh normals.
Referenced by SoKnot::generatePrimitives().
int Tube< Vector >::segments | ( | ) | [inline] |
Returns the number of segments on the tubular cross section.
Referenced by SoKnot::GLRender(), SoKnot::setKnot(), and SoKnot::updateMesh().
float Tube< Vector >::radius | ( | ) | [inline] |
Returns the current radius of the tubular curve.
Referenced by SoKnot::setKnot(), and SoKnot::updateMesh().
void Tube< 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 actully 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 Curve< Vector >::_Closed, Curve< Vector >::begin(), Matrix3::cay(), Tube< Vector >::clear_tube(), Vector3::cross(), Vector3::dot(), Curve< Vector >::link(), Curve< Vector >::nodes(), Vector3::normalize(), Curve< Vector >::resample(), Vector3::rotPtAroundAxis(), and Curve< Vector >::unlink().
Referenced by SoKnot::setKnot(), and SoKnot::updateMesh().
void Tube< 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.
Referenced by SoKnot::computeBBox().
Vector & Tube< Vector >::getCenter | ( | ) | [inline] |
Returns the center of mass of the tubular mesh.
Reimplemented from Curve< Vector >.
Referenced by SoKnot::computeBBox().
void Tube< 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 Curve< Vector >::_Closed, Curve< Vector >::begin(), Curve< Vector >::end(), and Curve< Vector >::nodes().