OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

treeNode< Type > Class Template Reference

Class to implement octree. More...

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

List of all members.


Public Member Functions

 treeNode (const treeBoundBox &)
 Construct from components.
 treeNode (Istream &)
 Construct from Istream.
 ~treeNode ()
const point & midpoint () const
 The midpoint position.
treeElem< Type > *const * subNodes () const
 array of 8 subNodes/leaves
label isNode (const label octant) const
 octant contains pointer to treeNode(1) or treeLeaf(0)
treeNode< Type > * getNodePtr (const label octant) const
 Get pointer to sub node.
treeLeaf< Type > * getLeafPtr (const label octant) const
 Get pointer to sub leaf.
void distribute (const label, octree< Type > &, const Type &shapes, const labelList &)
 Take list of shapes and distribute over the 8 octants.
void redistribute (const label, octree< Type > &, const Type &shapes, const label)
 Distribute at certain level only.
label setSubNodeType (const label level, octree< Type > &top, const Type &shapes)
 Set type of subnodes.
label getSampleType (const label level, const octree< Type > &top, const Type &shapes, const point &sample) const
 Find type of node sample is in. Used for inside/outside.
label find (const Type &shapes, const point &sample) const
 Find index of shape containing sample.
bool findTightest (const Type &shapes, const point &sample, treeBoundBox &tightest) const
 Find tightest bounding box around sample which is guaranteed.
bool findNearest (const Type &shapes, const point &sample, treeBoundBox &tightest, label &tightestI, scalar &tightestDist) const
 Find nearest shape to sample.
bool findNearest (const Type &shapes, const linePointRef &ln, treeBoundBox &tightest, label &tightestI, point &linePoint, point &shapePoint) const
 Find nearest shape to line.
bool findBox (const Type &shapes, const boundBox &bb, labelHashSet &elements) const
 Find shapes not outside box. Return true if anything found.
const treeLeaf< Type > * findLeafLine (const label level, const Type &shapes, point &start, const point &end) const
 Find treeLeaves intersecting line segment [start..end].
void findLeaves (List< treeLeaf< Type > * > &leafArray, label &leafIndex) const
 Collect all treeLeafs in leafArray. leafIndex points to first.
void findLeaves (List< const treeLeaf< Type > * > &leafArray, label &leafIndex) const
 Same but for const.
void printNode (Ostream &os, const label level) const
 Print contents of node.
void writeOBJ (Ostream &os, const label level, label &vertNo) const
 Write subleafs in OBJ format.

Friends

Istream & operator>> (Istream &, treeNode< Type > &)
Ostream & operator (Ostream &, const treeNode< Type > &)

Detailed Description

template<class Type>
class Foam::treeNode< Type >

Class to implement octree.

Holds the pointers to sub-octants. These are either other treeNodes or treeLeafs. The treeLeafs hold the actual data as a list of indices into octreeData.

Note:
To prevent calculation errors all bounding boxes used in octrees are calculated only once.
The pointers to either treeNode/treeLeaf are implemented 'by hand' (explicitly marking type) instead of using a proper virtual mechanism to save some space in the treeLeaves.

Source files

Definition at line 79 of file treeNode.H.


Constructor & Destructor Documentation

treeNode ( const treeBoundBox &  bb  )  [inline]

Construct from components.

Definition at line 291 of file treeNode.C.

treeNode ( Istream &  is  )  [inline]

Construct from Istream.

Definition at line 309 of file treeNode.C.

~treeNode (  )  [inline]

Definition at line 318 of file treeNode.C.


Member Function Documentation

const Foam::point & midpoint (  )  const [inline]

The midpoint position.

Definition at line 32 of file treeNodeI.H.

Foam::treeElem< Type > *const * subNodes (  )  const [inline]

array of 8 subNodes/leaves

Definition at line 39 of file treeNodeI.H.

Foam::label isNode ( const label  octant  )  const [inline]

