triangleFuncs.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9  Copyright (C) 2020-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::triangleFuncs
29 
30 Description
31  Contains various triangle static functions.
32 
33 SourceFiles
34  triangleFuncs.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_triangleFuncs_H
39 #define Foam_triangleFuncs_H
40 
41 #include "pointField.H"
42 #include "triangle.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class treeBoundBox;
51 
52 /*---------------------------------------------------------------------------*\
53  Class triangleFuncs Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class triangleFuncs
57 {
58  // Private Member Functions
59 
60  //- Sets pt to be anywhere on the edge between oppositeSidePt
61  //- and thisSidePt depending on both signs.
62  // \note Helper function for intersect()
63  static void setIntersection
64  (
65  const point& oppositeSidePt,
66  const scalar oppositeSign,
67  const point& thisSidePt,
68  const scalar thisSign,
69  const scalar tol,
70  point& pt
71  );
72 
73 public:
74 
75  // Static Member Functions
76 
77  //- Intersect triangle with parallel edges aligned with axis i0.
78  // Returns true (and intersection in pInter) if any of them intersects
79  // triangle. Used in intersectBb.
80  static bool intersectAxesBundle
81  (
82  const point& V0,
83  const point& V10,
84  const point& V20,
85  const label i0,
86  const pointField& origin,
87  const scalar maxLength,
88  point& pInter
89  );
90 
91  //- Intersect triangle with bounding box.
92  // \return true if any bounding box faces intersect the triangle,
93  // returns false if the triangle is inside the bounding box
94  static bool intersectBb
95  (
96  const triPointRef& tri,
97  const treeBoundBox& cubeBb
98  );
99 
100  //- Intersect triangle with bounding box.
101  // \return true if any bounding box faces intersect the triangle,
102  // returns false if the triangle is inside the bounding box
103  static bool intersectBb
104  (
105  const point& p0,
106  const point& p1,
107  const point& p2,
108  const treeBoundBox& cubeBb
109  );
110 
111  //- Intersect triangle with plane.
112  // \return bool and set intersection segment.
113  static bool intersect
114  (
115  const point& va0,
116  const point& va10,
117  const point& va20,
118 
119  const point& basePoint,
120  const vector& normal,
121 
122  point& pInter0,
123  point& pInter1
124  );
125 
126  //- Intersection of two triangles intersect.
127  // \return bool and set intersection segment.
128  static bool intersect
129  (
130  const point& va0,
131  const point& va10,
132  const point& va20,
133 
134  const point& vb0,
135  const point& vb10,
136  const point& vb20,
137 
138  point& pInter0,
139  point& pInter1
140  );
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #endif
151 
152 // ************************************************************************* //
A triangle primitive used to calculate face normals and swept volumes. Uses referred points...
Definition: triangle.H:217
Contains various triangle static functions.
Definition: triangleFuncs.H:51
static bool intersect(const point &va0, const point &va10, const point &va20, const point &basePoint, const vector &normal, point &pInter0, point &pInter1)
Intersect triangle with plane.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:90
const volScalarField & p0
Definition: EEqn.H:36
Namespace for OpenFOAM.
static bool intersectAxesBundle(const point &V0, const point &V10, const point &V20, const label i0, const pointField &origin, const scalar maxLength, point &pInter)
Intersect triangle with parallel edges aligned with axis i0.
Definition: triangleFuncs.C:60
static bool intersectBb(const triPointRef &tri, const treeBoundBox &cubeBb)
Intersect triangle with bounding box.