![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 #ifndef __NODE_ITERATOR_H 00005 #define __NODE_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 Boundary; 00017 class CellIterator; 00018 class GenericCell; 00019 00020 typedef Node* NodePointer; 00021 00022 class NodeIterator { 00023 public: 00024 00025 NodeIterator(const Mesh& mesh); 00026 NodeIterator(const Mesh* mesh); 00027 00028 NodeIterator(const Boundary& boundary); 00029 00030 NodeIterator(const Node& node); 00031 NodeIterator(const NodeIterator& nodeIterator); 00032 00033 NodeIterator(const Cell& cell); 00034 NodeIterator(const CellIterator& cellIterator); 00035 00036 ~NodeIterator(); 00037 00038 operator NodePointer() const; 00039 00040 NodeIterator& operator++(); 00041 bool end(); 00042 bool last(); 00043 int index(); 00044 00045 Node& operator*() const; 00046 Node* operator->() const; 00047 bool operator==(const NodeIterator& n) const; 00048 bool operator!=(const NodeIterator& n) const; 00049 bool operator==(const Node& n) const; 00050 bool operator!=(const Node& n) const; 00051 00052 // Base class for node iterators 00053 class GenericNodeIterator { 00054 public: 00055 00056 virtual void operator++() = 0; 00057 virtual bool end() = 0; 00058 virtual bool last() = 0; 00059 virtual int index() = 0; 00060 00061 virtual Node& operator*() const = 0; 00062 virtual Node* operator->() const = 0; 00063 virtual Node* pointer() const = 0; 00064 00065 }; 00066 00067 // Iterator for the nodes in a mesh 00068 class MeshNodeIterator : public GenericNodeIterator { 00069 public: 00070 00071 MeshNodeIterator(const Mesh& mesh); 00072 00073 void operator++(); 00074 bool end(); 00075 bool last(); 00076 int index(); 00077 00078 Node& operator*() const; 00079 Node* operator->() const; 00080 Node* pointer() const; 00081 00082 Table<Node>::Iterator node_iterator; 00083 Table<Node>::Iterator at_end; 00084 00085 }; 00086 00087 // Iterator for the nodes on a boundary 00088 class BoundaryNodeIterator : public GenericNodeIterator { 00089 public: 00090 00091 BoundaryNodeIterator(const Boundary& boundary); 00092 void operator++(); 00093 bool end(); 00094 bool last(); 00095 int index(); 00096 00097 Node& operator*() const; 00098 Node* operator->() const; 00099 Node* pointer() const; 00100 00101 private: 00102 00103 List<Node*>::Iterator node_iterator; 00104 00105 }; 00106 00107 // Iterator for the node neighbors of a node 00108 class NodeNodeIterator : public GenericNodeIterator { 00109 public: 00110 00111 NodeNodeIterator(const Node& node); 00112 void operator++(); 00113 bool end(); 00114 bool last(); 00115 int index(); 00116 00117 Node& operator*() const; 00118 Node* operator->() const; 00119 Node* pointer() const; 00120 00121 private: 00122 00123 Array<Node*>::Iterator node_iterator; 00124 00125 }; 00126 00127 // Iterator for the nodes in a cell 00128 class CellNodeIterator : public GenericNodeIterator { 00129 public: 00130 00131 CellNodeIterator(const Cell& cell); 00132 void operator++(); 00133 bool end(); 00134 bool last(); 00135 int index(); 00136 00137 Node& operator*() const; 00138 Node* operator->() const; 00139 Node* pointer() const; 00140 00141 private: 00142 00143 Array<Node*>::Iterator node_iterator; 00144 00145 }; 00146 00147 private: 00148 00149 GenericNodeIterator* n; 00150 00151 }; 00152 00153 } 00154 00155 #endif
Documentation automatically generated with Doxygen on 10 Sep 2004.