00001 #ifndef GRAL_GB_COMPLEX3D_BOUNDARY_H
00002 #define GRAL_GB_COMPLEX3D_BOUNDARY_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Gral/Base/boundary.h"
00019
00020
00021 #include "Gral/Base/vertex-set.h"
00022 #include "Gral/Base/facet-on-cell-function.h"
00023
00024 #include "Gral/Iterators/cell-on-cell-iterator.h"
00025 #include "Gral/Algorithms/cell-neighbor-search.h"
00026
00027 #include "Container/my-hash-map.h"
00028
00029 #include "Gral/Grids/Complex2D/grid-functions.h"
00030 #include "Gral/Grids/Complex3D/complex3d.h"
00031 #include "Gral/Grids/Complex3D/grid-functions.h"
00032
00033
00034 namespace GrAL {
00035
00036 namespace complex3d_detail {
00037
00038 class BdFacetIterator;
00039
00040 struct basic_grid_types {
00041 typedef grid_types<Complex3D> gt;
00042 typedef facet_on_cell_function<gt::grid_type, gt::cell_handle> nb_table_type;
00043
00044 typedef STDHASH::hash_map<vertex_set<gt::Facet>,
00045 gt::FacetOnCellIterator,
00046 STDEXT::hash<vertex_set<gt::Facet> > > facet_map_type;
00047
00048 typedef BdFacetIterator FacetIterator;
00049 typedef BdFacetIterator FaceIterator;
00050
00051
00052
00053 typedef gt::Vertex Vertex;
00054 typedef gt::Edge Edge;
00055 typedef gt::Face Face;
00056 typedef gt::Facet Facet;
00057
00058 typedef gt::vertex_handle vertex_handle;
00059 typedef gt::edge_handle edge_handle;
00060 typedef gt::face_handle face_handle;
00061 typedef gt::facet_handle facet_handle;
00062
00063 typedef gt::VertexOnFacetIterator VertexOnFacetIterator;
00064 typedef gt::VertexOnFaceIterator VertexOnFaceIterator;
00065 typedef gt::EdgeOnFacetIterator EdgeOnFacetIterator;
00066 typedef gt::EdgeOnFaceIterator EdgeOnFaceIterator;
00067 typedef gt::VertexOnEdgeIterator VertexOnEdgeIterator;
00068 };
00069
00070
00071 }
00072
00084 template<>
00085 class BoundaryRange<Complex3D> : public complex3d_detail::basic_grid_types
00086 {
00087 public:
00088 typedef Complex3D grid_type;
00089 private:
00090 friend class complex3d_detail::BdFacetIterator;
00091
00092 ref_ptr<grid_type const> g;
00093 facet_map_type facet_map;
00094
00095 public:
00097 BoundaryRange() {}
00099 BoundaryRange(grid_type const& gg) : g(gg) { init();}
00100
00102 ref_ptr<grid_type const> TheGrid() const { return g;}
00103
00105 void init()
00106 {
00107 nb_table_type nbs(*TheGrid(), -1);
00108 CalculateNeighborCells(nbs,*TheGrid(),facet_map, gt());
00109 }
00110
00112 FacetIterator FirstFacet() const;
00114 FacetIterator EndFacet() const;
00116 unsigned NumOfFacets() const { return facet_map.size();}
00117 };
00118
00123 template<>
00124 struct grid_types<BoundaryRange<Complex3D> >
00125 : public complex3d_detail::basic_grid_types
00126 {
00127
00128 };
00129
00130 namespace complex3d_detail {
00131
00132
00133 class BdFacetIterator : public basic_grid_types {
00134 typedef BdFacetIterator self;
00135
00136 typedef BoundaryRange<Complex3D> range_type;
00137 typedef facet_map_type::const_iterator range_iter;
00138 ref_ptr<range_type const> rge;
00139 range_iter it;
00140 public:
00141 BdFacetIterator() {}
00142 BdFacetIterator(range_type const& r);
00143 BdFacetIterator(range_type const& r, range_iter i) : rge(r), it(i) {}
00144
00145 self& operator++() { ++it; return *this;}
00146 Facet operator*() const { return val();}
00147 Facet val() const { return *((*it).second);}
00148 inline bool IsDone() const;
00149 facet_handle handle() const { return val().handle();}
00150
00151 gt::VertexOnFacetIterator FirstVertex() const { return val().FirstVertex();}
00152 gt::VertexOnFacetIterator EndVertex() const { return val().EndVertex();}
00153 unsigned NumOfVertices() const { return val().NumOfVertices();}
00154 };
00155
00156
00157 inline BdFacetIterator::BdFacetIterator(BdFacetIterator::range_type const& r)
00158 : rge(r), it(rge->facet_map.begin()) {}
00159
00160 inline bool BdFacetIterator::IsDone() const { return it == rge->facet_map.end();}
00161
00162 }
00163
00164
00165 inline
00166 BoundaryRange<Complex3D>::FacetIterator BoundaryRange<Complex3D>::FirstFacet() const
00167 { return FacetIterator(*this);}
00168
00169 inline
00170 BoundaryRange<Complex3D>::FacetIterator BoundaryRange<Complex3D>::EndFacet() const
00171 { return FacetIterator(*this, facet_map.end());}
00172
00173 }
00174
00175 #endif
00176