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