00001 #ifndef GRAL_GB_GRIDS_COMPLEX2D_H
00002 #define GRAL_GB_GRIDS_COMPLEX2D_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00024 #include <list>
00025 #include <vector>
00026
00027 #include "Utility/pre-post-conditions.h"
00028 #include "Gral/Grids/Complex2D/point.h"
00029
00030 #include "Gral/Base/common-grid-basics.h"
00031 #include "Gral/Base/element-handle.h"
00032
00033 #include "Gral/Base/polygon.h"
00034
00035
00036
00037 namespace GrAL {
00038
00039 class Complex2D;
00040 class Vertex2D;
00041 class Edge2D;
00042 class Cell2D;
00043
00044 class Vertex2D_Iterator;
00045 class Edge2D_Iterator;
00046 class Cell2D_Iterator;
00047 class BoundaryFacet2D_Iterator;
00048 class BoundaryComponent_Vertex2D_Iterator;
00049
00050 class VertexOnEdge2D_Iterator;
00051 class CellOnEdge2D_Iterator;
00052
00053 class VertexOnCell2D_Iterator;
00054 class EdgeOnCell2D_Iterator;
00055 class CellOnCell2D_Iterator;
00056
00057
00058 class CellOnVertex2D_Iterator;
00059 struct edge_handle_complex2d;
00060
00061
00062 struct complex2d_types : public grid_types_detail::grid_types_root {
00063
00064 typedef grid_dim_tag<2> dimension_tag;
00065
00066 typedef complex2d_types self;
00067 typedef Complex2D Complex;
00068 typedef Complex2D grid_type;
00069 typedef const Complex2D* ComplexPtr;
00070
00071 typedef Vertex2D Vertex;
00072 typedef Edge2D Edge;
00073 typedef Edge2D Facet;
00074 typedef Cell2D Cell;
00075 typedef Cell2D Face;
00076
00077
00078 typedef vertex_handle_int<Complex2D,self> vertex_handle;
00079 typedef cell_handle_int<Complex2D,self> cell_handle;
00080 typedef edge_handle_complex2d edge_handle;
00081 typedef edge_handle_complex2d facet_handle;
00082
00083
00084 typedef Vertex2D_Iterator GridVertexIterator;
00085 typedef Edge2D_Iterator GridEdgeIterator;
00086 typedef Edge2D_Iterator GridFacetIterator;
00087 typedef Cell2D_Iterator GridCellIterator;
00088
00089 typedef VertexOnEdge2D_Iterator VertexOnEdgeIterator;
00090 typedef VertexOnEdge2D_Iterator VertexOnFacetIterator;
00091 typedef CellOnEdge2D_Iterator CellOnEdgeIterator;
00092 typedef CellOnEdge2D_Iterator CellOnFacetIterator;
00093
00094
00095
00096 typedef VertexOnCell2D_Iterator VertexOnCellIterator;
00097 typedef EdgeOnCell2D_Iterator EdgeOnCellIterator;
00098 typedef EdgeOnCell2D_Iterator FacetOnCellIterator;
00099 typedef CellOnCell2D_Iterator CellNeighbourIterator;
00100 typedef CellOnCell2D_Iterator CellOnCellIterator;
00101
00102 typedef CellOnVertex2D_Iterator CellOnVertexIterator;
00103
00104 typedef polygon1d::polygon archetype_type;
00105 typedef std::vector<archetype_type> archetype_sequence;
00106 typedef archetype_sequence::const_iterator archetype_iterator;
00107 typedef int archetype_handle;
00108 typedef grid_types<archetype_type> archgt;
00109
00110 };
00111
00112
00113
00114
00115
00116
00117
00118 class vertex_base {
00119 public:
00120 typedef point2 CoordType;
00121 typedef complex2d_types::size_type size_type;
00122
00123 typedef std::vector<size_type> cell_list;
00124 private:
00125
00126
00127 CoordType _coord;
00128 cell_list _cells;
00129
00130 void reserve(unsigned n) { _cells.reserve(n);}
00131
00132 typedef vertex_base self;
00133 public:
00134
00135 vertex_base() : _coord(0.0), _cells() {}
00136 vertex_base(unsigned n) : _coord(0.0), _cells() { reserve(n);}
00137 vertex_base(const CoordType& coord)
00138 : _coord(coord), _cells() {}
00139
00140
00141 vertex_base(const vertex_base& rs) : _coord(rs._coord), _cells(rs._cells) {}
00142 vertex_base& operator=(const vertex_base& rs) {
00143 if (this != &rs) {
00144 _coord = rs._coord;
00145 _cells = rs._cells;
00146 }
00147 return *this;
00148 }
00149
00150 private:
00151 friend class Complex2D;
00152 friend class Vertex2D;
00153 };
00154
00155
00156
00157 class cell2d_connectivity {
00158 typedef complex2d_types::size_type size_type;
00159 public:
00160 typedef std::vector<size_type> vertex_list;
00161 typedef std::vector<size_type> cell_list;
00162
00163
00164
00165
00166
00167
00168
00169
00170 cell_list _neighbours;
00171 vertex_list _vertices;
00172
00173 void resize(size_type n) {
00174 _neighbours = cell_list(n);
00175 _vertices = vertex_list(n);
00176 }
00177
00178
00179 typedef cell2d_connectivity self;
00180 public:
00181
00182 cell2d_connectivity() {}
00183 cell2d_connectivity(size_type n) : _neighbours(n), _vertices(n) {}
00184 ~cell2d_connectivity() {}
00185
00186
00187 cell2d_connectivity(const self& rs)
00188 : _neighbours(rs._neighbours), _vertices(rs._vertices) {}
00189 self& operator=(const self& rs) {
00190 if(this != &rs) {
00191 _neighbours = rs._neighbours;
00192 _vertices = rs._vertices;
00193 }
00194 return (*this);
00195 }
00196
00197 private:
00198 friend class friend_for_input;
00199 friend class EdgeOnCell2D_Iterator;
00200 friend class Complex2D;
00201 friend class Cell2D;
00202 };
00203
00204
00205
00206
00207 typedef std::vector<cell2d_connectivity> cell_list_complex2d;
00208 typedef std::vector<vertex_base> vertex_list_complex2d;
00209
00210 struct edge_handle_complex2d {
00211 typedef complex2d_types::cell_handle cell_handle;
00212 cell_handle c;
00213
00214 int le;
00215 edge_handle_complex2d() {}
00216 edge_handle_complex2d(cell_handle cc, int lle) : c(cc), le(lle) {}
00217
00218 int local_facet() const { return le;}
00219
00220 typedef edge_handle_complex2d self;
00221 friend bool operator==(const self& ls, const self& rs)
00222 { return ((ls.c == rs.c) && (ls.le == rs.le)); }
00223 friend bool operator!=(const self& ls, const self& rs)
00224 { return !(ls == rs);}
00225 friend bool operator< (const self& ls, const self& rs)
00226 { return ((ls.c <rs.c) || ((ls.c == rs.c) && (ls.le < rs.le))); }
00227
00228 friend ::std::ostream& operator<< (::std::ostream& out, const self& e)
00229 { return (out << e.c << ' ' << e.le);}
00230 friend ::std::istream& operator>>(::std::istream& in, self& e)
00231 { return (in >> e.c >> e.le);}
00232 };
00233
00234 }
00235
00236 namespace STDEXT {
00237 template<class T> class hash;
00238
00239 template<>
00240 struct hash<GrAL::edge_handle_complex2d> {
00241 public:
00242 typedef GrAL::edge_handle_complex2d key_type;
00243 typedef GrAL::edge_handle_complex2d argument_type;
00244 typedef size_t result_type;
00245
00246 size_t operator()(const GrAL::edge_handle_complex2d& e) const
00247 { return (6*e.c + e.le);}
00248 };
00249
00250 }
00251
00252
00253 #include "Gral/Grids/Complex2D/internal/vertex2d.h"
00254 #include "Gral/Grids/Complex2D/internal/cell2d.h"
00255 #include "Gral/Grids/Complex2D/internal/cell-on-cell2d-it.h"
00256 #include "Gral/Grids/Complex2D/internal/cell-on-vertex2d-it.h"
00257 #include "Gral/Grids/Complex2D/internal/edge-on-cell2d-it.h"
00258
00259 namespace GrAL {
00260
00299 class Complex2D : public complex2d_types {
00300 typedef Complex2D self;
00301
00302 typedef std::list<EdgeOnCell2D_Iterator> boundary_facet_list;
00303 typedef vertex_list_complex2d v_list;
00304 typedef cell_list_complex2d c_list;
00305
00306
00307
00308 public:
00309 cell_list_complex2d _cells;
00310 vertex_list_complex2d _vertices;
00311 boundary_facet_list _boundary;
00312
00313 mutable size_type num_of_edges_cache;
00314 archetype_sequence archetypes;
00315 std::vector<archetype_handle> arch_for_n_vertices;
00316 public:
00317 typedef self grid_type;
00318 typedef grid_category_d<2> category;
00319
00320
00321
00322
00323 typedef Vertex2D_Iterator VertexIterator;
00324 typedef Edge2D_Iterator EdgeIterator;
00325 typedef Edge2D_Iterator FacetIterator;
00326 typedef Cell2D_Iterator CellIterator;
00327 typedef Cell2D_Iterator FaceIterator;
00328
00329 typedef BoundaryFacet2D_Iterator BoundaryFacetIterator;
00330 typedef BoundaryComponent_Vertex2D_Iterator BoundaryVertexIterator;
00331
00332 typedef vertex_base::CoordType CoordType;
00333
00334
00336 Complex2D();
00337 Complex2D(const Complex2D& rhs);
00338 Complex2D& operator=(const Complex2D& rhs);
00339 ~Complex2D();
00341 private:
00342 void clear();
00343 public:
00344
00345
00346 self const& TheGrid() const { return *this;}
00347 self & TheGrid() { return *this;}
00348
00350 enum { dim = 2};
00351 unsigned dimension() const { return 2;}
00353
00355 inline VertexIterator FirstVertex() const;
00356 inline VertexIterator EndVertex() const;
00357
00358 inline EdgeIterator FirstEdge() const;
00359 inline EdgeIterator EndEdge() const;
00360
00361 inline FacetIterator FirstFacet() const;
00362 inline FacetIterator EndFacet() const;
00363
00364 inline CellIterator FirstCell() const;
00365 inline CellIterator EndCell() const;
00366
00367 inline FaceIterator FirstFace() const;
00368 inline FaceIterator EndFace() const;
00370
00372 inline void switch_vertex(Vertex& v, Edge const& e) const;
00373 inline void switch_edge(Vertex const& v, Edge & e, Cell const& c) const;
00374 inline void switch_facet(Vertex const& v, Edge & e, Cell const& c) const
00375 { switch_edge(v,e,c);}
00376 inline void switch_cell(Edge const& e, Cell & c) const;
00377
00378 inline Vertex switched_vertex(Vertex const& v, Edge const& e) const;
00379 inline Edge switched_edge (Vertex const& v, Edge const& e, Cell const& c) const;
00380 inline Facet switched_facet (Vertex const& v, Edge const& e, Cell const& c) const;
00381 inline Cell switched_cell (Edge const& e, Cell const& c) const;
00383
00384
00386
00387
00388
00389 inline BoundaryFacetIterator FirstBoundaryFacet() const;
00390 inline BoundaryFacetIterator FirstBoundaryEdge () const;
00391 inline BoundaryVertexIterator FirstBoundaryVertex() const;
00392
00393 size_type NumOfBoundaryVertices() const { return NumOfBoundaryFacets();}
00394 size_type NumOfBoundaryFacets() const { return (_boundary.size());}
00395
00396
00397
00398
00399
00400
00401
00403
00404
00405
00407 size_type NumOfVertices() const {return (_vertices.size());}
00408 size_type NumOfEdges() const
00409 {
00410 if(num_of_edges_cache < 0)
00411 calculate_num_of_edges();
00412 return num_of_edges_cache;
00413 }
00414
00415 size_type NumOfFacets() const { return NumOfEdges();}
00416 size_type NumOfFaces() const {return NumOfCells();}
00417 size_type NumOfCells() const {return (_cells.size());}
00419
00420
00422
00423 cell_handle outer_cell_handle() const { return cell_handle(-1);}
00424
00425
00426 inline bool IsOnBoundary(EdgeOnCellIterator const& e ) const;
00427 inline bool IsOnBoundary(Edge const& e ) const;
00428
00429 bool IsInside(cell_handle c) const { return (c != outer_cell_handle());}
00430 bool IsInside(const Cell& c) const { return IsInside(c.handle());}
00432
00437 inline const CoordType& Coord(const Vertex& v) const;
00438 inline CoordType& Coord(const Vertex& v);
00440
00444 archetype_iterator BeginArchetype() const { return archetypes.begin();}
00445 archetype_iterator EndArchetype() const { return archetypes.end();}
00446 archetype_handle handle(archetype_iterator it) const { return it - BeginArchetype();}
00447
00448 archetype_type const& Archetype(archetype_handle a) const { return archetypes[a];}
00449 archetype_type & Archetype(archetype_handle a) { return archetypes[a];}
00450 archetype_type const& ArchetypeOf (Cell const& c) const
00451 { return Archetype(archetype_of(c));}
00452 archetype_type const& ArchetypeOf (cell_handle c) const
00453 { return ArchetypeOf(cell(c));}
00454 archetype_handle archetype_of(cell_handle c) const
00455 { return archetype_of(cell(c)); }
00456 archetype_handle archetype_of(Cell const& c) const
00457 { return arch_for_n_vertices[c.NumOfVertices()];}
00458 unsigned NumOfArchetypes() const { return archetypes.size(); }
00459
00460
00466 archetype_handle add_archetype(archetype_type const& A, int nv);
00467
00468 inline void swap_orientation(Cell const& c);
00473 private:
00474 friend class friend_for_input;
00475 friend class Vertex2D;
00476 friend class Edge2D;
00477 friend class Cell2D;
00478
00479 friend class VertexOnCell2D_Iterator;
00480 friend class EdgeOnCell2D_Iterator;
00481 friend class BoundaryFacet2D_Iterator;
00482 friend class CellOnCell2D_Iterator;
00483 friend class CellOnVertex2D_Iterator;
00484
00485 friend class Vertex2D_Iterator;
00486 friend class Edge2D_Iterator;
00487 friend class Cell2D_Iterator;
00488
00489
00490
00491 inline cell_handle _new_cell(int num_of_v);
00492 inline vertex_handle _new_vertex(const CoordType& coo = CoordType());
00493
00494
00495 inline void set_neighbour(const FacetOnCellIterator& n1_it, const Cell& n2);
00496 inline void add_cell_on_vertex(const Vertex& V, const Cell& C);
00497 inline void add_cell_on_vertex(const Vertex& V, const cell_handle& C);
00498
00499 void add_archetype_of(Cell const& c);
00500 void calculate_num_of_edges() const;
00501 void calculate_archetypes();
00502
00503 void calculate_neighbour_cells();
00504 void calculate_vertex_cells();
00505 void calculate_adjacencies() {
00506 calculate_neighbour_cells();
00507 calculate_vertex_cells();
00508 }
00509
00510 public:
00511
00512
00513
00515 inline cell_handle handle(Cell const& C) const;
00516 inline cell_handle handle(CellIterator const& c) const;
00517 inline cell_handle handle(CellNeighbourIterator const& c) const;
00518
00519 inline vertex_handle handle(Vertex const& V) const;
00520 inline vertex_handle handle(VertexIterator const& v) const;
00521 inline vertex_handle handle(VertexOnCellIterator const& v) const;
00522
00523 inline bool is_valid_vertex(vertex_handle v) const { return ((0 <= v) && (v < NumOfVertices()));}
00524 inline bool is_valid_cell (cell_handle c) const { return ((0 <= c) && (c < NumOfCells ()));}
00525 bool valid(vertex_handle v) const { return ((0 <= v) && (v < NumOfVertices()));}
00526 bool valid(cell_handle c) const { return ((0 <= c) && (c < NumOfCells ()));}
00527 bool valid_vertex(vertex_handle v) const { return valid(v);}
00528 bool valid_cell (cell_handle c) const { return valid(c);}
00529
00530 inline edge_handle handle(const Edge& E) const;
00531
00532
00533
00534 Vertex vertex(const vertex_handle& v) const { return Vertex(*this,v);}
00535 Cell cell (const cell_handle& c) const { return Cell (*this,c);}
00536 inline Edge edge (const edge_handle& e) const;
00537 inline Edge facet (const edge_handle& e) const;
00539 };
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 class friend_for_input : public complex2d_types {
00553 public:
00554
00555
00556 typedef Complex2D::CoordType CoordType;
00557 typedef Complex2D::boundary_facet_list boundary_facet_list;
00558
00559 friend_for_input(Complex2D& cc) : _cc(cc) {}
00560
00561 void clear() { _cc.clear();}
00562 boundary_facet_list& boundary() {return _cc._boundary;}
00563 vertex_list_complex2d& _vertices() {return _cc._vertices;}
00564 cell_list_complex2d& _cells() {return _cc._cells;}
00565
00566 void calculate_neighbour_cells() {_cc.calculate_neighbour_cells();}
00567 void calculate_vertex_cells() {_cc.calculate_vertex_cells();}
00568 void calculate_archetypes() {_cc.calculate_archetypes();}
00569 void add_archetype_of(Cell const& c) { _cc.add_archetype_of(c);}
00570
00571 cell_handle _new_cell(int i) { return _cc._new_cell(i);}
00572 vertex_handle _new_vertex(const CoordType& coo = CoordType(0,0)) { return _cc._new_vertex(coo);}
00573 Complex2D::archetype_handle add_archetype(Complex2D::archetype_type const& A, int nv) { return _cc.add_archetype(A, nv);}
00574
00575 CoordType& coord(const Vertex2D& V) { return _cc.Coord(V);}
00576
00577 void set_neighbour(const EdgeOnCell2D_Iterator& n1_it, const Cell2D& n2)
00578 { _cc.set_neighbour(n1_it,n2);}
00579 void add_cell_on_vertex(const Vertex2D& V, const Cell2D& C)
00580 {_cc.add_cell_on_vertex(V,C);}
00581 void add_cell_on_vertex(const Vertex2D& V, const Complex2D::cell_handle& c)
00582 {_cc.add_cell_on_vertex(V,c);}
00583
00584
00585 cell_handle outer_cell_handle() const { return _cc.outer_cell_handle();}
00586
00587 cell2d_connectivity::vertex_list& _cell_vertices (const cell_handle& c)
00588 { return (_cc._cells[c]._vertices);}
00589 cell2d_connectivity::cell_list& _cell_neighbours(const cell_handle& c)
00590 { return (_cc._cells[c]._neighbours);}
00591
00592
00593 private:
00594 Complex2D& _cc;
00595 };
00596
00597
00598 }
00599
00600
00601
00602
00603
00604 #include "Gral/Grids/Complex2D/internal/vertex-on-cell2d-it.h"
00605 #include "Gral/Grids/Complex2D/internal/vertex2d-it.h"
00606 #include "Gral/Grids/Complex2D/internal/cell2d-it.h"
00607
00608 #include "Gral/Grids/Complex2D/internal/edge2d.h"
00609 #include "Gral/Grids/Complex2D/internal/edge2d-it.h"
00610 #include "Gral/Grids/Complex2D/internal/vertex-on-edge2d-it.h"
00611 #include "Gral/Grids/Complex2D/internal/cell-on-edge2d-it.h"
00612 #include "Gral/Grids/Complex2D/internal/boundary-facet-it.h"
00613 #include "Gral/Grids/Complex2D/internal/boundary-vertex-iterator.h"
00614
00615 #include "Gral/Grids/Complex2D/internal/cell-on-cell2d-it.C"
00616 #include "Gral/Grids/Complex2D/internal/edge-on-cell2d-it.C"
00617 #include "Gral/Grids/Complex2D/internal/vertex2d.C"
00618 #include "Gral/Grids/Complex2D/internal/edge2d.C"
00619 #include "Gral/Grids/Complex2D/internal/cell2d.C"
00620 #include "Gral/Grids/Complex2D/internal/complex2d.C"
00621
00622
00623 namespace GrAL {
00624
00625
00626
00627
00628
00629 struct hash_vertex2d;
00630 struct hash_edge2d;
00631 struct hash_cell2d;
00632
00633 struct grid_types_Complex2D : public complex2d_types {
00634
00635 typedef Vertex2D_Iterator VertexIterator;
00636 typedef Edge2D_Iterator EdgeIterator;
00637 typedef Edge2D_Iterator FacetIterator;
00638 typedef Cell2D_Iterator CellIterator;
00639
00640 typedef Complex2D::BoundaryFacetIterator BoundaryFacetIterator;
00641 typedef Complex2D::BoundaryVertexIterator BoundaryVertexIterator;
00642
00643
00644 typedef cell_handle face_handle;
00645 typedef Cell Face;
00646 typedef CellIterator FaceIterator;
00647 typedef VertexOnCellIterator VertexOnFaceIterator;
00648 typedef CellOnVertexIterator FaceOnVertexIterator;
00649 typedef EdgeOnCellIterator EdgeOnFaceIterator;
00650 typedef CellOnEdgeIterator FaceOnEdgeIterator;
00651
00652 static size_t hash(const Vertex& V) { return V.handle();}
00653 static size_t hash(const Cell& C) { return C.handle();}
00654 static size_t hash(const Edge& E)
00655 {
00656
00657
00658 int c1 = hash(E.V1());
00659 int c2 = hash(E.V2());
00660 return (c1 > c2 ? c1 * 4 + c2
00661 : c2 * 4 + c1);
00662 }
00663
00664 typedef hash_vertex2d hash_vertex;
00665 typedef hash_edge2d hash_edge;
00666 typedef hash_edge2d hash_facet;
00667 typedef hash_cell2d hash_cell;
00668
00669 typedef vertex_base::CoordType CoordType;
00670
00671 typedef grid_dim_tag<2> dimension_tag;
00672 static int dimension(const Cell& ) { return 2;}
00673 static int dimension(const Facet&) { return 1;}
00674
00675 static grid_type const& GridOf(const Cell& C) {return C.TheGrid();}
00676 static grid_type const& GridOf(const Edge& E) {return E.TheGrid();}
00677 static grid_type const& GridOf(const Vertex& V) {return V.TheGrid();}
00678
00679 static CoordType Coord(const Vertex& V) { return GridOf(V).Coord(V);}
00680
00681 static cell_handle outer_cell_handle(grid_type const& G)
00682 { return G.outer_cell_handle();}
00683 static cell_handle invalid_cell_handle(grid_type const& G)
00684 { return G.outer_cell_handle();}
00685 };
00686
00690 template<>
00691 struct grid_types<Complex2D> : public grid_types_base<grid_types_Complex2D> {};
00692
00693
00694 #define gt grid_types<Complex2D>
00695
00696 inline gt::VertexIterator gral_begin(gt::grid_type const& G, gt::VertexIterator) { return G.FirstVertex();}
00697 inline gt::VertexIterator gral_end (gt::grid_type const& G, gt::VertexIterator) { return G.EndVertex();}
00698 inline gt::size_type gral_size (gt::grid_type const& G, gt::VertexIterator) { return G.NumOfVertices();}
00699
00700 inline gt::EdgeIterator gral_begin(gt::grid_type const& G, gt::EdgeIterator) { return G.FirstEdge();}
00701 inline gt::EdgeIterator gral_end (gt::grid_type const& G, gt::EdgeIterator) { return G.EndEdge(); }
00702 inline gt::size_type gral_size (gt::grid_type const& G, gt::EdgeIterator) { return G.NumOfEdges();}
00703
00704 inline gt::CellIterator gral_begin(gt::grid_type const& G, gt::CellIterator) { return G.FirstCell();}
00705 inline gt::CellIterator gral_end (gt::grid_type const& G, gt::CellIterator) { return G.EndCell();}
00706 inline gt::size_type gral_size (gt::grid_type const& G, gt::CellIterator) { return G.NumOfCells();}
00707
00708
00709 inline gt::VertexOnCellIterator gral_begin(gt::Cell a, gt::VertexOnCellIterator) { return a.FirstVertex();}
00710 inline gt::VertexOnCellIterator gral_end (gt::Cell a, gt::VertexOnCellIterator) { return a.EndVertex();}
00711 inline gt::size_type gral_size (gt::Cell a, gt::VertexOnCellIterator) { return a.NumOfVertices();}
00712
00713 inline gt::VertexOnEdgeIterator gral_begin(gt::Edge a, gt::VertexOnEdgeIterator) { return a.FirstVertex();}
00714 inline gt::VertexOnEdgeIterator gral_end (gt::Edge a, gt::VertexOnEdgeIterator) { return a.EndVertex();}
00715 inline gt::size_type gral_size (gt::Edge a, gt::VertexOnEdgeIterator) { return a.NumOfVertices();}
00716
00717 inline gt::EdgeOnCellIterator gral_begin(gt::Cell a, gt::EdgeOnCellIterator) { return a.FirstEdge();}
00718 inline gt::EdgeOnCellIterator gral_end (gt::Cell a, gt::EdgeOnCellIterator) { return a.EndEdge(); }
00719 inline gt::size_type gral_size (gt::Cell a, gt::EdgeOnCellIterator) { return a.NumOfEdges();}
00720
00721 inline gt::CellOnCellIterator gral_begin(gt::Cell a, gt::CellOnCellIterator) { return a.FirstCell();}
00722 inline gt::CellOnCellIterator gral_end (gt::Cell a, gt::CellOnCellIterator) { return a.EndCell();}
00723 inline gt::size_type gral_size (gt::Cell a, gt::CellOnCellIterator) { return a.NumOfCells();}
00724
00725
00726 #undef gt
00727
00728 struct hash_vertex2d {
00729 typedef grid_types<Complex2D> gt;
00730 typedef gt::Vertex Vertex;
00731 typedef Vertex key_type;
00732 typedef Vertex argument_type;
00733 typedef size_t result_type;
00734
00735 result_type operator()(const Vertex& V) const { return gt::hash(V);}
00736
00737 void operator=(hash_vertex2d const&) {}
00738 };
00739
00740 struct hash_edge2d {
00741 typedef grid_types<Complex2D> gt;
00742 typedef gt::Edge Edge;
00743 typedef Edge key_type;
00744 typedef Edge argument_type;
00745 typedef size_t result_type;
00746 result_type operator()(const Edge& E) const { return gt::hash(E);}
00747
00748 void operator=(hash_edge2d const&) {}
00749 };
00750
00751 struct hash_cell2d {
00752 typedef grid_types<Complex2D> gt;
00753 typedef gt::Cell Cell;
00754 typedef Cell key_type;
00755 typedef Cell argument_type;
00756 typedef size_t result_type;
00757
00758 result_type operator()(const Cell& C) const { return gt::hash(C);}
00759
00760 void operator=(hash_cell2d const&) {}
00761 };
00762
00763
00770 inline int relative_orientation(EdgeOnCell2D_Iterator e1,
00771 EdgeOnCell2D_Iterator e2)
00772 {
00773 REQUIRE(*e1 == *e2, "attempt to check orientation of different edges!",1);
00774 return ((*e1).v1() == (*e2).v1() ? 1 : -1);
00775 }
00776
00777
00778
00779 }
00780
00781 namespace STDEXT {
00782 template<class T>
00783 struct hash;
00784
00785 template<>
00786 struct hash<GrAL::Vertex2D>
00787 : public GrAL::hash_vertex2d {};
00788 template<>
00789 struct hash<GrAL::Edge2D>
00790 : public GrAL::hash_edge2d {};
00791 template<>
00792 struct hash<GrAL::Cell2D>
00793 : public GrAL::hash_cell2d {};
00794 }
00795
00796
00797 #include "Gral/Grids/Complex2D/element-traits.h"
00798
00799 #endif
00800