![]() |
00001 // Copyright (C) 2003 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 #ifndef __EDGE_ITERATOR_H 00005 #define __EDGE_ITERATOR_H 00006 00007 #include <dolfin/Array.h> 00008 #include <dolfin/List.h> 00009 #include <dolfin/Table.h> 00010 00011 namespace dolfin { 00012 00013 class Mesh; 00014 class Node; 00015 class Cell; 00016 class Edge; 00017 class Face; 00018 class Boundary; 00019 class NodeIterator; 00020 class CellIterator; 00021 class FaceIterator; 00022 class GenericCell; 00023 00024 typedef Edge* EdgePointer; 00025 00026 class EdgeIterator { 00027 public: 00028 00029 EdgeIterator(const Mesh& mesh); 00030 EdgeIterator(const Mesh* mesh); 00031 00032 EdgeIterator(const Boundary& boundary); 00033 EdgeIterator(const Boundary* boundary); 00034 00035 EdgeIterator(const Node& node); 00036 EdgeIterator(const NodeIterator& nodeIterator); 00037 00038 EdgeIterator(const Cell& cell); 00039 EdgeIterator(const CellIterator& cellIterator); 00040 00041 EdgeIterator(const Face& face); 00042 EdgeIterator(const FaceIterator& faceIterator); 00043 00044 ~EdgeIterator(); 00045 00046 operator EdgePointer() const; 00047 00048 EdgeIterator& operator++(); 00049 bool end(); 00050 bool last(); 00051 int index(); 00052 00053 Edge& operator*() const; 00054 Edge* operator->() const; 00055 bool operator==(const EdgeIterator& n) const; 00056 bool operator!=(const EdgeIterator& n) const; 00057 00058 // Base class for edge iterators 00059 class GenericEdgeIterator { 00060 public: 00061 00062 virtual void operator++() = 0; 00063 virtual bool end() = 0; 00064 virtual bool last() = 0; 00065 virtual int index() = 0; 00066 00067 virtual Edge& operator*() const = 0; 00068 virtual Edge* operator->() const = 0; 00069 virtual Edge* pointer() const = 0; 00070 00071 }; 00072 00073 // Iterator for the edges in a mesh 00074 class MeshEdgeIterator : public GenericEdgeIterator { 00075 public: 00076 00077 MeshEdgeIterator(const Mesh& mesh); 00078 00079 void operator++(); 00080 bool end(); 00081 bool last(); 00082 int index(); 00083 00084 Edge& operator*() const; 00085 Edge* operator->() const; 00086 Edge* pointer() const; 00087 00088 Table<Edge>::Iterator edge_iterator; 00089 Table<Edge>::Iterator at_end; 00090 00091 }; 00092 00093 // Iterator for the edges on a boundary 00094 class BoundaryEdgeIterator : public GenericEdgeIterator { 00095 public: 00096 00097 BoundaryEdgeIterator(const Boundary& boundary); 00098 void operator++(); 00099 bool end(); 00100 bool last(); 00101 int index(); 00102 00103 Edge& operator*() const; 00104 Edge* operator->() const; 00105 Edge* pointer() const; 00106 00107 private: 00108 00109 List<Edge*>::Iterator edge_iterator; 00110 00111 }; 00112 00113 // Iterator for the edges at a node 00114 class NodeEdgeIterator : public GenericEdgeIterator { 00115 public: 00116 00117 NodeEdgeIterator(const Node& node); 00118 void operator++(); 00119 bool end(); 00120 bool last(); 00121 int index(); 00122 00123 Edge& operator*() const; 00124 Edge* operator->() const; 00125 Edge* pointer() const; 00126 00127 private: 00128 00129 Array<Edge*>::Iterator edge_iterator; 00130 00131 }; 00132 00133 // Iterator for the edges in a cell 00134 class CellEdgeIterator : public GenericEdgeIterator { 00135 public: 00136 00137 CellEdgeIterator(const Cell& cell); 00138 void operator++(); 00139 bool end(); 00140 bool last(); 00141 int index(); 00142 00143 Edge& operator*() const; 00144 Edge* operator->() const; 00145 Edge* pointer() const; 00146 00147 private: 00148 00149 Array<Edge*>::Iterator edge_iterator; 00150 00151 }; 00152 00153 // Iterator for the edges in a face 00154 class FaceEdgeIterator : public GenericEdgeIterator { 00155 public: 00156 00157 FaceEdgeIterator(const Face& face); 00158 void operator++(); 00159 bool end(); 00160 bool last(); 00161 int index(); 00162 00163 Edge& operator*() const; 00164 Edge* operator->() const; 00165 Edge* pointer() const; 00166 00167 private: 00168 00169 Array<Edge*>::Iterator edge_iterator; 00170 00171 }; 00172 00173 private: 00174 00175 GenericEdgeIterator* e; 00176 00177 }; 00178 00179 } 00180 00181 #endif
Documentation automatically generated with Doxygen on 10 Sep 2004.