dynamicTreeDataPoint.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) 2012-2018 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 Class
25  Foam::dynamicTreeDataPoint
26 
27 Description
28  Holds (reference to) pointField. Encapsulation of data needed for
29  octree searches.
30  Used for searching for nearest point. No bounding boxes around points.
31  Only overlaps and calcNearest are implemented, rest makes little sense.
32 
33  Optionally works on subset of points.
34 
35 SourceFiles
36  dynamicTreeDataPoint.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef dynamicTreeDataPoint_H
41 #define dynamicTreeDataPoint_H
42 
43 #include "pointField.H"
44 #include "treeBoundBox.H"
45 #include "linePointRef.H"
46 #include "volumeType.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 template<class Type> class dynamicIndexedOctree;
55 
56 /*---------------------------------------------------------------------------*\
57  Class dynamicTreeDataPoint Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62  // Private data
63 
64  const DynamicList<point>& points_;
65 
66 public:
67 
68  // Declare name of the class and its debug switch
69  ClassName("dynamicTreeDataPoint");
70 
71 
72  // Constructors
73 
74  //- Construct from List. Holds reference!
76 
77 
78  // Member Functions
79 
80  // Access
81 
82  inline label size() const
83  {
84  return points_.size();
85  }
86 
87  //- Get representative point cloud for all shapes inside
88  // (one point per shape)
89  const DynamicList<point>& shapePoints() const;
90 
91 
92  // Search
93 
94  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
95  // Only makes sense for closed surfaces.
97  (
99  const point&
100  ) const;
101 
102  //- Does (bb of) shape at index overlap bb
103  bool overlaps
104  (
105  const label index,
106  const treeBoundBox& sampleBb
107  ) const;
108 
109  //- Check if any point on shape is inside sphere.
110  bool overlaps
111  (
112  const label index,
113  const point& centre,
114  const scalar radiusSqr
115  ) const;
116 
117  //- Calculates nearest (to sample) point in shape.
118  // Returns actual point and distance (squared)
119  void findNearest
120  (
121  const labelUList& indices,
122  const point& sample,
123 
124  scalar& nearestDistSqr,
125  label& nearestIndex,
126  point& nearestPoint
127  ) const;
128 
129  //- Calculates nearest (to line) point in shape.
130  // Returns point and distance (squared)
131  void findNearest
132  (
133  const labelUList& indices,
134  const linePointRef& ln,
135 
136  treeBoundBox& tightest,
137  label& minIndex,
138  point& linePoint,
139  point& nearestPoint
140  ) const;
141 
142  //- Calculate intersection of shape with ray. Sets result
143  // accordingly
145  (
146  const label index,
147  const point& start,
148  const point& end,
149  point& result
150  ) const
151  {
153  return false;
154  }
155 
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 
166 #endif
167 
168 // ************************************************************************* //
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
A line primitive.
Definition: line.H:56
ClassName("dynamicTreeDataPoint")
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
volumeType getVolumeType(const dynamicIndexedOctree< dynamicTreeDataPoint > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
dynamicTreeDataPoint(const DynamicList< point > &points)
Construct from List. Holds reference!
const pointField & points
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
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.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:896
const DynamicList< point > & shapePoints() const
Get representative point cloud for all shapes inside.
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. Sets result.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
Namespace for OpenFOAM.