1 #ifndef FILE_DEMOVIEW 2 #define FILE_DEMOVIEW 3 4 /*********************************************************************/ 5 /* File: demoview.hpp */ 6 /* Author: Robert, Joachim */ 7 /* Date: 6. Mar. 2003 */ 8 /*********************************************************************/ 9 10 using namespace netgen; 11 12 13 enum DEMOVIEW_TOKEN_TYPE 14 { 15 DTOK_MINUS = '-', DTOK_LP = '(', DTOK_RP = ')', DTOK_LSP = '[', DTOK_RSP = ']', 16 DTOK_EQU = '=', DTOK_COMMA = ',', DTOK_SEMICOLON = ';', DTOK_COLON = ':', DTOK_PLUS = '+', 17 DTOK_NUM = 100, DTOK_STRING, DTOK_TIME, DTOK_CAMPOS, DTOK_CAMPOINT, DTOK_CAMUP, 18 DTOK_END 19 }; 20 21 struct demoview_kwstruct 22 { 23 DEMOVIEW_TOKEN_TYPE kw; 24 const char * name; 25 }; 26 27 28 29 30 class DemoScanner 31 { 32 DEMOVIEW_TOKEN_TYPE token; 33 double num_value; 34 string string_value; 35 36 int linenum; 37 ifstream * scanin; 38 39 public: 40 41 DemoScanner (ifstream & ascanin); 42 GetToken() const43 DEMOVIEW_TOKEN_TYPE GetToken() const 44 { return token; } 45 GetNumValue() const46 double GetNumValue() const 47 { return num_value; } 48 GetStringValue() const49 const string & GetStringValue() const 50 { return string_value; } 51 52 void ReadNext(); 53 void Error (const string & err); 54 }; 55 56 57 void ParseChar (DemoScanner & scan, char ch); 58 59 double ParseNumber(DemoScanner & scan); 60 61 Vec<3> ParseVector (DemoScanner & scan); 62 63 64 65 template <class S> 66 class InterpolationPoint 67 { 68 double t; 69 S s; 70 71 public: InterpolationPoint()72 InterpolationPoint() 73 {}; 74 ~InterpolationPoint()75 ~InterpolationPoint() 76 {}; 77 GetT() const78 double GetT() const 79 { return t; }; 80 GetS() const81 S GetS() const 82 { return s; }; 83 SetTS(double at,S as)84 void SetTS(double at, S as) 85 { t = at; s = as; }; 86 operator =(const InterpolationPoint<S> & ip2)87 InterpolationPoint & operator= (const InterpolationPoint<S> & ip2) 88 { 89 SetTS (ip2.t, ip2.s); 90 return (*this); 91 }; 92 93 }; 94 95 96 97 template <class S> 98 class InterpolationSpline 99 { 100 protected: 101 // NgArray < InterpolationPoint<S>[3] > ip; 102 103 class intpts 104 { 105 public: 106 InterpolationPoint<S> pts[3]; operator [](int i)107 InterpolationPoint<S> & operator[](int i) { return pts[i]; } 108 }; 109 NgArray < intpts > ip; 110 111 int finished; 112 113 public: InterpolationSpline()114 InterpolationSpline() : finished(0) 115 {}; 116 InterpolationSpline(S s1)117 InterpolationSpline( S s1 ) : finished(0) 118 { 119 AddSpline (-1e99, -1e99, -1e99, s1, s1, s1); 120 // InterpolationSpline(); 121 } 122 ~InterpolationSpline()123 ~InterpolationSpline() 124 {}; 125 126 void AddSpline(double t1, double t2, double t3, S s1, S s2, S s3); 127 128 S Evaluate (double t); 129 IsFinished() const130 int IsFinished() const 131 { 132 return finished; 133 } 134 }; 135 136 137 138 139 140 class DemoView 141 { 142 InterpolationSpline< Vec<3> > campos; 143 InterpolationSpline< Vec<3> > campoint; 144 InterpolationSpline< Vec<3> > camup; 145 146 public: 147 DemoView (const char * filename); 148 ~DemoView (); 149 150 int SetTime (double time); 151 }; 152 153 154 155 #endif 156