triIntersect.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) 2021-2022 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 Description
25  Functions with which to perform an intersection of a pair of triangles; the
26  source and target. The source triangle is specified with three point
27  locations and three point normals. It is projected along it's point normals
28  onto the target triangle in order to calculate the intersection. The target
29  triangle is specified as three point locations only.
30 
31 SourceFiles
32  triIntersect.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef triIntersect_H
37 #define triIntersect_H
38 
39 #include "barycentric2D.H"
40 #include "DynamicField.H"
41 #include "primitivePatch.H"
42 #include "triFace.H"
43 #include "triIntersectLocation.H"
44 #include "unitConversion.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace triIntersect
51 {
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 //- Write a VTK file of a polygon
56 template<class PointField>
57 void writePolygon
58 (
59  const word& name,
60  const PointField& ps
61 );
62 
63 //- Write a VTK file of a triangle projection
65 (
66  const word& name,
67  const FixedList<point, 3>& srcTriPs,
68  const FixedList<vector, 3>& srcTriNs,
69  const label nEdge = 20,
70  const label nNormal = 20,
71  const scalar lNormal = 0.5
72 );
73 
74 //- Calculate the signed offset of a target point in relation to a projected
75 // source edge
77 (
78  const Pair<point>& srcPs,
79  const Pair<vector>& srcNs,
80  const point& tgtP
81 );
82 
83 //- Calculate the signed offset of a target point in relation to a projected
84 // source edge. Additional ordering argument can be used to account for
85 // edge orientation and thereby guarantee consistency of the result.
87 (
88  const Pair<point>& srcPs,
89  const Pair<vector>& srcNs,
90  const point& tgtP,
91  const bool srcDirection
92 );
93 
94 //- Calculate the signed offset of a projected source point in relation to a
95 // target edge
97 (
98  const point& srcP,
99  const vector& srcN,
100  const Pair<point>& tgtPs
101 );
102 
103 //- Calculate the signed offset of a projected source point in relation to a
104 // target edge. Additional ordering argument can be used to account for
105 // edge orientation and thereby guarantee consistency of the result.
107 (
108  const point& srcPs,
109  const vector& srcNs,
110  const Pair<point>& tgtP,
111  const bool tgtDirection
112 );
113 
114 //- Calculate the intersection of a target edge with a source edge's
115 // projected surface. Return the local coordinates of the intersection along
116 // both the source and target edges.
117 Pair<scalar> srcEdgeTgtEdgeIntersection
118 (
119  const Pair<point>& srcPs,
120  const Pair<vector>& srcNs,
121  const Pair<point>& tgtPs
122 );
123 
124 //- Calculate the intersection of a target point with a source triangle's
125 // projected volume. Return the local coordinates of the intersection within
126 // the source triangle.
128 (
129  const FixedList<point, 3>& srcPs,
130  const FixedList<vector, 3>& srcNs,
131  const point& tgtP
132 );
133 
134 //- Use the coordinates obtained from srcTriTgtPointIntersection to interpolate
135 // a property within a source triangle's projected volume
136 template<class Type>
138 (
139  const barycentric2D& y,
140  const FixedList<Type, 3>& tgtPsis
141 );
142 
143 //- Calculate the intersection of a projected source point with a target
144 // triangle. Return the local coordinates of the intersection within the
145 // target triangle.
147 (
148  const point& srcP,
149  const vector& srcN,
150  const FixedList<point, 3>& tgtPs
151 );
152 
153 //- Use the coordinates obtained from srcPointTgtTriIntersection to interpolate
154 // a property within a target triangle
155 template<class Type>
157 (
158  const barycentric2D& y,
159  const FixedList<Type, 3>& tgtPsis
160 );
161 
162 //- Construct the intersection of a source triangle's projected volume and a
163 // target triangle
164 void intersectTris
165 (
166  const FixedList<point, 3>& srcPs,
167  const FixedList<vector, 3>& srcNs,
168  const FixedList<bool, 3>& srcOwns,
169  const FixedList<label, 3>& srcTgtPis,
170  const FixedList<point, 3>& tgtPs,
171  const FixedList<bool, 3>& tgtOwns,
172  const FixedList<label, 3>& tgtSrcPis,
173  DynamicList<point>& srcPoints,
174  DynamicList<vector>& srcPointNormals,
175  DynamicList<point>& tgtPoints,
176  DynamicList<location>& pointLocations,
177  const bool debug,
178  const word& writePrefix=word::null
179 );
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace triIntersect
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #ifdef NoRepository
189  #include "triIntersectTemplates.C"
190 #endif
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
scalar y
static const word null
An empty word.
Definition: word.H:77
barycentric2D srcPointTgtTriIntersection(const point &srcP, const vector &srcN, const FixedList< point, 3 > &tgtPs)
Calculate the intersection of a projected source point with a target.
scalar srcPointTgtEdgeOffset(const point &srcP, const vector &srcN, const Pair< point > &tgtPs)
Calculate the signed offset of a projected source point in relation to a.
Definition: triIntersect.C:803
barycentric2D srcTriTgtPointIntersection(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const point &tgtP)
Calculate the intersection of a target point with a source triangle's.
Definition: triIntersect.C:990
void writeTriProjection(const word &name, const FixedList< point, 3 > &srcTriPs, const FixedList< vector, 3 > &srcTriNs, const label nEdge=20, const label nNormal=20, const scalar lNormal=0.5)
Write a VTK file of a triangle projection.
Definition: triIntersect.C:692
scalar srcEdgeTgtPointOffset(const Pair< point > &srcPs, const Pair< vector > &srcNs, const point &tgtP)
Calculate the signed offset of a target point in relation to a projected.
Definition: triIntersect.C:763
Type tgtTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcPointTgtTriIntersection to interpolate.
void writePolygon(const word &name, const PointField &ps)
Write a VTK file of a polygon.
Pair< scalar > srcEdgeTgtEdgeIntersection(const Pair< point > &srcPs, const Pair< vector > &srcNs, const Pair< point > &tgtPs)
Calculate the intersection of a target edge with a source edge's.
Definition: triIntersect.C:842
Type srcTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcTriTgtPointIntersection to interpolate.
void intersectTris(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< label, 3 > &srcTgtPis, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, const FixedList< label, 3 > &tgtSrcPis, DynamicList< point > &srcPoints, DynamicList< vector > &srcPointNormals, DynamicList< point > &tgtPoints, DynamicList< location > &pointLocations, const bool debug, const word &writePrefix=word::null)
Construct the intersection of a source triangle's projected volume and a.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Definition: barycentric2D.H:45
vector point
Point is a vector.
Definition: point.H:41
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
GeometricField< Type, pointPatchField, pointMesh > PointField
Class to encapsulate the topology of a point within a triangle intersection.
Unit conversion functions.