Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

CellIterator.h

Go to the documentation of this file.
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg.
00002 // Licensed under the GNU GPL Version 2.
00003 
00004 #ifndef __CELL_ITERATOR_H
00005 #define __CELL_ITERATOR_H
00006 
00007 #include <dolfin/Array.h>
00008 #include <dolfin/Table.h>
00009 
00010 namespace dolfin {
00011 
00012   class Mesh;
00013   class Cell;
00014   class Node;
00015   class NodeIterator;
00016 
00017   typedef Cell* CellPointer;
00018   
00019   class CellIterator {
00020   public:
00021          
00022     CellIterator(const Mesh& mesh);
00023     CellIterator(const Mesh* mesh);
00024 
00025     CellIterator(const Node& node);
00026     CellIterator(const NodeIterator& nodeIterator);
00027 
00028     CellIterator(const Cell& cell);
00029     CellIterator(const CellIterator& cellIterator);
00030          
00031     ~CellIterator();
00032 
00033     operator CellPointer() const;
00034          
00035     CellIterator& operator++();
00036     bool end();
00037     bool last();
00038     int index();
00039          
00040     Cell& operator*() const;
00041     Cell* operator->() const;
00042     bool  operator==(const CellIterator& c) const;
00043     bool  operator!=(const CellIterator& c) const;
00044     bool  operator==(const Cell& c) const;
00045     bool  operator!=(const Cell& c) const;
00046          
00047     // Base class for cell iterators
00048     class GenericCellIterator {
00049     public:
00050                 
00051       virtual void operator++() = 0;
00052       virtual bool end() = 0;
00053       virtual bool last() = 0;
00054       virtual int index() = 0;
00055                 
00056       virtual Cell& operator*() const = 0;
00057       virtual Cell* operator->() const = 0;
00058       virtual Cell* pointer() const = 0;
00059                 
00060     };
00061          
00062     // Iterator for the cells in a mesh
00063     class MeshCellIterator : public GenericCellIterator {
00064     public:
00065                 
00066       MeshCellIterator(const Mesh& mesh); 
00067                 
00068       void operator++();
00069       bool end();
00070       bool last();
00071       int index();
00072                 
00073       Cell& operator*() const;
00074       Cell* operator->() const;
00075       Cell* pointer() const;
00076 
00077       Table<Cell>::Iterator cell_iterator;
00078       Table<Cell>::Iterator at_end;
00079                 
00080     };
00081 
00082     // Iterator for the cell neigbors of a node
00083     class NodeCellIterator : public GenericCellIterator {
00084     public:
00085 
00086       NodeCellIterator(const Node& node);
00087       void operator++();
00088       bool end();
00089       bool last();
00090       int index();
00091 
00092       Cell& operator*() const;
00093       Cell* operator->() const;
00094       Cell* pointer() const;
00095 
00096     private:
00097 
00098       Array<Cell*>::Iterator cell_iterator;
00099                 
00100     };
00101 
00102     // Iterator for the cell neigbors of a cell
00103     class CellCellIterator : public GenericCellIterator {
00104     public:
00105 
00106       CellCellIterator(const Cell& cell);
00107       void operator++();
00108       bool end();
00109       bool last();
00110       int index();
00111 
00112       Cell& operator*() const;
00113       Cell* operator->() const;
00114       Cell* pointer() const;
00115 
00116     private:
00117 
00118       Array<Cell*>::Iterator cell_iterator;
00119                 
00120     };
00121          
00122   private:
00123          
00124     GenericCellIterator* c;
00125          
00126   };
00127 
00128 }
00129 
00130 #endif


Documentation automatically generated with Doxygen on 10 Sep 2004.