Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted. More...
Data Structures | |
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 contentListList & | contents () const |
List of all contents (referenced by those nodes that are. More... | |
const treeBoundBox & | bb () 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 ¢re, 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 labelList & | findIndices (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... | |
Private Member Functions | |
void | divide (const autoPtr< DynamicList< label > > &indices, const treeBoundBox &bb, contentListList &result) const |
Split list of indices into 8 bins. More... | |
node | divide (const treeBoundBox &bb, const label contentI, const label parentNodeIndex, const label octantToBeDivided) |
Subdivide the contents node at position contentI. More... | |
void | recursiveSubDivision (const treeBoundBox &subBb, const label contentI, const label parentIndex, const label octant, label &nLevels) |
volumeType | calcVolumeType (const label nodeI) const |
Determine inside/outside per node (mixed if cannot be. More... | |
volumeType | getVolumeType (const label nodeI, const point &) const |
Search cached volume type. More... | |
void | findNearest (const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint) const |
Find nearest point to line. More... | |
treeBoundBox | subBbox (const label parentNodeI, const direction octant) const |
Return bbox of octant. More... | |
bool | walkToParent (const label nodeI, const direction octant, label &parentNodeI, label &parentOctant) const |
Walk to parent of node+octant. More... | |
bool | walkToNeighbour (const point &facePoint, const direction faceID, label &nodeI, direction &octant) const |
Walk tree to neighbouring node. Return false if edge of tree. More... | |
void | traverseNode (const bool findAny, const point &treeStart, const vector &treeVec, const point &start, const point &end, const label nodeI, const direction octantI, pointIndexHit &hitInfo, direction &faceID) const |
Traverse a node. If intersects a triangle return first. More... | |
pointIndexHit | findLine (const bool findAny, const point &treeStart, const point &treeEnd, const label startNodeI, const direction startOctantI, const bool verbose=false) const |
Find any or nearest intersection. More... | |
pointIndexHit | findLine (const bool findAny, const point &start, const point &end) const |
Find any or nearest intersection of line between start and end. More... | |
void | findBox (const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const |
Find all elements intersecting box. More... | |
void | findSphere (const label nodeI, const point ¢re, const scalar radiusSqr, labelHashSet &elements) const |
Find all elements intersecting sphere. More... | |
label | countElements (const labelBits index) const |
Count number of elements on this and sublevels. More... | |
void | writeOBJ (const label nodeI, const direction octant) const |
Dump node+octant to an obj file. More... | |
Static Private Member Functions | |
static bool | overlaps (const treeBoundBox &parentBb, const direction octant, const scalar nearestDistSqr, const point &sample) |
Helper: does bb intersect a sphere around sample? Or is any. More... | |
static point | pushPoint (const treeBoundBox &, const point &, const bool pushInside) |
Helper: take a point on/close to face of bb and push it. More... | |
static point | pushPoint (const treeBoundBox &, const direction, const point &, const bool pushInside) |
Helper: take a point on face of bb and push it. More... | |
static point | pushPointIntoFace (const treeBoundBox &bb, const vector &dir, const point &pt) |
Helper: take point on face(s) of bb and push it away from. More... | |
static word | faceString (const direction faceID) |
Debug: return verbose the bounding box faces. More... | |
template<class CompareOp > | |
static void | findNear (const scalar nearDist, const bool okOrder, const dynamicIndexedOctree< Type > &tree1, const labelBits index1, const treeBoundBox &bb1, const dynamicIndexedOctree< Type > &tree2, const labelBits index2, const treeBoundBox &bb2, CompareOp &cop) |
static labelBits | contentPlusOctant (const label i, const direction octant) |
From index into contents_ to subNodes_ entry. More... | |
static labelBits | nodePlusOctant (const label i, const direction octant) |
From index into nodes_ to subNodes_ entry. More... | |
static labelBits | emptyPlusOctant (const direction octant) |
From empty to subNodes_ entry. More... | |
Private Attributes | |
const Type | shapes_ |
Underlying shapes for geometric queries. More... | |
const treeBoundBox | bb_ |
const label | maxLevels_ |
label | nLevelsMax_ |
Current number of levels in the tree. More... | |
const scalar | maxLeafRatio_ |
const label | minSize_ |
const scalar | maxDuplicity_ |
DynamicList< node > | nodes_ |
List of all nodes. More... | |
contentListList | contents_ |
List of all contents (referenced by those nodes that are contents) More... | |
PackedList< 2 > | nodeTypes_ |
Per node per octant whether is fully inside/outside/mixed. More... | |
Static Private Attributes | |
static scalar | perturbTol_ = 10*SMALL |
Relative peturbation tolerance. Determines when point is. More... | |
Friends | |
Ostream & | operator (Ostream &, const dynamicIndexedOctree< Type > &) |
Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted.
Definition at line 55 of file dynamicIndexedOctree.H.
dynamicIndexedOctree | ( | const Type & | shapes, |
const treeBoundBox & | bb, | ||
const label | maxLevels, | ||
const scalar | maxLeafRatio, | ||
const scalar | maxDuplicity | ||
) |
Construct from shapes.
Definition at line 2309 of file dynamicIndexedOctree.C.
References insert().
|
staticprivate |
Helper: does bb intersect a sphere around sample? Or is any.
corner point of bb closer than nearestDistSqr to sample. (bb is implicitly provided as parent bb + octant)
Accelerated version of
treeBoundBox subBb(parentBb.subBbox(mid, octant)) overlaps ( subBb.min(), subBb.max(), nearestDistSqr, sample )
Definition at line 87 of file dynamicIndexedOctree.C.
References boundBox::max(), Foam::max(), boundBox::min(), Foam::min(), Vector< Cmpt >::x(), Vector< Cmpt >::y(), and Vector< Cmpt >::z().
|
private |
Split list of indices into 8 bins.
according to where they are in relation to mid.
Definition at line 150 of file dynamicIndexedOctree.C.
References DynamicList::append(), forAll, and treeBoundBox::subBbox().
|
private |
Subdivide the contents node at position contentI.
Appends to contents.
Definition at line 193 of file dynamicIndexedOctree.C.
References Foam::abort(), dynamicIndexedOctree::node::bb_, Foam::diag(), Foam::divide(), Foam::FatalError, FatalErrorInFunction, Foam::mag(), boundBox::max(), Foam::max(), boundBox::min(), dynamicIndexedOctree::node::parent_, and dynamicIndexedOctree::node::subNodes_.
|
private |
Definition at line 288 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, Foam::divide(), treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
|
private |
Determine inside/outside per node (mixed if cannot be.
determined). Only valid for closed shapes.
Definition at line 341 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, boundBox::midpoint(), treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
|
private |
Search cached volume type.
|
private |
Find nearest point to line.
Definition at line 563 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, Foam::ln(), treeBoundBox::overlaps(), treeBoundBox::searchOrder(), treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
Referenced by main().
|
private |
Return bbox of octant.
Definition at line 629 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
|
staticprivate |
Helper: take a point on/close to face of bb and push it.
inside or outside of bb.
|
staticprivate |
Helper: take a point on face of bb and push it.
inside or outside of bb.
|
staticprivate |
Helper: take point on face(s) of bb and push it away from.
edges of face.
Definition at line 839 of file dynamicIndexedOctree.C.
References Foam::abort(), Foam::endl(), treeBoundBox::faceBits(), Foam::facePoint(), Foam::FatalError, FatalErrorInFunction, Foam::mag(), boundBox::max(), boundBox::min(), treeBoundBox::posBits(), s(), Vector< Cmpt >::x(), Vector< Cmpt >::y(), and Vector< Cmpt >::z().
|
private |
Walk to parent of node+octant.
Definition at line 1195 of file dynamicIndexedOctree.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and dynamicIndexedOctree::node::subNodes_.
|
private |
Walk tree to neighbouring node. Return false if edge of tree.
hit.
Definition at line 1245 of file dynamicIndexedOctree.C.
References Foam::abort(), treeBoundBox::contains(), Foam::endl(), Foam::facePoint(), Foam::FatalError, FatalErrorInFunction, and Y.
|
staticprivate |
Debug: return verbose the bounding box faces.
Definition at line 1483 of file dynamicIndexedOctree.C.
|
private |
Traverse a node. If intersects a triangle return first.
intersection point. findAny=true : return any intersection findAny=false: return nearest (to start) intersection
Definition at line 1535 of file dynamicIndexedOctree.C.
References Foam::abort(), treeBoundBox::contains(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, PointIndexHit< Point >::hit(), treeBoundBox::intersects(), treeBoundBox::posBits(), PointIndexHit< Point >::setHit(), PointIndexHit< Point >::setIndex(), PointIndexHit< Point >::setPoint(), List::size(), and dynamicIndexedOctree::node::subNodes_.
|
private |
Find any or nearest intersection.
|
private |
Find any or nearest intersection of line between start and end.
Definition at line 1886 of file dynamicIndexedOctree.C.
References treeBoundBox::intersects(), and treeBoundBox::posBits().
|
private |
Find all elements intersecting box.
Definition at line 1957 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, forAll, HashSet< Key, Hash >::insert(), treeBoundBox::overlaps(), treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
|
private |
Find all elements intersecting sphere.
Definition at line 2004 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, forAll, HashSet< Key, Hash >::insert(), treeBoundBox::overlaps(), treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
|
staticprivate |
Definition at line 2053 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::contents(), forAll, dynamicIndexedOctree::getContent(), dynamicIndexedOctree::getNode(), dynamicIndexedOctree::isContent(), dynamicIndexedOctree::isNode(), boundBox::max(), boundBox::min(), dynamicIndexedOctree::nodes(), treeBoundBox::overlaps(), dynamicIndexedOctree::shapes(), treeBoundBox::subBbox(), and dynamicIndexedOctree::node::subNodes_.
|
private |
Count number of elements on this and sublevels.
Definition at line 2227 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::subNodes_.
Dump node+octant to an obj file.
Definition at line 2260 of file dynamicIndexedOctree.C.
References Foam::constant::electromagnetic::e, Foam::endl(), forAll, OFstream::name(), Foam::name(), Foam::nl, treeBoundBox::points(), Foam::Pout, treeBoundBox::subBbox(), Vector< Cmpt >::x(), Vector< Cmpt >::y(), and Vector< Cmpt >::z().
From index into contents_ to subNodes_ entry.
Definition at line 390 of file dynamicIndexedOctree.H.
From index into nodes_ to subNodes_ entry.
Definition at line 400 of file dynamicIndexedOctree.H.
From empty to subNodes_ entry.
Definition at line 410 of file dynamicIndexedOctree.H.
|
static |
Get the perturbation tolerance.
Definition at line 2345 of file dynamicIndexedOctree.C.
|
inline |
Clone.
Definition at line 437 of file dynamicIndexedOctree.H.
|
inline |
Reference to shape.
Definition at line 451 of file dynamicIndexedOctree.H.
References dynamicIndexedOctree::shapes_.
Referenced by dynamicIndexedOctree::findNear().
List of all nodes.
Definition at line 457 of file dynamicIndexedOctree.H.
References dynamicIndexedOctree::nodes_.
Referenced by dynamicIndexedOctree::findNear().
|
inline |
List of all contents (referenced by those nodes that are.
contents)
Definition at line 464 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree::findNear().
|
inline |
Top bounding box.
Definition at line 470 of file dynamicIndexedOctree.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and dynamicIndexedOctree::nodes_.
Referenced by dynamicIndexedOctree::findNear().
|
inlinestatic |
Definition at line 483 of file dynamicIndexedOctree.H.
References labelBits::val().
Referenced by dynamicIndexedOctree::findNear(), and dynamicIndexedOctree::getContent().
|
inlinestatic |
Definition at line 488 of file dynamicIndexedOctree.H.
References labelBits::val().
|
inlinestatic |
Definition at line 493 of file dynamicIndexedOctree.H.
References labelBits::val().
Referenced by dynamicIndexedOctree::findNear(), and dynamicIndexedOctree::getNode().
Definition at line 498 of file dynamicIndexedOctree.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree::isContent(), and labelBits::val().
Referenced by dynamicIndexedOctree::findNear().
Definition at line 508 of file dynamicIndexedOctree.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree::isNode(), and labelBits::val().
Referenced by dynamicIndexedOctree::findNear().
Definition at line 518 of file dynamicIndexedOctree.H.
References labelBits::bits().
pointIndexHit findNearest | ( | const point & | sample, |
const scalar | nearestDistSqr | ||
) | const |
Calculate nearest point on nearest shape.
Returns
void findNearest | ( | const label | nodeI, |
const point & | , | ||
scalar & | nearestDistSqr, | ||
label & | nearestShapeI, | ||
point & | nearestPoint | ||
) | const |
Low level: calculate nearest starting from subnode.
Foam::pointIndexHit findNearest | ( | const linePointRef & | ln, |
treeBoundBox & | tightest, | ||
point & | linePoint | ||
) | const |
Find nearest to line.
Returns
Definition at line 2381 of file dynamicIndexedOctree.C.
References Foam::ln().
Foam::pointIndexHit findLine | ( | const point & | start, |
const point & | end | ||
) | const |
Find nearest intersection of line between start and end.
Definition at line 2415 of file dynamicIndexedOctree.C.
Foam::pointIndexHit findLineAny | ( | const point & | start, |
const point & | end | ||
) | const |
Find any intersection of line between start and end.
Definition at line 2427 of file dynamicIndexedOctree.C.
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)
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 2456 of file dynamicIndexedOctree.C.
References HashTable::toc().
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 2476 of file dynamicIndexedOctree.C.
References Foam::abort(), dynamicIndexedOctree::node::bb_, treeBoundBox::contains(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree::node::subNodes_, and treeBoundBox::subOctant().
Foam::label findInside | ( | const point & | sample | ) | const |
Find shape containing point. Only implemented for certain.
shapes.
Definition at line 2523 of file dynamicIndexedOctree.C.
References forAll, and dynamicIndexedOctree::node::subNodes_.
const Foam::labelList & findIndices | ( | const point & | sample | ) | const |
Find the shape indices that occupy the result of findNode.
Definition at line 2555 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::subNodes_.
volumeType getVolumeType | ( | const point & | ) | const |
Determine type (inside/outside/mixed) for point. unknown if.
cannot be determined (e.g. non-manifold surface)
|
static |
Helper function to return the side. Returns outside if.
outsideNormal&vec >= 0, inside otherwise
Definition at line 467 of file dynamicIndexedOctree.C.
|
static |
Helper: does bb intersect a sphere around sample? Or is any.
corner point of bb closer than nearestDistSqr to sample.
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 2650 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::bb().
Insert a new object into the tree.
Definition at line 2672 of file dynamicIndexedOctree.C.
References Foam::divide(), Foam::max(), and success.
Referenced by main().
Definition at line 2719 of file dynamicIndexedOctree.C.
References treeBoundBox::subBbox().
bool remove | ( | const label | index | ) |
Remove an object from the tree.
Definition at line 2795 of file dynamicIndexedOctree.C.
Referenced by main().
Foam::label removeIndex | ( | const label | nodIndex, |
const label | index | ||
) |
Definition at line 2810 of file dynamicIndexedOctree.C.
References DynamicList::append(), forAll, treeBoundBox::subBbox(), and DynamicList::transfer().
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 2894 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree::node::bb_, Foam::endl(), forAll, Foam::nl, dynamicIndexedOctree::node::parent_, prefixOSstream::prefix(), print(), List::size(), treeBoundBox::subBbox(), dynamicIndexedOctree::node::subNodes_, and writeOBJ().
bool write | ( | Ostream & | os | ) | const |
Definition at line 2993 of file dynamicIndexedOctree.C.
References IOstream::good().
void writeTreeInfo | ( | ) | const |
Definition at line 2966 of file dynamicIndexedOctree.C.
References Foam::endl(), forAll, Foam::nl, and Foam::Pout.
Referenced by main().
|
friend |
|
staticprivate |
Relative peturbation tolerance. Determines when point is.
considered to be close to face/edge of bb of node. The tolerance is relative to the bounding box of the smallest node.
Definition at line 134 of file dynamicIndexedOctree.H.
|
private |
Underlying shapes for geometric queries.
Definition at line 140 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree::shapes().
|
private |
Definition at line 142 of file dynamicIndexedOctree.H.
|
private |
Definition at line 144 of file dynamicIndexedOctree.H.
|
private |
Current number of levels in the tree.
Definition at line 147 of file dynamicIndexedOctree.H.
|
private |
Definition at line 149 of file dynamicIndexedOctree.H.
|
private |
Definition at line 151 of file dynamicIndexedOctree.H.
|
private |
Definition at line 153 of file dynamicIndexedOctree.H.
|
private |
List of all nodes.
Definition at line 156 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree::bb(), and dynamicIndexedOctree::nodes().
|
private |
List of all contents (referenced by those nodes that are contents)
Definition at line 159 of file dynamicIndexedOctree.H.
|
mutableprivate |
Per node per octant whether is fully inside/outside/mixed.
Definition at line 162 of file dynamicIndexedOctree.H.
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.