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 >:
[legend]
Collaboration diagram for dynamicIndexedOctree< Type >:
[legend]

Classes

class  node
 Tree node. Has up pointer and down pointers. More...
 

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
 Reference to shape. More...
 
const List< node > & nodes () const
 List of all nodes. More...
 
const contentListListcontents () const
 List of all contents (referenced by those nodes that are. 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...
 
labelList findBox (const treeBoundBox &bb) const
 Find (in no particular order) indices of all shapes inside or. More...
 
labelList findSphere (const point &centre, const scalar radiusSqr) const
 Find (in no particular order) indices of all shapes inside or. 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 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
 

Static Public Member Functions

static scalar & perturbTol ()
 Get the perturbation tolerance. More...
 
static bool isContent (const labelBits i)
 
static bool isEmpty (const labelBits i)
 
static bool isNode (const labelBits i)
 
static label getContent (const labelBits i)
 
static label getNode (const labelBits i)
 
static direction getOctant (const labelBits i)
 
static volumeType getSide (const vector &outsideNormal, const vector &vec)
 Helper function to return the side. Returns outside if. More...
 
static bool overlaps (const point &bbMin, const point &bbMax, const scalar nearestDistSqr, const point &sample)
 Helper: does bb intersect a sphere around sample? Or is any. More...
 

Friends

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

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 80 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 2136 of file dynamicIndexedOctree.C.

References dynamicIndexedOctree< Type >::insert(), and dynamicIndexedOctree< Type >::writeTreeInfo().

Here is the call graph for this function:

Member Function Documentation

◆ perturbTol()

Foam::scalar & perturbTol
static

Get the perturbation tolerance.

Definition at line 2173 of file dynamicIndexedOctree.C.

◆ clone()

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

Clone.

Definition at line 420 of file dynamicIndexedOctree.H.

References Foam::New().

Here is the call graph for this function:

◆ shapes()

const Type & shapes ( ) const
inline

Reference to shape.

Definition at line 431 of file dynamicIndexedOctree.H.

◆ nodes()

const List< node > & nodes ( ) const
inline

List of all nodes.

Definition at line 437 of file dynamicIndexedOctree.H.

◆ contents()

const contentListList & contents ( ) const
inline

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

contents)

Definition at line 444 of file dynamicIndexedOctree.H.

◆ bb()

const treeBoundBox & bb ( ) const
inline

Top bounding box.

Definition at line 450 of file dynamicIndexedOctree.H.

References Foam::abort(), UList< T >::empty(), Foam::FatalError, and FatalErrorInFunction.

Referenced by dynamicIndexedOctree< Type >::findNear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isContent()

static bool isContent ( const labelBits  i)
inlinestatic

Definition at line 463 of file dynamicIndexedOctree.H.

References labelBits::val().

Referenced by dynamicIndexedOctree< Type >::getContent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty()

static bool isEmpty ( const labelBits  i)
inlinestatic

Definition at line 468 of file dynamicIndexedOctree.H.

References labelBits::val().

Here is the call graph for this function:

◆ isNode()

static bool isNode ( const labelBits  i)
inlinestatic

Definition at line 473 of file dynamicIndexedOctree.H.

References labelBits::val().

Referenced by dynamicIndexedOctree< Type >::getNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContent()

static label getContent ( const labelBits  i)
inlinestatic

Definition at line 478 of file dynamicIndexedOctree.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree< Type >::isContent(), and labelBits::val().

Here is the call graph for this function:

◆ getNode()

static label getNode ( const labelBits  i)
inlinestatic

Definition at line 488 of file dynamicIndexedOctree.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree< Type >::isNode(), and labelBits::val().

Here is the call graph for this function:

◆ getOctant()

static direction getOctant ( const labelBits  i)
inlinestatic

Definition at line 498 of file dynamicIndexedOctree.H.

References labelBits::bits().

Here is the call 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 2180 of file dynamicIndexedOctree.C.

References Foam::Zero.

◆ 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 469 of file dynamicIndexedOctree.C.

References dynamicIndexedOctree< Type >::node::bb_, boundBox::max(), boundBox::min(), treeBoundBox::searchOrder(), and dynamicIndexedOctree< Type >::node::subNodes_.

Here is the call graph for this function:

◆ 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 2208 of file dynamicIndexedOctree.C.

References Foam::ln(), and Foam::Zero.

Here is the call graph for this function:

