searchableBox.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018 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::searchableBox
29 
30 Description
31  Searching on bounding box
32 
33  \heading Dictionary parameters
34  \table
35  Property | Description | Required | Default
36  type | box | selector |
37  min | minimum point for bounding box | yes |
38  max | maximum point for bounding box | yes |
39  \endtable
40 
41 Note
42  Longer type name : \c searchableBox
43 
44 SourceFiles
45  searchableBox.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef searchableBox_H
50 #define searchableBox_H
51 
52 #include "searchableSurface.H"
53 #include "treeBoundBox.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class searchableBox Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class searchableBox
65 :
66  public searchableSurface,
67  public treeBoundBox
68 {
69  // Private Member Data
70 
71  mutable wordList regions_;
72 
73 
74  // Private Member Functions
75 
76  //- Project onto component dir of planePt and update index() (=face)
77  void projectOntoCoordPlane
78  (
79  const direction dir,
80  const point& planePt,
82  ) const;
83 
84  //- Inherit findNearest from searchableSurface
86 
87  //- Returns miss or hit with face (0..5)
88  pointIndexHit findNearest
89  (
90  const point& bbMid,
91  const point& sample,
92  const scalar nearestDistSqr
93  ) const;
94 
95 
96  //- No copy construct
97  searchableBox(const searchableBox&) = delete;
98 
99  //- No copy assignment
100  void operator=(const searchableBox&) = delete;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("searchableBox");
107 
108 
109  // Constructors
110 
111  //- Construct from components
112  searchableBox(const IOobject& io, const treeBoundBox& bb);
113 
114  //- Construct from dictionary (used by searchableSurface)
116  (
117  const IOobject& io,
118  const dictionary& dict
119  );
120 
121 
122  //- Destructor
123  virtual ~searchableBox() = default;
124 
125 
126  // Member Functions
127 
128  //- Names of regions
129  virtual const wordList& regions() const;
130 
131  //- Whether surface supports volume type (below)
132  virtual bool hasVolumeType() const
133  {
134  return true;
135  }
136  //- What is type of points outside bounds
137  virtual volumeType outsideVolumeType() const
138  {
139  return volumeType::OUTSIDE;
140  }
141 
142  //- Range of local indices that can be returned.
143  virtual label size() const
144  {
145  return 6;
146  }
147 
148  //- Get representative set of element coordinates
149  // Usually the element centres (should be of length size()).
150  virtual tmp<pointField> coordinates() const;
151 
152  //- Get bounding spheres (centre and radius squared), one per element.
153  // Any point on element is guaranteed to be inside.
154  virtual void boundingSpheres
155  (
156  pointField& centres,
157  scalarField& radiusSqr
158  ) const;
159 
160  //- Get the points that define the surface.
161  virtual tmp<pointField> points() const;
162 
163  // Does any part of the surface overlap the supplied bound box?
164  virtual bool overlaps(const boundBox& bb) const
165  {
166  return boundBox::overlaps(bb);
167  }
168 
169  // Single point queries.
170 
171  //- Calculate nearest point on surface.
172  // Returns
173  // - bool : any point found nearer than nearestDistSqr
174  // - label: relevant index in surface (=face 0..5)
175  // - point: actual nearest point found
176  pointIndexHit findNearest
177  (
178  const point& sample,
179  const scalar nearestDistSqr
180  ) const;
181 
182  //- Calculate nearest point on edge.
183  // Returns
184  // - bool : any point found nearer than nearestDistSqr
185  // - label: relevant index in surface(=?)
186  // - point: actual nearest point found
188  (
189  const point& sample,
190  const scalar nearestDistSqr
191  ) const;
192 
193  //- Find nearest to segment.
194  // Returns
195  // - bool : any point found?
196  // - label: relevant index in shapes (=face 0..5)
197  // - point: actual nearest point found
198  // sets:
199  // - tightest : bounding box
200  // - linePoint : corresponding nearest point on line
201  pointIndexHit findNearest
202  (
203  const linePointRef& ln,
204  treeBoundBox& tightest,
205  point& linePoint
206  ) const;
207 
208  //- Find nearest intersection of line between start and end.
210  (
211  const point& start,
212  const point& end
213  ) const;
214 
215  //- Find any intersection of line between start and end.
217  (
218  const point& start,
219  const point& end
220  ) const;
221 
222 
223  // Multiple point queries.
224 
225  virtual void findNearest
226  (
227  const pointField& sample,
228  const scalarField& nearestDistSqr,
230  ) const;
231 
232  virtual void findLine
233  (
234  const pointField& start,
235  const pointField& end,
237  ) const;
238 
239  virtual void findLineAny
240  (
241  const pointField& start,
242  const pointField& end,
244  ) const;
245 
246  //- Get all intersections in order from start to end.
247  virtual void findLineAll
248  (
249  const pointField& start,
250  const pointField& end,
252  ) const;
253 
254  //- From a set of points and indices get the region
255  virtual void getRegion
256  (
257  const List<pointIndexHit>&,
258  labelList& region
259  ) const;
260 
261  //- From a set of points and indices get the normal
262  virtual void getNormal
263  (
264  const List<pointIndexHit>&,
265  vectorField& normal
266  ) const;
267 
268  //- Determine type (inside/outside) for points.
269  virtual void getVolumeType
270  (
271  const pointField& points,
272  List<volumeType>& volType
273  ) const;
274 
275 
276  // regIOobject implementation
277 
278  bool writeData(Ostream&) const
279  {
281  return false;
282  }
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #endif
293 
294 // ************************************************************************* //
Foam::searchableBox::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableBox.H:162
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::searchableBox::findLine
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
Definition: searchableBox.C:375
searchableSurface.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::searchableBox::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableBox.H:297
Foam::searchableBox::findLineAny
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
Definition: searchableBox.C:438
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:540
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::boundBox::overlaps
bool overlaps(const boundBox &bb) const
Overlaps/touches boundingBox?
Definition: boundBoxI.H:221
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:445
Foam::searchableBox::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableBox.C:565
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:52
Foam::searchableBox::findNearestOnEdge
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
Definition: searchableBox.C:293
Foam::volumeType
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:60
Foam::Field< vector >
treeBoundBox.H
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::searchableBox::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableBox.C:224
Foam::searchableBox::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableBox.C:276
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Foam::searchableBox::getVolumeType
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside) for points.
Definition: searchableBox.C:599
Foam::searchableBox::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableBox.H:183
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
Definition: pointIndexHit.H:46
Foam::Vector< scalar >
Foam::List< word >
Foam::searchableBox::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableBox.H:156
Foam::searchableBox::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableBox.C:213
Foam::searchableBox::~searchableBox
virtual ~searchableBox()=default
Destructor.
Foam::searchableBox::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
Definition: searchableBox.C:498
Foam::searchableBox::TypeName
TypeName("searchableBox")
Runtime type information.
Foam::searchableBox::hasVolumeType
virtual bool hasVolumeType() const
Whether surface supports volume type (below)
Definition: searchableBox.H:151
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::line
A line primitive.
Definition: line.H:59
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:915
Foam::searchableBox
Searching on bounding box.
Definition: searchableBox.H:83
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::searchableBox::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableBox.C:576
Foam::searchableBox::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableBox.C:242
Foam::volumeType::OUTSIDE
A location outside the volume.
Definition: volumeType.H:69