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