vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MTTriangulator.h
Go to the documentation of this file.
1 #ifndef _DA_TRIANGULATROR_H
2 #define _DA_TRIANGULATROR_H
3 
4 #include "MTControlPoint.h"
5 #include "MTBrush.h"
6 
7 typedef osg::ref_ptr<DAControlPoint> ref_ptr_DAControlPoint;
8 typedef osg::ref_ptr<SimpleBox> ref_ptr_SimpleBox;
9 
10 class MotionTrailTriangulator : public osg::Geode
11 {
12 public:
13  MotionTrailTriangulator(osg::ref_ptr<MTBrush> br);
15 
17  void interpolateVec3(std::vector<osg::Vec3>* controlPoints, std::vector<osg::Vec3>* interpolatedPoints, PoAInterpolationType type, bool closed, int p_steps);
18 
20  /*
21  * used for highlighting - when user point on Motion trail
22  */
23  osg::Vec4 highlightColour(osg::Vec4 col);
24 
26  /*
27  * if (length optimization == false)
28  * p_steps = number of interpolated points between two control points
29  * else
30  * p_steps is recomputed, based on length of segment
31  */
32  void interpolate(std::vector<ref_ptr_DAControlPoint>* controlPoints, std::vector<osg::Vec3>* interpolatedPoints, std::vector<double>* tvalues = NULL, int p_steps = 0, bool lengthOptimization = false, bool closed = false);
33 
34  void interpolateCrossSection() { interpolateCrossSection(brush, interpolatedCrosssPoints, interpolatedCrosssNormals); };
35 
36  void interpolateCrossSection(MTBrush *brush, std::vector<osg::Vec3> *interpolatedPoints, std::vector<osg::Vec3> *interpolatedNormals);
37 
38  inline bool getHighLighting() { return this->isHighlighted; }
39 
40  void setHighLighting(bool high) { this->isHighlighted = high; }
41 
42  void setUseFrenetFrame(bool frenet) { this->useFrenetFrame = frenet; }
43 
44  void triangulate(std::vector<ref_ptr_DAControlPoint>* controlPoints);
45 
46  //TODO only for test - move back to private
47  //Catmull-Rom interpolation
48  osg::Vec3 catmullRomInterpolation(double t, osg::Vec3 p0, osg::Vec3 p1, osg::Vec3 p2, osg::Vec3 p3);
49 
50  //derivation of Catmull-Rom interpolation
51  osg::Vec3 derivedCRI(double t, osg::Vec3 p0, osg::Vec3 p1, osg::Vec3 p2, osg::Vec3 p3);
52 
53  //second derivation of Catmull-Rom interpolation
54  osg::Vec3 doubleDerivedCRI(double t, osg::Vec3 p0, osg::Vec3 p1, osg::Vec3 p2, osg::Vec3 p3);
55 
56  //third derivation ...
57  osg::Vec3 tripleDerivedCRI(double t, osg::Vec3 p0, osg::Vec3 p1, osg::Vec3 p2, osg::Vec3 p3);
58 
59 
60 private:
61  PoATriangulationType triangulationType;
62  PoAInterpolationType interpolationType;
63 
64  osg::ref_ptr<osg::Geometry> geometry;
65  osg::ref_ptr<osg::Vec3Array> vertices;
66  osg::ref_ptr<osg::Vec3Array> normals;
67  osg::ref_ptr<osg::Vec4Array> colours;
68 
69  bool isHighlighted;
70 
71 
72 
73  //Tube
74  osg::ref_ptr<MTBrush> brush;
75  bool closedCrossSection;
76  bool interpolatedCrossSection;
77 
78  //TODO - useless - remove?
79  bool useFrenetFrame;
80 
81  std::vector<osg::Vec3> *interpolatedCrosssPoints;
82  std::vector<osg::Vec3> *interpolatedCrosssNormals;
83 
84 
86  bool createCrossSection(DAControlPoint *point, double diameter, osg::Vec3Array *crossSection, osg::Vec3Array *normals);
87 
89  osg::Vec3 interpolatePoint(double t, osg::Vec3 point1, osg::Vec3 point2, osg::Vec3 point0 = osg::Vec3(0.0, 0.0, 0.0), osg::Vec3 point3 = osg::Vec3(0.0, 0.0, 0.0));
90 
91  std::vector<ref_ptr_SimpleBox>* shapes; //for visualization
92 
93 };
94 
95 
96 #endif // _DA_TRIANGULATROR_H