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 / searchableBox | selector |
37  min | minimum point for bounding box | yes |
38  max | maximum point for bounding box | yes |
39  \endtable
40 
41 SourceFiles
42  searchableBox.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef searchableBox_H
47 #define searchableBox_H
48 
49 #include "searchableSurface.H"
50 #include "treeBoundBox.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class searchableBox Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class searchableBox
62 :
63  public searchableSurface,
64  public treeBoundBox
65 {
66  // Private Member Data
67 
68  mutable wordList regions_;
69 
70 
71  // Private Member Functions
72 
73  //- Project onto component dir of planePt and update index() (=face)
74  void projectOntoCoordPlane
75  (
76  const direction dir,
77  const point& planePt,
79  ) const;
80 
81  //- Inherit findNearest from searchableSurface
83 
84  //- Returns miss or hit with face (0..5)
85  pointIndexHit findNearest
86  (
87  const point& bbMid,
88  const point& sample,
89  const scalar nearestDistSqr
90  ) const;
91 
92 
93  //- No copy construct
94  searchableBox(const searchableBox&) = delete;
95 
96  //- No copy assignment
97  void operator=(const searchableBox&) = delete;
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeName("searchableBox");
104 
105 
106  // Constructors
107 
108  //- Construct from components
109  searchableBox(const IOobject& io, const treeBoundBox& bb);
110 
111  //- Construct from dictionary (used by searchableSurface)
113  (
114  const IOobject& io,
115  const dictionary& dict
116  );
117 
118  //- Destructor
119  virtual ~searchableBox() = default;
120 
121 
122  // Member Functions
123 
124  //- Names of regions
125  virtual const wordList& regions() const;
126 
127  //- Whether surface supports volume type (below)
128  virtual bool hasVolumeType() const
129  {
130  return true;
131  }
132  //- What is type of points outside bounds
133  virtual volumeType outsideVolumeType() const
134  {
135  return volumeType::OUTSIDE;
136  }
137 
138  //- Range of local indices that can be returned.
139  virtual label size() const
140  {
141  return 6;
142  }
143 
144  //- Get representative set of element coordinates
145  // Usually the element centres (should be of length size()).
146  virtual tmp<pointField> coordinates() const;
147 
148  //- Get bounding spheres (centre and radius squared), one per element.
149  // Any point on element is guaranteed to be inside.
150  virtual void boundingSpheres
151  (
152  pointField& centres,
153  scalarField& radiusSqr
154  ) const;
155 
156  //- Get the points that define the surface.
157  virtual tmp<pointField> points() const;
158 
159  // Does any part of the surface overlap the supplied bound box?
160  virtual bool overlaps(const boundBox& bb) const
161  {
162  return boundBox::overlaps(bb);
163  }
164 
165  // Single point queries.
166 
167  //- Calculate nearest point on surface.
168  // Returns
169  // - bool : any point found nearer than nearestDistSqr
170  // - label: relevant index in surface (=face 0..5)
171  // - point: actual nearest point found
172  pointIndexHit findNearest
173  (
174  const point& sample,
175  const scalar nearestDistSqr
176  ) const;
177 
178  //- Calculate nearest point on edge.
179  // Returns
180  // - bool : any point found nearer than nearestDistSqr
181  // - label: relevant index in surface(=?)
182  // - point: actual nearest point found
184  (
185  const point& sample,
186  const scalar nearestDistSqr
187  ) const;
188 
189  //- Find nearest to segment.
190  // Returns
191  // - bool : any point found?
192  // - label: relevant index in shapes (=face 0..5)
193  // - point: actual nearest point found
194  // sets:
195  // - tightest : bounding box
196  // - linePoint : corresponding nearest point on line
197  pointIndexHit findNearest
198  (
199  const linePointRef& ln,
200  treeBoundBox& tightest,
201  point& linePoint
202  ) const;
203 
204  //- Find nearest intersection of line between start and end.
206  (
207  const point& start,
208  const point& end
209  ) const;
210 
211  //- Find any intersection of line between start and end.
213  (
214  const point& start,
215  const point& end
216  ) const;
217 
218 
219  // Multiple point queries.
220 
221  virtual void findNearest
222  (
223  const pointField& sample,
224  const scalarField& nearestDistSqr,
226  ) const;
227 
228  virtual void findLine
229  (
230  const pointField& start,
231  const pointField& end,
233  ) const;
234 
235  virtual void findLineAny
236  (
237  const pointField& start,
238  const pointField& end,
240  ) const;
241 
242  //- Get all intersections in order from start to end.
243  virtual void findLineAll
244  (
245  const pointField& start,
246  const pointField& end,
248  ) const;
249 
250  //- From a set of points and indices get the region
251  virtual void getRegion
252  (
253  const List<pointIndexHit>&,
254  labelList& region
255  ) const;
256 
257  //- From a set of points and indices get the normal
258  virtual void getNormal
259  (
260  const List<pointIndexHit>&,
261  vectorField& normal
262  ) const;
263 
264  //- Determine type (inside/outside) for points.
265  virtual void getVolumeType
266  (
267  const pointField& points,
268  List<volumeType>& volType
269  ) const;
270 
271 
272  // regIOobject implementation
273 
274  bool writeData(Ostream&) const
275  {
277  return false;
278  }
279 };
280 
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace Foam
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
Foam::searchableBox::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableBox.H:158
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:386
searchableSurface.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::searchableBox::writeData
bool writeData(Ostream &) const
Pure virtual writeData function.
Definition: searchableBox.H:293
Foam::searchableBox::findLineAny
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
Definition: searchableBox.C:449
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:87
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:532
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:436
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:577
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:55
Foam::searchableBox::findNearestOnEdge
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
Definition: searchableBox.C:304
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:235
Foam::searchableBox::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableBox.C:287
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:611
Foam::searchableBox::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableBox.H:179
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
Definition: pointIndexHit.H:45
Foam::Vector< scalar >
Foam::List< word >
Foam::searchableBox::outsideVolumeType
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
Definition: searchableBox.H:152
Foam::searchableBox::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableBox.C:224
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:509
Foam::searchableBox::TypeName
TypeName("searchableBox")
Runtime type information.
Foam::searchableBox::hasVolumeType
virtual bool hasVolumeType() const
Whether surface supports volume type (below)
Definition: searchableBox.H:147
Foam::direction
uint8_t direction
Definition: direction.H:47
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:80
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:588
Foam::searchableBox::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableBox.C:253
Foam::volumeType::OUTSIDE
A location outside the volume.
Definition: volumeType.H:69