Class to implement octree. More...
#include <meshTools/treeNode.H>
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.
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.
Definition at line 84 of file treeNode.H.
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 > &) |
treeNode | ( | const treeBoundBox & | bb ) |
Construct from components.
Definition at line 298 of file treeNode.C.
Construct from Istream.
Definition at line 316 of file treeNode.C.
~treeNode | ( | ) |
Definition at line 325 of file treeNode.C.
const Foam::point & midpoint | ( | ) | const [inline]
|
The midpoint position.
Definition at line 39 of file treeNodeI.H.
Foam::treeElem< Type > *const subNodes | ( | ) | const [inline]
|
array of 8 subNodes/leaves
Definition at line 46 of file treeNodeI.H.
Foam::label isNode | ( | const label | octant ) | const [inline]
|
octant contains pointer to treeNode(1) or treeLeaf(0)
Definition at line 54 of file treeNodeI.H.
Foam::treeNode< Type > * getNodePtr | ( | const label | octant ) | const [inline]
|
Get pointer to sub node.
Definition at line 63 of file treeNodeI.H.
References Foam::abort(), Foam::FatalError, and FatalErrorIn.
Referenced by Foam::operator<<().
Foam::treeLeaf< Type > * getLeafPtr | ( | const label | octant ) | const [inline]
|
Get pointer to sub leaf.
Definition at line 83 of file treeNodeI.H.
References Foam::abort(), Foam::FatalError, and FatalErrorIn.
void distribute | ( | const label | level, |
octree< Type > & | top, | ||
const Type & | shapes, | ||
const labelList & | indices | ||
) |
Take list of shapes and distribute over the 8 octants.
Definition at line 349 of file treeNode.C.
References Foam::abort(), treeElem< Type >::bb(), Foam::endl(), Foam::FatalError, FatalErrorIn, forAll, treeLeaf< Type >::insert(), octree< Type >::nEntries(), octree< Type >::nLeaves(), Foam::Pout, octree< Type >::setEntries(), octree< Type >::setLeaves(), treeLeaf< Type >::size(), List< T >::size(), treeLeaf< Type >::trim(), and prefixOSstream::write().
Referenced by treeLeaf< Type >::redistribute().
void redistribute | ( | const label | level, |
octree< Type > & | top, | ||
const Type & | shapes, | ||
const label | refineLevel | ||
) |
Distribute at certain level only.
Definition at line 443 of file treeNode.C.
References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorIn, octree< Type >::nEntries(), octree< Type >::nLeaves(), Foam::Pout, treeLeaf< Type >::redistribute(), octree< Type >::setEntries(), octree< Type >::setLeaves(), and treeLeaf< Type >::size().
Foam::label setSubNodeType | ( | const label | level, |
octree< Type > & | top, | ||
const Type & | shapes | ||
) |
Set type of subnodes.
Definition at line 551 of file treeNode.C.
References Foam::endl(), boundBox::midpoint(), Foam::Pout, treeBoundBox::subBbox(), and octree< Type >::volType().
Foam::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.
determination
Definition at line 636 of file treeNode.C.
References Foam::abort(), Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorIn, Foam::Pout, Foam::type(), and octree< Type >::volType().
Foam::label find | ( | const Type & | shapes, |
const point & | sample | ||
) | const |
Find index of shape containing sample.
Definition at line 725 of file treeNode.C.
References treeNode< Type >::find().
Referenced by treeNode< Type >::find().
bool findTightest | ( | const Type & | shapes, |
const point & | sample, | ||
treeBoundBox & | tightest | ||
) | const |
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 755 of file treeNode.C.
References treeElem< Type >::bb(), treeLeaf< Type >::findTightest(), treeNode< Type >::findTightest(), and treeBoundBox::overlaps().
Referenced by treeNode< Type >::findTightest().
bool findNearest | ( | const Type & | shapes, |
const point & | sample, | ||
treeBoundBox & | tightest, | ||
label & | tightestI, | ||
scalar & | tightestDist | ||
) | const |
Find nearest shape to sample.
Returns true if found nearer shape and updates tightest, tightestI, tightestDist
Definition at line 829 of file treeNode.C.
References treeElem< Type >::bb(), Foam::endl(), treeLeaf< Type >::findNearest(), treeNode< Type >::findNearest(), treeBoundBox::overlaps(), and Foam::Pout.
Referenced by treeNode< Type >::findNearest().
bool findNearest | ( | const Type & | shapes, |
const linePointRef & | ln, | ||
treeBoundBox & | tightest, | ||
label & | tightestI, | ||
point & | linePoint, | ||
point & | shapePoint | ||
) | const |
Find nearest shape to line.
Returns true if found nearer shape and updates nearest and tightest
Definition at line 921 of file treeNode.C.
References treeElem< Type >::bb(), line< Point, PointRef >::centre(), treeLeaf< Type >::findNearest(), treeNode< Type >::findNearest(), and treeBoundBox::overlaps().
bool findBox | ( | const Type & | shapes, |
const boundBox & | bb, | ||
labelHashSet & | elements | ||
) | const |
Find shapes not outside box. Return true if anything found.
Definition at line 1004 of file treeNode.C.
References treeElem< Type >::bb(), treeLeaf< Type >::findBox(), treeNode< Type >::findBox(), boundBox::midpoint(), and treeBoundBox::overlaps().
Referenced by treeNode< Type >::findBox().
const Foam::treeLeaf< Type > * findLeafLine | ( | const label | level, |
const Type & | shapes, | ||
point & | start, | ||
const point & | end | ||
) | const |
Find treeLeaves intersecting line segment [start..end].
Updates: start
Definition at line 1074 of file treeNode.C.
References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorIn, Foam::mag(), and Foam::Pout.
Collect all treeLeafs in leafArray. leafIndex points to first.
empty slot in leafArray and gets updated.
Definition at line 1183 of file treeNode.C.
References treeNode< Type >::findLeaves().
Referenced by treeNode< Type >::findLeaves().
Same but for const.
Definition at line 1212 of file treeNode.C.
References treeNode< Type >::findLeaves().
void printNode | ( | Ostream & | os, |
const label | level | ||
) | const |
Print contents of node.
Definition at line 1241 of file treeNode.C.
References Foam::endl(), treeLeaf< Type >::printLeaf(), and octree< Type >::volType().
void writeOBJ | ( | Ostream & | os, |
const label | level, | ||
label & | vertNo | ||
) | const |
Write subleafs in OBJ format.
Definition at line 1281 of file treeNode.C.
References treeElem< Type >::bb(), Foam::endl(), boundBox::midpoint(), treeNode< Type >::writeOBJ(), Vector< Cmpt >::x(), Vector< Cmpt >::y(), and Vector< Cmpt >::z().
Referenced by treeNode< Type >::writeOBJ().