Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted. More...
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 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... | |
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 2081 of file dynamicIndexedOctree.C.
References insert().
Referenced by dynamicIndexedOctree< Type >::findNearest().
|
static |
Get the perturbation tolerance.
Definition at line 2117 of file dynamicIndexedOctree.C.
|
inline |
Clone.
Definition at line 418 of file dynamicIndexedOctree.H.
|
inline |
Reference to shape.
Definition at line 432 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest().
List of all nodes.
Definition at line 438 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest().
|
inline |
List of all contents (referenced by those nodes that are.
contents)
Definition at line 445 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::nodes().
|
inline |
Top bounding box.
Definition at line 451 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNear().
|
inlinestatic |
Definition at line 464 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getContent().
|
inlinestatic |
Definition at line 469 of file dynamicIndexedOctree.H.
|
inlinestatic |
Definition at line 474 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getNode().
Definition at line 479 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest().
Definition at line 489 of file dynamicIndexedOctree.H.
Referenced by dynamicIndexedOctree< Type >::findNearest().
Definition at line 499 of file dynamicIndexedOctree.H.
Foam::pointIndexHit findNearest | ( | const point & | sample, |
const scalar | nearestDistSqr | ||
) | const |
Calculate nearest point on nearest shape.
Returns
Definition at line 2125 of file dynamicIndexedOctree.C.
References Foam::Zero.
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 471 of file dynamicIndexedOctree.C.
References Foam::abort(), dynamicIndexedOctree< Type >::node::bb_, line< Point, PointRef >::centre(), treeBoundBox::contains(), dynamicIndexedOctree< Type >::contents(), dynamicIndexedOctree< Type >::dynamicIndexedOctree(), Foam::constant::electromagnetic::e, Foam::endl(), treeBoundBox::faceBits(), Foam::facePoint(), Foam::FatalError, FatalErrorInFunction, forAll, dynamicIndexedOctree< Type >::getContent(), dynamicIndexedOctree< Type >::getNode(), PointIndexHit< Point >::hit(), HashSet< Key, Hash >::insert(), treeBoundBox::intersects(), dynamicIndexedOctree< Type >::isContent(), dynamicIndexedOctree< Type >::isNode(), Foam::ln(), Foam::mag(), boundBox::max(), boundBox::min(), OFstream::name(), Foam::name(), Foam::nl, dynamicIndexedOctree< Type >::nodes(), boundBox::overlaps(), treeBoundBox::points(), treeBoundBox::posBits(), Foam::Pout, PointIndexHit< Point >::rawPoint(), s(), treeBoundBox::searchOrder(), PointIndexHit< Point >::setHit(), PointIndexHit< Point >::setIndex(), PointIndexHit< Point >::setPoint(), dynamicIndexedOctree< Type >::shapes(), List< T >::size(), boundBox::span(), treeBoundBox::subBbox(), dynamicIndexedOctree< Type >::node::subNodes_, WarningInFunction, Vector< Cmpt >::x(), Y, Vector< Cmpt >::y(), Vector< Cmpt >::z(), and Foam::Zero.
Foam::pointIndexHit findNearest | ( | const linePointRef & | ln, |
treeBoundBox & | tightest, | ||
point & | linePoint | ||
) | const |
Find nearest to line.
Returns
Definition at line 2153 of file dynamicIndexedOctree.C.
References Foam::Zero.
Foam::pointIndexHit findLine | ( | const point & | start, |
const point & | end | ||
) | const |
Find nearest intersection of line between start and end.
Definition at line 2186 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::findLineAny().
Foam::pointIndexHit findLineAny | ( | const point & | start, |
const point & | end | ||
) | const |
Find any intersection of line between start and end.
Definition at line 2197 of file dynamicIndexedOctree.C.
Referenced by dynamicIndexedOctree< Type >::findLine(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
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 2208 of file dynamicIndexedOctree.C.
References HashTable< T, Key, Hash >::toc().
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 2226 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::findNode(), and HashTable< T, Key, Hash >::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 2245 of file dynamicIndexedOctree.C.
References Foam::abort(), dynamicIndexedOctree< Type >::node::bb_, treeBoundBox::contains(), Foam::FatalError, FatalErrorInFunction, dynamicIndexedOctree< Type >::findInside(), dynamicIndexedOctree< Type >::node::subNodes_, and treeBoundBox::subOctant().
Referenced by dynamicIndexedOctree< Type >::findSphere(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
Foam::label findInside | ( | const point & | sample | ) | const |
Find shape containing point. Only implemented for certain.
shapes.
Definition at line 2292 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::findIndices(), forAll, and dynamicIndexedOctree< Type >::node::subNodes_.
Referenced by dynamicIndexedOctree< Type >::findNode(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
const Foam::labelList & findIndices | ( | const point & | sample | ) | const |
Find the shape indices that occupy the result of findNode.
Definition at line 2324 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::node::subNodes_.
Referenced by dynamicIndexedOctree< Type >::findInside(), and dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
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 2348 of file dynamicIndexedOctree.C.
References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::Pout, and Foam::type().
|
static |
Helper function to return the side. Returns outside if.
outsideNormal&vec >= 0, inside otherwise
Definition at line 453 of file dynamicIndexedOctree.C.
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant(), and dynamicIndexedOctree< Type >::overlaps().
|
static |
Helper: does bb intersect a sphere around sample? Or is any.
corner point of bb closer than nearestDistSqr to sample.
Definition at line 40 of file dynamicIndexedOctree.C.
References Foam::abort(), DynamicList< T, SizeInc, SizeMult, SizeDiv >::append(), dynamicIndexedOctree< Type >::node::bb_, Foam::divide(), Foam::FatalError, FatalErrorInFunction, forAll, dynamicIndexedOctree< Type >::getSide(), Foam::mag(), boundBox::max(), Foam::max(), boundBox::midpoint(), boundBox::min(), Foam::min(), Foam::nl, dynamicIndexedOctree< Type >::node::parent_, List< T >::size(), treeBoundBox::subBbox(), dynamicIndexedOctree< Type >::node::subNodes_, treeBoundBox::subOctant(), Foam::type(), Vector< Cmpt >::x(), Vector< Cmpt >::y(), and Vector< Cmpt >::z().
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 2418 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::bb().
Insert a new object into the tree.
Definition at line 2440 of file dynamicIndexedOctree.C.
References Foam::divide(), dynamicIndexedOctree< Type >::insertIndex(), Foam::max(), and success.
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
Definition at line 2487 of file dynamicIndexedOctree.C.
References treeBoundBox::subBbox().
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant(), and dynamicIndexedOctree< Type >::insert().
bool remove | ( | const label | index | ) |
Remove an object from the tree.
Definition at line 2563 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::removeIndex().
Foam::label removeIndex | ( | const label | nodIndex, |
const label | index | ||
) |
Definition at line 2578 of file dynamicIndexedOctree.C.
References DynamicList< T, SizeInc, SizeMult, SizeDiv >::append(), forAll, dynamicIndexedOctree< Type >::print(), List< T >::size(), treeBoundBox::subBbox(), and DynamicList< T, SizeInc, SizeMult, SizeDiv >::transfer().
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant(), and dynamicIndexedOctree< Type >::remove().
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 2661 of file dynamicIndexedOctree.C.
References dynamicIndexedOctree< Type >::node::bb_, Foam::endl(), forAll, Foam::nl, dynamicIndexedOctree< Type >::node::parent_, prefixOSstream::prefix(), List< T >::size(), treeBoundBox::subBbox(), dynamicIndexedOctree< Type >::node::subNodes_, and Foam::meshTools::writeOBJ().
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant(), and dynamicIndexedOctree< Type >::removeIndex().
bool write | ( | Ostream & | os | ) | const |
Definition at line 2759 of file dynamicIndexedOctree.C.
References Foam::endl(), forAll, and IOstream::good().
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
void writeTreeInfo | ( | ) | const |
Definition at line 2733 of file dynamicIndexedOctree.C.
References Foam::endl(), forAll, Foam::nl, and Foam::Pout.
Referenced by dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::getOctant().
|
friend |