treeDataPrimitivePatch.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-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::treeDataPrimitivePatch
28
29Description
30 Encapsulation of data needed to search on PrimitivePatches
31
32SourceFiles
33 treeDataPrimitivePatch.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef treeDataPrimitivePatch_H
38#define treeDataPrimitivePatch_H
39
40#include "treeBoundBoxList.H"
41#include "volumeType.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// Forward declaration of classes
49template<class Type> class indexedOctree;
50
51
52/*---------------------------------------------------------------------------*\
53 Class treeDataPrimitivePatchName Declaration
54\*---------------------------------------------------------------------------*/
57
58
59/*---------------------------------------------------------------------------*\
60 Class treeDataPrimitivePatch Declaration
61\*---------------------------------------------------------------------------*/
62
63template<class PatchType>
65:
66 public treeDataPrimitivePatchName
67{
68 // Private data
69
70 //- Underlying geometry
71 const PatchType& patch_;
72
73 //- Whether to precalculate and store face bounding box
74 const bool cacheBb_;
75
76 //- Tolerance to use for intersection tests
77 const scalar planarTol_;
78
79 //- Face bounding boxes (valid only if cacheBb_)
81
82
83 // Private Member Functions
84
85 //- Initialise all member data
86 void update();
87
88
89public:
90
92 class findNearestOp
93 {
95
96 public:
97
99
100 void operator()
101 (
102 const labelUList& indices,
103 const point& sample,
104
105 scalar& nearestDistSqr,
106 label& minIndex,
107 point& nearestPoint
108 ) const;
109
110 //- Calculates nearest (to line) point in shape.
111 // Returns point and distance (squared)
112 void operator()
113 (
114 const labelUList& indices,
115 const linePointRef& ln,
116
117 treeBoundBox& tightest,
118 label& minIndex,
119 point& linePoint,
120 point& nearestPoint
121 ) const;
122 };
123
125 class findIntersectOp
126 {
128
129 public:
130
132
133 //- Calculate intersection of any face with ray.
134 // Sets result accordingly. Used to find first intersection.
135 bool operator()
136 (
137 const label index,
138 const point& start,
139 const point& end,
140 point& intersectionPoint
141 ) const;
142 };
143
146 {
148
149 DynamicList<label>& shapeMask_;
150
151 public:
152
154 (
156 DynamicList<label>& shapeMask
157 );
158
159 //- Calculate intersection of unique face with ray.
160 // Sets result accordingly. Used to find all faces.
161 bool operator()
162 (
163 const label index,
164 const point& start,
165 const point& end,
166 point& intersectionPoint
167 ) const;
168 };
169
172 {
174
175 const label edgeID_;
176
177 public:
178
180 (
182 const label edgeID
183 );
184
185 //- Calculate intersection of face with edge of patch.
186 // Excludes faces that use edgeID. Used to find self intersection.
187 bool operator()
188 (
189 const label index,
190 const point& start,
191 const point& end,
192 point& intersectionPoint
193 ) const;
194 };
195
196
197 // Constructors
198
199 //- Construct from patch.
201 (
202 const bool cacheBb,
203 const PatchType&,
204 const scalar planarTol
205 );
206
207
208 // Member Functions
209
210 // Access
212 label size() const
213 {
214 return patch_.size();
215 }
216
217 //- Representative point cloud for all shapes inside
218 //- (one point per shape)
219 pointField shapePoints() const;
220
221 //- Return access to the underlying patch
222 const PatchType& patch() const
223 {
224 return patch_;
225 }
226
227
228 // Search
229
230 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
231 // Only makes sense for closed surfaces.
233 (
235 const point&
236 ) const;
237
238 //- Does shape at index overlap bb
239 bool overlaps
240 (
241 const label index,
242 const treeBoundBox& sampleBb
243 ) const;
244
245 //- Does shape at index overlap sphere
246 bool overlaps
247 (
248 const label index,
249 const point& centre,
250 const scalar radiusSqr
251 ) const;
252
253 //- Helper: find intersection of line with shapes
254 static bool findIntersection
255 (
257 const label index,
258 const point& start,
259 const point& end,
260 point& intersectionPoint
261 );
262};
263
264
265// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266
267} // End namespace Foam
268
269// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270
271#ifdef NoRepository
272 #include "treeDataPrimitivePatch.C"
273#endif
274
275// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276
277#endif
278
279// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Minimal example by using system/controlDict.functions:
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
A line primitive.
Definition: line.H:68
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
Encapsulation of data needed to search on PrimitivePatches.
volumeType getVolumeType(const indexedOctree< treeDataPrimitivePatch< PatchType > > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does shape at index overlap bb.
static bool findIntersection(const indexedOctree< treeDataPrimitivePatch< PatchType > > &tree, const label index, const point &start, const point &end, point &intersectionPoint)
Helper: find intersection of line with shapes.
const PatchType & patch() const
Return access to the underlying patch.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
#define TemplateName(TemplateNameString)
Add typeName information from argument TypeNameString to a.
Definition: className.H:79
Namespace for OpenFOAM.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:933