MESH_SceneGraphTypes.h

Go to the documentation of this file.
00001 #ifndef MESH_SCENEGRAPHTYPES_H
00002 #define MESH_SCENEGRAPHTYPES_H
00003 
00004 #include "Platform.h"
00005 
00006 #include <vector>
00007 #include <map>
00008 #include <set>
00009 #include <list>
00010 #include <iostream>
00011 
00012 namespace X3DTK {
00013 namespace MESH {
00014 
00015 template<class A, class B>
00016 struct ConstMapIterator : public std::map<A, B>::const_iterator
00017 {
00018   typedef typename std::map<A, B>::const_iterator Base;
00019   
00020   ConstMapIterator(const typename std::map<A, B>::const_iterator &it) : Base(it) {}
00021 //  ConstMapIterator(const typename std::map<A, B>::iterator &it) : std::map<A, B>::const_iterator(it) {}
00022   
00023   const B &operator*() const 
00024   {
00025     return (this->Base::operator*()).second;
00026   }  
00027 };
00028 
00029 template<class A, class B>
00030 struct NonConstMapIterator : public std::map<A, B>::iterator
00031 {
00032   typedef typename std::map<A, B>::iterator Base;
00033   
00034   NonConstMapIterator(const typename std::map<A, B>::iterator &it) : Base(it) {}
00035   
00036   B &operator*() const 
00037   {
00038     return (this->Base::operator*()).second;
00039   }  
00040 };
00041 
00042 class X3DNode;
00043 
00044 template<class MData, class VData, class EData, class FData, bool RW> class SFTemplateVertex;
00045 template<class MData, class VData, class EData, class FData, bool RW> class SFTemplateEdge;
00046 template<class MData, class VData, class EData, class FData, bool RW> class SFTemplateFace;
00047 
00053 template<class MData, class VData, class EData, class FData, bool RW>
00054 class EntityMFTemplateVertex : public std::list<SFTemplateVertex<MData, VData, EData, FData, RW> *>
00055 {
00056 public:
00057   typedef typename std::list<SFTemplateVertex<MData, VData, EData, FData, RW> *> Base;
00058   
00060   EntityMFTemplateVertex();
00062   explicit EntityMFTemplateVertex(const std::vector<SFTemplateVertex<MData, VData, EData, FData, RW> *> &vector);
00063 };
00064 
00065 
00071 template<class MData, class VData, class EData, class FData, bool RW>
00072 class MeshMFTemplateVertex : public std::map<unsigned int, SFTemplateVertex<MData, VData, EData, FData, RW> *>
00073 {
00074 public:
00075   typedef typename std::map<unsigned int, SFTemplateVertex<MData, VData, EData, FData, RW> *> Base;
00076 
00077   typedef NonConstMapIterator<unsigned int, SFTemplateVertex<MData, VData, EData, FData, RW> *> iterator;
00078   typedef ConstMapIterator<unsigned int, SFTemplateVertex<MData, VData, EData, FData, RW> *> const_iterator;
00079 
00081   MeshMFTemplateVertex();
00083   explicit MeshMFTemplateVertex(const std::vector<SFTemplateVertex<MData, VData, EData, FData, RW> *> &vector);
00084   
00086   SFTemplateVertex<MData, VData, EData, FData, RW> *const &operator[](const unsigned int &n) const 
00087   {
00088     return (*Base::find(n)).second;
00089   }
00090   
00092   typename std::map<unsigned int, SFTemplateVertex<MData, VData, EData, FData, RW> *>::iterator find(SFTemplateVertex<MData, VData, EData, FData, RW> *const &element)
00093   {
00094     typename Base::iterator it = Base::find(element->getIndex());
00095     if ((*it).second == element)
00096       return it;
00097     return end();  
00098   }
00099   
00101   typename std::map<unsigned int, SFTemplateVertex<MData, VData, EData, FData, RW> *>::const_iterator find(SFTemplateVertex<MData, VData, EData, FData, RW> *const &element) const
00102   {
00103     typename Base::const_iterator it = Base::find(element->getIndex());
00104     if ((*it).second == element)
00105       return it;
00106     return end();  
00107   }
00108 };
00109 
00110 
00116 template<class MData, class VData, class EData, class FData, bool RW>
00117 class EntityMFTemplateEdge : public std::list<SFTemplateEdge<MData, VData, EData, FData, RW> *>
00118 {
00119 public:
00120   typedef typename std::list<SFTemplateEdge<MData, VData, EData, FData, RW> *> Base;
00121 
00123   EntityMFTemplateEdge();
00125   explicit EntityMFTemplateEdge(const std::vector<SFTemplateEdge<MData, VData, EData, FData, RW> *> &vector, bool ccw);
00126 };
00127 
00128 
00134 template<class MData, class VData, class EData, class FData, bool RW>
00135 class MeshMFTemplateEdge : public std::set<SFTemplateEdge<MData, VData, EData, FData, RW> *>
00136 {
00137 public:
00138   typedef typename std::set<SFTemplateEdge<MData, VData, EData, FData, RW> *> Base;
00139 
00141   MeshMFTemplateEdge();
00143   explicit MeshMFTemplateEdge(const std::vector<SFTemplateEdge<MData, VData, EData, FData, RW> *> &vector, bool ccw);
00144 
00146   SFTemplateEdge<MData, VData, EData, FData, RW> *const &operator[](const unsigned int &n) const
00147   {
00148     typename Base::const_iterator it = begin();
00149     for (unsigned int i = 0; i < n; ++i)
00150       ++it;
00151     return *it;  
00152   }
00153 };
00154 
00155 
00161 template<class MData, class VData, class EData, class FData, bool RW>
00162 class EntityMFTemplateFace : public std::list<SFTemplateFace<MData, VData, EData, FData, RW> *>
00163 {
00164 public:
00165   typedef typename std::list<SFTemplateFace<MData, VData, EData, FData, RW> *> Base;
00166 
00168   EntityMFTemplateFace();
00170   explicit EntityMFTemplateFace(const std::vector<SFTemplateFace<MData, VData, EData, FData, RW> *> &vector);
00171 };
00172 
00173 
00179 template<class MData, class VData, class EData, class FData, bool RW>
00180 class MeshMFTemplateFace : public std::map<unsigned int, SFTemplateFace<MData, VData, EData, FData, RW> *>
00181 {
00182 public:
00183   typedef typename std::map<unsigned int, SFTemplateFace<MData, VData, EData, FData, RW> *> Base;
00184 
00185   typedef NonConstMapIterator<unsigned int, SFTemplateFace<MData, VData, EData, FData, RW> *> iterator;
00186   typedef ConstMapIterator<unsigned int, SFTemplateFace<MData, VData, EData, FData, RW> *> const_iterator;
00187 
00189   MeshMFTemplateFace();
00191   explicit MeshMFTemplateFace(const std::vector<SFTemplateFace<MData, VData, EData, FData, RW> *> &vector);
00192 
00194   SFTemplateFace<MData, VData, EData, FData, RW> * const &operator[](const unsigned int &n) const 
00195   {
00196     return (*Base::find(n)).second;
00197   }
00198 
00200   typename std::map<unsigned int, SFTemplateFace<MData, VData, EData, FData, RW> *>::iterator find(SFTemplateFace<MData, VData, EData, FData, RW> *const &element)
00201   {
00202     typename Base::iterator it = Base::find(element->getIndex());
00203     if ((*it).second == element)  
00204       return it;
00205     return end();
00206   }
00208   typename std::map<unsigned int, SFTemplateFace<MData, VData, EData, FData, RW> *>::const_iterator find(SFTemplateFace<MData, VData, EData, FData, RW> *const &element) const
00209   {
00210     typename Base::const_iterator it = Base::find(element->getIndex());
00211     if ((*it).second == element)  
00212       return it;
00213     return end(); 
00214   }
00215 };
00216 
00218 
00219 #ifdef TEMPLATE_SPECIALIZATION_SUPPORTED
00220 
00221 template<class MData, class VData, class EData, class FData>
00222 class EntityMFTemplateVertex<MData, VData, EData, FData, false> : public std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *>
00223 {
00224 public:
00225   typedef typename std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *> Base;
00226 
00228   EntityMFTemplateVertex();
00230   explicit EntityMFTemplateVertex(const std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *> &vector);
00231 };
00232 
00233 template<class MData, class VData, class EData, class FData>
00234 class MeshMFTemplateVertex<MData, VData, EData, FData, false> : public std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *>
00235 {
00236 public:
00237   typedef typename std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *> Base;
00238   
00240   MeshMFTemplateVertex();
00242   explicit MeshMFTemplateVertex(const std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *> &vector);
00243 
00245   std::pair<typename std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *>::iterator, bool> insert(const std::pair<unsigned int, SFTemplateVertex<MData, VData, EData, FData, false> *> &x)
00246   {
00247     if (x.first >= size())
00248       resize(x.first + 1, 0);
00249   
00250     typename Base::iterator it = begin();
00251     it += x.first;
00252     *it = x.second;
00253     
00254     return std::pair<typename Base::iterator, bool>(it, true);
00255   }
00256 
00258   typename std::vector<SFTemplateVertex<MData, VData, EData, FData, false> *>::iterator find(SFTemplateVertex<MData, VData, EData, FData, false> *const &element) const
00259   {
00260     return std::find(begin(), end(), element);
00261   }
00262 
00263 };
00264 
00265 template<class MData, class VData, class EData, class FData>
00266 class EntityMFTemplateEdge<MData, VData, EData, FData, false> : public std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *>
00267 {
00268 public:
00269   typedef typename std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *> Base;
00270 
00272   EntityMFTemplateEdge();
00274   explicit EntityMFTemplateEdge(const std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *> &vector, bool ccw);
00275 };
00276 
00277 template<class MData, class VData, class EData, class FData>
00278 class MeshMFTemplateEdge<MData, VData, EData, FData, false> : public std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *>
00279 {
00280 public:
00281   typedef std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *> Base;
00282   
00284   MeshMFTemplateEdge();
00286   explicit MeshMFTemplateEdge(const std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *> &vector, bool ccw);
00287 
00289   std::pair<typename std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *>::iterator, bool> insert(const typename std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *>::value_type &x)
00290   {
00291     push_back(x);
00292     return std::pair<typename Base::iterator, bool>(end(), true);
00293   }
00294 
00296   typename std::vector<SFTemplateEdge<MData, VData, EData, FData, false> *>::iterator find(SFTemplateEdge<MData, VData, EData, FData, false> *const &element) const
00297   {
00298     return std::find(begin(), end(), element);
00299   }
00300 };
00301 
00302 template<class MData, class VData, class EData, class FData>
00303 class EntityMFTemplateFace<MData, VData, EData, FData, false> : public std::vector<SFTemplateFace<MData, VData, EData, FData, false> *>
00304 {
00305 public:
00306   typedef typename std::vector<SFTemplateFace<MData, VData, EData, FData, false> *> Base;
00307 
00309   EntityMFTemplateFace();
00311   explicit EntityMFTemplateFace(const std::vector<SFTemplateFace<MData, VData, EData, FData, false> *> &vector);
00312 };
00313 
00314 template<class MData, class VData, class EData, class FData>
00315 class MeshMFTemplateFace<MData, VData, EData, FData, false> : public std::vector<SFTemplateFace<MData, VData, EData, FData, false> *>
00316 {
00317 public:
00318   typedef std::vector<SFTemplateFace<MData, VData, EData, FData, false> *> Base;
00319 
00321   MeshMFTemplateFace();
00323   explicit MeshMFTemplateFace(const std::vector<SFTemplateFace<MData, VData, EData, FData, false> *> &vector);
00324 
00326   std::pair<typename Base::iterator, bool> insert(const std::pair<unsigned int, SFTemplateFace<MData, VData, EData, FData, false> *> &x)
00327   {
00328     if (x.first >= size())
00329       resize(x.first + 1, 0);
00330   
00331     typename Base::iterator it = begin();
00332     it += x.first;
00333     *it = x.second;
00334     
00335     return std::pair<typename Base::iterator, bool>(it, true);
00336   }
00337 
00339   typename std::vector<SFTemplateFace<MData, VData, EData, FData, false> *>::iterator find(SFTemplateFace<MData, VData, EData, FData, false> *const &element)
00340   {
00341     return std::find(begin(), end(), element);
00342   }
00344   typename std::vector<SFTemplateFace<MData, VData, EData, FData, false> *>::const_iterator find(SFTemplateFace<MData, VData, EData, FData, false> *const &element) const
00345   {
00346     return std::find(begin(), end(), element);
00347   }
00348 };
00349 
00350 #endif
00351 
00352 }
00353 }
00354 
00355 #include "MESH_SceneGraphTypes.inl"
00356 
00357 #endif

Generated on Fri Jul 30 12:02:28 2004 for X3DToolKit by doxygen 1.3.6