1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 //- Return swept-volume
128 inline scalar sweptVol
130 const pointField& oldPoints,
131 const pointField& newPoints
134 //- Return point intersection with a ray starting at p, with
140 const pointField& points,
141 const intersection::algorithm = intersection::FULL_RAY,
142 const intersection::direction dir = intersection::VECTOR
145 //- Return the triangle
146 inline triPointRef tri(const pointField&) const;
151 // - -1: same face, but different orientation
152 static inline int compare(const triFace&, const triFace&);
156 friend bool operator==(const triFace&, const triFace&);
157 friend bool operator!=(const triFace&, const triFace&);
161 //- Hash<triFace> specialisation
162 // Simple commutative hash.
164 inline label Hash<triFace>::operator()(const triFace& t) const
166 return (t[0]*t[1]*t[2] + t[0]+t[1]+t[2]);
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 #include "triFaceI.H"
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 // ************************************************************************* //