dynamicIndexedOctree< Type > Class Template Reference

Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted. More...

Inheritance diagram for dynamicIndexedOctree< Type >:
Collaboration diagram for dynamicIndexedOctree< Type >:

Public Member Functions

 dynamicIndexedOctree (const Type &shapes, const treeBoundBox &bb, const label maxLevels, const scalar maxLeafRatio, const scalar maxDuplicity)
 Construct from shapes. More...
 
autoPtr< dynamicIndexedOctree< Type > > clone () const
 Clone. More...
 
const Type & shapes () const noexcept
 Reference to shape. More...
 
const List< node > & nodes () const noexcept
 List of all nodes. More...
 
const DynamicList< DynamicList< label > > & contents () const noexcept
 List of all contents (referenced by those nodes that are contents) More...
 
PackedList< 2 > & nodeTypes () const noexcept
 Per node, per octant whether is fully inside/outside/mixed. More...
 
const treeBoundBoxbb () const
 Top bounding box. More...
 
pointIndexHit findNearest (const point &sample, const scalar nearestDistSqr) const
 Calculate nearest point on nearest shape. More...
 
void findNearest (const label nodeI, const point &, scalar &nearestDistSqr, label &nearestShapeI, point &nearestPoint) const
 Low level: calculate nearest starting from subnode. More...
 
pointIndexHit findNearest (const linePointRef &ln, treeBoundBox &tightest, point &linePoint) const
 Find nearest to line. More...
 
pointIndexHit findLine (const point &start, const point &end) const
 Find nearest intersection of line between start and end. More...
 
pointIndexHit findLineAny (const point &start, const point &end) const
 Find any intersection of line between start and end. More...
 
bool overlaps (const treeBoundBox &bb) const
 True if any shapes overlap the bounding box. More...
 
labelList findBox (const treeBoundBox &bb) const
 Find indices of all shapes inside or overlapping a bounding box (i.e. all shapes not outside box) More...
 
label findBox (const treeBoundBox &bb, labelHashSet &elements) const
 Find indices of all shapes inside or overlapping a bounding box (i.e. all shapes not outside box) More...
 
bool overlaps (const point &centre, const scalar radiusSqr) const
 True if any shapes overlap the bounding sphere. More...
 
labelList findSphere (const point &centre, const scalar radiusSqr) const
 Find indices of all shapes inside or overlapping a bounding sphere (i.e. all shapes not outside a sphere) More...
 
label findSphere (const point &centre, const scalar radiusSqr, labelHashSet &elements) const
 Find indices of all shapes inside or overlapping a bounding sphere (i.e. all shapes not outside sphere) More...
 
labelBits findNode (const label nodeI, const point &) const
 Find deepest node (as parent+octant) containing point. Starts. More...
 
label findInside (const point &) const
 Find shape containing point. Only implemented for certain. More...
 
const labelListfindIndices (const point &) const
 Find the shape indices that occupy the result of findNode. More...
 
volumeType getVolumeType (const point &) const
 Determine type (inside/outside/mixed) for point. unknown if. More...
 
template<class CompareOp >
void findNear (const scalar nearDist, const dynamicIndexedOctree< Type > &tree2, CompareOp &cop) const
 Find near pairs and apply CompareOp to them. More...
 
bool insert (label startIndex, label endIndex)
 Insert a new object into the tree. More...
 
bool insertIndex (const label nodIndex, const label index, label &nLevels)
 
bool remove (const label index)
 Remove an object from the tree. More...
 
label removeIndex (const label nodIndex, const label index)
 
void writeOBJ (Ostream &os) const
 Write all tree boxes as OBJ format. More...
 
void print (prefixOSstream &, const bool printContents, const label) const
 Print tree. Either print all indices (printContent = true) or. More...
 
bool write (Ostream &os) const
 
void writeTreeInfo () const
 
- Public Member Functions inherited from dynamicIndexedOctreeBase
 ClassName ("dynamicIndexedOctree")
 Runtime type information. More...
 
 dynamicIndexedOctreeBase ()=default
 Default construct. More...
 
- Public Member Functions inherited from indexedOctreeBase
 ClassName ("indexedOctree")
 Runtime type information. More...
 
 indexedOctreeBase ()=default
 Default construct. More...
 

Static Public Member Functions

static volumeType getSide (const vector &outsideNormal, const vector &vec)
 Helper function to return the side. Returns outside if. More...
 
- Static Public Member Functions inherited from indexedOctreeBase
static bool isEmpty (labelBits i) noexcept
 An empty node - no content. More...
 
static bool isContent (labelBits i) noexcept
 Node with content (leaf) More...
 
static bool isNode (labelBits i) noexcept
 A parent node. More...
 
static label getContent (labelBits i)
 Return real (dereferenced) index for a content node. More...
 
