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
29 A triangle face primitive using a FixedList.
34 \*---------------------------------------------------------------------------*/
39 #include "FixedList.H"
42 #include "intersection.H"
43 #include "pointField.H"
44 #include "triPointRef.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 // Forward declaration of friend functions and operators
56 inline bool operator==(const triFace&, const triFace&);
57 inline bool operator!=(const triFace&, const triFace&);
60 /*---------------------------------------------------------------------------*\
61 class triFace Declaration
62 \*---------------------------------------------------------------------------*/
66 public FixedList<label, 3>
76 //- Construct from three point labels
84 //- Construct from a UList<label>
85 explicit inline triFace(const UList<label>&);
87 //- Construct from Istream
88 inline triFace(Istream&);
93 //- Collapse face by removing duplicate point labels
94 // return the collapsed size, set collapsed point labels to -1
95 inline label collapse();
97 //- Return the edge direction on the face
98 // - +1: forward (counter-clockwise) on the face
99 // - -1: reverse (clockwise) on the face
100 // - 0: edge not found on the face
101 inline int edgeDirection(const edge&) const;
106 //- Return the points corresponding to this face
107 inline pointField points(const pointField& points) const;
109 //- Return triangle as a face
110 inline face triFaceFace() const;
112 //- Return number of edges
113 inline label nEdges() const;
116 inline edgeList edges() const;
118 //- Return centre (centroid)
119 inline point centre(const pointField&) const;
121 //- Return scalar magnitude
122 inline scalar mag(const pointField&) const;
124 //- Return vector normal
125 inline vector normal(const pointField&) const;
127 //- Number of triangles after splitting
128 inline label nTriangles() const;
130 //- Return face with reverse direction
131 inline triFace reverseFace() const;
133 //- Return swept-volume
134 inline scalar sweptVol
136 const pointField& oldPoints,
137 const pointField& newPoints
140 //- Return point intersection with a ray starting at p, with
146 const pointField& points,
147 const intersection::algorithm = intersection::FULL_RAY,
148 const intersection::direction dir = intersection::VECTOR
151 //- Return the triangle
152 inline triPointRef tri(const pointField&) const;
157 // - -1: same face, but different orientation
158 static inline int compare(const triFace&, const triFace&);
162 friend bool operator==(const triFace&, const triFace&);
163 friend bool operator!=(const triFace&, const triFace&);
167 //- Hash specialization for hashing triFace - a commutative hash value.
168 // Hash incrementally.
170 inline unsigned Hash<triFace>::operator()(const triFace& t, unsigned seed) const
172 // Fortunately we don't need this very often
173 const uLabel t0(t[0]);
174 const uLabel t1(t[1]);
175 const uLabel t2(t[2]);
177 const uLabel val = (t0*t1*t2 + t0+t1+t2);
179 return Hash<uLabel>()(val, seed);
183 //- Hash specialization for hashing triFace - a commutative hash value.
184 // Hash incrementally.
186 inline unsigned Hash<triFace>::operator()(const triFace& t) const
188 return Hash<triFace>::operator()(t, 0);
193 inline bool contiguous<triFace>() {return true;}
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace Foam
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 #include "triFaceI.H"
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 // ************************************************************************* //