| 1 | #ifndef _TUBE_ |
| 2 | #define _TUBE_ |
| 3 | |
| 4 | #include <Inventor/nodes/SoSeparator.h> |
| 5 | #include <Inventor/nodes/SoShapeHints.h> |
| 6 | #include <Inventor/nodes/SoCoordinate3.h> |
| 7 | #include <Inventor/nodes/SoQuadMesh.h> |
| 8 | #include <Inventor/nodes/SoFaceSet.h> |
| 9 | |
| 10 | |
| 11 | // A class that is a placeholder of the routines for creating a tube. |
| 12 | // The proper way would be to define a subclass of SoShape? |
| 13 | |
| 14 | |
| 15 | class Tube { |
| 16 | public: |
| 17 | Tube() {} |
| 18 | |
| 19 | // constructor: sets up variables, doesn't create anything yet |
| 20 | Tube(const int num_pts, float xyz_path[][3], |
| 21 | const float radius=1.0, const int num_edges=20); |
| 22 | |
| 23 | // creates a sceen subtree desribing a tube, with some material |
| 24 | SoSeparator *createTube(); |
| 25 | |
| 26 | private: |
| 27 | // computes the points of the tube, stores them into mesh[][3] |
| 28 | void createMesh(); |
| 29 | |
| 30 | float (*path)[3]; // pointer to the array supplied by the user |
| 31 | float (*mesh)[3]; // this one is allocated/deallocated internally |
| 32 | |
| 33 | float radius; |
| 34 | int n_edges; // # of edges of the tube (vertices of its cross-section) |
| 35 | int path_pts; // # of points of the path |
| 36 | int n_segments; // number of segments the path consists of |
| 37 | int mesh_pts; // number of points in quad mesh |
| 38 | |
| 39 | bool open_path; // true if the given path is not closed (the path is |
| 40 | // considered closed if the first and the last points |
| 41 | // in the supplied array are exactly the same) |
| 42 | }; |
| 43 | |
| 44 | #endif //_TUBE_ |
| 45 | |
| 46 | |
| 47 | // To do: |
| 48 | // - add an array for scaling / coloring? |
| 49 | // - define bounding box, compute defualt tube radius as a fraction of |
| 50 | // the boundin box size |
| 51 | |
| 52 |