treeDataPoint.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) 2011-2020 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::treeDataPoint
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  treeDataPoint.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef treeDataPoint_H
41 #define treeDataPoint_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 indexedOctree;
55 
56 /*---------------------------------------------------------------------------*\
57  Class treeDataPoint Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class treeDataPoint
61 {
62  // Private Data
63 
64  const pointField& points_;
65 
66  //- Subset of points to work on (or empty)
67  const labelList pointLabels_;
68 
69  const bool useSubset_;
70 
71 public:
72 
73 
74  class findNearestOp
75  {
76  const indexedOctree<treeDataPoint>& tree_;
77 
78  public:
79 
81 
82  void operator()
83  (
84  const labelUList& indices,
85  const point& sample,
86 
87  scalar& nearestDistSqr,
88  label& minIndex,
89  point& nearestPoint
90  ) const;
91 
92  void operator()
93  (
94  const labelUList& indices,
95  const linePointRef& ln,
96 
97  treeBoundBox& tightest,
98  label& minIndex,
99  point& linePoint,
100  point& nearestPoint
101  ) const;
102  };
103 
105  class findIntersectOp
106  {
107  public:
108 
110 
111  //- Calculate intersection of triangle with ray. Sets result
112  // accordingly
113  bool operator()
114  (
115  const label index,
116  const point& start,
117  const point& end,
118  point& intersectionPoint
119  ) const;
120  };
121 
122 
123  // Declare name of the class and its debug switch
124  ClassName("treeDataPoint");
125 
126 
127  // Constructors
128 
129  //- Construct from pointField. Holds reference!
130  treeDataPoint(const pointField&);
131 
132  //- Construct from subset of pointField. Holds reference!
133  treeDataPoint(const pointField&, const labelList&);
134 
135 
136  // Member Functions
137 
138  // Access
140  inline label size() const
141  {
142  return
143  (
144  useSubset_
145  ? pointLabels_.size()
146  : points_.size()
147  );
148  }
150  inline const labelList& pointLabels() const
151  {
152  return pointLabels_;
153  }
155  const pointField& points() const
156  {
157  return points_;
158  }
160  bool useSubset() const
161  {
162  return useSubset_;
163  }
164 
165  //- Get representative point cloud for all shapes inside
166  // (one point per shape)
167  pointField shapePoints() const;
168 
169 
170  // Search
171 
172  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
173  // Only makes sense for closed surfaces.
175  (
177  const point&
178  ) const;
179 
180  //- Does (bb of) shape at index overlap bb
181  bool overlaps
182  (
183  const label index,
184  const treeBoundBox& sampleBb
185  ) const;
186 
187  //- Does shape at index overlap the sphere
188  bool overlaps
189  (
190  const label index,
191  const point& centre,
192  const scalar radiusSqr
193  ) const;
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 
204 #endif
205 
206 // ************************************************************************* //
volumeType getVolumeType(const indexedOctree< treeDataPoint > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataPoint.C:92
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
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.
Definition: treeDataPoint.H:59
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
bool useSubset() const
ClassName("treeDataPoint")
findNearestOp(const indexedOctree< treeDataPoint > &tree)
Definition: treeDataPoint.C:61
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:60
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
const pointField & points() const
const labelList & pointLabels() const
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
treeDataPoint(const pointField &)
Construct from pointField. Holds reference!
Definition: treeDataPoint.C:41
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataPoint.C:78
label size() const
Namespace for OpenFOAM.