triangleFuncs.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::triangleFuncs
26 
27 Description
28  Various triangle functions.
29 
30 SourceFiles
31  triangleFuncs.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef triangleFuncs_H
36 #define triangleFuncs_H
37 
38 #include "point.H"
39 #include "label.H"
40 #include "scalar.H"
41 #include "pointField.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 class treeBoundBox;
50 
51 /*---------------------------------------------------------------------------*\
52  Class triangleFuncs Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class triangleFuncs
56 {
57 
58 public:
59 
60  // Public data types
61 
62  //- Enumeration defining nearness classification
63  enum proxType
64  {
67  EDGE
68  };
69 
70 
71 private:
72 
73  // Private Member Functions
74 
75  //- Helper function for intersect. Sets pt to be anywhere on the edge
76  // between oppositeSidePt and thisSidePt depending on both signs.
77  static void setIntersection
78  (
79  const point& oppositeSidePt,
80  const scalar oppositeSign,
81  const point& thisSidePt,
82  const scalar thisSign,
83  const scalar tol,
84  point& pt
85  );
86 
87  //- Helper function.
88  static void selectPt
89  (
90  const bool select0,
91  const point& p0,
92  const point& p1,
93  point& min
94  );
95 
96 public:
97 
98  //- Intersect triangle with parallel edges aligned with axis i0.
99  // Returns true (and intersection in pInter) if any of them intersects
100  // triangle. Used in intersectBb.
101  static bool intersectAxesBundle
102  (
103  const point& V0,
104  const point& V10,
105  const point& V20,
106  const label i0,
107  const pointField& origin,
108  const scalar maxLength,
109  point& pInter
110  );
111 
112  //- Does triangle intersect bounding box.
113  static bool intersectBb
114  (
115  const point& p0,
116  const point& p1,
117  const point& p2,
118  const treeBoundBox& cubeBb
119  );
120 
121  //- Does triangle intersect plane. Return bool and set intersection segment.
122  static bool intersect
123  (
124  const point& va0,
125  const point& va10,
126  const point& va20,
127 
128  const point& basePoint,
129  const vector& normal,
130 
131  point& pInter0,
132  point& pInter1
133  );
134 
135  //- Do triangles intersect. Return bool and set intersection segment.
136  static bool intersect
137  (
138  const point& va0,
139  const point& va10,
140  const point& va20,
141 
142  const point& vb0,
143  const point& vb10,
144  const point& vb20,
145 
146  point& pInter0,
147  point& pInter1
148  );
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #endif
159 
160 // ************************************************************************* //
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Does triangle intersect bounding box.
Various triangle functions.
Definition: triangleFuncs.H:54
proxType
Enumeration defining nearness classification.
Definition: triangleFuncs.H:62
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
static bool intersect(const point &va0, const point &va10, const point &va20, const point &basePoint, const vector &normal, point &pInter0, point &pInter1)
Does triangle intersect plane. Return bool and set intersection segment.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
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:85