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