searchableRotatedBox.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) 2014 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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::searchableRotatedBox
26 
27 Description
28  Searching on a rotated box
29 
30  Box defined as min and max coordinate. Rotation by coordinate system
31  at box middle.
32 
33  E.g. box with sides 1 1 1 rotated 45 degrees around z-axis at
34  origin (0.5 0.5 0.5)
35  \verbatim
36  span (1 1 1);
37  origin (0.5 0.5 0.5);
38  e1 (1 1 0);
39  e3 (0 0 1);
40  \endverbatim
41 
42 SourceFiles
43  searchableRotatedBox.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef searchableRotatedBox_H
48 #define searchableRotatedBox_H
49 
50 #include "searchableSurface.H"
51 #include "coordinateSystem.H"
52 #include "searchableBox.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class searchableRotatedBox Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 :
65  public searchableSurface
66 {
67 private:
68 
69  // Private Member Data
70 
71  //- box in local coordinate system
73 
74  //- transformation from local to global coordinates
76 
77  //- (global) corner points (in treeBoundBox order)
79 
80 
81  // Private Member Functions
82 
83  //- Disallow default bitwise copy construct
85 
86  //- Disallow default bitwise assignment
87  void operator=(const searchableRotatedBox&);
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("searchableRotatedBox");
94 
95 
96  // Constructors
97 
98  //- Construct from dictionary (used by searchableSurface)
100  (
101  const IOobject& io,
102  const dictionary& dict
103  );
104 
105 
106  //- Destructor
107  virtual ~searchableRotatedBox();
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  // Single point queries.
145 
146  //- Inherit findNearest from searchableSurface
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
155  (
156  const point& sample,
157  const scalar nearestDistSqr
158  ) const;
159 
160  //- Find nearest to segment.
161  // Returns
162  // - bool : any point found?
163  // - label: relevant index in shapes (=face 0..5)
164  // - point: actual nearest point found
165  // sets:
166  // - tightest : bounding box
167  // - linePoint : corresponding nearest point on line
169  (
170  const linePointRef& ln,
171  treeBoundBox& tightest,
172  point& linePoint
173  ) const;
174 
175  //- Find nearest intersection of line between start and end.
177  (
178  const point& start,
179  const point& end
180  ) const;
181 
182  //- Find any intersection of line between start and end.
184  (
185  const point& start,
186  const point& end
187  ) const;
188 
189 
190  // Multiple point queries.
191 
192  virtual void findNearest
193  (
194  const pointField& sample,
195  const scalarField& nearestDistSqr,
197  ) const;
198 
199  virtual void findLine
200  (
201  const pointField& start,
202  const pointField& end,
204  ) const;
205 
206  virtual void findLineAny
207  (
208  const pointField& start,
209  const pointField& end,
211  ) const;
212 
213  //- Get all intersections in order from start to end.
214  virtual void findLineAll
215  (
216  const pointField& start,
217  const pointField& end,
219  ) const;
220 
221  //- From a set of points and indices get the region
222  virtual void getRegion
223  (
224  const List<pointIndexHit>&,
225  labelList& region
226  ) const;
227 
228  //- From a set of points and indices get the normal
229  virtual void getNormal
230  (
231  const List<pointIndexHit>&,
233  ) const;
234 
235  //- Determine type (inside/outside/mixed) for point. unknown if
236  // cannot be determined (e.g. non-manifold surface)
237  virtual void getVolumeType
238  (
239  const pointField&,
241  ) const;
242 
243 
244  // regIOobject implementation
245 
246  bool writeData(Ostream&) const
247  {
249  return false;
250  }
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::searchableRotatedBox::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableRotatedBox.C:82
searchableSurface.H
Foam::searchableRotatedBox::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableRotatedBox.C:105
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::searchableRotatedBox::operator=
void operator=(const searchableRotatedBox &)
Disallow default bitwise assignment.
searchableBox.H
Foam::searchableRotatedBox::findLineAny
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
Definition: searchableRotatedBox.C:237
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::searchableRotatedBox::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: searchableRotatedBox.C:363
Foam::searchableRotatedBox::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableRotatedBox.C:374
Foam::searchableRotatedBox::writeData
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: searchableRotatedBox.H:245
Foam::searchableRotatedBox::box_
searchableBox box_
box in local coordinate system
Definition: searchableRotatedBox.H:71
coordinateSystem.H
Foam::searchableRotatedBox::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableRotatedBox.C:88
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
Foam::searchableRotatedBox::points_
pointField points_
(global) corner points (in treeBoundBox order)
Definition: searchableRotatedBox.H:77
Foam::searchableRotatedBox::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableRotatedBox.C:111
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
Foam::searchableRotatedBox::TypeName
TypeName("searchableRotatedBox")
Runtime type information.
Foam::searchableRotatedBox::findNearest
pointIndexHit findNearest(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on surface.
Definition: searchableRotatedBox.C:183
Foam::searchableRotatedBox::transform_
coordinateSystem transform_
transformation from local to global coordinates
Definition: searchableRotatedBox.H:74
Foam::searchableRotatedBox::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableRotatedBox.H:114
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Foam::searchableRotatedBox::~searchableRotatedBox
virtual ~searchableRotatedBox()
Destructor.
Definition: searchableRotatedBox.C:76
Foam::searchableRotatedBox::findLine
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
Definition: searchableRotatedBox.C:216
Foam::searchableRotatedBox::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableRotatedBox.C:95
Foam::Vector< scalar >
Foam::searchableRotatedBox
Searching on a rotated box.
Definition: searchableRotatedBox.H:62
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::line
A line primitive.
Definition: line.H:56
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::searchableRotatedBox::searchableRotatedBox
searchableRotatedBox(const searchableRotatedBox &)
Disallow default bitwise copy construct.
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:854
Foam::searchableRotatedBox::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: searchableRotatedBox.C:387
Foam::searchableBox
Searching on bounding box.
Definition: searchableBox.H:51
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::searchableRotatedBox::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
Definition: searchableRotatedBox.C:295
normal
A normal distribution model.
Foam::coordinateSystem
Base class for other coordinate system specifications.
Definition: coordinateSystem.H:85
Foam::searchableRotatedBox::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableRotatedBox.H:120