initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / meshShapes / triFace / triFace.H
blob38301fec589d6906ad10a92ec5134f66aa17802a
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 Class
26     Foam::triFace
28 Description
29     A triangle face primitive using a FixedList.
31 SourceFiles
32     triFaceI.H
34 \*---------------------------------------------------------------------------*/
36 #ifndef triFace_H
37 #define triFace_H
39 #include "FixedList.H"
40 #include "edgeList.H"
41 #include "pointHit.H"
42 #include "intersection.H"
43 #include "pointField.H"
44 #include "triPointRef.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 class face;
53 // Forward declaration of friend functions and operators
55 class triFace;
56 inline bool operator==(const triFace&, const triFace&);
57 inline bool operator!=(const triFace&, const triFace&);
60 /*---------------------------------------------------------------------------*\
61                            class triFace Declaration
62 \*---------------------------------------------------------------------------*/
64 class triFace
66     public FixedList<label, 3>
69 public:
71     // Constructors
73         //- Construct null
74         inline triFace();
76         //- Construct from three point labels
77         inline triFace
78         (
79             const label a,
80             const label b,
81             const label c
82         );
84         //- Construct from a UList<label>
85         explicit inline triFace(const UList<label>&);
87         //- Construct from Istream
88         inline triFace(Istream&);
91     // Member Functions
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;
104         // Properties
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;
115             //- Return edges
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
129             (
130                 const pointField& oldPoints,
131                 const pointField& newPoints
132             ) const;
134             //- Return point intersection with a ray starting at p, with
135             //  direction n.
136             inline pointHit ray
137             (
138                 const point& p,
139                 const vector& q,
140                 const pointField& points,
141                 const intersection::algorithm = intersection::FULL_RAY,
142                 const intersection::direction dir = intersection::VECTOR
143             ) const;
145             //- Return the triangle
146             inline triPointRef tri(const pointField&) const;
148         //- compare triFaces
149         //  -  0: different
150         //  - +1: identical
151         //  - -1: same face, but different orientation
152         static inline int compare(const triFace&, const triFace&);
154     // Friend Operators
156         friend bool operator==(const triFace&, const triFace&);
157         friend bool operator!=(const triFace&, const triFace&);
161 //- Hash<triFace> specialisation
162 //  Simple commutative hash.
163 template<>
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 #endif
182 // ************************************************************************* //