triIntersectLocationI.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 \*---------------------------------------------------------------------------*/
25 
26 #include "triIntersectLocation.H"
27 
28 // * * * * * * * * * * * Private Static Member Functions * * * * * * * * * * //
29 
30 inline Foam::label Foam::triIntersect::location::noi()
31 {
32  return -labelMax;
33 }
34 
35 
36 // * * * * * * * * * * * * * * Private Constructors * * * * * * * * * * * * //
37 
39 (
40  const label srci,
41  const label tgti
42 )
43 :
44  labelPair(srci, tgti)
45 {}
46 
47 
48 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
49 
52 {
53  return location(srcPi, noi());
54 }
55 
56 
59 {
60  return location(noi(), tgtPi);
61 }
62 
63 
66 {
67  return location(srcPi, tgtPi);
68 }
69 
70 
73 {
74  return Foam::triIntersect::location(-1 - srcEi, -1 - tgtEi);
75 }
76 
77 
78 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
79 
81 :
82  labelPair(noi(), noi())
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  return first() == noi() && second() == noi();
91 }
92 
93 
95 {
96  return first() != noi() && first() >= 0;
97 }
98 
99 
101 {
102  return second() != noi() && second() >= 0;
103 }
104 
105 
107 {
108  return isSrcPoint() && !isTgtPoint();
109 }
110 
111 
113 {
114  return !isSrcPoint() && isTgtPoint();
115 }
116 
117 
119 {
120  return isSrcPoint() && isTgtPoint();
121 }
122 
123 
125 {
126  return
127  first() != noi() && first() < 0
128  && second() != noi() && second() < 0;
129 }
130 
131 
133 {
134  #ifdef FULLDEBUG
135  if (!isSrcPoint())
136  {
138  << "Source point requested from non-source-point location"
139  << exit(FatalError);
140  }
141  #endif
142  return first();
143 }
144 
145 
147 {
148  #ifdef FULLDEBUG
149  if (!isTgtPoint())
150  {
152  << "Target point requested from non-source-point location"
153  << exit(FatalError);
154  }
155  #endif
156  return second();
157 }
158 
159 
161 {
162  #ifdef FULLDEBUG
163  if (!isIntersection())
164  {
166  << "Source edge requested from non-intersection location"
167  << exit(FatalError);
168  }
169  #endif
170  return -1 - first();
171 }
172 
173 
175 {
176  #ifdef FULLDEBUG
177  if (!isIntersection())
178  {
180  << "Target edge requested from non-intersection location"
181  << exit(FatalError);
182  }
183  #endif
184  return -1 - second();
185 }
186 
187 
188 // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
189 
190 inline bool Foam::triIntersect::operator==(const location& a, const location& b)
191 {
192  return
193  static_cast<const labelPair&>(a)
194  == static_cast<const labelPair&>(b);
195 }
196 
197 
198 inline bool Foam::triIntersect::operator!=(const location& a, const location& b)
199 {
200  return !(a == b);
201 }
202 
203 
204 // ************************************************************************* //
bool isTgtNotSrcPoint() const
Return whether the location is a target point and not a source.
static location intersection(const label srcEi, const label tgtEi)
Construct an intersection location between a source and a.
bool isTgtPoint() const
Return whether the location is a target point.
label tgtEdgei() const
Return the target edge index.
static location srcTgtPoint(const label srcPi, const label tgtPi)
Construct a source and target point location.
bool isSrcNotTgtPoint() const
Return whether the location is a source point and not a target.
static location tgtPoint(const label tgtPi)
Construct a target point location.
label srcPointi() const
Return the source point index.
label tgtPointi() const
Return the target point index.
bool isSrcAndTgtPoint() const
Return whether the location is a source point and a target point.
bool isNull() const
Return whether the location is null.
bool isIntersection() const
Return whether the location is an intersection.
bool isSrcPoint() const
Return whether the location is a source point.
label srcEdgei() const
Return the source edge index.
static location srcPoint(const label srcPi)
Construct a source point location.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
volScalarField & b
Definition: createFields.H:27
bool operator!=(const location &a, const location &b)
bool operator==(const location &a, const location &b)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Pair< label > labelPair
Label pair.
Definition: labelPair.H:48
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
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
error FatalError
static const label labelMax
Definition: label.H:62
Class to encapsulate the topology of a point within a triangle intersection.