00001
00002
00003
00005
00006
00011
00016
00021
00023
00024 #ifndef X3DBASETYPES_H
00025 #define X3DBASETYPES_H
00026
00027 #include "SFString.h"
00028 #include "SFVec3f.h"
00029 #include "SFPoint3f.h"
00030 #include "SFMatrix34f.h"
00031
00032 #include <iostream>
00033 #include <string>
00034 #include <list>
00035 #include <vector>
00036 #include <map>
00037
00038 namespace X3DTK {
00039
00041 class MFString : public std::vector<SFString>
00042 {
00043 public:
00045 MFString(){};
00047 explicit MFString(const SFString &s);
00048 };
00049
00051 typedef bool SFBool;
00052
00054 class MFBool : public std::vector<SFBool>
00055 {
00056 public:
00058 MFBool(){};
00060 explicit MFBool(const SFString &s);
00061 };
00062
00064 typedef int SFInt32;
00065
00067 class MFInt32 : public std::vector<SFInt32>
00068 {
00069 public:
00071 MFInt32(){};
00073 explicit MFInt32(size_type n, const SFInt32 &V = SFInt32());
00075 explicit MFInt32(const SFString &s);
00076 };
00077
00079 typedef float SFFloat;
00080
00082 class MFFloat : public std::vector<SFFloat>
00083 {
00084 public:
00086 MFFloat(){};
00088 explicit MFFloat(size_type n, const SFFloat &V = SFFloat());
00090 explicit MFFloat(const SFString &s);
00091 };
00092
00094 typedef double SFDouble;
00095
00097 class MFDouble : public std::vector<SFDouble>
00098 {
00099 public:
00101 MFDouble(){};
00103 explicit MFDouble(const SFString &s);
00104 };
00105
00107 class SFColorRGBA
00108 {
00109 public:
00111 SFFloat r;
00113 SFFloat g;
00115 SFFloat b;
00117 SFFloat a;
00119 SFColorRGBA(){};
00121 SFColorRGBA(SFFloat r, SFFloat g, SFFloat b, SFFloat a);
00123 explicit SFColorRGBA(const SFString &s);
00124
00126 friend bool operator== (const SFColorRGBA &r1, const SFColorRGBA &r2);
00128 friend bool operator!= (const SFColorRGBA &r1, const SFColorRGBA &r2);
00129 };
00130
00132 class MFColorRGBA : public std::vector<SFColorRGBA>
00133 {
00134 public:
00136 MFColorRGBA(){};
00138 MFColorRGBA(size_type n, const SFColorRGBA &C = SFColorRGBA());
00140 explicit MFColorRGBA(const SFString &s);
00141 };
00142
00144 class SFColor
00145 {
00146 public:
00148 SFFloat r;
00150 SFFloat g;
00152 SFFloat b;
00154 SFColor(){};
00156 SFColor(SFFloat r, SFFloat g, SFFloat b);
00158 explicit SFColor(const SFString &s);
00160 operator const SFColorRGBA() const;
00161
00163 friend bool operator== (const SFColor &r1, const SFColor &r2);
00165 friend bool operator!= (const SFColor &r1, const SFColor &r2);
00166 };
00167
00168
00170 class MFColor : public std::vector<SFColor>
00171 {
00172 public:
00174 MFColor(){};
00176 explicit MFColor(const SFString &s);
00177 operator const MFColorRGBA() const;
00178 };
00179
00180 class X3DAbstractNode;
00182 typedef X3DAbstractNode *SFAbstractNode;
00184 typedef std::list<SFAbstractNode> MFAbstractNode;
00185
00186 namespace X3D {
00187
00188 class X3DNode;
00190 typedef X3DNode *SFNode;
00192 typedef std::list<SFNode> MFNode;
00194 typedef std::pair<SFNode, SFNode> SFNodeLink;
00196 typedef std::list<SFNodeLink> MFDNode;
00197
00198 }
00199
00200 namespace GL {
00201
00202 class X3DNode;
00204 typedef X3DNode *SFNode;
00206 typedef std::list<SFNode> MFNode;
00207
00208 }
00209
00211 class SFVec2d
00212 {
00213 public:
00214 SFDouble x, y;
00216 SFVec2d();
00218 SFVec2d(SFDouble x, SFDouble y);
00220 explicit SFVec2d(const SFString &s);
00221 };
00222
00224 class MFVec2d : public std::vector<SFVec2d>
00225 {
00226 public:
00228 MFVec2d(){};
00230 explicit MFVec2d(const SFString &s);
00231 };
00232
00234 class SFVec2f
00235 {
00236 public:
00237 SFFloat x, y;
00239 SFVec2f();
00241 SFVec2f(SFFloat x, SFFloat y);
00243 explicit SFVec2f(const SFString &s);
00244 };
00245
00247 class MFVec2f : public std::vector<SFVec2f>
00248 {
00249 public:
00251 MFVec2f(){};
00253 explicit MFVec2f(const SFString &s);
00254 };
00255
00257 class SFVec3d
00258 {
00259 public:
00260 SFDouble x, y, z;
00262 SFVec3d();
00264 SFVec3d(SFDouble x, SFDouble y, SFDouble z);
00266 explicit SFVec3d(const SFString &s);
00267 };
00268
00270 class MFVec3d : public std::vector<SFVec3d>
00271 {
00272 public:
00274 MFVec3d(){};
00276 explicit MFVec3d(const SFString &s);
00277 };
00278
00280 class MFVec3f : public std::vector<SFVec3f>
00281 {
00282 public:
00284 MFVec3f(){};
00286 explicit MFVec3f(size_type n, const SFVec3f &V = SFVec3f());
00288 explicit MFVec3f(const SFString &s);
00289 };
00290
00292 class SFRotation
00293 {
00294 public:
00295 SFFloat x, y, z, angle;
00297 SFRotation(){};
00299 SFRotation(SFFloat x, SFFloat y, SFFloat z, SFFloat angle);
00301 explicit SFRotation(const SFString &s);
00302
00304 friend bool operator== (const SFRotation &r1, const SFRotation &r2);
00306 friend bool operator!= (const SFRotation &r1, const SFRotation &r2);
00307 };
00308
00309
00311 class MFRotation : public std::vector<SFRotation>
00312 {
00313 public:
00315 MFRotation(){};
00317 explicit MFRotation(const SFString &s);
00318 };
00319
00320
00321
00322 static const double PI = 3.14159265358979323846;
00323 static const double radCoef = 180.0/PI;
00324
00326 inline SFFloat radiansToDegrees(SFFloat alpha)
00327 {
00328 return radCoef*alpha;
00329 }
00330
00331 #ifndef DOXYGEN
00332
00333 struct eqSFString
00334 {
00335 inline bool operator()(const SFString &s1, const SFString &s2) const
00336 {
00337 return s1 == s2;
00338 }
00339 };
00340
00341 struct ltSFString
00342 {
00343 bool operator()(const SFString &s1, const SFString &s2) const
00344 {
00345 return strcmp(s1, s2) < 0;
00346 }
00347 };
00348
00349 }
00350
00351 #endif
00352
00353 namespace X3DTK {
00354
00355
00356 class Type;
00357 class Component;
00358 class CreationFunction;
00359 class WalkingFunction;
00360 class VisitingFunctions;
00361 class EnterFunction;
00362 class WalkOnFunction;
00363 class LeaveFunction;
00364
00365 class X3DComponentCreator;
00367 typedef X3D::SFNode (X3DComponentCreator::* ptrToCreationFunction)() const;
00368
00369 class X3DComponentWalker;
00371 typedef void (X3DComponentWalker::* ptrToWalkingFunction)(SFAbstractNode) const;
00372
00373 class X3DComponentVisitor;
00375 typedef void (X3DComponentVisitor::* ptrToEnterFunction)(SFAbstractNode) const;
00377 typedef bool (X3DComponentVisitor::* ptrToWalkOnFunction)(SFAbstractNode, SFAbstractNode) const;
00379 typedef void (X3DComponentVisitor::* ptrToLeaveFunction)(SFAbstractNode) const;
00380
00382 typedef std::map<SFString, Type *, ltSFString> MFType;
00383
00385 typedef std::map<SFString, Component *, ltSFString> MFComponent;
00387 typedef std::map<SFString, CreationFunction *, ltSFString> CreationDict;
00389 typedef std::map<SFString, WalkingFunction *, ltSFString> WalkingDict;
00391 typedef std::map<SFString, EnterFunction *, ltSFString> EnterDict;
00393 typedef std::map<SFString, WalkOnFunction *, ltSFString> WalkOnDict;
00395 typedef std::map<SFString, LeaveFunction *, ltSFString> LeaveDict;
00396
00398 typedef std::vector<WalkingFunction *> WalkingArray;
00400 typedef std::vector<VisitingFunctions *> VisitingArray;
00401
00402 class X3DNodeProxy;
00403 typedef std::list<X3DNodeProxy *> MFNodeProxy;
00404
00406 std::ostream& operator<<(std::ostream& o, const X3DTK::MFString &ms);
00408 std::ostream& operator<<(std::ostream& o, const X3DTK::MFBool &mb);
00410 std::ostream& operator<<(std::ostream& o, const X3DTK::MFInt32 &mi);
00412 std::ostream& operator<<(std::ostream& o, const X3DTK::MFFloat &mf);
00414 std::ostream& operator<<(std::ostream& o, const X3DTK::MFDouble &md);
00416 std::ostream& operator<<(std::ostream& o, const X3DTK::SFColor &c);
00418 std::ostream& operator<<(std::ostream& o, const X3DTK::MFColor &mc);
00420 std::ostream& operator<<(std::ostream& o, const X3DTK::SFColorRGBA &c);
00422 std::ostream& operator<<(std::ostream& o, const X3DTK::MFColorRGBA &mc);
00424 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec2d &v);
00426 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec2d &mv);
00428 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec2f &v);
00430 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec2f &mv);
00432 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec3d &v);
00434 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec3d &mv);
00436 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec3f &v);
00438 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec3f &mv);
00440 std::ostream& operator<<(std::ostream& o, const X3DTK::SFPoint3f &v);
00442 std::ostream& operator<<(std::ostream& o, const X3DTK::SFRotation &r);
00444 std::ostream& operator<<(std::ostream& o, const X3DTK::MFRotation &mr);
00445
00446 }
00447
00448 #endif