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 | Copyright (C) 2011-2013 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  {
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 
104 
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
139 
140  inline label size() const
141  {
142  return
143  (
144  useSubset_
145  ? pointLabels_.size()
146  : points_.size()
147  );
148  }
149 
150  inline const labelList& pointLabels() const
151  {
152  return pointLabels_;
153  }
154 
155  const pointField& points() const
156  {
157  return points_;
158  }
159 
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 // ************************************************************************* //
Foam::treeDataPoint::pointLabels
const labelList & pointLabels() const
Definition: treeDataPoint.H:149
Foam::treeDataPoint::size
label size() const
Definition: treeDataPoint.H:139
Foam::treeDataPoint::points
const pointField & points() const
Definition: treeDataPoint.H:154
Foam::treeDataPoint::findIntersectOp::findIntersectOp
findIntersectOp(const indexedOctree< treeDataPoint > &tree)
Definition: treeDataPoint.C:70
Foam::treeDataPoint::useSubset
bool useSubset() const
Definition: treeDataPoint.H:159
Foam::treeDataPoint::points_
const pointField & points_
Definition: treeDataPoint.H:63
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::treeDataPoint::treeDataPoint
treeDataPoint(const pointField &)
Construct from pointField. Holds reference!
Definition: treeDataPoint.C:41
Foam::treeDataPoint
Holds (reference to) pointField. Encapsulation of data needed for octree searches....
Definition: treeDataPoint.H:59
volumeType.H
Foam::label
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
Foam::volumeType
Definition: volumeType.H:54
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::treeDataPoint::findIntersectOp
Definition: treeDataPoint.H:104
treeBoundBox.H
Foam::treeDataPoint::pointLabels_
const labelList pointLabels_
Subset of points to work on (or empty)
Definition: treeDataPoint.H:66
Foam::treeDataPoint::shapePoints
pointField shapePoints() const
Get representative point cloud for all shapes inside.
Definition: treeDataPoint.C:78
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
Foam::treeDataPoint::ClassName
ClassName("treeDataPoint")
Foam::treeDataPoint::findNearestOp
Definition: treeDataPoint.H:73
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::treeDataPoint::findNearestOp::findNearestOp
findNearestOp(const indexedOctree< treeDataPoint > &tree)
Definition: treeDataPoint.C:61
Foam::treeDataPoint::findNearestOp::tree_
const indexedOctree< treeDataPoint > & tree_
Definition: treeDataPoint.H:75
pointField.H
Foam::treeDataPoint::getVolumeType
volumeType getVolumeType(const indexedOctree< treeDataPoint > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: treeDataPoint.C:94
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::UList
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
Foam::treeDataPoint::overlaps
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: treeDataPoint.C:105
Foam::treeDataPoint::useSubset_
const bool useSubset_
Definition: treeDataPoint.H:68
Foam::line
A line primitive.
Definition: line.H:56
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:854
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
linePointRef.H