indexedOctree.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::indexedOctree
29 
30 Description
31  Non-pointer based hierarchical recursive searching
32 
33 SourceFiles
34  indexedOctree.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_indexedOctree_H
39 #define Foam_indexedOctree_H
40 
41 #include "treeBoundBox.H"
42 #include "pointIndexHit.H"
43 #include "FixedList.H"
44 #include "Ostream.H"
45 #include "HashSet.H"
46 #include "labelBits.H"
47 #include "PackedList.H"
48 #include "volumeType.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 template<class Type> class indexedOctree;
57 template<class Type> Ostream& operator<<(Ostream&, const indexedOctree<Type>&);
58 
59 
60 /*---------------------------------------------------------------------------*\
61  Class indexedOctreeBase Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 //- Template invariant parts for indexedOctree
65 // The internal node bookkeeping is encoded follows:
66 // - 0: empty
67 // - +ve: parent
68 // - -ve: leaf
70 {
71 public:
72 
73  // Public Data Types
74 
75  //- Tree node. Has up pointer and down pointers.
76  class node
77  {
78  public:
79 
80  //- Has exactly 8 sub-nodes (octants)
81  static constexpr direction nChildren = 8;
82 
83  //- Bounding box of this node
85 
86  //- Parent node (index into flat list addressing for tree)
87  label parent_ = -1;
88 
89  //- IDs of the 8 nodes on all sides of the mid point
91 
92 
93  // Operators
94 
95  friend bool operator==(const node& a, const node& b)
96  {
97  return
98  (
99  a.parent_ == b.parent_
100  && a.subNodes_ == b.subNodes_
101  && a.bb_ == b.bb_
102  );
103  }
104 
105  friend bool operator!=(const node& a, const node& b)
106  {
107  return !(a == b);
108  }
109 
110  friend Ostream& operator<< (Ostream& os, const node& n)
111  {
112  return os << n.bb_ << token::SPACE
113  << n.parent_ << token::SPACE << n.subNodes_;
114  }
115 
116  friend Istream& operator>> (Istream& is, node& n)
117  {
118  return is >> n.bb_ >> n.parent_ >> n.subNodes_;
119  }
120  };
121 
122 
123  // Static Functions
125  // Tests for node handling
126  // (0: empty, +ve: parent, -ve: leaf)
127 
128  //- An empty node - no content
129  static bool isEmpty(labelBits i) noexcept
130  {
131  return (i.val() == 0);
132  }
133 
134  //- Node with content (leaf)
135  static bool isContent(labelBits i) noexcept
136  {
137  return (i.val() < 0);
138  }
140  //- A parent node
141  static bool isNode(labelBits i) noexcept
142  {
143  return (i.val() > 0);
144  }
145 
146 
147  // Decode/retrieve node addressing
148 
149  //- Return real (dereferenced) index for a content node
150  static label getContent(labelBits i)
151  {
152  if (!isContent(i))
153  {
156  }
157  return (-i.val()-1);
158  }
159 
160  //- Return real (dereferenced) index for a parent node
161  static label getNode(const labelBits i)
162  {
163  if (!isNode(i))
164  {
167  }
168  return (i.val()-1);
169  }
170 
171  //- Return sub-node direction/octant
172  static direction getOctant(labelBits i) noexcept
173  {
174  return i.bits();
175  }
176 
177 
178 protected:
180  // Static Data
181 
182  //- Relative perturbation tolerance.
183  // Determines when point is considered to be close to face/edge
184  // of bb of node.
185  // The tolerance is relative to the bounding box of the smallest
186  // node.
187  static scalar perturbTol_;
188 
189 
190  // Protected Member Functions
191 
192  // Encode node addressing
193  // (only used when building)
194 
195  //- From empty to subNodes_ entry
196  static labelBits emptyPlusOctant(direction octant)
197  {
198  return labelBits(0, octant);
199  }
200 
201  //- From index into contents_ to subNodes_ entry
202  static labelBits contentPlusOctant(label i, direction octant)
203  {
204  return labelBits(-i-1, octant);
205  }
206 
207  //- From index into nodes_ to subNodes_ entry
208  static labelBits nodePlusOctant(label i, direction octant)
209  {
210  return labelBits(i+1, octant);
211  }
212 
213 
214 public:
215 
216  //- Get the perturbation tolerance
217  static scalar& perturbTol() noexcept { return perturbTol_; }
218 
219  //- Set the perturbation tolerance, return the old value
220  static scalar perturbTol(scalar tol) noexcept
221  {
222  scalar old(perturbTol_);
223  perturbTol_ = tol;
224  return old;
225  }
226 
227 
228  //- Runtime type information
229  ClassName("indexedOctree");
230 
231 
232  // Constructors
233 
234  //- Default construct
235  indexedOctreeBase() = default;
236 
238  // Output Helpers
239 
240  //- Write treeBoundBox in OBJ format
241  static void writeOBJ
242  (
243  Ostream& os,
244  const treeBoundBox& bb,
245  label& vertIndex,
246  const bool writeLinesOnly = false
247  );
248 };
249 
250 
251 /*---------------------------------------------------------------------------*\
252  Class indexedOctree Declaration
253 \*---------------------------------------------------------------------------*/
254 
255 template<class Type>
256 class indexedOctree
257 :
258  public indexedOctreeBase
259 {
260  // Private Data
261 
262  //- Underlying shapes for geometric queries.
263  const Type shapes_;
264 
265  //- List of all nodes
266  List<node> nodes_;
267 
268  //- List of all contents (referenced by those nodes that are contents)
269  List<labelList> contents_;
270 
271  //- Per node per octant whether is fully inside/outside/mixed.
272  mutable PackedList<2> nodeTypes_;
273 
274 
275  // Private Member Functions
276 
277  // Construction
278 
279  //- Split list of indices into 8 bins
280  // according to where they are in relation to mid.
281  void divide
282  (
283  const labelUList& indices,
284  const treeBoundBox& bb,
285  FixedList<labelList, 8>& dividedIndices
286  ) const;
287 
288  //- Subdivide the contents node at position contentI.
289  // Appends to contents.
290  node divide
291  (
292  const treeBoundBox& bb,
294  label contentIndex
295  ) const;
296 
297  //- Split any contents node with more than minSize elements.
298  void splitNodes
299  (
300  const label minSize,
303  ) const;
304 
305  //- Reorder contents to be in same order as nodes.
306  // Returns number of nodes on the compactLevel.
307  static label compactContents
308  (
311  const label compactLevel,
312  const label nodeI,
313  const label level,
314  List<labelList>& compactedContents,
315  label& compactI
316  );
317 
318  //- Determine inside/outside per node (mixed if cannot be
319  // determined). Only valid for closed shapes.
320  volumeType calcVolumeType(const label nodeI) const;
321 
322  //- Search cached volume type.
323  volumeType getVolumeType(const label nodeI, const point&) const;
324 
325 
326  // Query
327 
328  //- Find nearest point to line.
329  template<class FindNearestOp>
330  void findNearest
331  (
332  const label nodeI,
333  const linePointRef& ln,
334 
335  treeBoundBox& tightest,
336  label& nearestShapeI,
337  point& linePoint,
338  point& nearestPoint,
339 
340  const FindNearestOp& fnOp
341  ) const;
342 
343  //- Return bbox of octant
344  treeBoundBox subBbox
345  (
346  const label parentNodeI,
347  const direction octant
348  ) const;
349 
350  //- Helper: take a point on/close to face of bb and push it
351  // inside or outside of bb.
352  static point pushPoint
353  (
354  const treeBoundBox&,
355  const point&,
356  const bool pushInside
357  );
358 
359  //- Helper: take a point on face of bb and push it
360  // inside or outside of bb.
361  static point pushPoint
362  (
363  const treeBoundBox&,
364  const direction,
365  const point&,
366  const bool pushInside
367  );
368 
369  //- Helper: take point on face(s) of bb and push it away from
370  // edges of face.
371  // Guarantees that if pt is on a face it gets perturbed
372  // so it is away from the face edges.
373  // If pt is not on a face does nothing.
374  static point pushPointIntoFace
375  (
376  const treeBoundBox& bb,
377  const vector& dir, // end-start
378  const point& pt
379  );
380 
381  //- Walk to parent of node+octant.
382  bool walkToParent
383  (
384  const label nodeI,
385  const direction octant,
386 
387  label& parentNodeI,
388  label& parentOctant
389  ) const;
390 
391  //- Walk tree to neighbouring node. Return false if edge of tree
392  // hit.
393  bool walkToNeighbour
394  (
395  const point& facePoint,
396  const direction faceID, // direction to walk in
397  label& nodeI,
398  direction& octant
399  ) const;
400 
401  //- Debug: return verbose the bounding box faces
402  static word faceString(const direction faceID);
403 
404  //- Traverse a node. If intersects a triangle return first
405  // intersection point.
406  // findAny=true : return any intersection
407  // findAny=false: return nearest (to start) intersection
408  template<class FindIntersectOp>
409  void traverseNode
410  (
411  const bool findAny,
412  const point& treeStart,
413  const vector& treeVec,
414 
415  const point& start,
416  const point& end,
417  const label nodeI,
418  const direction octantI,
419 
420  pointIndexHit& hitInfo,
421  direction& faceID,
422 
423  const FindIntersectOp& fiOp
424  ) const;
425 
426  //- Find any or nearest intersection
427  template<class FindIntersectOp>
428  pointIndexHit findLine
429  (
430  const bool findAny,
431  const point& treeStart,
432  const point& treeEnd,
433  const label startNodeI,
434  const direction startOctantI,
435  const FindIntersectOp& fiOp,
436  const bool verbose = false
437  ) const;
438 
439  //- Find any or nearest intersection of line between start and end.
440  template<class FindIntersectOp>
441  pointIndexHit findLine
442  (
443  const bool findAny,
444  const point& start,
445  const point& end,
446  const FindIntersectOp& fiOp
447  ) const;
448 
449  //- Find elements intersecting box
450  // Store all results in elements (if non-null), or early exit
451  bool findBox
452  (
453  const label nodeI,
454  const treeBoundBox& searchBox,
455  labelHashSet* elements
456  ) const;
457 
458  //- Find elements intersecting sphere.
459  // Store all results in elements (if non-null), or early exit
460  bool findSphere
461  (
462  const label nodeI,
463  const point& centre,
464  const scalar radiusSqr,
465  labelHashSet* elements
466  ) const;
467 
468 
469  template<class CompareOp>
470  static void findNear
471  (
472  const scalar nearDist,
473  const bool okOrder,
474  const indexedOctree<Type>& tree1,
475  const labelBits index1,
476  const treeBoundBox& bb1,
477  const indexedOctree<Type>& tree2,
478  const labelBits index2,
479  const treeBoundBox& bb2,
480  CompareOp& cop
481  );
482 
483 
484  // Other
485 
486  //- Count number of elements on this and sublevels
487  label countElements(const labelBits index) const;
488 
489  //- Number of leafs below given node
490  label countLeafs(const label nodeI) const;
491 
492  //- Write node treeBoundBoxes in OBJ format
493  void writeOBJ
494  (
495  const label nodeI,
496  Ostream& os,
497  label& vertIndex,
498  const bool leavesOnly,
499  const bool writeLinesOnly = false
500  ) const;
501 
502  //- Dump node+octant to an obj file
503  void writeOBJ(const label nodeI, const direction octant) const;
504 
505 
506 public:
507 
508  // Constructors
509 
510  //- Construct null
511  indexedOctree(const Type& shapes);
512 
513  //- Construct from components
515  (
516  const Type& shapes,
517  const List<node>& nodes,
519  );
520 
521  //- Construct from shapes
523  (
524  const Type& shapes,
525  const treeBoundBox& bb,
526  const label maxLevels, // maximum number of levels
527  const scalar maxLeafRatio, // how many elements per leaf
528  const scalar maxDuplicity // in how many leaves is a shape on
529  // average
530  );
531 
532  //- Construct from Istream
533  indexedOctree(const Type& shapes, Istream& is);
534 
535  //- Clone
537  {
538  return autoPtr<indexedOctree<Type>>::New(*this);
539  }
540 
541 
542  // Member Functions
543 
544  // Access
545 
546  //- Reference to shape
547  const Type& shapes() const noexcept { return shapes_; }
548 
549  //- List of all nodes
550  const List<node>& nodes() const noexcept { return nodes_; }
551 
552  //- List of all contents
553  //- (referenced by those nodes that are contents)
554  const List<labelList>& contents() const noexcept
555  {
556  return contents_;
557  }
558 
559  //- Per node, per octant whether is fully inside/outside/mixed.
561  {
562  return nodeTypes_;
563  }
564 
565  //- Top bounding box
566  const treeBoundBox& bb() const
567  {
568  if (nodes_.empty())
569  {
570  return treeBoundBox::null();
571  }
572  return nodes_[0].bb_;
573  }
574 
575  //- Return the number of leaf nodes
576  label nLeafs() const;
577 
578 
579  // Queries
580 
581  pointIndexHit findNearest
582  (
583  const point& sample,
584  const scalar nearestDistSqr
585  ) const;
586 
587  //- Calculate nearest point on nearest shape.
588  // Returns
589  // - bool : any point found nearer than nearestDistSqr
590  // - label: index in shapes
591  // - point: actual nearest point found
592  template<class FindNearestOp>
593  pointIndexHit findNearest
594  (
595  const point& sample,
596  const scalar nearestDistSqr,
597 
598  const FindNearestOp& fnOp
599  ) const;
600 
601  //- Low level: calculate nearest starting from subnode.
602  template<class FindNearestOp>
603  void findNearest
604  (
605  const label nodeI,
606  const point&,
607 
608  scalar& nearestDistSqr,
609  label& nearestShapeI,
610  point& nearestPoint,
611 
612  const FindNearestOp& fnOp
613  ) const;
614 
615  //- Find nearest to line.
616  // Returns
617  // - bool : any point found?
618  // - label: index in shapes
619  // - point: actual nearest point found
620  // sets:
621  // - linePoint : corresponding nearest point on line
622  pointIndexHit findNearest
623  (
624  const linePointRef& ln,
625  treeBoundBox& tightest,
626  point& linePoint
627  ) const;
628 
629  template<class FindNearestOp>
630  pointIndexHit findNearest
631  (
632  const linePointRef& ln,
633  treeBoundBox& tightest,
634  point& linePoint,
635 
636  const FindNearestOp& fnOp
637  ) const;
638 
639  //- Find nearest intersection of line between start and end.
640  pointIndexHit findLine
641  (
642  const point& start,
643  const point& end
644  ) const;
645 
646  //- Find any intersection of line between start and end.
648  (
649  const point& start,
650  const point& end
651  ) const;
652 
653  //- Find nearest intersection of line between start and end.
654  template<class FindIntersectOp>
655  pointIndexHit findLine
656  (
657  const point& start,
658  const point& end,
659  const FindIntersectOp& fiOp
660  ) const;
661 
662  //- Find any intersection of line between start and end.
663  template<class FindIntersectOp>
665  (
666  const point& start,
667  const point& end,
668  const FindIntersectOp& fiOp
669  ) const;
670 
671  //- True if any shapes overlap the bounding box
672  bool overlaps(const treeBoundBox& bb) const;
673 
674  //- Find indices of all shapes inside or overlapping
675  //- a bounding box (i.e. all shapes not outside box)
676  // \returns the indices (in no particular order)
677  labelList findBox
678  (
679  const treeBoundBox& bb
680  ) const;
681 
682  //- Find indices of all shapes inside or overlapping
683  //- a bounding box (i.e. all shapes not outside box)
684  // \returns the number of elements found
685  label findBox
686  (
687  const treeBoundBox& bb,
688  labelHashSet& elements
689  ) const;
691  //- True if any shapes overlap the bounding sphere
692  bool overlaps
693  (
694  const point& centre,
695  const scalar radiusSqr
696  ) const;
697 
698  //- Find indices of all shapes inside or overlapping
699  //- a bounding sphere (i.e. all shapes not outside a sphere)
700  // \returns the indices (in no particular order)
701  labelList findSphere
702  (
703  const point& centre,
704  const scalar radiusSqr
705  ) const;
706 
707  //- Find indices of all shapes inside or overlapping
708  //- a bounding sphere (i.e. all shapes not outside sphere)
709  // \returns the number of elements found
710  label findSphere
711  (
712  const point& centre,
713  const scalar radiusSqr,
714  labelHashSet& elements
715  ) const;
716 
717 
718  //- Find deepest node (as parent+octant) containing point. Starts
719  // off from starting index in nodes_ (use 0 to start from top)
720  // Use getNode and getOctant to extract info, or call findIndices.
721  labelBits findNode(const label nodeI, const point&) const;
722 
723  //- Find shape containing point. Only implemented for certain
724  // shapes.
725  label findInside(const point&) const;
726 
727  //- Find the shape indices that occupy the result of findNode
728  const labelList& findIndices(const point&) const;
729 
730  //- Determine type (inside/outside/mixed) for point. unknown if
731  // cannot be determined (e.g. non-manifold surface)
732  volumeType getVolumeType(const point&) const;
733 
734  //- Helper function to return the side. Returns outside if
735  // outsideNormal&vec >= 0, inside otherwise
736  static volumeType getSide
737  (
738  const vector& outsideNormal,
739  const vector& vec
740  );
741 
742  //- Find near pairs and apply CompareOp to them.
743  // tree2 can be *this or different tree.
744  template<class CompareOp>
745  void findNear
746  (
747  const scalar nearDist,
748  const indexedOctree<Type>& tree2,
749  CompareOp& cop
750  ) const;
751 
752 
753  // Write
754 
755  //- Write (non-empty) tree boxes in OBJ format
756  void writeOBJ(Ostream& os) const;
757 
758  //- Print tree. Either print all indices (printContent = true) or
759  // just size of contents nodes.
760  void print
761  (
763  const bool printContents,
764  const label
765  ) const;
766 
767  bool write(Ostream& os) const;
768 
769 
770  // IOstream Operators
771 
772  friend Ostream& operator<< <Type>(Ostream&, const indexedOctree<Type>&);
773 };
774 
775 
776 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
777 
778 } // End namespace Foam
779 
780 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
781 
782 #ifdef NoRepository
783  #include "indexedOctree.C"
784 #endif
785 
786 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
787 
788 #endif
789 
790 // ************************************************************************* //
static label getNode(const labelBits i)
Return real (dereferenced) index for a parent node.
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
static void writeOBJ(Ostream &os, const treeBoundBox &bb, label &vertIndex, const bool writeLinesOnly=false)
Write treeBoundBox in OBJ format.
treeBoundBox bb_
Bounding box of this node.
Definition: indexedOctree.H:88
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
uint8_t direction
Definition: direction.H:46
A line primitive.
Definition: line.H:52
static const treeBoundBox & null() noexcept
The null treeBoundBox is the same as an inverted box.
Definition: treeBoundBox.H:187
const List< node > & nodes() const noexcept
List of all nodes.
bool overlaps(const treeBoundBox &bb) const
True if any shapes overlap the bounding box.
const List< labelList > & contents() const noexcept
List of all contents (referenced by those nodes that are contents)
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:107
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
static scalar perturbTol_
Relative perturbation tolerance.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
const Type & shapes() const noexcept
Reference to shape.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:666
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
friend bool operator!=(const node &a, const node &b)
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
Definition: pointIndexHit.H:44
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
Definition: volumeType.H:55
label parent_
Parent node (index into flat list addressing for tree)
Definition: indexedOctree.H:93
ClassName("indexedOctree")
Runtime type information.
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
static bool isEmpty(labelBits i) noexcept
An empty node - no content.
static label getContent(labelBits i)
Return real (dereferenced) index for a content node.
static bool isContent(labelBits i) noexcept
Node with content (leaf)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:51
Version of OSstream that prints a prefix on each line.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
static labelBits nodePlusOctant(label i, direction octant)
From index into nodes_ to subNodes_ entry.
A class for handling words, derived from Foam::string.
Definition: word.H:63
friend Ostream & operator<<(Ostream &os, const node &n)
Space [isspace].
Definition: token.H:131
PackedList< 2 > & nodeTypes() const noexcept
Per node, per octant whether is fully inside/outside/mixed.
const treeBoundBox & bb() const
Top bounding box.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
static direction getOctant(labelBits i) noexcept
Return sub-node direction/octant.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:1237
indexedOctree(const Type &shapes)
Construct null.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
label facePoint(const int facei, const block &block, const label i, const label j)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:201
OBJstream os(runTime.globalPath()/outputName)
autoPtr< indexedOctree< Type > > clone() const
Clone.
friend Istream & operator>>(Istream &is, node &n)
static constexpr direction nChildren
Has exactly 8 sub-nodes (octants)
Definition: indexedOctree.H:83
Template invariant parts for indexedOctree.
Definition: indexedOctree.H:67
static bool isNode(labelBits i) noexcept
A parent node.
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
static labelBits contentPlusOctant(label i, direction octant)
From index into contents_ to subNodes_ entry.
Non-pointer based hierarchical recursive searching.
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:90
indexedOctreeBase()=default
Default construct.
A 29bits (or 61bits) integer label with 3bits direction (eg, octant) packed into single label...
Definition: labelBits.H:48
label n
static labelBits emptyPlusOctant(direction octant)
From empty to subNodes_ entry.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
label val() const noexcept
Return the integer value.
Definition: labelBits.H:137
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
Definition: indexedOctree.H:98
label nLeafs() const
Return the number of leaf nodes.
friend bool operator==(const node &a, const node &b)
bool write(Ostream &os) const
Namespace for OpenFOAM.
Tree node. Has up pointer and down pointers.
Definition: indexedOctree.H:76