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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::dynamicTreeDataPoint
28 
29 Description
30  Holds (reference to) pointField. Encapsulation of data needed for
31  octree searches.
32  Used for searching for nearest point. No bounding boxes around points.
33  Only overlaps and calcNearest are implemented, rest makes little sense.
34 
35  Optionally works on subset of points.
36 
37 SourceFiles
38  dynamicTreeDataPoint.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef dynamicTreeDataPoint_H
43 #define dynamicTreeDataPoint_H
44 
45 #include "pointField.H"
46 #include "treeBoundBox.H"
47 #include "linePointRef.H"
48 #include "volumeType.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 template<class Type> class dynamicIndexedOctree;
57 
58 /*---------------------------------------------------------------------------*\
59  Class dynamicTreeDataPoint Declaration
60 \*---------------------------------------------------------------------------*/
61 
63 {
64  // Private data
65 
66  const DynamicList<point>& points_;
67 
68 public:
69 
70  // Declare name of the class and its debug switch
71  ClassName("dynamicTreeDataPoint");
72 
73 
74  // Constructors
75 
76  //- Construct from List. Holds reference!
78 
79 
80  // Member Functions
81 
82  // Access
83 
84  inline label size() const
85  {
86  return points_.size();
87  }
88 
89  //- Get representative point cloud for all shapes inside
90  // (one point per shape)
91  const DynamicList<point>& shapePoints() const;
92 
93 
94  // Search
95 
96  //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
97  // Only makes sense for closed surfaces.
99  (
101  const point&
102  ) const;
103 
104  //- Does (bb of) shape at index overlap bb
105  bool overlaps
106  (
107  const label index,
108  const treeBoundBox& sampleBb
109  ) const;
110 
111  //- Check if any point on shape is inside sphere.
112  bool overlaps
113  (
114  const label index,
115  const point& centre,
116  const scalar radiusSqr
117  ) const;
118 
119  //- Calculates nearest (to sample) point in shape.
120  // Returns actual point and distance (squared)
121  void findNearest
122  (
123  const labelUList& indices,
124  const point& sample,
125 
126  scalar& nearestDistSqr,
127  label& nearestIndex,
128  point& nearestPoint
129  ) const;
130 
131  //- Calculates nearest (to line) point in shape.
132  // Returns point and distance (squared)
133  void findNearest
134  (
135  const labelUList& indices,
136  const linePointRef& ln,
137 
138  treeBoundBox& tightest,
139  label& minIndex,
140  point& linePoint,
141  point& nearestPoint
142  ) const;
143 
144  //- Calculate intersection of shape with ray. Sets result
145  // accordingly
147  (
148  const label index,
149  const point& start,
150  const point& end,
151  point& result
152  ) const
153  {
155  return false;
156  }
157 
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 
168 #endif
169 
170 // ************************************************************************* //
Foam::DynamicList< point >
Foam::dynamicTreeDataPoint::findNearest
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
Definition: dynamicTreeDataPoint.C:101
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::dynamicTreeDataPoint::shapePoints
const DynamicList< point > & shapePoints() const
Get representative point cloud for all shapes inside.
Definition: dynamicTreeDataPoint.C:54
Foam::dynamicTreeDataPoint::overlaps
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does (bb of) shape at index overlap bb.
Definition: dynamicTreeDataPoint.C:71
Foam::dynamicIndexedOctree
Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted.
Definition: dynamicIndexedOctree.H:57
Foam::dynamicTreeDataPoint::intersects
bool intersects(const label index, const point &start, const point &end, point &result) const
Calculate intersection of shape with ray. Sets result.
Definition: dynamicTreeDataPoint.H:146
Foam::dynamicTreeDataPoint
Holds (reference to) pointField. Encapsulation of data needed for octree searches....
Definition: dynamicTreeDataPoint.H:61
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
volumeType.H
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
treeBoundBox.H
Foam::dynamicTreeDataPoint::ClassName
ClassName("dynamicTreeDataPoint")
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
pointField.H
Foam::Vector< scalar >
Foam::dynamicTreeDataPoint::getVolumeType
volumeType getVolumeType(const dynamicIndexedOctree< dynamicTreeDataPoint > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
Definition: dynamicTreeDataPoint.C:61
Foam::UList< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::line
A line primitive.
Definition: line.H:53
Foam::dynamicTreeDataPoint::dynamicTreeDataPoint
dynamicTreeDataPoint(const DynamicList< point > &points)
Construct from List. Holds reference!
Definition: dynamicTreeDataPoint.C:43
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:925
Foam::dynamicTreeDataPoint::size
label size() const
Definition: dynamicTreeDataPoint.H:83
sample
Minimal example by using system/controlDict.functions:
linePointRef.H