00001 #ifndef X3DTK_X3DBASETYPES_H
00002 #define X3DTK_X3DBASETYPES_H
00003
00004 #include "Platform.h"
00005 #include "SFString.h"
00006 #include "SFVec3f.h"
00007 #include "SFVec2f.h"
00008 #include "SFPoint3f.h"
00009 #include "SFMatrix34f.h"
00010
00011 #include <iostream>
00012 #include <string>
00013 #include <list>
00014 #include <vector>
00015 #include <map>
00016
00018
00019 namespace X3DTK {
00020
00027 class MFString : public std::vector<SFString>
00028 {
00029 public:
00031 MFString() {};
00033 explicit MFString(const SFString &s);
00034 };
00035
00041 typedef bool SFBool;
00042
00049 class MFBool : public std::vector<SFBool>
00050 {
00051 public:
00053 MFBool(){};
00055 explicit MFBool(const SFString &s);
00056 };
00057
00063 typedef int SFInt32;
00064
00071 class MFInt32 : public std::vector<SFInt32>
00072 {
00073 public:
00075 MFInt32(){};
00077 explicit MFInt32(size_type n, const SFInt32 &V = SFInt32());
00079 explicit MFInt32(const SFString &s);
00080 };
00081
00087 typedef float SFFloat;
00088
00095 class MFFloat : public std::vector<SFFloat>
00096 {
00097 public:
00099 MFFloat(){};
00101 explicit MFFloat(size_type n, const SFFloat &V = SFFloat());
00103 explicit MFFloat(const SFString &s);
00104 };
00105
00111 typedef double SFDouble;
00112
00119 class MFDouble : public std::vector<SFDouble>
00120 {
00121 public:
00123 MFDouble(){};
00125 explicit MFDouble(const SFString &s);
00126 };
00127
00133 class SFColorRGBA
00134 {
00135 public:
00137 SFFloat r;
00139 SFFloat g;
00141 SFFloat b;
00143 SFFloat a;
00145 SFColorRGBA(){};
00147 SFColorRGBA(SFFloat r, SFFloat g, SFFloat b, SFFloat a);
00149 explicit SFColorRGBA(const SFString &s);
00150
00152 friend bool operator== (const SFColorRGBA &r1, const SFColorRGBA &r2);
00154 friend bool operator!= (const SFColorRGBA &r1, const SFColorRGBA &r2);
00155
00157 static const SFColorRGBA null;
00158 };
00159
00166 class MFColorRGBA : public std::vector<SFColorRGBA>
00167 {
00168 public:
00170 MFColorRGBA(){};
00172 MFColorRGBA(size_type n, const SFColorRGBA &C = SFColorRGBA());
00174 explicit MFColorRGBA(const SFString &s);
00175 };
00176
00183 class SFColor
00184 {
00185 public:
00187 SFFloat r;
00189 SFFloat g;
00191 SFFloat b;
00193 SFColor(){};
00195 SFColor(SFFloat r, SFFloat g, SFFloat b);
00197 explicit SFColor(const SFString &s);
00199 operator const SFColorRGBA() const;
00200
00202 friend bool operator== (const SFColor &r1, const SFColor &r2);
00204 friend bool operator!= (const SFColor &r1, const SFColor &r2);
00206 static const SFColor null;
00207 };
00208
00209
00216 class MFColor : public std::vector<SFColor>
00217 {
00218 public:
00220 MFColor(){};
00222 explicit MFColor(const SFString &s);
00224 operator const MFColorRGBA() const;
00225 };
00226
00227 class X3DAbstractNode;
00228
00234 typedef X3DAbstractNode *SFAbstractNode;
00235
00242 typedef std::list<X3DAbstractNode *> MFAbstractNode;
00243
00249 class SFVec2d
00250 {
00251 public:
00252 SFDouble x, y;
00254 SFVec2d();
00256 SFVec2d(SFDouble x, SFDouble y);
00258 explicit SFVec2d(const SFString &s);
00259 };
00260
00267 class MFVec2d : public std::vector<SFVec2d>
00268 {
00269 public:
00271 MFVec2d(){};
00273 explicit MFVec2d(const SFString &s);
00274 };
00275
00282 class MFVec2f : public std::vector<SFVec2f>
00283 {
00284 public:
00286 MFVec2f(){};
00288 explicit MFVec2f(size_type n, const SFVec2f &V = SFVec2f());
00290 explicit MFVec2f(const SFString &s);
00291 };
00292
00298 class SFVec3d
00299 {
00300 public:
00301 SFDouble x, y, z;
00303 SFVec3d();
00305 SFVec3d(SFDouble x, SFDouble y, SFDouble z);
00307 explicit SFVec3d(const SFString &s);
00308 };
00309
00316 class MFVec3d : public std::vector<SFVec3d>
00317 {
00318 public:
00320 MFVec3d(){};
00322 explicit MFVec3d(const SFString &s);
00323 };
00324
00331 class MFVec3f : public std::vector<SFVec3f>
00332 {
00333 public:
00335 MFVec3f(){};
00337 explicit MFVec3f(size_type n, const SFVec3f &V = SFVec3f());
00339 explicit MFVec3f(const SFString &s);
00340 };
00341
00348 class SFRotation
00349 {
00350 public:
00351 SFFloat x, y, z, angle;
00353 SFRotation(){};
00355 SFRotation(SFFloat x, SFFloat y, SFFloat z, SFFloat angle);
00357 explicit SFRotation(const SFString &s);
00358
00360 friend bool operator== (const SFRotation &r1, const SFRotation &r2);
00362 friend bool operator!= (const SFRotation &r1, const SFRotation &r2);
00363 };
00364
00365
00372 class MFRotation : public std::vector<SFRotation>
00373 {
00374 public:
00376 MFRotation(){};
00378 explicit MFRotation(const SFString &s);
00379 };
00380
00386 static const double PI = 3.14159265358979323846;
00387
00393 static const double radCoef = 180.0/PI;
00394
00401 inline SFFloat radiansToDegrees(SFFloat alpha)
00402 {
00403 return static_cast<SFFloat>(radCoef*alpha);
00404 }
00405
00406 }
00407
00408 #ifndef DOXYGEN
00409
00410 namespace X3DTK {
00411
00412 struct eqSFString
00413 {
00414 inline bool operator()(const SFString &s1, const SFString &s2) const
00415 {
00416 return s1 == s2;
00417 }
00418 };
00419
00420 struct ltSFString
00421 {
00422 bool operator()(const SFString &s1, const SFString &s2) const
00423 {
00424 return strcmp(s1, s2) < 0;
00425 }
00426 };
00427
00428 }
00429
00430 #endif
00431
00432 namespace X3DTK {
00433
00434
00435 class SFType;
00436 class SFComponent;
00437 class SFSceneGraph;
00438 class WalkFunction;
00439 class VisitingFunctions;
00440 class EnterFunction;
00441 class WalkOnFunction;
00442 class LeaveFunction;
00443
00450 typedef std::map<SFString, SFType *, ltSFString> MFType;
00451
00458 typedef std::map<SFString, SFComponent *, ltSFString> MFComponent;
00459
00466 typedef std::map<SFString, SFSceneGraph *, ltSFString> MFSceneGraph;
00467
00473 typedef std::map<SFString, WalkFunction *, ltSFString> WalkingDict;
00474
00480 typedef std::map<SFString, EnterFunction *, ltSFString> EnterDict;
00481
00487 typedef std::map<SFString, WalkOnFunction *, ltSFString> WalkOnDict;
00488
00494 typedef std::map<SFString, LeaveFunction *, ltSFString> LeaveDict;
00495
00502 typedef std::vector<WalkFunction *> WalkingArray;
00503
00510 typedef std::vector<VisitingFunctions *> VisitingArray;
00511
00513 std::ostream& operator<<(std::ostream& o, const MFString &ms);
00515 std::ostream& operator<<(std::ostream& o, const MFBool &mb);
00517 std::ostream& operator<<(std::ostream& o, const MFInt32 &mi);
00519 std::ostream& operator<<(std::ostream& o, const MFFloat &mf);
00521 std::ostream& operator<<(std::ostream& o, const MFDouble &md);
00523 std::ostream& operator<<(std::ostream& o, const SFColor &c);
00525 std::ostream& operator<<(std::ostream& o, const MFColor &mc);
00527 std::ostream& operator<<(std::ostream& o, const SFColorRGBA &c);
00529 std::ostream& operator<<(std::ostream& o, const MFColorRGBA &mc);
00531 std::ostream& operator<<(std::ostream& o, const SFVec2d &v);
00533 std::ostream& operator<<(std::ostream& o, const MFVec2d &mv);
00535 std::ostream& operator<<(std::ostream& o, const SFVec2f &v);
00537 std::ostream& operator<<(std::ostream& o, const MFVec2f &mv);
00539 std::ostream& operator<<(std::ostream& o, const SFVec3d &v);
00541 std::ostream& operator<<(std::ostream& o, const MFVec3d &mv);
00543 std::ostream& operator<<(std::ostream& o, const SFVec3f &v);
00545 std::ostream& operator<<(std::ostream& o, const MFVec3f &mv);
00547 std::ostream& operator<<(std::ostream& o, const SFPoint3f &v);
00549 std::ostream& operator<<(std::ostream& o, const SFRotation &r);
00551 std::ostream& operator<<(std::ostream& o, const MFRotation &mr);
00553 std::ostream& operator<<(std::ostream& o, const SFMatrix34f &M);
00554
00555 }
00556
00557 #endif