treeDataPoint.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-2013 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::treeDataPoint
29
30Description
31 Holds (reference to) pointField. Encapsulation of data needed for
32 octree searches.
33 Used for searching for nearest point. No bounding boxes around points.
34 Only overlaps and calcNearest are implemented, rest makes little sense.
35
36 Optionally works on subset of points.
37
38SourceFiles
39 treeDataPoint.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef treeDataPoint_H
44#define treeDataPoint_H
45
46#include "pointField.H"
47#include "treeBoundBox.H"
48#include "linePointRef.H"
49#include "volumeType.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward declarations
57template<class Type> class indexedOctree;
58
59/*---------------------------------------------------------------------------*\
60 Class treeDataPoint Declaration
61\*---------------------------------------------------------------------------*/
63class treeDataPoint
64{
65 // Private Data
66
67 const pointField& points_;
68
69 //- Subset of points to work on (or empty)
70 const labelList pointLabels_;
71
72 const bool useSubset_;
73
74public:
75
77 class findNearestOp
78 {
80
81 public:
82
84
85 void operator()
86 (
87 const labelUList& indices,
88 const point& sample,
89
90 scalar& nearestDistSqr,
91 label& minIndex,
92 point& nearestPoint
93 ) const;
94
95 void operator()
96 (
97 const labelUList& indices,
98 const linePointRef& ln,
99
100 treeBoundBox& tightest,
101 label& minIndex,
102 point& linePoint,
103 point& nearestPoint
104 ) const;
105 };
106
108 class findIntersectOp
109 {
110 public:
111
113
114 //- Calculate intersection of triangle with ray.
115 // Sets result accordingly
116 bool operator()
117 (
118 const label index,
119 const point& start,
120 const point& end,
121 point& intersectionPoint
122 ) const;
123 };
124
125
126 // Declare name of the class and its debug switch
127 ClassName("treeDataPoint");
128
129
130 // Constructors
131
132 //- Construct from pointField
133 // \note Holds reference to the points!
134 explicit treeDataPoint(const pointField& points);
135
136 //- Construct from subset of pointField, copies point ids
137 // \note Holds reference to the points!
139 (
140 const pointField& points,
141 const labelUList& pointLabels,
142 const bool useSubsetPoints = true
143 );
144
145 //- Construct from subset of pointField, moves point ids
146 // \note Holds reference to the points!
148 (
149 const pointField& points,
151 const bool useSubsetPoints = true
152 );
153
154
155 // Member Functions
156
157 // Access
158
159 //- An empty effective point field?
160 inline bool empty() const
161 {
162 return
163 (
164 useSubset_
165 ? pointLabels_.empty()
166 : points_.empty()
167 );
168 }
169
170 //- The effective point field size
171 inline label size() const
172 {
173 return
174 (
175 useSubset_
176 ? pointLabels_.size()
177 : points_.size()
178 );
179 }
180
181 //- The original point field
182 inline const pointField& points() const
183 {
184 return points_;
185 }
186
187 //- The original point ids
188 inline const labelList& pointLabels() const
189 {
190 return pointLabels_;
191 }
192
193 //- Use a subset of points
194 inline bool useSubset() const
195 {
196 return useSubset_;
197 }
198
199 //- The original (non-subset) point label
200 inline label pointLabel(const label index) const
201 {
202 return
203 (
204 useSubset_ && index >= 0
205 ? pointLabels_[index]
206 : index
207 );
208 }
209
210 //- Point at specified index
211 inline const point& shapePoint(const label index) const
212 {
213 return
214 (
215 useSubset_
216 ? points_[pointLabels_[index]]
217 : points_[index]
218 );
219 }
220
221 //- Representative point cloud for all shapes inside
222 //- (one point per shape)
223 pointField shapePoints() const;
224
225
226 // Search
227
228 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
229 // Only makes sense for closed surfaces.
231 (
233 const point& sample
234 ) const;
235
236 //- Does (bb of) shape at index overlap bb
237 bool overlaps
238 (
239 const label index,
240 const treeBoundBox& sampleBb
241 ) const;
242
243 //- Does shape at index overlap the sphere
244 bool overlaps
245 (
246 const label index,
247 const point& centre,
248 const scalar radiusSqr
249 ) const;
250
251
252 // Member Operators
253
254 //- The point at the specified index
255 inline const point& operator[](const label index) const
256 {
257 return shapePoint(index);
258 }
259};
260
261
262// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263
264} // End namespace Foam
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268
269#endif
270
271// ************************************************************************* //
Minimal example by using system/controlDict.functions:
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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
Holds (reference to) pointField. Encapsulation of data needed for octree searches....
Definition: treeDataPoint.H:63
const point & shapePoint(const label index) const
Point at specified index.
const labelList & pointLabels() const
The original point ids.
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
ClassName("treeDataPoint")
bool useSubset() const
Use a subset of points.
bool empty() const
An empty effective point field?
label size() const
The effective point field size.
const point & operator[](const label index) const
The point at the specified index.
volumeType getVolumeType(const indexedOctree< treeDataPoint > &os, const point &sample) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
label pointLabel(const label index) const
The original (non-subset) point label.
pointField shapePoints() const
Definition: treeDataPoint.C:95
const pointField & points() const
The original point field.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
OBJstream os(runTime.globalPath()/outputName)
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