00001
00002
00004
00005 #ifndef X3DBASETYPES_H
00006 #define X3DBASETYPES_H
00007
00008 #include "SFString.h"
00009 #include "SFVec3f.h"
00010 #include "SFPoint3f.h"
00011 #include "SFMatrix34f.h"
00012
00013 #include <iostream>
00014 #include <string>
00015 #include <list>
00016 #include <vector>
00017 #include <map>
00018 #include <set>
00019
00020 #ifndef DOXYGEN
00021
00022 #if defined(__GNUC__) && (__GNUC__ < 3)
00023
00024 #include <hash_map>
00025 using __STD::hash_map;
00026 using __STD::hash_multimap;
00027 using __STD::hash;
00028
00029 #else
00030
00031 #include <ext/hash_map>
00032 using __gnu_cxx::hash_map;
00033 using __gnu_cxx::hash_multimap;
00034 using __gnu_cxx::hash;
00035
00036 #endif
00037
00038 #endif
00039
00040 namespace X3DTK {
00041
00043 class MFString : public std::vector<SFString>
00044 {
00045 public:
00047 MFString(){};
00049 explicit MFString(const SFString &s);
00050 };
00051
00053 typedef bool SFBool;
00054
00056 class MFBool : public std::vector<SFBool>
00057 {
00058 public:
00060 MFBool(){};
00062 explicit MFBool(const SFString &s);
00063 };
00064
00066 typedef int SFInt32;
00067
00069 class MFInt32 : public std::vector<SFInt32>
00070 {
00071 public:
00073 MFInt32(){};
00075 explicit MFInt32(size_type n, const SFInt32 &V = SFInt32());
00077 explicit MFInt32(const SFString &s);
00078 };
00079
00081 typedef float SFFloat;
00082
00084 class MFFloat : public std::vector<SFFloat>
00085 {
00086 public:
00088 MFFloat(){};
00090 explicit MFFloat(size_type n, const SFFloat &V = SFFloat());
00092 explicit MFFloat(const SFString &s);
00093 };
00094
00096 typedef double SFDouble;
00097
00099 class MFDouble : public std::vector<SFDouble>
00100 {
00101 public:
00103 MFDouble(){};
00105 explicit MFDouble(const SFString &s);
00106 };
00107
00109 class SFColorRGBA
00110 {
00111 public:
00113 SFFloat r;
00115 SFFloat g;
00117 SFFloat b;
00119 SFFloat a;
00121 SFColorRGBA(){};
00123 SFColorRGBA(SFFloat r, SFFloat g, SFFloat b, SFFloat a);
00125 explicit SFColorRGBA(const SFString &s);
00126
00128 friend bool operator== (const SFColorRGBA &r1, const SFColorRGBA &r2);
00130 friend bool operator!= (const SFColorRGBA &r1, const SFColorRGBA &r2);
00131 };
00132
00134 class MFColorRGBA : public std::vector<SFColorRGBA>
00135 {
00136 public:
00138 MFColorRGBA(){};
00140 MFColorRGBA(size_type n, const SFColorRGBA &C = SFColorRGBA());
00142 explicit MFColorRGBA(const SFString &s);
00143 };
00144
00146 class SFColor
00147 {
00148 public:
00150 SFFloat r;
00152 SFFloat g;
00154 SFFloat b;
00156 SFColor(){};
00158 SFColor(SFFloat r, SFFloat g, SFFloat b);
00160 explicit SFColor(const SFString &s);
00162 operator const SFColorRGBA() const;
00163
00165 friend bool operator== (const SFColor &r1, const SFColor &r2);
00167 friend bool operator!= (const SFColor &r1, const SFColor &r2);
00168 };
00169
00170
00172 class MFColor : public std::vector<SFColor>
00173 {
00174 public:
00176 MFColor(){};
00178 explicit MFColor(const SFString &s);
00179 operator const MFColorRGBA() const;
00180 };
00181
00182 class X3DAbstractNode;
00184 typedef X3DAbstractNode *SFAbstractNode;
00186 typedef std::list<SFAbstractNode> MFAbstractNode;
00187
00188 namespace X3D {
00189
00190 class X3DNode;
00192 typedef X3DNode *SFNode;
00194 typedef std::list<SFNode> MFNode;
00196 typedef std::pair<SFNode, SFNode> SFNodeLink;
00198 typedef std::list<SFNodeLink> MFDNode;
00199
00200 }
00201
00202 namespace GL {
00203
00204 class X3DNode;
00206 typedef X3DNode *SFNode;
00208 typedef std::list<SFNode> MFNode;
00209
00210 }
00211
00213 class SFVec2d
00214 {
00215 public:
00216 SFDouble x, y;
00218 SFVec2d();
00220 SFVec2d(SFDouble x, SFDouble y);
00222 explicit SFVec2d(const SFString &s);
00223 };
00224
00226 class MFVec2d : public std::vector<SFVec2d>
00227 {
00228 public:
00230 MFVec2d(){};
00232 explicit MFVec2d(const SFString &s);
00233 };
00234
00236 class SFVec2f
00237 {
00238 public:
00239 SFFloat x, y;
00241 SFVec2f();
00243 SFVec2f(SFFloat x, SFFloat y);
00245 explicit SFVec2f(const SFString &s);
00246 };
00247
00249 class MFVec2f : public std::vector<SFVec2f>
00250 {
00251 public:
00253 MFVec2f(){};
00255 explicit MFVec2f(const SFString &s);
00256 };
00257
00259 class SFVec3d
00260 {
00261 public:
00262 SFDouble x, y, z;
00264 SFVec3d();
00266 SFVec3d(SFDouble x, SFDouble y, SFDouble z);
00268 explicit SFVec3d(const SFString &s);
00269 };
00270
00272 class MFVec3d : public std::vector<SFVec3d>
00273 {
00274 public:
00276 MFVec3d(){};
00278 explicit MFVec3d(const SFString &s);
00279 };
00280
00282 class MFVec3f : public std::vector<SFVec3f>
00283 {
00284 public:
00286 MFVec3f(){};
00288 explicit MFVec3f(size_type n, const SFVec3f &V = SFVec3f());
00290 explicit MFVec3f(const SFString &s);
00291 };
00292
00294 class SFRotation
00295 {
00296 public:
00297 SFFloat x, y, z, angle;
00299 SFRotation(){};
00301 SFRotation(SFFloat x, SFFloat y, SFFloat z, SFFloat angle);
00303 explicit SFRotation(const SFString &s);
00304
00306 friend bool operator== (const SFRotation &r1, const SFRotation &r2);
00308 friend bool operator!= (const SFRotation &r1, const SFRotation &r2);
00309 };
00310
00311
00313 class MFRotation : public std::vector<SFRotation>
00314 {
00315 public:
00317 MFRotation(){};
00319 explicit MFRotation(const SFString &s);
00320 };
00321
00322
00323
00324 static const double PI = 3.14159265358979323846;
00325 static const double radCoef = 180.0/PI;
00326
00328 inline SFFloat radiansToDegrees(SFFloat alpha)
00329 {
00330 return radCoef*alpha;
00331 }
00332
00333 #ifndef DOXYGEN
00334
00335 struct eqSFString
00336 {
00337 inline bool operator()(const SFString &s1, const SFString &s2) const
00338 {
00339 return s1 == s2;
00340 }
00341 };
00342
00343 namespace X3D {
00344
00345 class Scene;
00346
00347 struct ltScene
00348 {
00349 inline bool operator() (Scene *s1, Scene *s2)
00350 {
00351 return s1 < s2;
00352 }
00353 };
00354
00355 }
00356
00357 }
00358
00359
00360 #if defined(__GNUC__) && (__GNUC__ < 3)
00361 __STL_BEGIN_NAMESPACE
00362
00363 template<> struct hash<X3DTK::SFString>
00364 {
00365 size_t operator()(const X3DTK::SFString &x) const
00366 {
00367 return hash<const char*>()(x.c_str());
00368 }
00369 };
00370
00371 __STL_END_NAMESPACE
00372
00373 #else
00374 namespace __gnu_cxx
00375 {
00376 template<> struct hash<X3DTK::SFString>
00377 {
00378 size_t operator()(const X3DTK::SFString &x) const
00379 {
00380 return hash<const char*>()(x.c_str());
00381 }
00382 };
00383 }
00384 #endif
00385
00386 #endif
00387
00388 namespace X3DTK {
00389
00390
00391 class Type;
00392 class Component;
00393 class CreationFunction;
00394 class WalkingFunction;
00395 class VisitingFunctions;
00396 class EnterFunction;
00397 class WalkOnFunction;
00398 class LeaveFunction;
00399
00400 class X3DComponentCreator;
00402 typedef X3D::SFNode (X3DComponentCreator::* ptrToCreationFunction)() const;
00403
00404 class X3DComponentWalker;
00406 typedef void (X3DComponentWalker::* ptrToWalkingFunction)(SFAbstractNode) const;
00407
00408 class X3DComponentVisitor;
00410 typedef void (X3DComponentVisitor::* ptrToEnterFunction)(SFAbstractNode) const;
00412 typedef bool (X3DComponentVisitor::* ptrToWalkOnFunction)(SFAbstractNode, SFAbstractNode) const;
00414 typedef void (X3DComponentVisitor::* ptrToLeaveFunction)(SFAbstractNode) const;
00415
00417 typedef hash_map<SFString, Type *, hash<SFString>, eqSFString> MFType;
00419 typedef hash_map<SFString, Component *, hash<SFString>, eqSFString> MFComponent;
00420 typedef hash_multimap<SFString, SFAbstractNode, hash<SFString>, eqSFString> X3DDict;
00421
00423 typedef hash_map<SFString, CreationFunction *, hash<SFString>, eqSFString> CreationDict;
00425 typedef hash_map<SFString, WalkingFunction *, hash<SFString>, eqSFString> WalkingDict;
00427 typedef hash_map<SFString, EnterFunction *, hash<SFString>, eqSFString> EnterDict;
00429 typedef hash_map<SFString, WalkOnFunction *, hash<SFString>, eqSFString> WalkOnDict;
00431 typedef hash_map<SFString, LeaveFunction *, hash<SFString>, eqSFString> LeaveDict;
00432
00434 typedef std::vector<WalkingFunction *> WalkingArray;
00436 typedef std::vector<VisitingFunctions *> VisitingArray;
00437
00438 class X3DNodeProxy;
00439 typedef std::list<X3DNodeProxy *> MFNodeProxy;
00440
00441 namespace X3D {
00442 typedef std::set<Scene *, ltScene> MFScene;
00443 }
00444
00446 std::ostream& operator<<(std::ostream& o, const X3DTK::MFString &ms);
00448 std::ostream& operator<<(std::ostream& o, const X3DTK::MFBool &mb);
00450 std::ostream& operator<<(std::ostream& o, const X3DTK::MFInt32 &mi);
00452 std::ostream& operator<<(std::ostream& o, const X3DTK::MFFloat &mf);
00454 std::ostream& operator<<(std::ostream& o, const X3DTK::MFDouble &md);
00456 std::ostream& operator<<(std::ostream& o, const X3DTK::SFColor &c);
00458 std::ostream& operator<<(std::ostream& o, const X3DTK::MFColor &mc);
00460 std::ostream& operator<<(std::ostream& o, const X3DTK::SFColorRGBA &c);
00462 std::ostream& operator<<(std::ostream& o, const X3DTK::MFColorRGBA &mc);
00464 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec2d &v);
00466 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec2d &mv);
00468 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec2f &v);
00470 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec2f &mv);
00472 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec3d &v);
00474 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec3d &mv);
00476 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec3f &v);
00478 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec3f &mv);
00480 std::ostream& operator<<(std::ostream& o, const X3DTK::SFPoint3f &v);
00482 std::ostream& operator<<(std::ostream& o, const X3DTK::SFRotation &r);
00484 std::ostream& operator<<(std::ostream& o, const X3DTK::MFRotation &mr);
00485
00486 }
00487
00488 #endif