1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Foam::patchPointEdgeCirculator
28 Walks from starting edge/face around point on patch.
32 patchPointEdgeCirculator circ(..);
37 Info<< "edge:" << circ.edgeID() << endl;
40 while (circ != circ.end());
43 -# Use like STL iterator: \n
45 patchPointEdgeCirculator circ(..);
48 patchPointEdgeCirculator iter = circ.begin();
53 Info<< "edge:" << iter.edgeID() << endl;
59 patchPointEdgeCirculator.C
61 \*---------------------------------------------------------------------------*/
63 #ifndef patchPointEdgeCirculator_H
64 #define patchPointEdgeCirculator_H
68 #include "primitiveFacePatch.H"
69 #include "PackedBoolList.H"
70 #include "InfoProxy.H"
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 // Forward declaration of classes
79 /*---------------------------------------------------------------------------*\
80 Class patchPointEdgeCirculator Declaration
81 \*---------------------------------------------------------------------------*/
83 class patchPointEdgeCirculator
85 // Static data members
88 static const patchPointEdgeCirculator endConstIter;
94 const primitiveFacePatch& patch_;
96 const PackedBoolList& nonManifoldEdge_;
101 //- Current direction (face, expressed as index into edgeFaces()[edgeID]
107 //- Starting edge so we know when to stop.
111 // Private Member Functions
113 //- Set to end() iterator
114 inline void setEnd();
116 //- Set edgeID_ to be the other edge on the face that uses the
118 inline void otherEdge(const label cellI);
124 //- Construct from components
125 inline patchPointEdgeCirculator
127 const primitiveFacePatch&,
128 const PackedBoolList& nonManifoldEdge,
134 //- Construct as copy
135 inline patchPointEdgeCirculator(const patchPointEdgeCirculator&);
140 inline label edgeID() const;
142 inline label index() const;
144 inline label pointID() const;
146 //- Helper: get face according to the index.
147 // Returns -1 if on end.
148 inline label faceID() const;
150 //- Walk back until non-manifold edge (if any) or minimum edge.
151 inline void setCanonical();
156 inline void operator=(const patchPointEdgeCirculator& iter);
158 inline bool operator==(const patchPointEdgeCirculator& iter) const;
160 inline bool operator!=(const patchPointEdgeCirculator& iter) const;
162 //- Step to next face.
163 inline patchPointEdgeCirculator& operator++();
165 //- iterator set to the beginning face. For internal edges this is
166 // the current face. For boundary edges this is the first boundary face
167 // reached from walking back (i.e. in opposite direction to ++)
168 inline patchPointEdgeCirculator begin() const;
169 inline patchPointEdgeCirculator cbegin() const;
171 //- iterator set to beyond the end of the walk.
172 inline const patchPointEdgeCirculator& end() const;
173 inline const patchPointEdgeCirculator& cend() const;
177 //- Return info proxy.
178 // Used to print token information to a stream
179 InfoProxy<patchPointEdgeCirculator> info() const
184 friend Ostream& operator<<
187 const InfoProxy<patchPointEdgeCirculator>&
191 Ostream& operator<<(Ostream&, const InfoProxy<patchPointEdgeCirculator>&);
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 } // End namespace Foam
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 #include "patchPointEdgeCirculatorI.H"
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 // ************************************************************************* //