Go to Overview over all GrAL packages.
Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Gral/Grids/Complex2D/internal/edge2d.h

Go to the documentation of this file.
00001 #ifndef NMWR_GB_EDGE2D_H
00002 #define NMWR_GB_EDGE2D_H
00003 
00004 
00005 
00006 // $LICENSE
00007 
00008 
00009 #include "Gral/Grids/Complex2D/complex2d.h"
00010 
00011 class Edge2D : public complex2d_types {
00012 public:
00013 
00014   typedef edge_handle_complex2d   handle_type;
00015   typedef Complex2D               anchor_type;
00016   typedef VertexOnEdge2D_Iterator VertexIterator;
00017 
00018 private:
00019   //----- DATA --------
00020   EdgeOnCell2D_Iterator _e;
00021 
00022   typedef Edge2D self;
00023 public:
00024   //------------- constructors -------------------------
00025   Edge2D() : _e() {}
00026   explicit Edge2D(Complex2D const& cc);
00027   Edge2D(Complex2D const& cc, edge_handle eh);
00028 
00029   Edge2D(const Cell& C1, const Cell& C2)
00030     : _e(C1.find_local_facet(C2),C1) {}
00031 
00032 
00033   Edge2D(const EdgeOnCell2D_Iterator& e) : _e(e) {}
00034   Edge2D(const CellOnCell2D_Iterator& e) : _e(e) {}
00035 
00036   ~Edge2D() {}
00037 
00038 
00039   //-------------- iteration -----------------
00040 
00041   inline VertexOnEdge2D_Iterator FirstVertex() const;
00042   inline VertexOnEdge2D_Iterator EndVertex()   const;
00043   int NumOfVertices() const { return 2;}
00044 
00045   inline CellOnEdge2D_Iterator FirstCell() const;
00046   inline CellOnEdge2D_Iterator EndCell()   const;
00047   int NumOfCells() const { return 2;}
00048 
00049 
00050   //--------- edge-vertex operations ---------
00051   inline vertex_handle v1() const { return _e.TheCell().vertex(1,_e);}
00052   inline vertex_handle v2() const { return _e.TheCell().vertex(2,_e);}
00053 
00054 
00055   inline Vertex V1() const { return Vertex(TheGrid(),v1());}
00056   inline Vertex V2() const { return Vertex(TheGrid(),v2());}
00057 
00058 
00059 
00060   //--------- facet-cell operations ----------
00061 
00062   inline cell_handle c1() const { return _e.the_cell();}
00063   inline cell_handle c2() const { return _e.other_cell();}
00064 
00065   inline Cell   C1() const { return (_e.TheCell()  );}
00066   inline Cell   C2() const { return (_e.OtherCell());}
00067 
00068   //----------- switch operations -----------
00069 
00070   void FlipVertex(Vertex& v) const { v = ( v == V1() ? V2() : V1());}
00071   void FlipCell(Cell& c)     const { c = ( c == C1() ? C2() : C1());}
00072   Vertex FlippedVertex(Vertex const& v) const { return ( v == V1() ? V2() : V1());}
00073   Cell   FlippedCell  (Cell   const& c) const { return ( c == C1() ? C2() : C1());}
00074 
00075   //-------------- anchors -------------------
00076   
00077   Complex const& TheGrid()   const { return _e.TheGrid();}
00078   Complex const& TheAnchor() const { return _e.TheGrid();}
00079 
00080   handle_type    handle()  const { return TheGrid().handle(*this);}
00081 
00082   //---------------- comparision ------------------------
00083 
00084   friend bool operator< (const self& lhs, const self& rhs);
00085   friend bool operator==(const self& lhs, const self& rhs);
00086   friend bool operator!=(const self& lhs, const self& rhs)
00087     { return !(lhs == rhs);}
00088 
00089   friend class Cell2D;
00090   friend class Complex2D;
00091 };
00092 
00093 
00094 //---------------------------------------------------------
00095 
00096 
00097 
00098 inline bool operator==(const Edge2D& lhs, const Edge2D& rhs)
00099 { // vertices anstelle von cells: sonst probleme am rand, speziell an ecken!
00100   // 2 randkanten derselben zelle wuerden als gleich erkannt.
00101   return (  (lhs.V1() == rhs.V1() && lhs.V2() == rhs.V2())
00102           ||(lhs.V1() == rhs.V2() && lhs.V2() == rhs.V1()));
00103 }
00104 
00105 inline bool operator<(const Edge2D& s1, const Edge2D& s2)
00106 {
00107   // etwas effizienter mit ordered_pair(C(1),C(2))
00108   // evtl. gleich cnbit gleich so waehlen, dass reihenfolge stimmt?
00109   typedef Edge2D::vertex_handle vh;
00110   vh max1(std::max(s1.v1(),s1.v2()));
00111   vh min1(std::min(s1.v1(),s1.v2()));
00112   vh max2(std::max(s2.v1(),s2.v2()));
00113   vh min2(std::min(s2.v1(),s2.v2()));
00114   
00115   return ( (max1 < max2)  || ( (max1 == max2) && (min1 < min2)));
00116 }
00117 
00118 
00119 
00120 #endif
00121 

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 16:06:45 2002 for GrAL Complex2D by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000