00001
00002
00003
00004
00005
00006
00007 #include "algorithm"
00008
00009 inline Complex2D::vertex_handle Complex2D::handle(const Complex2D::Vertex& V) const {
00010 REQUIRE(( &(V.TheGrid()) == this),
00011 "handle(Vertex): V.TheGrid() == "
00012 << &(V.TheGrid()) << " != this = " << this << '\n',1);
00013 return (V._pos);
00014 }
00015
00016 inline Complex2D::vertex_handle Complex2D::handle(const Complex2D::VertexIterator& v) const
00017 { return v._pos;}
00018 inline Complex2D::vertex_handle Complex2D::handle(const Complex2D::VertexOnCellIterator& v) const
00019 { return v.handle();}
00020
00021
00022 inline Complex2D::cell_handle Complex2D::handle(const Complex2D::Cell& C) const {
00023 REQUIRE(( &(C.TheGrid()) == this),
00024 "handle(Cell): C.TheGrid() == "
00025 << &(C.TheGrid()) << " != this = " << this << '\n',1);
00026 return (C._pos);
00027 }
00028
00029 inline Complex2D::cell_handle Complex2D::handle(const Complex2D::CellIterator& c) const
00030 { return c._pos;}
00031 inline Complex2D::cell_handle Complex2D::handle(const Complex2D::CellNeighbourIterator& c) const
00032 { return (_cells[c._f.C.handle()]._neighbours[c._f.lf]); }
00033
00034 inline Edge2D Complex2D::edge(const Complex2D::edge_handle& e) const
00035 { return Edge(EdgeOnCellIterator(e.le,Cell(*this,e.c)));}
00036
00037 inline Edge2D Complex2D::facet(const Complex2D::edge_handle& e) const
00038 { return Edge(EdgeOnCellIterator(e.le,Cell(*this,e.c)));}
00039
00040 inline Complex2D::edge_handle Complex2D::handle(const Edge2D& E) const
00041 {
00042
00043 cell_handle c1 = E._e.C.handle();
00044 cell_handle c2 = _cells[c1]._neighbours[E._e.lf];
00045 if (c1 > c2)
00046 return edge_handle(c1,E._e.lf);
00047 else
00048 return edge_handle(c2, find(_cells[c2]._neighbours.begin(),
00049 _cells[c2]._neighbours.end(), c1)
00050 - _cells[c2]._neighbours.begin());
00051 }
00052
00053 inline bool Complex2D::IsOnBoundary(const EdgeOnCell2D_Iterator& e) const
00054 { return (_cells[e.C.handle()]._neighbours[e.lf] == outer_cell_handle());}
00055 inline bool Complex2D::IsOnBoundary(const Edge2D& e) const
00056 { return (IsOnBoundary(e._e));}
00057
00058
00059
00060
00061
00062 inline Complex2D::VertexIterator Complex2D::FirstVertex() const
00063 { return VertexIterator(*this,0);}
00064
00065 inline Complex2D::VertexIterator Complex2D::EndVertex() const
00066 { return VertexIterator(*this, NumOfVertices());}
00067
00068
00069 inline Complex2D::EdgeIterator Complex2D::FirstEdge() const
00070 {
00071 CellIterator FC(FirstCell());
00072 if( ! FC.IsDone())
00073 return EdgeIterator(FC,(*(FC)).FirstEdge());
00074 else
00075 return EdgeIterator(FC,EdgeOnCellIterator());
00076 }
00077 inline Complex2D::EdgeIterator Complex2D::EndEdge() const
00078 { return EdgeIterator(EndCell(), EdgeOnCellIterator()); }
00079
00080 inline Complex2D::EdgeIterator Complex2D::FirstFacet() const
00081 { return FirstEdge();}
00082 inline Complex2D::EdgeIterator Complex2D::EndFacet() const
00083 { return EndEdge();}
00084
00085 inline void Complex2D::switch_vertex(Complex2D::Vertex & v,
00086 Complex2D::Edge const& e) const
00087 { e.FlipVertex(v);}
00088
00089 inline void Complex2D::switch_edge(Complex2D::Vertex const& v,
00090 Complex2D::Edge & e,
00091 Complex2D::Cell const& c) const
00092 { c.FlipEdge(v,e);}
00093
00094
00095 inline void Complex2D::switch_cell(Complex2D::Edge const& e,
00096 Complex2D::Cell & c) const
00097 { e.FlipCell(c);}
00098
00099 inline Complex2D::Vertex
00100 Complex2D::switched_vertex(Complex2D::Vertex const& v,
00101 Complex2D::Edge const& e) const
00102 { Vertex sv(v); switch_vertex(sv,e); return sv;}
00103
00104 inline Complex2D::Edge
00105 Complex2D::switched_edge(Complex2D::Vertex const& v,
00106 Complex2D::Edge const& e,
00107 Complex2D::Cell const& c) const
00108 { Edge se(e); switch_edge(v,se,c); return se;}
00109
00110 inline Complex2D::Facet
00111 Complex2D::switched_facet(Complex2D::Vertex const& v,
00112 Complex2D::Edge const& e,
00113 Complex2D::Cell const& c) const
00114 { Edge se(e); switch_edge(v,se,c); return se;}
00115
00116 inline Complex2D::Cell
00117 Complex2D::switched_cell(Complex2D::Edge const& e,
00118 Complex2D::Cell const& c) const
00119 { Cell sc(c); switch_cell(e,sc); return sc;}
00120
00121
00122 inline Complex2D::BoundaryFacetIterator Complex2D::FirstBoundaryFacet() const
00123 { return BoundaryFacetIterator(_boundary.begin(),this);}
00124
00125 inline Complex2D::BoundaryFacetIterator Complex2D::FirstBoundaryEdge() const
00126 { return BoundaryFacetIterator(_boundary.begin(),this);}
00127
00128 inline Complex2D::BoundaryVertexIterator Complex2D::FirstBoundaryVertex() const
00129 {
00130
00131
00132 if (! FirstBoundaryFacet().IsDone()) {
00133 return BoundaryVertexIterator(* (FirstBoundaryFacet()));
00134 }
00135 else
00136 return BoundaryVertexIterator();
00137 }
00138
00139 inline Complex2D::CellIterator Complex2D::FirstCell() const
00140 { return CellIterator(0,*this);}
00141 inline Complex2D::CellIterator Complex2D::EndCell() const
00142 { return CellIterator(NumOfCells(),*this);}
00143
00144
00145
00146
00147 inline Complex2D::cell_handle Complex2D::_new_cell(int num_of_v)
00148 {
00149 _cells.push_back(cell2d_connectivity());
00150 _cells.back().resize(num_of_v);
00151 return (_cells.size() -1);
00152 }
00153
00154 inline Complex2D::vertex_handle Complex2D::_new_vertex(const Complex2D::CoordType& coo)
00155 {
00156 _vertices.push_back(vertex_base(coo));
00157 _vertices.back().reserve(4);
00158 return (_vertices.size() -1);
00159 }
00160
00161
00162
00163
00164 inline void Complex2D::set_neighbour(const Complex2D::EdgeOnCellIterator& n1_it,
00165 const Complex2D::Cell& n2)
00166 { _cells[n1_it.C.handle()]._neighbours[n1_it.lf] = handle(n2);}
00167
00168 inline void Complex2D::add_cell_on_vertex(const Complex2D::Vertex& V, const Complex2D::Cell& C)
00169 { add_cell_on_vertex(V,handle(C)); }
00170
00171 inline void Complex2D::add_cell_on_vertex(const Complex2D::Vertex& V, const Complex2D::cell_handle& c)
00172 { _vertices[handle(V)]._cells.push_back(c);}
00173
00174
00175
00176
00177 inline const Complex2D::CoordType& Complex2D::Coord(const Complex2D::Vertex& v) const
00178 { return (_vertices[v._pos]._coord); }
00179
00180 inline Complex2D::CoordType& Complex2D::Coord(const Complex2D::Vertex& v)
00181 { return (_vertices[v._pos]._coord);}
00182
00183