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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::dynamicTreeDataPoint
29 
30 Description
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 
38 SourceFiles
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 
53 namespace Foam
54 {
55 
56 // Forward Declarations
57 template<class Type> class dynamicIndexedOctree;
58 
59 /*---------------------------------------------------------------------------*\
60  Class dynamicTreeDataPoint Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 {
65  // Private Data
66 
67  //- The point field
68  const DynamicList<point>& points_;
69 
70 
71 public:
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; }
87 
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
133  bool overlaps
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 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
A line primitive.
Definition: line.H:52
const point & operator[](label index) const
Point at specified shape index.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:666
const DynamicList< point > & points() const noexcept
The original point field.
label size() const noexcept
The size of the effective point field.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
Definition: volumeType.H:55
bool overlaps(const label index, const treeBoundBox &searchBox) const
Does (bb of) shape at index overlap bb.
volumeType getVolumeType(const dynamicIndexedOctree< dynamicTreeDataPoint > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
label objectIndex(label index) const noexcept
Map from shape index to original (non-subset) point label.
int nDim() const noexcept
Object dimension == 0 (point element)
dynamicTreeDataPoint(const DynamicList< point > &points)
Construct from List. Holds reference!
ClassNameNoDebug("dynamicTreeDataPoint")
Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted...
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:1237
const direction noexcept
Definition: Scalar.H:258
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:201
bool empty() const noexcept
Is the effective point field empty?
treeBoundBox bounds(const labelUList &indices) const
Return bounding box for the specified point indices.
const DynamicList< point > & centres() const noexcept
Representative point cloud.
Holds (reference to) pointField. Encapsulation of data needed for octree searches. Used for searching for nearest point. No bounding boxes around points. Only overlaps and calcNearest are implemented, rest makes little sense.
bool intersects(const label index, const point &start, const point &end, point &result) const
Calculate intersection of shape with ray.
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:90
const point & centre(label index) const
Point at specified shape index.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
bool useSubset() const noexcept
const labelList& pointLabels() const noexcept { labelList::null(); }
Namespace for OpenFOAM.