1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 Implementation of the tetrahedron intersection algorithm given in:
31 D.H. Eberly, 3D Game Engine Design: A Practical Approach to Real-time
32 Computer Graphics, Morgan Kaufmann, 2001.
35 Distributed under the Boost Software License, Version 1.0.
36 http://www.boost.org/LICENSE_1_0.txt
40 University of Massachusetts Amherst
45 \*---------------------------------------------------------------------------*/
47 #ifndef tetIntersection_H
48 #define tetIntersection_H
53 #include "FixedList.H"
54 #include "DynamicList.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 /*---------------------------------------------------------------------------*\
62 Class tetIntersection Declaration
63 \*---------------------------------------------------------------------------*/
69 //- Const reference to clipping tetrahedron
70 const FixedList<point, 4>& clipTet_;
72 //- Hessian-normal plane definition
73 typedef Tuple2<vector, scalar> hPlane;
75 FixedList<hPlane, 4> clipPlanes_;
77 //- Magnitude of clipping tetrahedron
80 //- Tetrahedra used as temporaries
81 DynamicList<FixedList<point, 4> > inside_;
83 //- All intersection tets
84 DynamicList<FixedList<point, 4> > allTets_;
86 // Private Member Functions
88 //- Disallow default bitwise copy construct
89 tetIntersection(const tetIntersection&);
91 //- Disallow default bitwise assignment
92 void operator=(const tetIntersection&);
94 //- Compute clip-planes
95 inline void computeClipPlanes();
97 //- Split and decompose
98 inline void splitAndDecompose
100 const label tetPlaneIndex,
101 FixedList<point, 4>& tetra,
102 DynamicList<FixedList<point, 4> >& decompTets
109 //- Construct from components
110 inline tetIntersection(const FixedList<point, 4>& clipTet);
115 inline ~tetIntersection();
120 //- Return magnitude of clipping tetrahedron
121 inline scalar clipTetMag() const;
123 //- Evaluate for intersections against input tetrahedron
124 inline bool evaluate(const FixedList<point, 4>& subjectTet);
126 //- Return intersections
127 inline const DynamicList<FixedList<point, 4> >& getIntersection() const;
129 //- Evaluate and return volume / centroid
130 inline void getVolumeAndCentre(scalar& volume, vector& centre) const;
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 } // End namespace Foam
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 #include "tetIntersectionI.H"
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 // ************************************************************************* //