vtf-logo

SimplexAdj.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_SimplexAdj_h__)
00009 #define __geom_SimplexAdj_h__
00010 
00011 #if defined(DEBUG_geom) && !defined(DEBUG_SimplexAdj)
00012 #define DEBUG_SimplexAdj
00013 #endif
00014 
00015 #include "../../defs.h"
00016 
00017 #include "VertexSimplexInc.h"
00018 
00019 #include <vector>
00020 #include <iosfwd>
00021 
00022 BEGIN_NAMESPACE_GEOM
00023 
00025 
00032 template<int M>
00033 class SimplexAdj {
00034   //
00035   // Private types.
00036   //
00037 
00038 private:
00039 
00041   typedef ads::FixedArray<M+1,int> IndexContainer;
00042 
00044   typedef ads::Array<1,IndexContainer> AdjacenciesContainer;
00045 
00046   //
00047   // Data
00048   //
00049 
00050 private:
00051 
00052   // The array of simplex-simplex adjacencies.
00053   AdjacenciesContainer _adj;
00054 
00055 public:
00056 
00057   //--------------------------------------------------------------------------
00059   // @{
00060 
00062   SimplexAdj() :
00063     _adj()
00064   {}
00065 
00067   SimplexAdj(const SimplexAdj& other) :
00068     _adj(other._adj)
00069   {}
00070 
00072   SimplexAdj& 
00073   operator=(const SimplexAdj& other) {
00074     if (&other != this) {
00075       _adj = other._adj;
00076     }
00077     return *this;
00078   }
00079   
00081 
00084   template<typename IS, bool A>
00085   SimplexAdj(const ads::Array<1,IS,A>& simplices,
00086              const VertexSimplexInc<M>& vertexSimplexInc) {
00087     build(simplices, vertexSimplexInc);
00088   }
00089 
00091   template<typename IS, bool A>
00092   void
00093   build(const ads::Array<1,IS,A>& simplices,
00094         const VertexSimplexInc<M>& vertexSimplexInc);
00095 
00097 
00100   template<typename IS, bool A>
00101   SimplexAdj(const int numVertices, const ads::Array<1,IS,A>& simplices) {
00102     build(numVertices, simplices);
00103   }
00104 
00106   template<typename IS, bool A>
00107   void
00108   build(const int numVertices, const ads::Array<1,IS,A>& simplices) {
00109     VertexSimplexInc<M> vsi(numVertices, simplices);
00110     build(simplices, vsi);
00111   }
00112 
00114   void
00115   swap(SimplexAdj& x) {
00116     _adj.swap(x._adj);
00117   }
00118 
00120   ~SimplexAdj()
00121   {}
00122 
00123   // @}
00124   //--------------------------------------------------------------------------
00126   // @{
00127 
00129   const ads::FixedArray<M+1,int>&
00130   operator()(const int n) const {
00131     return _adj[n];
00132   }
00133 
00135   int
00136   operator()(const int n, const int m) const {
00137     return _adj[n][m];
00138   }
00139 
00141   int
00142   getSize() const {
00143     return _adj.size();
00144   }
00145 
00147   int
00148   getSize(const int n) const {
00149     return M + 1 - int(std::count(_adj[n].begin(), _adj[n].end(), -1));
00150   }
00151 
00152   // @}
00153   //--------------------------------------------------------------------------
00155   // @{
00156 
00158   ads::FixedArray<M+1,int>&
00159   operator()(const int n) {
00160     return _adj[n];
00161   }
00162 
00164   void
00165   set(const int n, const int m, const int index) {
00166     _adj[n][m] = index;
00167   }
00168 
00169   // @}
00170   //--------------------------------------------------------------------------
00172 
00173 
00175   bool
00176   operator==(const SimplexAdj& x) const {
00177     return _adj == x._adj;
00178   }
00179 
00181   bool
00182   operator!=(const SimplexAdj& x) const {
00183     return ! operator==(x);
00184   }
00185 
00186   // @}
00187   //--------------------------------------------------------------------------
00189 
00190 
00192   void
00193   put(std::ostream& out) const {
00194     out << _adj;
00195   }
00196 
00198 };
00199 
00200 
00201 //
00202 // File output.
00203 //
00204 
00205 
00207 template<int M>
00208 inline
00209 std::ostream&
00210 operator<<(std::ostream& out, const SimplexAdj<M>& x) {
00211   x.put(out);
00212   return out;
00213 }
00214 
00215 END_NAMESPACE_GEOM
00216 
00217 #define __geom_SimplexAdj_ipp__
00218 #include "SimplexAdj.ipp"
00219 #undef __geom_SimplexAdj_ipp__
00220 
00221 #endif

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