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

Gral/Base/facet-handle.h

00001 #ifndef GRAL_BASE_GB_GRID_FACET_HANDLE_H
00002 #define GRAL_BASE_GB_GRID_FACET_HANDLE_H
00003 
00004 
00005 // $LICENSE
00006 
00007 #include "Config/compiler-config.h"
00008 
00009 #include <iostream.h>
00010 #include <stdlib.h>
00011 
00012 //----------------------------------------------------------------
00029 //----------------------------------------------------------------
00030 
00031 
00032 
00033 template<class CHandle>
00034 struct facet_handle {
00035   CHandle c;  // cell
00036   int     lf; // 0 <= lf < NumOfFacets(c) : local position in cell
00037 
00038   facet_handle() {}
00039   facet_handle(CHandle cc, int llf) : c(cc), lf(llf) {}
00040 
00041   int local_facet() const { return lf;}
00042 };
00043 
00046 template<class CHandle>
00047 inline
00048 bool operator== (facet_handle<CHandle> const& ls, facet_handle<CHandle> const& rs)
00049    { return ((ls.c == rs.c) && (ls.lf == rs.lf)); }
00050 
00053 template<class CHandle>
00054 inline
00055 bool operator!= (facet_handle<CHandle> const& ls, facet_handle<CHandle> const& rs)
00056    { return ! (ls == rs) }
00057 
00060 template<class CHandle>
00061 inline
00062 bool operator<  (facet_handle<CHandle> const& ls, facet_handle<CHandle> const& rs)
00063   { return ((ls.c < rs.c)  || ((ls.c == rs.c) &&  (ls.lf < rs.lf))); }
00064 
00067 template<class CHandle>
00068 inline
00069 ostream& operator<< ( ostream& out, facet_handle<CHandle> const& e)
00070  { return (out << e.c << ' ' << e.lf);}
00071 
00074 template<class CHandle>
00075 inline
00076 istream& operator>> ( istream& in,  facet_handle<CHandle>     & e)
00077  { return (in >> e.c >> e.lf);}
00078 
00081 inline size_t hash_facet_handle(facet_handle<int> const& h)
00082 { return (8*h.c + h.lf);}
00083 
00088 template<class T> class hash;
00089 struct hash<facet_handle<int> > {
00090 public:
00091   typedef facet_handle<int>     argument_type;
00092   typedef size_t                result_type;
00093 
00094   // hash function -- the factor 8 is heuristic, but it makes at
00095   // least sure that for the common cell types in 2D and 3D no two
00096   // different handles map to the same value 
00097   size_t operator()(const facet_handle<int>& h) const
00098     { return (8*h.c + h.lf);}
00099 };
00100 
00101 #endif
00102 

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

Generated at Tue Feb 26 16:05:42 2002 for GrAL Base by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000