1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Implementation of the tetrahedron intersection algorithm given in:
30 D.H. Eberly, 3D Game Engine Design: A Practical Approach to Real-time
31 Computer Graphics, Morgan Kaufmann, 2001.
34 Distributed under the Boost Software License, Version 1.0.
35 http://www.boost.org/LICENSE_1_0.txt
39 University of Massachusetts Amherst
44 \*---------------------------------------------------------------------------*/
46 #ifndef tetIntersection_H
47 #define tetIntersection_H
52 #include "FixedList.H"
53 #include "DynamicList.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 /*---------------------------------------------------------------------------*\
61 Class tetIntersection Declaration
62 \*---------------------------------------------------------------------------*/
68 //- Const reference to clipping tetrahedron
69 const FixedList<point, 4>& clipTet_;
71 //- Hessian-normal plane definition
72 typedef Tuple2<vector, scalar> hPlane;
74 FixedList<hPlane, 4> clipPlanes_;
76 //- Magnitude of clipping tetrahedron
79 //- Tetrahedra used as temporaries
80 DynamicList<FixedList<point, 4> > inside_;
82 //- All intersection tets
83 DynamicList<FixedList<point, 4> > allTets_;
85 // Private Member Functions
87 //- Disallow default bitwise copy construct
88 tetIntersection(const tetIntersection&);
90 //- Disallow default bitwise assignment
91 void operator=(const tetIntersection&);
93 //- Compute clip-planes
94 inline void computeClipPlanes();
96 //- Split and decompose
97 inline void splitAndDecompose
99 const label tetPlaneIndex,
100 FixedList<point, 4>& tetra,
101 DynamicList<FixedList<point, 4> >& decompTets
108 //- Construct from components
109 inline tetIntersection(const FixedList<point, 4>& clipTet);
114 inline ~tetIntersection();
119 //- Return magnitude of clipping tetrahedron
120 inline scalar clipTetMag() const;
122 //- Evaluate for intersections against input tetrahedron
123 inline bool evaluate(const FixedList<point, 4>& subjectTet);
125 //- Return intersections
126 inline const DynamicList<FixedList<point, 4> >& getIntersection() const;
128 //- Evaluate and return volume / centroid
129 inline void getVolumeAndCentre(scalar& volume, vector& centre) const;
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 } // End namespace Foam
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 #include "tetIntersectionI.H"
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 // ************************************************************************* //