◆ findLine()

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

Find nearest intersection of line between start and end.

Definition at line 2241 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 2252 of file dynamicIndexedOctree.C.

◆ findBox()

Foam::labelList findBox ( const treeBoundBox bb) const

Find (in no particular order) indices of all shapes inside or.

overlapping bounding box (i.e. all shapes not outside box)

Definition at line 2263 of file dynamicIndexedOctree.C.

References HashTable< T, Key, Hash >::toc().

Here is the call graph for this function:

◆ findSphere()

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

Find (in no particular order) indices of all shapes inside or.

overlapping a bounding sphere (i.e. all shapes not outside sphere)

Definition at line 2283 of file dynamicIndexedOctree.C.

References HashTable< T, Key, Hash >::toc().

Here is the call graph for this function:

◆ 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 2304 of file dynamicIndexedOctree.C.

References Foam::abort(), dynamicIndexedOctree< Type >::node::bb_, treeBoundBox::contains(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree< Type >::node::subNodes_, and treeBoundBox::subOctant().

Here is the call graph for this function:

◆ findInside()

Foam::label findInside ( const point sample) const

Find shape containing point. Only implemented for certain.

shapes.

Definition at line 2351 of file dynamicIndexedOctree.C.

References forAll, Foam::getOctant(), and dynamicIndexedOctree< Type >::node::subNodes_.

Here is the call graph for this function:

◆ findIndices()

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

Find the shape indices that occupy the result of findNode.

Definition at line 2383 of file dynamicIndexedOctree.C.

References Foam::getOctant(), List< label >::null(), and dynamicIndexedOctree< Type >::node::subNodes_.

Here is the call graph for this function:

◆ 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 2405 of file dynamicIndexedOctree.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, volumeType::INSIDE, volumeType::MIXED, volumeType::OUTSIDE, Foam::Pout, Foam::type(), and volumeType::UNKNOWN.

Here is the call graph for this function:

◆ 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 451 of file dynamicIndexedOctree.C.

◆ overlaps()

bool overlaps ( const point bbMin,
const point bbMax,
const scalar  nearestDistSqr,
const point sample 
)
static

Helper: does bb intersect a sphere around sample? Or is any.

corner point of bb closer than nearestDistSqr to sample.

Definition at line 42 of file dynamicIndexedOctree.C.

References Foam::mag(), pTraits< bool >::nComponents, and p0.

Here is the call graph for this function:

◆ 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 2475 of file dynamicIndexedOctree.C.

References dynamicIndexedOctree< Type >::bb().

Here is the call graph for this function:

◆ insert()

bool insert ( label  startIndex,
label  endIndex 
)

Insert a new object into the tree.

Definition at line 2498 of file dynamicIndexedOctree.C.

References Foam::divide(), Foam::max(), and success.

Referenced by dynamicIndexedOctree< Type >::dynamicIndexedOctree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertIndex()

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

Definition at line 2544 of file dynamicIndexedOctree.C.

References treeBoundBox::subBbox().

Here is the call graph for this function:

◆ remove()

bool remove ( const label  index)

Remove an object from the tree.

Definition at line 2621 of file dynamicIndexedOctree.C.

◆ removeIndex()

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

Definition at line 2635 of file dynamicIndexedOctree.C.

References DynamicList< T, SizeMin >::append(), forAll, DynamicList< T, SizeMin >::shrink(), UList< T >::size(), treeBoundBox::subBbox(), and DynamicList< T, SizeMin >::transfer().

Here is the call graph for this function:

◆ 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 2718 of file dynamicIndexedOctree.C.

References dynamicIndexedOctree< Type >::node::bb_, Foam::endl(), forAll, Foam::nl, os(), dynamicIndexedOctree< Type >::node::parent_, UList< T >::size(), treeBoundBox::subBbox(), and dynamicIndexedOctree< Type >::node::subNodes_.

Here is the call graph for this function:

◆ write()

bool write ( Ostream os) const

Definition at line 2817 of file dynamicIndexedOctree.C.

References IOstream::good(), and os().

Here is the call graph for this function:

◆ writeTreeInfo()

void writeTreeInfo

Definition at line 2791 of file dynamicIndexedOctree.C.

References Foam::endl(), forAll, Foam::nl, and Foam::Pout.

Referenced by dynamicIndexedOctree< Type >::dynamicIndexedOctree().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator

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

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