static label getNode (const labelBits i)
 Return real (dereferenced) index for a parent node. More...
 
static direction getOctant (labelBits i) noexcept
 Return sub-node direction/octant. More...
 
static scalar & perturbTol () noexcept
 Get the perturbation tolerance. More...
 
static scalar perturbTol (scalar tol) noexcept
 Set the perturbation tolerance, return the old value. More...
 
static void writeOBJ (Ostream &os, const treeBoundBox &bb, label &vertIndex, const bool writeLinesOnly=false)
 Write treeBoundBox in OBJ format. More...
 

Friends

Ostreamoperator (Ostream &, const dynamicIndexedOctree< Type > &)
 

Additional Inherited Members

- Public Types inherited from dynamicIndexedOctreeBase
using node = indexedOctreeBase::node
 Document that we are using the same types of node. More...
 
- Static Protected Member Functions inherited from indexedOctreeBase
static labelBits emptyPlusOctant (direction octant)
 From empty to subNodes_ entry. More...
 
static labelBits contentPlusOctant (label i, direction octant)
 From index into contents_ to subNodes_ entry. More...
 
static labelBits nodePlusOctant (label i, direction octant)
 From index into nodes_ to subNodes_ entry. More...
 
- Static Protected Attributes inherited from indexedOctreeBase
static scalar perturbTol_ = 10*SMALL
 Relative perturbation tolerance. More...
 

Detailed Description

template<class Type>
class Foam::dynamicIndexedOctree< Type >

Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted.

Source files

Definition at line 46 of file dynamicIndexedOctree.H.

Constructor & Destructor Documentation

◆ dynamicIndexedOctree()

dynamicIndexedOctree ( const Type &  shapes,
const treeBoundBox bb,
const label  maxLevels,
const scalar  maxLeafRatio,
const scalar  maxDuplicity 
)

Construct from shapes.

Definition at line 2024 of file dynamicIndexedOctree.C.

Member Function Documentation

◆ clone()

autoPtr<dynamicIndexedOctree<Type> > clone ( ) const
inline

Clone.

Definition at line 410 of file dynamicIndexedOctree.H.

◆ shapes()

const Type& shapes ( ) const
inlinenoexcept

Reference to shape.

Definition at line 423 of file dynamicIndexedOctree.H.

◆ nodes()

const List<node>& nodes ( ) const
inlinenoexcept

List of all nodes.

Definition at line 428 of file dynamicIndexedOctree.H.

◆ contents()

const DynamicList<DynamicList<label> >& contents ( ) const
inlinenoexcept

List of all contents (referenced by those nodes that are contents)

Definition at line 434 of file dynamicIndexedOctree.H.

◆ nodeTypes()

PackedList<2>& nodeTypes ( ) const
inlinenoexcept

Per node, per octant whether is fully inside/outside/mixed.

Definition at line 442 of file dynamicIndexedOctree.H.

◆ bb()

const treeBoundBox& bb ( ) const
inline

Top bounding box.

Definition at line 450 of file dynamicIndexedOctree.H.

Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::findNear().

Here is the caller graph for this function:

◆ findNearest() [1/3]

Foam::pointIndexHit findNearest ( const point sample,
const scalar  nearestDistSqr 
) const

Calculate nearest point on nearest shape.

Returns

  • bool : any point found nearer than nearestDistSqr
  • label: index in shapes
  • point: actual nearest point found

Definition at line 2061 of file dynamicIndexedOctree.C.

◆ findNearest() [2/3]

void findNearest ( const label  nodeI,
const point sample,
scalar &  nearestDistSqr,
label &  nearestShapeI,
point nearestPoint 
) const

Low level: calculate nearest starting from subnode.

Definition at line 342 of file dynamicIndexedOctree.C.

◆ findNearest() [3/3]

Foam::pointIndexHit findNearest ( const linePointRef ln,
treeBoundBox tightest,
point linePoint 
) const

Find nearest to line.

Returns

  • bool : any point found?
  • label: index in shapes
  • point: actual nearest point found sets:
  • linePoint : corresponding nearest point on line

Definition at line 2089 of file dynamicIndexedOctree.C.

◆ findLine()

Foam::pointIndexHit findLine ( const point start,
const point end 
) const

Find nearest intersection of line between start and end.

Definition at line 2118 of file dynamicIndexedOctree.C.

◆ findLineAny()

Foam::pointIndexHit findLineAny ( const point start,
const point end 
) const

Find any intersection of line between start and end.

Definition at line 2129 of file dynamicIndexedOctree.C.

◆ overlaps() [1/2]

bool overlaps ( const treeBoundBox bb) const

True if any shapes overlap the bounding box.

Definition at line 2140 of file dynamicIndexedOctree.C.

◆ findBox() [1/2]

Foam::labelList findBox ( const treeBoundBox bb) const

