X3DBaseTypes.h

Go to the documentation of this file.
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 "SFPoint2f.h"
00010 #include "SFMatrix34f.h"
00011 
00012 #include <iostream>
00013 #include <string>
00014 #include <list>
00015 #include <vector>
00016 #include <map>
00017 
00019 
00020 namespace X3DTK {
00021 
00028 class nil {};
00029 
00036 class MFString : public std::vector<SFString>
00037 {
00038 public:
00040   MFString() {};
00042   explicit MFString(const SFString &s);
00044   SFString toSFString() const;
00045 };
00046 
00052 typedef bool SFBool;
00053 
00060 class MFBool : public std::vector<SFBool>
00061 {
00062 public:
00064   MFBool(){};
00066   explicit MFBool(const SFString &s);
00068   SFString toSFString() const;
00069 };
00070 
00076 typedef int SFInt32;
00077 
00084 class MFInt32 : public std::vector<SFInt32>
00085 {
00086 public:
00088   MFInt32(){};
00090   explicit MFInt32(size_type n, const SFInt32 &V = SFInt32()); 
00092   explicit MFInt32(const SFString &s);
00094   SFString toSFString() const;
00095 };
00096 
00102 typedef float SFFloat;
00103 
00110 class MFFloat : public std::vector<SFFloat>
00111 {
00112 public:
00114   MFFloat(){};
00116   explicit MFFloat(size_type n, const SFFloat &V = SFFloat());
00118   explicit MFFloat(const SFString &s);
00120   SFString toSFString() const;
00121 };
00122 
00128 typedef double SFDouble;
00129 
00136 class MFDouble : public std::vector<SFDouble>
00137 {
00138 public:
00140   MFDouble(){};
00142   explicit MFDouble(const SFString &s);
00144   SFString toSFString() const;
00145 };
00146 
00147 class SFColor;
00148 
00154 class SFColorRGBA
00155 {
00156 public:
00158   SFFloat r;
00160   SFFloat g;
00162   SFFloat b;
00164   SFFloat a;
00166   SFColorRGBA(){};
00168   SFColorRGBA(const SFColor &color);
00170   SFColorRGBA(SFFloat r, SFFloat g, SFFloat b, SFFloat a);
00172   explicit SFColorRGBA(const SFString &s);
00174   inline float *f_data() {return &r;};
00176   inline const float *f_data() const {return &r;};
00178   inline operator float *() {return &r;};
00180   inline operator const float *() const {return &r;};
00181  
00183   friend bool operator== (const SFColorRGBA &r1, const SFColorRGBA &r2);
00185   friend bool operator!= (const SFColorRGBA &r1, const SFColorRGBA &r2);
00187   SFString toSFString() const;  
00188   
00190   static const SFColorRGBA null;
00191 };
00192 
00199 class MFColorRGBA : public std::vector<SFColorRGBA>
00200 {
00201 public:
00203   MFColorRGBA(){};
00205   MFColorRGBA(size_type n, const SFColorRGBA &C = SFColorRGBA());
00207   explicit MFColorRGBA(const SFString &s);
00209   SFString toSFString() const;
00210 };
00211 
00218 class SFColor
00219 {
00220 public:
00222   SFFloat r;
00224   SFFloat g;
00226   SFFloat b;
00228   SFColor(){};
00230   SFColor(SFFloat r, SFFloat g, SFFloat b);
00232   explicit SFColor(const SFString &s);
00234   inline float *f_data() {return &r;};
00236   inline const float *f_data() const {return &r;};
00238   inline operator float *() {return &r;};
00240   inline operator const float *() const {return &r;};
00241  
00243   friend bool operator== (const SFColor &r1, const SFColor &r2);
00245   friend bool operator!= (const SFColor &r1, const SFColor &r2);
00247   SFString toSFString() const;
00248   
00250   static const SFColor null;
00251 };
00252 
00259 class MFColor : public std::vector<SFColor>
00260 {
00261 public:
00263   MFColor(){};
00265   explicit MFColor(const SFString &s);
00267   operator const MFColorRGBA() const;
00269   SFString toSFString() const;
00270 };
00271 
00272 class X3DAbstractNode;
00273 
00279 typedef X3DAbstractNode *SFNode;
00280 
00287 typedef std::list<X3DAbstractNode *> MFNode;
00288 
00294 class SFVec2d
00295 {
00296 public:
00297   SFDouble x, y;
00299   SFVec2d();
00301   SFVec2d(SFDouble x, SFDouble y);
00303   explicit SFVec2d(const SFString &s);
00305   SFString toSFString() const;
00306 };
00307   
00314 class MFVec2d : public std::vector<SFVec2d>
00315 {
00316 public:
00318   MFVec2d(){};
00320   explicit MFVec2d(const SFString &s);
00322   SFString toSFString() const;
00323 };
00324   
00331 class MFVec2f : public std::vector<SFVec2f>
00332 {
00333 public:
00335   MFVec2f(){};
00337   explicit MFVec2f(size_type n, const SFVec2f &V = SFVec2f());
00339   explicit MFVec2f(const SFString &s);
00341   SFString toSFString() const;
00342 };
00343 
00350 class MFPoint2f : public std::vector<SFPoint2f>
00351 {
00352 public:
00354   MFPoint2f(){};
00356   explicit MFPoint2f(size_type n, const SFPoint2f &V = SFPoint2f());
00358   explicit MFPoint2f(const SFString &s);
00360   SFString toSFString() const;
00361 };
00362 
00368 class SFVec3d
00369 {
00370 public:
00371   SFDouble x, y, z;
00373   SFVec3d();
00375   SFVec3d(SFDouble x, SFDouble y, SFDouble z);
00377   explicit SFVec3d(const SFString &s);    
00379   SFString toSFString() const;
00380 };
00381 
00388 class MFVec3d : public std::vector<SFVec3d>
00389 {
00390 public:
00392   MFVec3d(){};
00394   explicit MFVec3d(const SFString &s);
00396   SFString toSFString() const;
00397 };
00398 
00405 class MFVec3f : public std::vector<SFVec3f>
00406 {
00407 public:
00409   MFVec3f(){};
00411   explicit MFVec3f(size_type n, const SFVec3f &V = SFVec3f());
00413   explicit MFVec3f(const SFString &s);
00415   SFString toSFString() const;
00416 };
00417 
00424 class MFPoint3f : public std::vector<SFPoint3f>
00425 {
00426 public:
00428   MFPoint3f(){};
00430   explicit MFPoint3f(size_type n, const SFPoint3f &V = SFPoint3f());
00432   explicit MFPoint3f(const SFString &s);
00434   SFString toSFString() const;
00435 };
00436 
00443 class SFRotation
00444 {
00445 public:
00446   SFFloat x, y, z, angle;
00448   SFRotation(){};
00450   SFRotation(SFFloat x, SFFloat y, SFFloat z, SFFloat angle);
00452   explicit SFRotation(const SFString &s);
00454   SFString toSFString() const;
00455   
00457   friend bool operator== (const SFRotation &r1, const SFRotation &r2);
00459   friend bool operator!= (const SFRotation &r1, const SFRotation &r2);
00460 };
00461 
00462 
00469 class MFRotation : public std::vector<SFRotation>
00470 {
00471 public:
00473   MFRotation(){};
00475   explicit MFRotation(const SFString &s);
00477   SFString toSFString() const;
00478 };
00479 
00485 static const double PI = 3.14159265358979323846;
00486 
00492 static const double radCoef = 180.0/PI;
00493 
00500 inline SFFloat radiansToDegrees(SFFloat alpha)
00501 {
00502   return static_cast<SFFloat>(radCoef*alpha);
00503 }
00504 
00505 }
00506 
00507 #ifndef DOXYGEN
00508 
00509 namespace X3DTK {
00510 
00511 struct eqSFString
00512 {
00513   inline bool operator()(const SFString &s1, const SFString &s2) const
00514   {
00515     return s1 == s2;
00516   }
00517 };
00518 
00519 struct ltSFString
00520 {
00521   bool operator()(const SFString &s1, const SFString &s2) const
00522   {
00523     return strcmp(s1, s2) < 0;
00524   }
00525 };
00526 
00527 }
00528 
00529 #endif
00530 
00531 namespace X3DTK {
00532 
00533 // other types
00534 class SFType;
00535 class SFComponent;
00536 class SFSceneGraph;
00537 class WalkFunction;
00538 class VisitingFunctions;
00539 class EnterFunction;
00540 class WalkOnFunction;
00541 class CreationFunction;
00542 class LeaveFunction;
00543 
00550 typedef std::map<SFString, SFType *, ltSFString> MFType;
00551 
00558 typedef std::map<SFString, SFComponent *, ltSFString> MFComponent;
00559 
00566 typedef std::map<SFString, SFSceneGraph *, ltSFString> MFSceneGraph;
00567 
00573 typedef std::map<SFString, WalkFunction *, ltSFString> WalkingDict;
00574 
00580 typedef std::map<SFString, EnterFunction *, ltSFString> EnterDict;
00581 
00587 typedef std::map<SFString, WalkOnFunction *, ltSFString> WalkOnDict;
00588 
00594 typedef std::map<SFString, LeaveFunction *, ltSFString> LeaveDict;
00595 
00601 typedef std::map<SFString, CreationFunction *, ltSFString> CreationDict;
00602 
00603 
00610 typedef std::vector<WalkFunction *> WalkingArray;
00611 
00618 typedef std::vector<VisitingFunctions *> VisitingArray;
00619 
00621 std::ostream& operator<<(std::ostream& o, const MFString &ms);
00623 std::ostream& operator<<(std::ostream& o, const MFBool &mb);
00625 std::ostream& operator<<(std::ostream& o, const MFInt32 &mi);
00627 std::ostream& operator<<(std::ostream& o, const MFFloat &mf);
00629 std::ostream& operator<<(std::ostream& o, const MFDouble &md);
00631 std::ostream& operator<<(std::ostream& o, const SFColor &c);
00633 std::ostream& operator<<(std::ostream& o, const MFColor &mc);
00635 std::ostream& operator<<(std::ostream& o, const SFColorRGBA &c);
00637 std::ostream& operator<<(std::ostream& o, const MFColorRGBA &mc);
00639 std::ostream& operator<<(std::ostream& o, const SFVec2d &v);
00641 std::ostream& operator<<(std::ostream& o, const MFVec2d &mv);
00643 std::ostream& operator<<(std::ostream& o, const SFVec2f &v);
00645 std::ostream& operator<<(std::ostream& o, const MFVec2f &mv);
00647 std::ostream& operator<<(std::ostream& o, const SFVec3d &v);
00649 std::ostream& operator<<(std::ostream& o, const MFVec3d &mv);
00651 std::ostream& operator<<(std::ostream& o, const SFVec3f &v);
00653 std::ostream& operator<<(std::ostream& o, const MFVec3f &mv);
00655 std::ostream& operator<<(std::ostream& o, const SFPoint3f &v);
00657 std::ostream& operator<<(std::ostream& o, const SFRotation &r);
00659 std::ostream& operator<<(std::ostream& o, const MFRotation &mr);
00661 std::ostream& operator<<(std::ostream& o, const SFMatrix34f &M);
00662 
00663 }
00664 
00665 #endif

Generated on Fri Aug 27 13:16:23 2004 for X3DToolKit by doxygen 1.3.6