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-2024 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 its 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 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace triIntersect
50 {
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 //- Write a VTK file of a polygon
55 template<class PointField>
56 void writePolygon
57 (
58  const word& name,
59  const PointField& ps
60 );
61 
62 //- Write a VTK file of a triangle projection
64 (
65  const word& name,
66  const FixedList<point, 3>& srcTriPs,
67  const FixedList<vector, 3>& srcTriNs,
68  const label nEdge = 20,
69  const label nNormal = 20,
70  const scalar lNormal = 0.5
71 );
72 
73 //- Calculate the signed offset of a target point in relation to a projected
74 // source edge
76 (
77  const Pair<point>& srcPs,
78  const Pair<vector>& srcNs,
79  const point& tgtP
80 );
81 
82 //- Calculate the signed offset of a target point in relation to a projected
83 // source edge. Additional ordering argument can be used to account for
84 // edge orientation and thereby guarantee consistency of the result.
86 (
87  const Pair<point>& srcPs,
88  const Pair<vector>& srcNs,
89  const point& tgtP,
90  const bool srcDirection
91 );
92 
93 //- Calculate the signed offset of a projected source point in relation to a
94 // target edge
96 (
97  const point& srcP,
98  const vector& srcN,
99  const Pair<point>& tgtPs
100 );
101 
102 //- Calculate the signed offset of a projected source point in relation to a
103 // target edge. Additional ordering argument can be used to account for
104 // edge orientation and thereby guarantee consistency of the result.
106 (
107  const point& srcPs,
108  const vector& srcNs,
109  const Pair<point>& tgtP,
110  const bool tgtDirection
111 );
112 
113 //- Calculate the intersection of a target edge with a source edge's
114 // projected surface. Return the local coordinates of the intersection along
115 // both the source and target edges.
116 Pair<scalar> srcEdgeTgtEdgeIntersection
117 (
118  const Pair<point>& srcPs,
119  const Pair<vector>& srcNs,
120  const Pair<point>& tgtPs
121 );
122 
123 //- Calculate the intersection of a target point with a source triangle's
124 // projected volume. Return the local coordinates of the intersection within
125 // the source triangle.
127 (
128  const FixedList<point, 3>& srcPs,
129  const FixedList<vector, 3>& srcNs,
130  const point& tgtP
131 );
132 
133 //- Use the coordinates obtained from srcTriTgtPointIntersection to interpolate
134 // a property within a source triangle's projected volume
135 template<class Type>
137 (
138  const barycentric2D& y,
139  const FixedList<Type, 3>& tgtPsis
140 );
141 
142 //- Calculate the intersection of a projected source point with a target
143 // triangle. Return the local coordinates of the intersection within the
144 // target triangle.
146 (
147  const point& srcP,
148  const vector& srcN,
149  const FixedList<point, 3>& tgtPs
150 );
151 
152 //- Use the coordinates obtained from srcPointTgtTriIntersection to interpolate
153 // a property within a target triangle
154 template<class Type>
156 (
157  const barycentric2D& y,
158  const FixedList<Type, 3>& tgtPsis
159 );
160 
161 //- Construct the intersection of a source triangle's projected volume and a
162 // target triangle
163 void intersectTris
164 (
165  const FixedList<point, 3>& srcPs,
166  const FixedList<vector, 3>& srcNs,
167  const FixedList<bool, 3>& srcOwns,
168  const FixedList<label, 3>& srcTgtPis,
169  const FixedList<point, 3>& tgtPs,
170  const FixedList<bool, 3>& tgtOwns,
171  const FixedList<label, 3>& tgtSrcPis,
172  DynamicList<point>& srcPoints,
173  DynamicList<vector>& srcPointNormals,
174  DynamicList<point>& tgtPoints,
175  DynamicList<location>& pointLocations,
176  const bool debug,
177  const word& writePrefix=word::null
178 );
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace triIntersect
183 } // End namespace Foam
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #ifdef NoRepository
188  #include "triIntersectTemplates.C"
189 #endif
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
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.
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.
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.
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.
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.
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.