Find indices of all shapes inside or overlapping a bounding box (i.e. all shapes not outside box)

Returns
the indices (in no particular order)
Parameters
bbbound box limits

Definition at line 2174 of file dynamicIndexedOctree.C.

◆ findBox() [2/2]

Foam::label findBox ( const treeBoundBox bb,
labelHashSet elements 
) const

Find indices of all shapes inside or overlapping a bounding box (i.e. all shapes not outside box)

Returns
the number of elements found
Parameters
bbbound box limits
[out]elementselements found

Definition at line 2151 of file dynamicIndexedOctree.C.

◆ overlaps() [2/2]

bool overlaps ( const point centre,
const scalar  radiusSqr 
) const

True if any shapes overlap the bounding sphere.

Parameters
centrecentre of bound sphere
radiusSqrradius^2 of sphere

Definition at line 2194 of file dynamicIndexedOctree.C.

◆ findSphere() [1/2]

Foam::labelList findSphere ( const point centre,
const scalar  radiusSqr 
) const

Find indices of all shapes inside or overlapping a bounding sphere (i.e. all shapes not outside a sphere)

Returns
the indices (in no particular order)
Parameters
centrecentre of bound sphere
radiusSqrradius^2 of sphere

Definition at line 2230 of file dynamicIndexedOctree.C.

◆ findSphere() [2/2]

Foam::label findSphere ( const point centre,
const scalar  radiusSqr,
labelHashSet elements 
) const

Find indices of all shapes inside or overlapping a bounding sphere (i.e. all shapes not outside sphere)

Returns
the number of elements found
Parameters
centrecentre of bound sphere
radiusSqrradius^2 of sphere
[out]elementselements found

Definition at line 2206 of file dynamicIndexedOctree.C.

◆ findNode()

Foam::labelBits findNode ( const label  nodeI,
const point sample 
) const

Find deepest node (as parent+octant) containing point. Starts.

off from starting index in nodes_ (use 0 to start from top) Use getNode and getOctant to extract info, or call findIndices.

Definition at line 2251 of file dynamicIndexedOctree.C.

◆ findInside()

Foam::label findInside ( const point sample) const

Find shape containing point. Only implemented for certain.

shapes.

Definition at line 2298 of file dynamicIndexedOctree.C.

◆ findIndices()

const Foam::labelList & findIndices ( const point sample) const

Find the shape indices that occupy the result of findNode.

Definition at line 2330 of file dynamicIndexedOctree.C.

◆ getVolumeType()

Foam::volumeType getVolumeType ( const point sample) const

Determine type (inside/outside/mixed) for point. unknown if.

cannot be determined (e.g. non-manifold surface)

Definition at line 2352 of file dynamicIndexedOctree.C.

◆ getSide()

Foam::volumeType getSide ( const vector outsideNormal,
const vector vec 
)
static

Helper function to return the side. Returns outside if.

outsideNormal&vec >= 0, inside otherwise

Definition at line 324 of file dynamicIndexedOctree.C.

◆ findNear()

void findNear ( const scalar  nearDist,
const dynamicIndexedOctree< Type > &  tree2,
CompareOp &  cop 
) const

Find near pairs and apply CompareOp to them.

tree2 can be *this or different tree.

Definition at line 2422 of file dynamicIndexedOctree.C.

◆ insert()

bool insert ( label  startIndex,
label  endIndex 
)

Insert a new object into the tree.

Definition at line 2444 of file dynamicIndexedOctree.C.

◆ insertIndex()

bool insertIndex ( const label  nodIndex,
const label  index,
label &  nLevels 
)

Definition at line 2483 of file dynamicIndexedOctree.C.

◆ remove()

bool remove ( const label  index)

Remove an object from the tree.

Definition at line 2554 of file dynamicIndexedOctree.C.

◆ removeIndex()

Foam::label removeIndex ( const label  nodIndex,
const label  index 
)

Definition at line 2569 of file dynamicIndexedOctree.C.

◆ writeOBJ()

void writeOBJ ( Ostream os) const

Write all tree boxes as OBJ format.

Definition at line 2009 of file dynamicIndexedOctree.C.

◆ print()

void print ( prefixOSstream os,
const bool  printContents,
const label  nodeI 
) const

Print tree. Either print all indices (printContent = true) or.

just size of contents nodes.

Definition at line 2652 of file dynamicIndexedOctree.C.

◆ write()

bool write ( Ostream os) const

Definition at line 2750 of file dynamicIndexedOctree.C.

◆ writeTreeInfo()

void writeTreeInfo ( ) const

Definition at line 2724 of file dynamicIndexedOctree.C.

Friends And Related Function Documentation

◆ operator

Ostream& operator ( Ostream ,
const dynamicIndexedOctree< Type > &   
)
friend

The documentation for this class was generated from the following files: