00001 #ifndef NMWR_GB_CELL2D_H
00002 #define NMWR_GB_CELL2D_H
00003
00004
00005
00006
00007 #include "Gral/Grids/Complex2D/complex2d.h"
00008
00009
00010 class Cell2D : public complex2d_types {
00011
00012 public:
00013 cell_handle _pos;
00014 private:
00015 ComplexPtr _cc;
00016
00017 public:
00018 typedef CellNeighbourIterator NeighbourIterator;
00019 typedef EdgeOnCell2D_Iterator EdgeOnCellIterator;
00020
00021 typedef VertexOnCellIterator VertexIterator;
00022 typedef EdgeOnCellIterator EdgeIterator;
00023 typedef FacetOnCellIterator FacetIterator;
00024 typedef Cell2D self;
00025
00026
00027 Cell2D() : _pos(-1), _cc(0) {}
00028 explicit Cell2D(Complex2D const& cc);
00029 Cell2D(Complex2D const& cc, cell_handle pos)
00030 : _pos(pos), _cc(&cc) {}
00031
00032 ~Cell2D() {}
00033
00034
00035
00036
00037
00038 inline VertexOnCellIterator FirstVertex() const;
00039 inline VertexOnCellIterator EndVertex() const;
00040 inline EdgeOnCellIterator FirstEdge() const;
00041 inline EdgeOnCellIterator EndEdge() const;
00042 inline FacetOnCellIterator FirstFacet() const;
00043 inline FacetOnCellIterator EndFacet() const;
00044 inline NeighbourIterator FirstNeighbour() const;
00045 inline NeighbourIterator EndNeighbour() const;
00046 inline NeighbourIterator FirstCell() const;
00047 inline NeighbourIterator EndCell() const;
00048
00049
00050 inline Vertex V(int i) const;
00051 inline Edge E(int i) const;
00052 inline Edge F(int i) const;
00053
00054 int NumOfVertices() const {
00055 REQUIRE((is_valid()),"Cell2D: action with invalid cell!",1);
00056 return (base()._vertices.size());
00057 }
00058 int NumOfEdges() const {return NumOfVertices();}
00059 int NumOfFacets() const {return NumOfVertices();}
00060 int NumOfNeighbours() const;
00061
00062 inline void FlipEdge(const Vertex& v, Edge& e) const;
00063 Edge FlippedEdge(Vertex const& v, Edge const& e) const;
00064
00065 Complex const& TheGrid() const {return (*_cc);}
00066 cell_handle handle() const { return _pos;}
00067
00068
00069
00070 friend bool operator<(const self& s1, const self& s2)
00071 { return (s1._pos < s2._pos);}
00072 friend bool operator==(const self& s1, const self& s2)
00073 { return (s1._pos == s2._pos);}
00074 friend bool operator!=(const self& lhs, const self& rhs)
00075 { return !(lhs == rhs);}
00076
00077 inline bool is_valid() const;
00078 inline bool valid() const { return is_valid();}
00079 private:
00080 friend class VertexOnCell2D_Iterator;
00081 friend class EdgeOnCell2D_Iterator;
00082 friend class CellOnCell2D_Iterator;
00083 friend class Vertex2D;
00084 friend class Edge2D;
00085 friend class Complex2D;
00086
00087 inline vertex_handle vertex(int lv) const;
00088 inline cell_handle cell (int lc) const;
00089
00090 cell2d_connectivity const& base() const;
00091 public:
00092 inline int find_local_facet(const Cell& Nb) const;
00093 inline vertex_handle vertex(unsigned side, const EdgeOnCellIterator& nb) const;
00094
00095 friend ostream& operator <<(ostream& out, self const& rs)
00096 { return (out << rs._pos << ' ' << rs._cc); }
00097
00098 };
00099
00100
00101 #endif
00102