initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / meshShapes / face / faceI.H
blobce8fab30e3cdce80daafd6d0d24dad65aa0e9fe0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 namespace Foam
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 // Edge to the right of face vertex i
33 inline label face::right(const label i) const
35     return i;
39 // Edge to the left of face vertex i
40 inline label face::left(const label i) const
42     return i == 0 ? size() - 1 : (i - 1);
46 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
48 // Construct NULL
49 inline face::face()
53 // Construct given size
54 inline face::face(label s)
56     labelList(s, -1)
60 // Construct from components
61 inline face::face(const labelList& l)
63     labelList(l)
67 // Construct from Istream
68 inline face::face(Istream& is)
70     is >> *this;
74 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
76 inline pointField face::points(const pointField& meshPoints) const
78     // There are as many points as there labels for them
79     pointField p(size());
81     // For each point in list, set it to the point in 'pnts' addressed
82     // by 'labs'
83     forAll(p, i)
84     {
85         p[i] = meshPoints[operator[](i)];
86     }
88     // Return list
89     return p;
93 inline scalar face::mag(const pointField& p) const
95     return ::Foam::mag(normal(p));
99 inline label face::nEdges() const
101     // for a closed polygon a number of edges is the same as number of points
102     return size();
106 inline edge face::faceEdge(const label n) const
108     return edge(operator[](n), operator[](fcIndex(n)));
112 // Next vertex on face
113 inline label face::nextLabel(const label i) const
115     return operator[](fcIndex(i));
119 // Previous vertex on face
120 inline label face::prevLabel(const label i) const
122     return operator[](rcIndex(i));
126 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
128 inline bool operator==(const face& a, const face& b)
130     return face::compare(a,b) != 0;
134 inline bool operator!=(const face& a, const face& b)
136     return face::compare(a,b) == 0;
140 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
142 inline Istream& operator>>(Istream& is, face& f)
144     if (is.version() == IOstream::originalVersion)
145     {
146         // Read starting (
147         is.readBegin("face");
149         // Read the 'name' token for the face
150         token t(is);
152         // Read labels
153         is >> static_cast<labelList&>(f);
155         // Read end)
156         is.readEnd("face");
157     }
158     else
159     {
160         is >> static_cast<labelList&>(f);
161     }
163     // Check state of Ostream
164     is.check("Istream& operator>>(Istream&, face&)");
166     return is;
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // ************************************************************************* //