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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::triangleFuncs
28 
29 Description
30  Various triangle functions.
31 
32 SourceFiles
33  triangleFuncs.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef triangleFuncs_H
38 #define triangleFuncs_H
39 
40 #include "point.H"
41 #include "label.H"
42 #include "scalar.H"
43 #include "pointField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class treeBoundBox;
52 
53 /*---------------------------------------------------------------------------*\
54  Class triangleFuncs Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class triangleFuncs
58 {
59 
60 public:
61 
62  // Public data types
63 
64  //- Enumeration defining nearness classification
65  enum proxType
66  {
69  EDGE
70  };
71 
72 
73 private:
74 
75  // Private Member Functions
76 
77  //- Helper function for intersect. Sets pt to be anywhere on the edge
78  // between oppositeSidePt and thisSidePt depending on both signs.
79  static void setIntersection
80  (
81  const point& oppositeSidePt,
82  const scalar oppositeSign,
83  const point& thisSidePt,
84  const scalar thisSign,
85  const scalar tol,
86  point& pt
87  );
88 
89  //- Helper function.
90  static void selectPt
91  (
92  const bool select0,
93  const point& p0,
94  const point& p1,
95  point& min
96  );
97 
98 public:
99 
100  //- Intersect triangle with parallel edges aligned with axis i0.
101  // Returns true (and intersection in pInter) if any of them intersects
102  // triangle. Used in intersectBb.
103  static bool intersectAxesBundle
104  (
105  const point& V0,
106  const point& V10,
107  const point& V20,
108  const label i0,
109  const pointField& origin,
110  const scalar maxLength,
111  point& pInter
112  );
113 
114  //- Does triangle intersect bounding box.
115  static bool intersectBb
116  (
117  const point& p0,
118  const point& p1,
119  const point& p2,
120  const treeBoundBox& cubeBb
121  );
122 
123  //- Does triangle intersect plane. Return bool and set intersection segment.
124  static bool intersect
125  (
126  const point& va0,
127  const point& va10,
128  const point& va20,
129 
130  const point& basePoint,
131  const vector& normal,
132 
133  point& pInter0,
134  point& pInter1
135  );
136 
137  //- Do triangles intersect. Return bool and set intersection segment.
138  static bool intersect
139  (
140  const point& va0,
141  const point& va10,
142  const point& va20,
143 
144  const point& vb0,
145  const point& vb10,
146  const point& vb20,
147 
148  point& pInter0,
149  point& pInter1
150  );
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
Foam::triangleFuncs::intersectAxesBundle
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:89
point.H
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:87
Foam::triangleFuncs::POINT
Definition: triangleFuncs.H:67
Foam::triangleFuncs::NONE
Definition: triangleFuncs.H:66
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::triangleFuncs
Various triangle functions.
Definition: triangleFuncs.H:56
Foam::triangleFuncs::intersectBb
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Does triangle intersect bounding box.
Definition: triangleFuncs.C:176
Foam::Field< vector >
scalar.H
Foam::triangleFuncs::proxType
proxType
Enumeration defining nearness classification.
Definition: triangleFuncs.H:64
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::triangleFuncs::EDGE
Definition: triangleFuncs.H:68
pointField.H
Foam::Vector< scalar >
label.H
Foam::triangleFuncs::intersect
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.
Definition: triangleFuncs.C:233
p0
const volScalarField & p0
Definition: EEqn.H:36