vtf-logo

IndSimpSet.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_IndSimpSet_h__)
00009 #define __geom_IndSimpSet_h__
00010 
00011 #if defined(DEBUG_geom) && !defined(DEBUG_IndSimpSet)
00012 #define DEBUG_IndSimpSet
00013 #endif
00014 
00015 #include "../../defs.h"
00016 
00017 #include "SimplexIterator.h"
00018 
00019 #include "../simplex/Simplex.h"
00020 
00021 #include "../../../ads/array/Array.h"
00022 
00023 #include <cassert>
00024 
00025 BEGIN_NAMESPACE_GEOM
00026 
00027 // CONTINUE: Perhaps Mutable should be a template parameter.
00029 
00056 template<int _N,
00057          int _M = _N,
00058          bool _A = true,
00059          typename T = double,
00060          typename V = ads::FixedArray<_N,T>,
00061          typename IS = Simplex<_M,int> >
00062 class IndSimpSet {
00063   //
00064   // Enumerations.
00065   //
00066 
00067 public:
00068 
00070   enum {N = _N, M = _M, A = _A};
00071 
00072   //
00073   // Public types.
00074   //
00075 
00076 public:
00077 
00079   typedef T Number;
00081   typedef V Vertex;
00083   typedef Simplex<M,Vertex> Simplex;
00085   typedef typename Simplex::Face SimplexFace;
00086 
00088   typedef IS IndexedSimplex;
00090   typedef typename IndexedSimplex::Face IndexedSimplexFace;
00091 
00093   typedef ads::Array<1,Vertex,A> VertexContainer;
00095   typedef typename VertexContainer::const_iterator VertexConstIterator;
00097   typedef typename VertexContainer::iterator VertexIterator;
00098 
00100   typedef ads::Array<1,IndexedSimplex,A> IndexedSimplexContainer;
00102   typedef typename IndexedSimplexContainer::const_iterator 
00103   IndexedSimplexConstIterator;
00105   typedef typename IndexedSimplexContainer::iterator 
00106   IndexedSimplexIterator;
00107 
00109   typedef SimplexIterator<IndSimpSet> SimplexConstIterator;
00110 
00112   typedef typename VertexContainer::size_type SizeType;
00113 
00114 private:
00115 
00116   //
00117   // Data
00118   //
00119 
00121   VertexContainer _vertices;
00122 
00124   IndexedSimplexContainer _indexedSimplices;
00125 
00126 public:
00127 
00128   //--------------------------------------------------------------------------
00166 
00167 
00169   IndSimpSet() :
00170     _vertices(),
00171     _indexedSimplices()
00172   {}
00173 
00175 
00183   template<bool A1, bool A2>
00184   IndSimpSet
00185   (const ads::Array<1,Vertex,A1>& vertices, 
00186    const ads::Array<1,IndexedSimplex,A2>& indexedSimplices) :
00187     _vertices(vertices),
00188     _indexedSimplices(indexedSimplices)
00189   {}
00190 
00192 
00198   template<bool A1, bool A2>
00199   void
00200   build(const ads::Array<1,Vertex,A1>& vertices, 
00201         const ads::Array<1,IndexedSimplex,A2>& indexedSimplices) {
00202     _vertices = vertices;
00203     _indexedSimplices = indexedSimplices;
00204     updateTopology();
00205   }
00206 
00208 
00221   IndSimpSet(const SizeType numVertices, 
00222              void* vertices,
00223              const SizeType numSimplices, 
00224              void* indexedSimplices) :
00225     _vertices(numVertices, vertices),
00226     _indexedSimplices(numSimplices, indexedSimplices)
00227   {}
00228 
00230 
00238   void
00239   build(const SizeType numVertices, void* vertices,
00240         const SizeType numSimplices, void* indexedSimplices);
00241 
00243 
00256   IndSimpSet(const SizeType numVertices, 
00257              const void* vertices,
00258              const SizeType numSimplices, 
00259              const void* indexedSimplices) :
00260     _vertices(numVertices, vertices),
00261     _indexedSimplices(numSimplices, indexedSimplices)
00262   {
00263     LOKI_STATIC_CHECK(A == true, MustAllocateOwnMemory);
00264   }
00265 
00267 
00275   void
00276   build(const SizeType numVertices, const void* vertices,
00277         const SizeType numSimplices, const void* indexedSimplices);
00278 
00280 
00288   IndSimpSet(const SizeType numVertices, const SizeType numSimplices) :
00289     _vertices(numVertices),
00290     _indexedSimplices(numSimplices)
00291   {}
00292 
00294 
00300   void
00301   build(const SizeType numVertices, const SizeType numSimplices) {
00302     _vertices.resize(numVertices);
00303     _indexedSimplices.resize(numSimplices);
00304   }
00305 
00307   void
00308   swap(IndSimpSet& x) {
00309     _vertices.swap(x._vertices);
00310     _indexedSimplices.swap(x._indexedSimplices);
00311   }
00312 
00314   IndSimpSet(const IndSimpSet& other) :
00315     _vertices(other._vertices),
00316     _indexedSimplices(other._indexedSimplices)
00317   {}
00318 
00320   IndSimpSet&
00321   operator=(const IndSimpSet& other);
00322 
00324   virtual
00325   ~IndSimpSet()
00326   {}
00327 
00329   //--------------------------------------------------------------------------
00332 
00334   int
00335   getSpaceDimension() const {
00336     return N;
00337   }
00338 
00340   SizeType
00341   getVerticesSize() const {
00342     return _vertices.size();
00343   }
00344 
00346   SizeType
00347   areVerticesEmpty() const {
00348     return getVerticesSize() == 0;
00349   }
00350 
00352   VertexConstIterator
00353   getVerticesBeginning() const { 
00354     return _vertices.begin();
00355   }
00356 
00358   VertexConstIterator
00359   getVerticesEnd() const { 
00360     return _vertices.end();
00361   }
00362 
00364   const Vertex&
00365   getVertex(const int n) const {
00366     return _vertices[n];
00367   }
00368 
00370   const VertexContainer&
00371   getVertices() const {
00372     return _vertices;
00373   }
00374 
00376   //--------------------------------------------------------------------------
00379 
00381   int
00382   getSimplexDimension() const {
00383     return M;
00384   }
00385 
00387   SizeType
00388   getSimplicesSize() const {
00389     return _indexedSimplices.size();
00390   }
00391 
00393   SizeType
00394   areSimplicesEmpty() const {
00395     return getSimplicesSize() == 0;
00396   }
00397 
00399   SizeType
00400   isEmpty() const {
00401     return areVerticesEmpty() && areSimplicesEmpty();
00402   }
00403 
00405   IndexedSimplexConstIterator
00406   getIndexedSimplicesBeginning() const { 
00407     return _indexedSimplices.begin();
00408   }
00409 
00411   IndexedSimplexConstIterator
00412   getIndexedSimplicesEnd() const { 
00413     return _indexedSimplices.end();
00414   }
00415 
00417   const IndexedSimplex&
00418   getIndexedSimplex(const int n) const {
00419     return _indexedSimplices[n];
00420   }
00421 
00423   const IndexedSimplexContainer&
00424   getIndexedSimplices() const {
00425     return _indexedSimplices;
00426   }
00427 
00429   SimplexConstIterator
00430   getSimplicesBeginning() const {
00431     return SimplexConstIterator(*this);
00432   }
00433 
00435   SimplexConstIterator
00436   getSimplicesEnd() const {
00437     SimplexConstIterator i(*this);
00438     i += getSimplicesSize();
00439     return i;
00440   }
00441 
00443   const Vertex&
00444   getSimplexVertex(const int n, const int m) const {
00445     return _vertices[_indexedSimplices[n][m]];
00446   }
00447 
00449   void
00450   getSimplex(const int n, Simplex* s) const {
00451     getSimplex(_indexedSimplices.begin() + n, s);
00452   }
00453 
00455   void
00456   getSimplex(IndexedSimplexConstIterator i, Simplex* s) const {
00457     for (int m = 0; m != M+1; ++m) {
00458       (*s)[m] = _vertices[(*i)[m]];
00459     }
00460   }
00461 
00463   //--------------------------------------------------------------------------
00466 
00468   VertexIterator
00469   getVerticesBeginning() { 
00470     return _vertices.begin();
00471   }
00472 
00474   VertexIterator
00475   getVerticesEnd() { 
00476     return _vertices.end();
00477   }
00478 
00480   void
00481   setVertex(const int n, const Vertex& vertex) {
00482     _vertices[n] = vertex;
00483   }
00484 
00486   VertexContainer&
00487   getVertices() {
00488     return _vertices;
00489   }
00490 
00492   //--------------------------------------------------------------------------
00495 
00497   IndexedSimplexIterator
00498   getIndexedSimplicesBeginning() { 
00499     return _indexedSimplices.begin();
00500   }
00501 
00503   IndexedSimplexIterator
00504   getIndexedSimplicesEnd() { 
00505     return _indexedSimplices.end();
00506   }
00507 
00509   IndexedSimplexContainer&
00510   getIndexedSimplices() {
00511     return _indexedSimplices;
00512   }
00513 
00515   //--------------------------------------------------------------------------
00518 
00520 
00524   virtual
00525   void
00526   updateTopology()
00527   {}
00528   
00530 };
00531 
00532 END_NAMESPACE_GEOM
00533 
00534 #define __geom_IndSimpSet_ipp__
00535 #include "IndSimpSet.ipp"
00536 #undef __geom_IndSimpSet_ipp__
00537 
00538 #endif

Generated on Fri Aug 24 12:55:53 2007 for Computational Geometry Package by  doxygen 1.4.7