octant contains pointer to treeNode(1) or treeLeaf(0)

Definition at line 47 of file treeNodeI.H.

Foam::treeNode< Type > * getNodePtr ( const label  octant  )  const [inline]

Get pointer to sub node.

Definition at line 56 of file treeNodeI.H.

Foam::treeLeaf< Type > * getLeafPtr ( const label  octant  )  const [inline]

Get pointer to sub leaf.

Definition at line 76 of file treeNodeI.H.

void distribute ( const label  level,
octree< Type > &  top,
const Type &  shapes,
const labelList &  indices 
) [inline]

Take list of shapes and distribute over the 8 octants.

Definition at line 342 of file treeNode.C.

void redistribute ( const label  level,
octree< Type > &  top,
const Type &  shapes,
const label  refineLevel 
) [inline]

Distribute at certain level only.

Definition at line 436 of file treeNode.C.

Foam::label setSubNodeType ( const label  level,
octree< Type > &  top,
const Type &  shapes 
) [inline]

Set type of subnodes.

Definition at line 544 of file treeNode.C.

Foam::label getSampleType ( const label  level,
const octree< Type > &  top,
const Type &  shapes,
const point &  sample 
) const [inline]

Find type of node sample is in. Used for inside/outside.

determination

Definition at line 629 of file treeNode.C.

Foam::label find ( const Type &  shapes,
const point &  sample 
) const [inline]

Find index of shape containing sample.

Definition at line 718 of file treeNode.C.

bool findTightest ( const Type &  shapes,
const point &  sample,
treeBoundBox &  tightest 
) const [inline]

Find tightest bounding box around sample which is guaranteed.

to hold at least one cell. Current best bb in tightest, returns true if newTightest has changed, 0 otherwise.

Definition at line 748 of file treeNode.C.

bool findNearest ( const Type &  shapes,
const point &  sample,
treeBoundBox &  tightest,
label &  tightestI,
scalar &  tightestDist 
) const [inline]

Find nearest shape to sample.

Returns true if found nearer shape and updates tightest, tightestI, tightestDist

Definition at line 822 of file treeNode.C.

bool findNearest ( const Type &  shapes,
const linePointRef &  ln,
treeBoundBox &  tightest,
label &  tightestI,
point &  linePoint,
point &  shapePoint 
) const [inline]

Find nearest shape to line.

Returns true if found nearer shape and updates nearest and tightest

Definition at line 914 of file treeNode.C.

bool findBox ( const Type &  shapes,
const boundBox &  bb,
labelHashSet &  elements 
) const [inline]

Find shapes not outside box. Return true if anything found.

Definition at line 997 of file treeNode.C.

const treeLeaf<Type>* findLeafLine ( const label  level,
const Type &  shapes,
point &  start,
const point &  end 
) const

Find treeLeaves intersecting line segment [start..end].

Updates: start

void findLeaves ( List< treeLeaf< Type > * > &  leafArray,
label &  leafIndex 
) const [inline]

Collect all treeLeafs in leafArray. leafIndex points to first.

empty slot in leafArray and gets updated.

Definition at line 1176 of file treeNode.C.

void findLeaves ( List< const treeLeaf< Type > * > &  leafArray,
label &  leafIndex 
) const [inline]

Same but for const.

Definition at line 1205 of file treeNode.C.

void printNode ( Ostream &  os,
const label  level 
) const [inline]

Print contents of node.

Definition at line 1234 of file treeNode.C.

void writeOBJ ( Ostream &  os,
const label  level,
label &  vertNo 
) const [inline]

Write subleafs in OBJ format.

Definition at line 1274 of file treeNode.C.


Friends And Related Function Documentation

Istream& operator>> ( Istream &  ,
treeNode< Type > &   
) [friend]

Ostream& operator ( Ostream &  ,
const treeNode< Type > &   
) [friend]


The documentation for this class was generated from the following files:
Copyright © 2000-2009 OpenCFD Ltd