Loading...
Searching...
No Matches
dynamicTreeDataPoint.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) 2012-2015 OpenFOAM Foundation
9 Copyright (C) 2022 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::dynamicTreeDataPoint
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 dynamicTreeDataPoint.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_dynamicTreeDataPoint_H
44#define Foam_dynamicTreeDataPoint_H
45
46#include "pointField.H"
47#include "treeBoundBox.H"
48#include "line.H"
49#include "volumeType.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward Declarations
57template<class Type> class dynamicIndexedOctree;
59/*---------------------------------------------------------------------------*\
60 Class dynamicTreeDataPoint Declaration
61\*---------------------------------------------------------------------------*/
62
64{
65 // Private Data
66
67 //- The point field
68 const DynamicList<point>& points_;
69
70
71public:
72
73 // Declare name of the class
74 ClassNameNoDebug("dynamicTreeDataPoint");
75
76
77 // Constructors (non-caching)
78
79 //- Construct from List. Holds reference!
81
82
83 // Member Functions
84
85 //- Object dimension == 0 (point element)
86 int nDim() const noexcept { return 0; }
88 //- Return bounding box for the specified point indices
89 treeBoundBox bounds(const labelUList& indices) const;
90
91
92 // Access
93
94 //- The original point field
95 const DynamicList<point>& points() const noexcept { return points_; }
96
97 //TDB //- The subset of point ids to use
99
100 //- Use a subset of points
101 bool useSubset() const noexcept { return false; }
102
103 //- Is the effective point field empty?
104 bool empty() const noexcept { return points_.empty(); }
105
106 //- The size of the effective point field
107 label size() const noexcept { return points_.size(); }
109 //- Map from shape index to original (non-subset) point label
110 label objectIndex(label index) const noexcept { return index; }
111
112 //- Point at specified shape index
113 const point& operator[](label index) const { return points_[index]; }
114
115 //- Point at specified shape index
116 const point& centre(label index) const { return points_[index]; }
117
118 //- Representative point cloud
119 const DynamicList<point>& centres() const noexcept { return points_; }
120
121
122 // Search
124 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
125 // Only makes sense for closed surfaces.
127 (
129 const point&
130 ) const;
131
132 //- Does (bb of) shape at index overlap bb
134 (
135 const label index,
136 const treeBoundBox& searchBox
137 ) const;
139 //- Check if any point on shape is inside sphere.
140 bool overlaps
141 (
142 const label index,
143 const point& centre,
144 const scalar radiusSqr
145 ) const;
146
147 //- Calculates nearest (to sample) point in shape.
148 // Returns actual point and distance (squared)
149 void findNearest
150 (
151 const labelUList& indices,
152 const point& sample,
153
154 scalar& nearestDistSqr,
155 label& nearestIndex,
156 point& nearestPoint
157 ) const;
158
159 //- Calculates nearest (to line) point in shape.
160 // Returns point and distance (squared)
161 void findNearest
162 (
163 const labelUList& indices,
164 const linePointRef& ln,
165
166 treeBoundBox& tightest,
167 label& minIndex,
168 point& linePoint,
169 point& nearestPoint
170 ) const;
171
172 //- Calculate intersection of shape with ray.
173 // Sets result accordingly
174 bool intersects
175 (
176 const label index,
177 const point& start,
178 const point& end,
179 point& result
180 ) const
181 {
183 return false;
184 }
185};
186
187
188// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189
190} // End namespace Foam
191
192// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193
194
195#endif
196
197// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Minimal example by using system/controlDict.functions:
bool empty() const noexcept
True if List is empty (ie, size() is zero).
Definition UList.H:701
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted.
const point & operator[](label index) const
Point at specified shape index.
bool useSubset() const noexcept
const labelList& pointLabels() const noexcept { labelList::null(); }
const DynamicList< point > & centres() const noexcept
Representative point cloud.
label objectIndex(label index) const noexcept
Map from shape index to original (non-subset) point label.
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
volumeType getVolumeType(const dynamicIndexedOctree< dynamicTreeDataPoint > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
bool empty() const noexcept
Is the effective point field empty?
int nDim() const noexcept
Object dimension == 0 (point element).
bool intersects(const label index, const point &start, const point &end, point &result) const
Calculate intersection of shape with ray.
dynamicTreeDataPoint(const DynamicList< point > &points)
Construct from List. Holds reference!
treeBoundBox bounds(const labelUList &indices) const
Return bounding box for the specified point indices.
const point & centre(label index) const
Point at specified shape index.
label size() const noexcept
The size of the effective point field.
const DynamicList< point > & points() const noexcept
The original point field.
ClassNameNoDebug("dynamicTreeDataPoint")
bool overlaps(const label index, const treeBoundBox &searchBox) const
Does (bb of) shape at index overlap bb.
Standard boundBox with extra functionality for use in octree.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition volumeType.H:56
#define ClassNameNoDebug(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:39
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
Namespace for bounding specifications. At the moment, mostly for tables.
Namespace for OpenFOAM.
line< point, const point & > linePointRef
A line using referred points.
Definition line.H:66
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition POSIX.C:1239