00001 #ifndef GRAL_GB_BASE_PREDICATES_H
00002 #define GRAL_GB_BASE_PREDICATES_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Gral/Base/common-grid-basics.h"
00019
00020 namespace GrAL {
00021
00022 namespace detail {
00023
00024 template<class tag1, class tag2, class E1, class E2, class GT>
00025 struct incidence_aux {};
00026
00027
00028
00029 template<class E1, class E2, class GT>
00030 struct incidence_aux<vertex_type_tag, cell_type_tag,E1,E2,GT>
00031 {
00032 typedef typename GT::VertexOnCellIterator iterator;
00033 };
00034
00035 template<class E1, class E2, class GT>
00036 struct incidence_aux<edge_type_tag, cell_type_tag,E1,E2,GT>
00037 {
00038 typedef typename GT::EdgeOnCellIterator iterator;
00039 };
00040
00041 template<class E1, class E2, class GT>
00042 struct incidence_aux<face_type_tag, cell_type_tag,E1,E2,GT>
00043 { typedef typename GT::FaceOnCellIterator iterator; };
00044
00045 template<class E1, class E2, class GT>
00046 struct incidence_aux<facet_type_tag, cell_type_tag,E1,E2,GT>
00047 {
00048 typedef typename GT::FacetOnCellIterator iterator;
00049 };
00050
00051
00052
00053 template<class E1, class E2, class GT>
00054 struct incidence_aux<vertex_type_tag, face_type_tag,E1,E2,GT>
00055 {
00056 typedef typename GT::VertexOnFaceIterator iterator;
00057 };
00058
00059 template<class E1, class E2, class GT>
00060 struct incidence_aux<edge_type_tag, face_type_tag,E1,E2,GT>
00061 {
00062 typedef typename GT::EdgeOnFaceIterator iterator;
00063 };
00064
00065 template<class E1, class E2, class GT>
00066 struct incidence_aux<facet_type_tag, face_type_tag,E1,E2,GT>
00067 {
00068 typedef typename GT::FacetOnFaceIterator iterator;
00069 };
00070
00071 template<class E1, class E2, class GT>
00072 struct incidence_aux<cell_type_tag, face_type_tag,E1,E2,GT>
00073 {
00074 typedef typename GT::CellOnFaceIterator iterator;
00075 };
00076
00077
00078
00079
00080 template<class E1, class E2, class GT>
00081 struct incidence_aux<vertex_type_tag, facet_type_tag,E1,E2,GT>
00082 {
00083 typedef typename GT::VertexOnFacetIterator iterator;
00084 };
00085
00086 template<class E1, class E2, class GT>
00087 struct incidence_aux<edge_type_tag, facet_type_tag,E1,E2,GT>
00088 {
00089 typedef typename GT::EdgeOnFacetIterator iterator;
00090 };
00091
00092 template<class E1, class E2, class GT>
00093 struct incidence_aux<face_type_tag, facet_type_tag,E1,E2,GT>
00094 {
00095 typedef typename GT::FaceOnFacetIterator iterator;
00096 };
00097 template<class E1, class E2, class GT>
00098 struct incidence_aux<cell_type_tag, facet_type_tag,E1,E2,GT>
00099 {
00100 typedef typename GT::CellOnFacetIterator iterator;
00101 };
00102
00103
00104
00105 template<class E1, class E2, class GT>
00106 struct incidence_aux<vertex_type_tag, edge_type_tag,E1,E2,GT>
00107 {
00108 typedef typename GT::VertexOnEdgeIterator iterator;
00109 };
00110
00111 template<class E1, class E2, class GT>
00112 struct incidence_aux<face_type_tag, edge_type_tag,E1,E2,GT>
00113 {
00114 typedef typename GT::FaceOnEdgeIterator iterator;
00115 };
00116
00117 template<class E1, class E2, class GT>
00118 struct incidence_aux<facet_type_tag, edge_type_tag,E1,E2,GT>
00119 {
00120 typedef typename GT::FacetOnEdgeIterator iterator;
00121 };
00122
00123 template<class E1, class E2, class GT>
00124 struct incidence_aux<cell_type_tag, edge_type_tag,E1,E2,GT>
00125 {
00126 typedef typename GT::CellOnEdgeIterator iterator;
00127 };
00128
00129
00130 template<class E1, class E2, class GT>
00131 struct incidence_aux<edge_type_tag, vertex_type_tag,E1,E2,GT>
00132 {
00133 typedef typename GT::EdgeOnVertexIterator iterator;
00134 };
00135
00136 template<class E1, class E2, class GT>
00137 struct incidence_aux<face_type_tag, vertex_type_tag,E1,E2,GT>
00138 {
00139 typedef typename GT::FaceOnVertexIterator iterator;
00140 };
00141
00142 template<class E1, class E2, class GT>
00143 struct incidence_aux<facet_type_tag, vertex_type_tag,E1,E2,GT>
00144 {
00145 typedef typename GT::FacetOnVertexIterator iterator;
00146 };
00147
00148 template<class E1, class E2, class GT>
00149 struct incidence_aux<cell_type_tag, vertex_type_tag,E1,E2,GT>
00150 {
00151 typedef typename GT::CellOnVertexIterator iterator;
00152 };
00153
00154
00155 }
00156
00157
00158
00161 template<class E1, class E2, class GT = grid_types<typename element_traits<E1>::grid_type> >
00162 struct incidence : public detail::incidence_aux<typename element_traits<E1>::element_type_tag,
00163 typename element_traits<E2>::element_type_tag,
00164 E1, E2, GT>
00165 {};
00166
00172 template<class E>
00173 struct VertexOn {
00174 typedef element_traits<E> et;
00175 typedef grid_types<typename et::grid_type> gt;
00176 typedef typename gt::Vertex Vertex;
00177
00178 typedef typename incidence<Vertex,E>::iterator Iterator;
00179 typedef typename incidence<Vertex,E>::iterator type;
00180
00181 };
00182
00183
00184
00194 template<class E1, class E2>
00195 bool incident(E1 const& e1, E2 const& e2)
00196 {
00197 typedef typename incidence<E1,E2>::iterator E1OnE2Iterator;
00198 for(E1OnE2Iterator e1e2(e2); ! e1e2.IsDone(); ++e1e2)
00199 if(*e1e2 == e1)
00200 return true;
00201 return false;
00202 }
00203
00222 template<class GT, class E1, class E2>
00223 bool incident(E1 const& e1, E2 const& e2)
00224 {
00225 typedef typename incidence<E1,E2, GT>::iterator E1OnE2Iterator;
00226 for(E1OnE2Iterator e1e2(e2); ! e1e2.IsDone(); ++e1e2)
00227 if(*e1e2 == e1)
00228 return true;
00229 return false;
00230 }
00231
00232
00233
00234 }
00235
00236 #endif
00237