1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
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 #include <OpenFOAM/IOstreams.H>
29 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
35 // - -1: same edge, but different orientation
36 inline int Foam::edge::compare(const edge& a, const edge& b)
38 if (a[0] == b[0] && a[1] == b[1])
42 else if (a[0] == b[1] && a[1] == b[0])
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 inline Foam::edge::edge()
59 inline Foam::edge::edge(const label a, const label b)
66 inline Foam::edge::edge(const FixedList<label, 2>& a)
73 inline Foam::edge::edge(Istream& is)
75 FixedList<label, 2>(is)
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 inline Foam::label Foam::edge::start() const
86 inline Foam::label& Foam::edge::start()
92 inline Foam::label Foam::edge::end() const
97 inline Foam::label& Foam::edge::end()
103 inline Foam::label Foam::edge::otherVertex(const label a) const
115 // The given vertex is not on the edge in the first place.
121 inline Foam::label Foam::edge::commonVertex(const edge& a) const
123 if (start() == a.start() || start() == a.end())
127 else if (end() == a.start() || end() == a.end())
139 inline Foam::edge Foam::edge::reverseEdge() const
141 return edge(end(), start());
145 inline Foam::point Foam::edge::centre(const pointField& p) const
147 return 0.5*(p[start()] + p[end()]);
151 inline Foam::vector Foam::edge::vec(const pointField& p) const
153 return p[end()] - p[start()];
157 inline Foam::scalar Foam::edge::mag(const pointField& p) const
159 return ::Foam::mag(vec(p));
163 inline Foam::linePointRef Foam::edge::line(const pointField& p) const
165 return linePointRef(p[start()], p[end()]);
169 // * * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * //
171 inline bool Foam::operator==(const edge& a, const edge& b)
173 return edge::compare(a,b) != 0;
177 inline bool Foam::operator!=(const edge& a, const edge& b)
179 return edge::compare(a,b) == 0;
183 // ************************ vim: set sw=4 sts=4 et: ************************ //