dynamicIndexedOctree.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::dynamicIndexedOctree
26 
27 Description
28  Non-pointer based hierarchical recursive searching.
29  Storage is dynamic, so elements can be deleted.
30 
31 SourceFiles
32  dynamicIndexedOctree.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef dynamicIndexedOctree_H
37 #define dynamicIndexedOctree_H
38 
39 #include "treeBoundBox.H"
40 #include "pointIndexHit.H"
41 #include "FixedList.H"
42 #include "Ostream.H"
43 #include "HashSet.H"
44 #include "labelBits.H"
45 #include "PackedList.H"
46 #include "volumeType.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
54 
55 // Forward declaration of classes
56 template<class Type> class dynamicIndexedOctree;
57 
58 template<class Type> Ostream& operator<<
59 (
60  Ostream&,
62 );
63 
64 class Istream;
65 
66 
67 /*---------------------------------------------------------------------------*\
68  Class dynamicIndexedOctreeName Declaration
69 \*---------------------------------------------------------------------------*/
70 
72 
73 
74 /*---------------------------------------------------------------------------*\
75  Class dynamicIndexedOctree Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 template<class Type>
80 :
81  public dynamicIndexedOctreeName
82 {
83 public:
84 
85  // Data types
86 
87  //- Tree node. Has up pointer and down pointers.
88  class node
89  {
90  public:
91 
92  //- Bounding box of this node
94 
95  //- Parent node (index into nodes_ of tree)
96  label parent_;
97 
98  //- IDs of the 8 nodes on all sides of the mid point
100 
101  friend Ostream& operator<< (Ostream& os, const node& n)
102  {
103  return os << n.bb_ << token::SPACE
104  << n.parent_ << token::SPACE << n.subNodes_;
105  }
106 
107  friend Istream& operator>> (Istream& is, node& n)
108  {
109  return is >> n.bb_ >> n.parent_ >> n.subNodes_;
110  }
111 
112  friend bool operator==(const node& a, const node& b)
113  {
114  return
115  a.bb_ == b.bb_
116  && a.parent_ == b.parent_
117  && a.subNodes_ == b.subNodes_;
118  }
119 
120  friend bool operator!=(const node& a, const node& b)
121  {
122  return !(a == b);
123  }
124  };
125 
126 
127 private:
128 
129  // Static data
130 
131  //- Relative peturbation tolerance. Determines when point is
132  // considered to be close to face/edge of bb of node.
133  // The tolerance is relative to the bounding box of the smallest
134  // node.
135  static scalar perturbTol_;
136 
137 
138  // Private data
139 
140  //- Underlying shapes for geometric queries.
141  const Type shapes_;
142 
143  const treeBoundBox bb_;
144 
145  const label maxLevels_;
146 
147  //- Current number of levels in the tree.
149 
150  const scalar maxLeafRatio_;
151 
152  const label minSize_;
153 
154  const scalar maxDuplicity_;
155 
156  //- List of all nodes
158 
159  //- List of all contents (referenced by those nodes that are contents)
161 
162  //- Per node per octant whether is fully inside/outside/mixed.
163  mutable PackedList<2> nodeTypes_;
164 
165  // Private Member Functions
166 
167  //- Helper: does bb intersect a sphere around sample? Or is any
168  // corner point of bb closer than nearestDistSqr to sample.
169  // (bb is implicitly provided as parent bb + octant)
170  static bool overlaps
171  (
172  const treeBoundBox& parentBb,
173  const direction octant,
174  const scalar nearestDistSqr,
175  const point& sample
176  );
177 
178  // Construction
179 
180  //- Split list of indices into 8 bins
181  // according to where they are in relation to mid.
182  void divide
183  (
184  const autoPtr<DynamicList<label> >& indices,
185  const treeBoundBox& bb,
186  contentListList& result
187  ) const;
188 
189  //- Subdivide the contents node at position contentI.
190  // Appends to contents.
191  node divide
192  (
193  const treeBoundBox& bb,
194  const label contentI,
195  const label parentNodeIndex,
196  const label octantToBeDivided
197  );
198 
199  // Recursively call the divide function
201  (
202  const treeBoundBox& subBb,
203  const label contentI,
204  const label parentIndex,
205  const label octant,
206  label& nLevels
207  );
208 
209 // static label compactContents
210 // (
211 // DynamicList<node>& nodes,
212 // DynamicList<labelList>& contents,
213 // const label compactLevel,
214 // const label nodeI,
215 // const label level,
216 // List<labelList>& compactedContents,
217 // label& compactI
218 // );
219 
220  //- Determine inside/outside per node (mixed if cannot be
221  // determined). Only valid for closed shapes.
222  volumeType calcVolumeType(const label nodeI) const;
223 
224  //- Search cached volume type.
225  volumeType getVolumeType(const label nodeI, const point&) const;
226 
227 
228  // Query
229 
230  //- Find nearest point to line.
231  void findNearest
232  (
233  const label nodeI,
234  const linePointRef& ln,
235 
236  treeBoundBox& tightest,
237  label& nearestShapeI,
238  point& linePoint,
239  point& nearestPoint
240  ) const;
241 
242  //- Return bbox of octant
244  (
245  const label parentNodeI,
246  const direction octant
247  ) const;
248 
249  //- Helper: take a point on/close to face of bb and push it
250  // inside or outside of bb.
251  static point pushPoint
252  (
253  const treeBoundBox&,
254  const point&,
255  const bool pushInside
256  );
257 
258  //- Helper: take a point on face of bb and push it
259  // inside or outside of bb.
260  static point pushPoint
261  (
262  const treeBoundBox&,
263  const direction,
264  const point&,
265  const bool pushInside
266  );
267 
268  //- Helper: take point on face(s) of bb and push it away from
269  // edges of face.
270  static point pushPointIntoFace
271  (
272  const treeBoundBox& bb,
273  const vector& dir, // end-start
274  const point& pt
275  );
276 
278  //static void checkMultipleFaces
279  //(
280  // const treeBoundBox& bb,
281  // const vector& dir, // end-start
282  // pointIndexHit& faceHitInfo,
283  // direction& faceID
284  //);
285 
286  //- Walk to parent of node+octant.
287  bool walkToParent
288  (
289  const label nodeI,
290  const direction octant,
291 
292  label& parentNodeI,
293  label& parentOctant
294  ) const;
295 
296  //- Walk tree to neighbouring node. Return false if edge of tree
297  // hit.
298  bool walkToNeighbour
299  (
300  const point& facePoint,
301  const direction faceID, // direction to walk in
302  label& nodeI,
303  direction& octant
304  ) const;
305 
306  //- Debug: return verbose the bounding box faces
307  static word faceString(const direction faceID);
308 
309  //- Traverse a node. If intersects a triangle return first
310  // intersection point.
311  // findAny=true : return any intersection
312  // findAny=false: return nearest (to start) intersection
313  void traverseNode
314  (
315  const bool findAny,
316  const point& treeStart,
317  const vector& treeVec,
318 
319  const point& start,
320  const point& end,
321  const label nodeI,
322  const direction octantI,
323 
324  pointIndexHit& hitInfo,
325  direction& faceID
326  ) const;
327 
328  //- Find any or nearest intersection
330  (
331  const bool findAny,
332  const point& treeStart,
333  const point& treeEnd,
334  const label startNodeI,
335  const direction startOctantI,
336  const bool verbose = false
337  ) const;
338 
339  //- Find any or nearest intersection of line between start and end.
341  (
342  const bool findAny,
343  const point& start,
344  const point& end
345  ) const;
346 
347  //- Find all elements intersecting box.
348  void findBox
349  (
350  const label nodeI,
351  const treeBoundBox& searchBox,
352  labelHashSet& elements
353  ) const;
354 
355 
356  //- Find all elements intersecting sphere.
357  void findSphere
358  (
359  const label nodeI,
360  const point& centre,
361  const scalar radiusSqr,
362  labelHashSet& elements
363  ) const;
364 
365 
366  template<class CompareOp>
367  static void findNear
368  (
369  const scalar nearDist,
370  const bool okOrder,
371  const dynamicIndexedOctree<Type>& tree1,
372  const labelBits index1,
373  const treeBoundBox& bb1,
374  const dynamicIndexedOctree<Type>& tree2,
375  const labelBits index2,
376  const treeBoundBox& bb2,
377  CompareOp& cop
378  );
379 
380 
381  // Other
382 
383  //- Count number of elements on this and sublevels
384  label countElements(const labelBits index) const;
385 
386  //- Dump node+octant to an obj file
387  void writeOBJ(const label nodeI, const direction octant) const;
388 
389  //- From index into contents_ to subNodes_ entry
391  (
392  const label i,
393  const direction octant
394  )
395  {
396  return labelBits(-i - 1, octant);
397  }
398 
399  //- From index into nodes_ to subNodes_ entry
401  (
402  const label i,
403  const direction octant
404  )
405  {
406  return labelBits(i + 1, octant);
407  }
408 
409  //- From empty to subNodes_ entry
411  (
412  const direction octant
413  )
414  {
415  return labelBits(0, octant);
416  }
417 
418 public:
419 
420  //- Get the perturbation tolerance
421  static scalar& perturbTol();
422 
423 
424  // Constructors
425 
426  //- Construct from shapes
428  (
429  const Type& shapes,
430  const treeBoundBox& bb,
431  const label maxLevels, // maximum number of levels
432  const scalar maxLeafRatio, // how many elements per leaf
433  const scalar maxDuplicity // in how many leaves is a shape on
434  // average
435  );
436 
437  //- Clone
439  {
441  (
442  new dynamicIndexedOctree<Type>(*this)
443  );
444  }
445 
446 
447  // Member Functions
448 
449  // Access
450 
451  //- Reference to shape
452  const Type& shapes() const
453  {
454  return shapes_;
455  }
456 
457  //- List of all nodes
458  const List<node>& nodes() const
459  {
460  return nodes_;
461  }
462 
463  //- List of all contents (referenced by those nodes that are
464  // contents)
465  const contentListList& contents() const
466  {
467  return contents_;
468  }
469 
470  //- Top bounding box
471  const treeBoundBox& bb() const
472  {
473  if (nodes_.empty())
474  {
476  << "Tree is empty" << abort(FatalError);
477  }
478  return nodes_[0].bb_;
479  }
480 
481 
482  // Conversions for entries in subNodes_.
483 
484  static bool isContent(const labelBits i)
485  {
486  return i.val() < 0;
487  }
488 
489  static bool isEmpty(const labelBits i)
490  {
491  return i.val() == 0;
492  }
493 
494  static bool isNode(const labelBits i)
495  {
496  return i.val() > 0;
497  }
498 
499  static label getContent(const labelBits i)
500  {
501  if (!isContent(i))
502  {
504  << abort(FatalError);
505  }
506  return -i.val()-1;
507  }
508 
509  static label getNode(const labelBits i)
510  {
511  if (!isNode(i))
512  {
514  << abort(FatalError);
515  }
516  return i.val() - 1;
517  }
518 
519  static direction getOctant(const labelBits i)
520  {
521  return i.bits();
522  }
523 
524 
525  // Queries
526 
527  //- Calculate nearest point on nearest shape.
528  // Returns
529  // - bool : any point found nearer than nearestDistSqr
530  // - label: index in shapes
531  // - point: actual nearest point found
533  (
534  const point& sample,
535  const scalar nearestDistSqr
536  ) const;
537 
538  //- Low level: calculate nearest starting from subnode.
539  void findNearest
540  (
541  const label nodeI,
542  const point&,
543 
544  scalar& nearestDistSqr,
545  label& nearestShapeI,
546  point& nearestPoint
547  ) const;
548 
549  //- Find nearest to line.
550  // Returns
551  // - bool : any point found?
552  // - label: index in shapes
553  // - point: actual nearest point found
554  // sets:
555  // - linePoint : corresponding nearest point on line
557  (
558  const linePointRef& ln,
559  treeBoundBox& tightest,
560  point& linePoint
561  ) const;
562 
563  //- Find nearest intersection of line between start and end.
565  (
566  const point& start,
567  const point& end
568  ) const;
569 
570  //- Find any intersection of line between start and end.
572  (
573  const point& start,
574  const point& end
575  ) const;
576 
577  //- Find (in no particular order) indices of all shapes inside or
578  // overlapping bounding box (i.e. all shapes not outside box)
579  labelList findBox(const treeBoundBox& bb) const;
580 
581  //- Find (in no particular order) indices of all shapes inside or
582  // overlapping a bounding sphere (i.e. all shapes not outside
583  // sphere)
585  (
586  const point& centre,
587  const scalar radiusSqr
588  ) const;
589 
590  //- Find deepest node (as parent+octant) containing point. Starts
591  // off from starting index in nodes_ (use 0 to start from top)
592  // Use getNode and getOctant to extract info, or call findIndices.
593  labelBits findNode(const label nodeI, const point&) const;
594 
595  //- Find shape containing point. Only implemented for certain
596  // shapes.
597  label findInside(const point&) const;
598 
599  //- Find the shape indices that occupy the result of findNode
600  const labelList& findIndices(const point&) const;
601 
602  //- Determine type (inside/outside/mixed) for point. unknown if
603  // cannot be determined (e.g. non-manifold surface)
604  volumeType getVolumeType(const point&) const;
605 
606  //- Helper function to return the side. Returns outside if
607  // outsideNormal&vec >= 0, inside otherwise
608  static volumeType getSide
609  (
610  const vector& outsideNormal,
611  const vector& vec
612  );
613 
614  //- Helper: does bb intersect a sphere around sample? Or is any
615  // corner point of bb closer than nearestDistSqr to sample.
616  static bool overlaps
617  (
618  const point& bbMin,
619  const point& bbMax,
620  const scalar nearestDistSqr,
621  const point& sample
622  );
623 
624  //- Find near pairs and apply CompareOp to them.
625  // tree2 can be *this or different tree.
626  template<class CompareOp>
627  void findNear
628  (
629  const scalar nearDist,
630  const dynamicIndexedOctree<Type>& tree2,
631  CompareOp& cop
632  ) const;
633 
634 
635  // Edit
636 
637  //- Insert a new object into the tree.
638  bool insert(label startIndex, label endIndex);
639 
640  bool insertIndex
641  (
642  const label nodIndex,
643  const label index,
644  label& nLevels
645  );
646 
647  //- Remove an object from the tree.
648  bool remove(const label index);
649 
650  label removeIndex(const label nodIndex, const label index);
651 
652 
653  // Write
654 
655  //- Print tree. Either print all indices (printContent = true) or
656  // just size of contents nodes.
657  void print
658  (
660  const bool printContents,
661  const label
662  ) const;
663 
664  bool write(Ostream& os) const;
665 
666  void writeTreeInfo() const;
667 
668 
669  // IOstream Operators
670 
671  friend Ostream& operator<< <Type>
672  (
673  Ostream&,
675  );
676 };
677 
678 
679 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
680 
681 } // End namespace Foam
682 
683 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
684 
685 #ifdef NoRepository
686 # include "dynamicIndexedOctree.C"
687 #endif
688 
689 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
690 
691 #endif
692 
693 // ************************************************************************* //
Foam::dynamicIndexedOctree::minSize_
const label minSize_
Definition: dynamicIndexedOctree.H:151
Foam::dynamicIndexedOctree::findSphere
void findSphere(const label nodeI, const point &centre, const scalar radiusSqr, labelHashSet &elements) const
Find all elements intersecting sphere.
Definition: dynamicIndexedOctree.C:2004
Foam::dynamicIndexedOctree::nodes_
DynamicList< node > nodes_
List of all nodes.
Definition: dynamicIndexedOctree.H:156
Foam::dynamicIndexedOctree::insert
bool insert(label startIndex, label endIndex)
Insert a new object into the tree.
Definition: dynamicIndexedOctree.C:2672
pointIndexHit.H
Foam::dynamicIndexedOctree::nodePlusOctant
static labelBits nodePlusOctant(const label i, const direction octant)
From index into nodes_ to subNodes_ entry.
Definition: dynamicIndexedOctree.H:400
PackedList.H
Foam::dynamicIndexedOctree::findInside
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
Definition: dynamicIndexedOctree.C:2523
labelBits.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dynamicIndexedOctree::node::operator!=
friend bool operator!=(const node &a, const node &b)
Definition: dynamicIndexedOctree.H:119
Foam::labelBits
A 29bits label and 3bits direction packed into single label.
Definition: labelBits.H:51
Foam::dynamicIndexedOctree::maxDuplicity_
const scalar maxDuplicity_
Definition: dynamicIndexedOctree.H:153
Foam::dynamicIndexedOctree::isContent
static bool isContent(const labelBits i)
Definition: dynamicIndexedOctree.H:483
Foam::dynamicIndexedOctree::getOctant
static direction getOctant(const labelBits i)
Definition: dynamicIndexedOctree.H:518
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::dynamicIndexedOctree::writeOBJ
void writeOBJ(const label nodeI, const direction octant) const
Dump node+octant to an obj file.
Definition: dynamicIndexedOctree.C:2260
Foam::dynamicIndexedOctree::getContent
static label getContent(const labelBits i)
Definition: dynamicIndexedOctree.H:498
Foam::dynamicIndexedOctree::pushPoint
static point pushPoint(const treeBoundBox &, const point &, const bool pushInside)
Helper: take a point on/close to face of bb and push it.
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::dynamicIndexedOctree::subBbox
treeBoundBox subBbox(const label parentNodeI, const direction octant) const
Return bbox of octant.
Definition: dynamicIndexedOctree.C:629
Foam::dynamicIndexedOctree::walkToNeighbour
bool walkToNeighbour(const point &facePoint, const direction faceID, label &nodeI, direction &octant) const
Walk tree to neighbouring node. Return false if edge of tree.
Definition: dynamicIndexedOctree.C:1245
Foam::dynamicIndexedOctree::faceString
static word faceString(const direction faceID)
Debug: return verbose the bounding box faces.
Definition: dynamicIndexedOctree.C:1483
Foam::dynamicIndexedOctree::bb_
const treeBoundBox bb_
Definition: dynamicIndexedOctree.H:142
Foam::HashSet< label, Hash< label > >
Foam::dynamicIndexedOctree::divide
void divide(const autoPtr< DynamicList< label > > &indices, const treeBoundBox &bb, contentListList &result) const
Split list of indices into 8 bins.
Definition: dynamicIndexedOctree.C:150
Foam::dynamicIndexedOctree::contents_
contentListList contents_
List of all contents (referenced by those nodes that are contents)
Definition: dynamicIndexedOctree.H:159
Foam::dynamicIndexedOctree::node::operator<<
friend Ostream & operator<<(Ostream &os, const node &n)
Definition: dynamicIndexedOctree.H:100
Foam::labelBits::bits
direction bits() const
Definition: labelBits.H:102
Foam::dynamicIndexedOctree::countElements
label countElements(const labelBits index) const
Count number of elements on this and sublevels.
Definition: dynamicIndexedOctree.C:2227
Foam::dynamicIndexedOctree
Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted.
Definition: dynamicIndexedOctree.H:55
Foam::facePoint
label facePoint(const int facei, const block &block, const label i, const label j)
Definition: blockMeshMergeFast.C:202
Foam::dynamicIndexedOctree::findNear
static void findNear(const scalar nearDist, const bool okOrder, const dynamicIndexedOctree< Type > &tree1, const labelBits index1, const treeBoundBox &bb1, const dynamicIndexedOctree< Type > &tree2, const labelBits index2, const treeBoundBox &bb2, CompareOp &cop)
Definition: dynamicIndexedOctree.C:2053
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::prefixOSstream
Version of OSstream which prints a prefix on each line.
Definition: prefixOSstream.H:51
Foam::dynamicIndexedOctree::perturbTol_
static scalar perturbTol_
Relative peturbation tolerance. Determines when point is.
Definition: dynamicIndexedOctree.H:134
Foam::dynamicIndexedOctree::remove
bool remove(const label index)
Remove an object from the tree.
Definition: dynamicIndexedOctree.C:2795
volumeType.H
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::dynamicIndexedOctree::removeIndex
label removeIndex(const label nodIndex, const label index)
Definition: dynamicIndexedOctree.C:2810
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::volumeType
Definition: volumeType.H:54
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
Foam::dynamicIndexedOctree::findBox
void findBox(const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const
Find all elements intersecting box.
Definition: dynamicIndexedOctree.C:1957
Foam::dynamicIndexedOctree::node::operator>>
friend Istream & operator>>(Istream &is, node &n)
Definition: dynamicIndexedOctree.H:106
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
treeBoundBox.H
Foam::dynamicIndexedOctree::getVolumeType
volumeType getVolumeType(const label nodeI, const point &) const
Search cached volume type.
Foam::contentListList
DynamicList< autoPtr< DynamicList< label > > > contentListList
Definition: dynamicIndexedOctree.H:52
dynamicIndexedOctree.C
Foam::TemplateName
TemplateName(blendedSchemeBase)
Foam::dynamicIndexedOctree::maxLevels_
const label maxLevels_
Definition: dynamicIndexedOctree.H:144
Foam::dynamicIndexedOctree::shapes
const Type & shapes() const
Reference to shape.
Definition: dynamicIndexedOctree.H:451
Foam::dynamicIndexedOctree::perturbTol
static scalar & perturbTol()
Get the perturbation tolerance.
Definition: dynamicIndexedOctree.C:2345
Foam::dynamicIndexedOctree::emptyPlusOctant
static labelBits emptyPlusOctant(const direction octant)
From empty to subNodes_ entry.
Definition: dynamicIndexedOctree.H:410
Foam::dynamicIndexedOctree::dynamicIndexedOctree
dynamicIndexedOctree(const Type &shapes, const treeBoundBox &bb, const label maxLevels, const scalar maxLeafRatio, const scalar maxDuplicity)
Construct from shapes.
Definition: dynamicIndexedOctree.C:2309
Foam::dynamicIndexedOctree::calcVolumeType
volumeType calcVolumeType(const label nodeI) const
Determine inside/outside per node (mixed if cannot be.
Definition: dynamicIndexedOctree.C:341
HashSet.H
Foam::dynamicIndexedOctree::traverseNode
void traverseNode(const bool findAny, const point &treeStart, const vector &treeVec, const point &start, const point &end, const label nodeI, const direction octantI, pointIndexHit &hitInfo, direction &faceID) const
Traverse a node. If intersects a triangle return first.
Definition: dynamicIndexedOctree.C:1535
Foam::dynamicIndexedOctree::pushPointIntoFace
static point pushPointIntoFace(const treeBoundBox &bb, const vector &dir, const point &pt)
Helper: take point on face(s) of bb and push it away from.
Definition: dynamicIndexedOctree.C:839
Foam::labelBits::val
label val() const
Definition: labelBits.H:97
Foam::FatalError
error FatalError
Foam::dynamicIndexedOctree::isEmpty
static bool isEmpty(const labelBits i)
Definition: dynamicIndexedOctree.H:488
Foam::dynamicIndexedOctree::nodes
const List< node > & nodes() const
List of all nodes.
Definition: dynamicIndexedOctree.H:457
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::dynamicIndexedOctree::shapes_
const Type shapes_
Underlying shapes for geometric queries.
Definition: dynamicIndexedOctree.H:140
Foam::dynamicIndexedOctree::clone
autoPtr< dynamicIndexedOctree< Type > > clone() const
Clone.
Definition: dynamicIndexedOctree.H:437
Foam::dynamicIndexedOctree::recursiveSubDivision
void recursiveSubDivision(const treeBoundBox &subBb, const label contentI, const label parentIndex, const label octant, label &nLevels)
Definition: dynamicIndexedOctree.C:288
Ostream.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::dynamicIndexedOctree::findNode
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
Definition: dynamicIndexedOctree.C:2476
Foam::dynamicIndexedOctree::nodeTypes_
PackedList< 2 > nodeTypes_
Per node per octant whether is fully inside/outside/mixed.
Definition: dynamicIndexedOctree.H:162
Foam::dynamicIndexedOctree::node::operator==
friend bool operator==(const node &a, const node &b)
Definition: dynamicIndexedOctree.H:111
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::dynamicIndexedOctree::writeTreeInfo
void writeTreeInfo() const
Definition: dynamicIndexedOctree.C:2966
Foam::dynamicIndexedOctree::node::bb_
treeBoundBox bb_
Bounding box of this node.
Definition: dynamicIndexedOctree.H:92
Foam::dynamicIndexedOctree::node
Tree node. Has up pointer and down pointers.
Definition: dynamicIndexedOctree.H:87
Foam::Vector< scalar >
Foam::dynamicIndexedOctree::insertIndex
bool insertIndex(const label nodIndex, const label index, label &nLevels)
Definition: dynamicIndexedOctree.C:2719
Foam::dynamicIndexedOctree::node::subNodes_
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
Definition: dynamicIndexedOctree.H:98
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::PackedList< 2 >
Foam::dynamicIndexedOctree::node::parent_
label parent_
Parent node (index into nodes_ of tree)
Definition: dynamicIndexedOctree.H:95
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::dynamicIndexedOctree::maxLeafRatio_
const scalar maxLeafRatio_
Definition: dynamicIndexedOctree.H:149
Foam::dynamicIndexedOctree::contentPlusOctant
static labelBits contentPlusOctant(const label i, const direction octant)
From index into contents_ to subNodes_ entry.
Definition: dynamicIndexedOctree.H:390
Foam::dynamicIndexedOctree::nLevelsMax_
label nLevelsMax_
Current number of levels in the tree.
Definition: dynamicIndexedOctree.H:147
Foam::dynamicIndexedOctree::bb
const treeBoundBox & bb() const
Top bounding box.
Definition: dynamicIndexedOctree.H:470
Foam::dynamicIndexedOctree::walkToParent
bool walkToParent(const label nodeI, const direction octant, label &parentNodeI, label &parentOctant) const
Walk to parent of node+octant.
Definition: dynamicIndexedOctree.C:1195
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::line
A line primitive.
Definition: line.H:56
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::dynamicIndexedOctree::write
bool write(Ostream &os) const
Definition: dynamicIndexedOctree.C:2993
Foam::dynamicIndexedOctree::findIndices
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
Definition: dynamicIndexedOctree.C:2555
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::dynamicIndexedOctree::findNearest
void findNearest(const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint) const
Find nearest point to line.
Definition: dynamicIndexedOctree.C:563
FixedList.H
Foam::dynamicIndexedOctree::getSide
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
Definition: dynamicIndexedOctree.C:467
Foam::dynamicIndexedOctree::findLineAny
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
Definition: dynamicIndexedOctree.C:2427
Foam::dynamicIndexedOctree::getNode
static label getNode(const labelBits i)
Definition: dynamicIndexedOctree.H:508
Foam::dynamicIndexedOctree::isNode
static bool isNode(const labelBits i)
Definition: dynamicIndexedOctree.H:493
Foam::token::SPACE
@ SPACE
Definition: token.H:95
Foam::dynamicIndexedOctree::findLine
pointIndexHit findLine(const bool findAny, const point &treeStart, const point &treeEnd, const label startNodeI, const direction startOctantI, const bool verbose=false) const
Find any or nearest intersection.
Foam::dynamicIndexedOctree::overlaps
static bool overlaps(const treeBoundBox &parentBb, const direction octant, const scalar nearestDistSqr, const point &sample)
Helper: does bb intersect a sphere around sample? Or is any.
Definition: dynamicIndexedOctree.C:87
Foam::dynamicIndexedOctree::contents
const contentListList & contents() const
List of all contents (referenced by those nodes that are.
Definition: dynamicIndexedOctree.H:464
Foam::dynamicIndexedOctree::print
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.
Definition: dynamicIndexedOctree.C:2894