Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

X3DBaseTypes.h

Go to the documentation of this file.
00001 
00002 //                            X3DBaseTypes.h                                  //
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 
00042 class X3DNode;
00043 class X3DAbstractNode;
00044 
00046 class MFString : public std::vector<SFString>
00047 {
00048 public:
00050   MFString(){};
00052   explicit MFString(const SFString &s);
00053 };
00054 
00056 typedef bool SFBool;
00057 
00059 class MFBool : public std::vector<SFBool>
00060 {
00061 public:
00063   MFBool(){};
00065   explicit MFBool(const SFString &s);
00066 };
00067 
00069 typedef int SFInt32;
00070 
00072 class MFInt32 : public std::vector<SFInt32>
00073 {
00074 public:
00076   MFInt32(){};
00078   MFInt32(size_type n, const SFInt32 &V = SFInt32()); 
00080   explicit MFInt32(const SFString &s);
00081 };
00082 
00084 typedef float SFFloat;
00085 
00087 class MFFloat : public std::vector<SFFloat>
00088 {
00089 public:
00091   MFFloat(){};
00093   MFFloat(size_type n, const SFFloat &V = SFFloat());
00095   explicit MFFloat(const SFString &s);
00096 };
00097 
00099 typedef double SFDouble;
00100 
00102 class MFDouble : public std::vector<SFDouble>
00103 {
00104 public:
00106   MFDouble(){};
00108   explicit MFDouble(const SFString &s);
00109 };
00110 
00112 class SFColorRGBA
00113 {
00114 public:
00116   SFFloat r;
00118   SFFloat g;
00120   SFFloat b;
00122   SFFloat a;
00124   SFColorRGBA(){};
00126   SFColorRGBA(SFFloat r, SFFloat g, SFFloat b, SFFloat a);
00128   explicit SFColorRGBA(const SFString &s);
00129   
00131   friend bool operator== (const SFColorRGBA &r1, const SFColorRGBA &r2);
00133   friend bool operator!= (const SFColorRGBA &r1, const SFColorRGBA &r2);
00134 };
00135 
00137 class MFColorRGBA : public std::vector<SFColorRGBA>
00138 {
00139 public:
00141   MFColorRGBA(){};
00143   MFColorRGBA(size_type n, const SFColorRGBA &C = SFColorRGBA());
00145   explicit MFColorRGBA(const SFString &s);
00146 };
00147 
00149 class SFColor
00150 {
00151 public:
00153   SFFloat r;
00155   SFFloat g;
00157   SFFloat b;
00159   SFColor(){};
00161   SFColor(SFFloat r, SFFloat g, SFFloat b);
00163   explicit SFColor(const SFString &s);
00165   operator const SFColorRGBA() const;
00166  
00168   friend bool operator== (const SFColor &r1, const SFColor &r2);
00170   friend bool operator!= (const SFColor &r1, const SFColor &r2);
00171 };
00172 
00173 
00175 class MFColor : public std::vector<SFColor>
00176 {
00177 public:
00179   MFColor(){};
00181   explicit MFColor(const SFString &s);
00182   operator const MFColorRGBA() const;
00183 };
00184 
00186 typedef X3DAbstractNode *SFNode;
00188 typedef std::list<SFNode> MFNode;
00190 typedef std::pair<SFNode, SFNode> SFNodeLink;
00192 typedef std::list<SFNodeLink> MFDNode;
00193 
00195 class SFVec2d
00196 {
00197 public:
00198   SFDouble x, y;
00200   SFVec2d();
00202   SFVec2d(SFDouble x, SFDouble y);
00204   explicit SFVec2d(const SFString &s);
00205 };
00206   
00208 class MFVec2d : public std::vector<SFVec2d>
00209 {
00210 public:
00212   MFVec2d(){};
00214   explicit MFVec2d(const SFString &s);
00215 };
00216   
00218 class SFVec2f
00219 {
00220 public:
00221   SFFloat x, y;
00223   SFVec2f();
00225   SFVec2f(SFFloat x, SFFloat y);
00227   explicit SFVec2f(const SFString &s);
00228 };
00229 
00231 class MFVec2f : public std::vector<SFVec2f>
00232 {
00233 public:
00235   MFVec2f(){};
00237   explicit MFVec2f(const SFString &s);
00238 };
00239 
00241 class SFVec3d
00242 {
00243 public:
00244   SFDouble x, y, z;
00246   SFVec3d();
00248   SFVec3d(SFDouble x, SFDouble y, SFDouble z);
00250   explicit SFVec3d(const SFString &s);    
00251 };
00252 
00254 class MFVec3d : public std::vector<SFVec3d>
00255 {
00256 public:
00258   MFVec3d(){};
00260   explicit MFVec3d(const SFString &s);
00261 };
00262 
00264 class MFVec3f : public std::vector<SFVec3f>
00265 {
00266 public:
00268   MFVec3f(){};
00270   MFVec3f(size_type n, const SFVec3f &V = SFVec3f());
00272   explicit MFVec3f(const SFString &s);
00273 };
00274 
00276 class SFRotation
00277 {
00278 public:
00279   SFFloat x, y, z, angle;
00281   SFRotation(){};
00283   SFRotation(SFFloat x, SFFloat y, SFFloat z, SFFloat angle);
00285   explicit SFRotation(const SFString &s);
00286   
00288   friend bool operator== (const SFRotation &r1, const SFRotation &r2);
00290   friend bool operator!= (const SFRotation &r1, const SFRotation &r2);
00291 };
00292 
00293 
00295 class MFRotation : public std::vector<SFRotation>
00296 {
00297 public:
00299   MFRotation(){};
00301   explicit MFRotation(const SFString &s);
00302 };
00303 
00304 
00305 //constants
00306 static const double PI = 3.14159265358979323846;
00307 static const double radCoef = 180.0/PI;
00308 
00310 inline SFFloat radiansToDegrees(SFFloat alpha)
00311 {
00312   return radCoef*alpha;
00313 }
00314 
00315 #ifndef DOXYGEN
00316 
00317 struct eqSFString
00318 {
00319   inline bool operator()(const SFString &s1, const SFString &s2) const
00320   {
00321     return s1 == s2;
00322   }
00323 };
00324 
00325 class Scene;
00326 
00327 struct ltScene
00328 {
00329   inline bool operator() (Scene *s1, Scene *s2)
00330   {
00331     return s1 < s2;
00332   }
00333 };
00334 
00335 }
00336 
00337 
00338 #if defined(__GNUC__) && (__GNUC__ < 3)
00339 __STL_BEGIN_NAMESPACE
00340 
00341   template<> struct hash<X3DTK::SFString>
00342   {
00343     size_t operator()(const X3DTK::SFString &x) const
00344     {
00345       return hash<const char*>()(x.c_str());
00346     }
00347   };
00348 
00349 __STL_END_NAMESPACE
00350 
00351 #else
00352 namespace __gnu_cxx
00353 {
00354   template<> struct hash<X3DTK::SFString>
00355   {
00356     size_t operator()(const X3DTK::SFString &x) const
00357     {
00358       return hash<const char*>()(x.c_str());
00359     }
00360   };
00361 }
00362 #endif
00363 
00364 #endif
00365 
00366 namespace X3DTK {
00367 
00368 // other types
00369 class Type;
00370 class Component;
00371 class CreationFunction;
00372 class WalkingFunction;
00373 class VisitingFunctions;
00374 class EnterFunction;
00375 class WalkOnFunction;
00376 class LeaveFunction;
00377 
00378 class X3DComponentCreator;
00380 typedef SFNode (X3DComponentCreator::* ptrToCreationFunction)() const;
00381 
00382 class X3DComponentWalker;
00384 typedef void (X3DComponentWalker::* ptrToWalkingFunction)(SFNode) const;
00385 
00386 class X3DComponentVisitor;
00388 typedef void (X3DComponentVisitor::* ptrToEnterFunction)(SFNode) const;
00390 typedef bool (X3DComponentVisitor::* ptrToWalkOnFunction)(SFNode, SFNode) const;
00392 typedef void (X3DComponentVisitor::* ptrToLeaveFunction)(SFNode) const;
00393 
00395 typedef hash_map<SFString, Type *, hash<SFString>, eqSFString> MFType;
00397 typedef hash_map<SFString, Component *, hash<SFString>, eqSFString> MFComponent;
00398 typedef hash_multimap<SFString, SFNode, hash<SFString>, eqSFString> X3DDict;
00399 
00401 typedef hash_map<SFString, CreationFunction *, hash<SFString>, eqSFString> CreationDict;
00403 typedef hash_map<SFString, WalkingFunction *, hash<SFString>, eqSFString> WalkingDict;
00405 typedef hash_map<SFString, EnterFunction *, hash<SFString>, eqSFString> EnterDict;
00407 typedef hash_map<SFString, WalkOnFunction *, hash<SFString>, eqSFString> WalkOnDict;
00409 typedef hash_map<SFString, LeaveFunction *, hash<SFString>, eqSFString> LeaveDict;
00410 
00412 typedef std::vector<WalkingFunction *> WalkingArray;
00414 typedef std::vector<VisitingFunctions *> VisitingArray;
00415 
00416 class X3DNodeProxy;
00417 typedef std::list<X3DNodeProxy *> MFNodeProxy; 
00418 
00419 typedef std::set<Scene *, ltScene> MFScene;
00420 
00422 std::ostream& operator<<(std::ostream& o, const X3DTK::MFString &ms);
00424 std::ostream& operator<<(std::ostream& o, const X3DTK::MFBool &mb);
00426 std::ostream& operator<<(std::ostream& o, const X3DTK::MFInt32 &mi);
00428 std::ostream& operator<<(std::ostream& o, const X3DTK::MFFloat &mf);
00430 std::ostream& operator<<(std::ostream& o, const X3DTK::MFDouble &md);
00432 std::ostream& operator<<(std::ostream& o, const X3DTK::SFColor &c);
00434 std::ostream& operator<<(std::ostream& o, const X3DTK::MFColor &mc);
00436 std::ostream& operator<<(std::ostream& o, const X3DTK::SFColorRGBA &c);
00438 std::ostream& operator<<(std::ostream& o, const X3DTK::MFColorRGBA &mc);
00440 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec2d &v);
00442 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec2d &mv);
00444 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec2f &v);
00446 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec2f &mv);
00448 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec3d &v);
00450 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec3d &mv);
00452 std::ostream& operator<<(std::ostream& o, const X3DTK::SFVec3f &v);
00454 std::ostream& operator<<(std::ostream& o, const X3DTK::MFVec3f &mv);
00456 std::ostream& operator<<(std::ostream& o, const X3DTK::SFPoint3f &v);
00458 std::ostream& operator<<(std::ostream& o, const X3DTK::SFRotation &r);
00460 std::ostream& operator<<(std::ostream& o, const X3DTK::MFRotation &mr);
00461 
00462 }
00463 
00464 #endif

Generated on Wed May 14 10:38:10 2003 for X3DToolKit by doxygen1.3