searchableSurfaceWithGaps.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::searchableSurfaceWithGaps
26 
27 Description
28  searchableSurface using multiple slightly shifted underlying surfaces
29  to make sure pierces don't go through gaps:
30  - shift test vector with two small vectors (of size gap_) perpendicular
31  to the original.
32  Test with + and - this vector. Only if both register a hit is it seen
33  as one.
34  - extend the test vector slightly (with SMALL) to account for numerical
35  inaccuracies.
36 
37  \verbatim
38  sphere.stl
39  {
40  type triSurfaceMesh;
41  }
42 
43  sphere
44  {
45  type searchableSurfaceWithGaps;
46  // Underlying surface
47  surface sphere.stl;
48  // Perturb distance
49  gap 1e-3;
50  }
51  \endverbatim
52 
53 SourceFiles
54  searchableSurfaceWithGaps.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef searchableSurfaceWithGaps_H
59 #define searchableSurfaceWithGaps_H
60 
61 #include "searchableSurface.H"
62 #include "UPtrList.H"
63 #include "Pair.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 // Forward declaration of classes
71 
72 /*---------------------------------------------------------------------------*\
73  Class searchableSurfaceWithGaps Declaration
74 \*---------------------------------------------------------------------------*/
75 
77 :
78  public searchableSurface
79 {
80 private:
81 
82  // Private Member Data
83 
84  //- Gap size in metre
85  const scalar gap_;
86 
87  //- Underlying geometry (size 1)
89 
90 
91  // Private Member Functions
92 
93  Pair<vector> offsetVecs(const point&, const point&) const;
94 
95  void offsetVecs
96  (
97  const pointField& start,
98  const pointField& end,
99  pointField& offset0,
100  pointField& offset1
101  ) const;
102 
103  static label countMisses
104  (
105  const List<pointIndexHit>& info,
106  labelList& missMap
107  );
108 
109  static label countMisses
110  (
111  const List<pointIndexHit>& plusInfo,
112  const List<pointIndexHit>& minInfo,
113  labelList& missMap
114  );
115 
116 
117  //- Disallow default bitwise copy construct
119 
120  //- Disallow default bitwise assignment
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("searchableSurfaceWithGaps");
128 
129 
130  // Constructors
131 
132  //- Construct from dictionary (used by searchableSurface)
134  (
135  const IOobject& io,
136  const dictionary& dict
137  );
138 
139  //- Destructor
140  virtual ~searchableSurfaceWithGaps();
141 
142 
143  // Member Functions
144 
145  const searchableSurface& surface() const
146  {
147  return subGeom_[0];
148  }
149 
150 
151  virtual const wordList& regions() const
152  {
153  return surface().regions();
154  }
155 
156  //- Whether supports volume type below
157  virtual bool hasVolumeType() const
158  {
159  return surface().hasVolumeType();
160  }
161 
162  //- Range of local indices that can be returned.
163  virtual label size() const
164  {
165  return surface().size();
166  }
167 
168  //- Get representative set of element coordinates
169  // Usually the element centres (should be of length size()).
170  virtual tmp<pointField> coordinates() const
171  {
172  return surface().coordinates();
173  }
174 
175  //- Get bounding spheres (centre and radius squared), one per element.
176  // Any point on element is guaranteed to be inside.
177  virtual void boundingSpheres
178  (
179  pointField& centres,
180  scalarField& radiusSqr
181  ) const
182  {
183  surface().boundingSpheres(centres, radiusSqr);
184  }
185 
186  //- Get the points that define the surface.
187  virtual tmp<pointField> points() const
188  {
189  return surface().points();
190  }
191 
192  //- Does any part of the surface overlap the supplied bound box?
193  // Note: use perturbed surface? Since uses boundbox of points and
194  // not actual intersection chosen to use unperturbed surface.
195  virtual bool overlaps(const boundBox& bb) const
196  {
197  return surface().overlaps(bb);
198  }
199 
200 
201  // Multiple point queries.
202 
203  //- Find nearest on original surface. Note:does not use perturbation
204  // and hence might be inconsistent with intersections.
205  virtual void findNearest
206  (
207  const pointField& sample,
208  const scalarField& nearestDistSqr,
210  ) const
211  {
213  (
214  sample,
215  nearestDistSqr,
216  info
217  );
218  }
219 
220  virtual void findLine
221  (
222  const pointField& start,
223  const pointField& end,
225  ) const;
226 
227  virtual void findLineAny
228  (
229  const pointField& start,
230  const pointField& end,
232  ) const;
233 
234  //- Get all intersections in order from start to end.
235  virtual void findLineAll
236  (
237  const pointField& start,
238  const pointField& end,
240  ) const;
241 
242  //- From a set of points and indices get the region
243  virtual void getRegion
244  (
245  const List<pointIndexHit>& info,
246  labelList& region
247  ) const
248  {
249  surface().getRegion(info, region);
250  }
251 
252  //- From a set of points and indices get the normal
253  virtual void getNormal
254  (
255  const List<pointIndexHit>& info,
257  ) const
258  {
260  }
261 
262  //- Determine type (inside/outside/mixed) for point. unknown if
263  // cannot be determined (e.g. non-manifold surface)
264  virtual void getVolumeType
265  (
266  const pointField& samples,
268  ) const
269  {
271  }
272 
273 
274  // Other
275 
276  //- Set bounds of surface. Bounds currently set as list of
277  // bounding boxes. The bounds are hints to the surface as for
278  // the range of queries it can expect. faceMap/pointMap can be
279  // set if the surface has done any redistribution.
280  //virtual void distribute
281  //(
282  // const List<treeBoundBox>& bbs,
283  // const bool keepNonLocal,
284  // autoPtr<mapDistribute>& faceMap,
285  // autoPtr<mapDistribute>& pointMap
286  //)
287  //{
288  // subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
289  //}
290 
291  //- WIP. Store element-wise field.
292  virtual void setField(const labelList& values)
293  {
294  subGeom_[0].setField(values);
295  }
296 
297  //- WIP. From a set of hits (points and
298  // indices) get the specified field. Misses do not get set. Return
299  // empty field if not supported.
300  virtual void getField
301  (
302  const List<pointIndexHit>& info,
303  labelList& values
304  ) const
305  {
306  surface().getField(info, values);
307  }
308 
309  // regIOobject implementation
310 
311  bool writeData(Ostream& os) const
312  {
313  return surface().writeData(os);
314  }
315 
316 };
317 
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 } // End namespace Foam
322 
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 
325 #endif
326 
327 // ************************************************************************* //
Foam::searchableSurfaceWithGaps::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Find nearest on original surface. Note:does not use perturbation.
Definition: searchableSurfaceWithGaps.H:205
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
UPtrList.H
Foam::searchableSurfaceWithGaps::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: searchableSurfaceWithGaps.H:169
Foam::searchableSurfaceWithGaps::getField
virtual void getField(const List< pointIndexHit > &info, labelList &values) const
WIP. From a set of hits (points and.
Definition: searchableSurfaceWithGaps.H:300
Foam::searchableSurfaceWithGaps::countMisses
static label countMisses(const List< pointIndexHit > &info, labelList &missMap)
Definition: searchableSurfaceWithGaps.C:111
searchableSurface.H
Foam::searchableSurface::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::searchableSurface::coordinates
virtual tmp< pointField > coordinates() const =0
Get representative set of element coordinates.
Foam::regIOobject::writeData
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
Foam::searchableSurfaceWithGaps::size
virtual label size() const
Range of local indices that can be returned.
Definition: searchableSurfaceWithGaps.H:162
Foam::searchableSurfaceWithGaps::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
Definition: searchableSurfaceWithGaps.C:341
Pair.H
Foam::searchableSurface::size
virtual label size() const =0
Range of local indices that can be returned.
Foam::searchableSurfaceWithGaps::operator=
void operator=(const searchableSurfaceWithGaps &)
Disallow default bitwise assignment.
Foam::searchableSurfaceWithGaps::offsetVecs
Pair< vector > offsetVecs(const point &, const point &) const
Definition: searchableSurfaceWithGaps.C:45
Foam::searchableSurfaceWithGaps::gap_
const scalar gap_
Gap size in metre.
Definition: searchableSurfaceWithGaps.H:84
Foam::IOobject::info
InfoProxy< IOobject > info() const
Return info proxy.
Definition: IOobject.H:434
Foam::searchableSurface::hasVolumeType
virtual bool hasVolumeType() const =0
Whether supports volume type below.
Foam::searchableSurfaceWithGaps::subGeom_
UPtrList< searchableSurface > subGeom_
Underlying geometry (size 1)
Definition: searchableSurfaceWithGaps.H:87
samples
scalarField samples(nIntervals, 0)
Foam::searchableSurface::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const =0
From a set of points and indices get the region.
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::regions
virtual const wordList & regions() const =0
Names of regions.
Foam::searchableSurface::points
virtual tmp< pointField > points() const =0
Get the points that define the surface.
Foam::searchableSurface::overlaps
virtual bool overlaps(const boundBox &bb) const =0
Does any part of the surface overlap the supplied bound box?
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
Foam::UPtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:53
Foam::searchableSurfaceWithGaps::getNormal
virtual void getNormal(const List< pointIndexHit > &info, vectorField &normal) const
From a set of points and indices get the normal.
Definition: searchableSurfaceWithGaps.H:253
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::searchableSurfaceWithGaps::searchableSurfaceWithGaps
searchableSurfaceWithGaps(const searchableSurfaceWithGaps &)
Disallow default bitwise copy construct.
Foam::searchableSurfaceWithGaps::writeData
bool writeData(Ostream &os) const
Pure virtual writaData function.
Definition: searchableSurfaceWithGaps.H:310
Foam::searchableSurfaceWithGaps::regions
virtual const wordList & regions() const
Names of regions.
Definition: searchableSurfaceWithGaps.H:150
Foam::searchableSurfaceWithGaps::surface
const searchableSurface & surface() const
Definition: searchableSurfaceWithGaps.H:144
Foam::searchableSurfaceWithGaps::getRegion
virtual void getRegion(const List< pointIndexHit > &info, labelList &region) const
From a set of points and indices get the region.
Definition: searchableSurfaceWithGaps.H:243
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
Foam::searchableSurfaceWithGaps::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: searchableSurfaceWithGaps.C:329
Foam::Vector< scalar >
Foam::searchableSurfaceWithGaps::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Definition: searchableSurfaceWithGaps.C:204
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::searchableSurfaceWithGaps::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: searchableSurfaceWithGaps.H:186
Foam::searchableSurfaceWithGaps::setField
virtual void setField(const labelList &values)
Set bounds of surface. Bounds currently set as list of.
Definition: searchableSurfaceWithGaps.H:291
Foam::searchableSurfaceWithGaps::getVolumeType
virtual void getVolumeType(const pointField &samples, List< volumeType > &info) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: searchableSurfaceWithGaps.H:264
Foam::searchableSurfaceWithGaps::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
Definition: searchableSurfaceWithGaps.H:177
Foam::searchableSurfaceWithGaps
searchableSurface using multiple slightly shifted underlying surfaces to make sure pierces don't go t...
Definition: searchableSurfaceWithGaps.H:75
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::searchableSurface::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::searchableSurfaceWithGaps::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: searchableSurfaceWithGaps.H:194
Foam::searchableSurface::getField
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
Definition: searchableSurface.H:365
Foam::searchableSurface::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point. unknown if.
Foam::searchableSurfaceWithGaps::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below.
Definition: searchableSurfaceWithGaps.H:156
normal
A normal distribution model.
Foam::searchableSurfaceWithGaps::~searchableSurfaceWithGaps
virtual ~searchableSurfaceWithGaps()
Destructor.
Definition: searchableSurfaceWithGaps.C:197
Foam::searchableSurfaceWithGaps::TypeName
TypeName("searchableSurfaceWithGaps")
Runtime type information.