Go to the documentation of this file.
36 #ifndef dynamicIndexedOctree_H
37 #define dynamicIndexedOctree_H
58 template<
class Type>
Ostream&
operator<<
81 public dynamicIndexedOctreeName
109 return is >>
n.bb_ >>
n.parent_ >>
n.subNodes_;
174 const scalar nearestDistSqr,
194 const label contentI,
195 const label parentNodeIndex,
196 const label octantToBeDivided
203 const label contentI,
204 const label parentIndex,
237 label& nearestShapeI,
245 const label parentNodeI,
255 const bool pushInside
265 const bool pushInside
316 const point& treeStart,
332 const point& treeStart,
333 const point& treeEnd,
334 const label startNodeI,
336 const bool verbose =
false
361 const scalar radiusSqr,
366 template<
class CompareOp>
369 const scalar nearDist,
431 const label maxLevels,
432 const scalar maxLeafRatio,
433 const scalar maxDuplicity
452 const Type&
shapes()
const
535 const scalar nearestDistSqr
544 scalar& nearestDistSqr,
545 label& nearestShapeI,
587 const scalar radiusSqr
610 const vector& outsideNormal,
620 const scalar nearestDistSqr,
626 template<
class CompareOp>
629 const scalar nearDist,
642 const label nodIndex,
660 const bool printContents,
671 friend Ostream& operator<< <Type>
void findSphere(const label nodeI, const point ¢re, const scalar radiusSqr, labelHashSet &elements) const
Find all elements intersecting sphere.
DynamicList< node > nodes_
List of all nodes.
bool insert(label startIndex, label endIndex)
Insert a new object into the tree.
static labelBits nodePlusOctant(const label i, const direction octant)
From index into nodes_ to subNodes_ entry.
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
A class for handling words, derived from string.
friend bool operator!=(const node &a, const node &b)
A 29bits label and 3bits direction packed into single label.
const scalar maxDuplicity_
static bool isContent(const labelBits i)
static direction getOctant(const labelBits i)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void writeOBJ(const label nodeI, const direction octant) const
Dump node+octant to an obj file.
static label getContent(const labelBits i)
static point pushPoint(const treeBoundBox &, const point &, const bool pushInside)
Helper: take a point on/close to face of bb and push it.
Standard boundBox + extra functionality for use in octree.
treeBoundBox subBbox(const label parentNodeI, const direction octant) const
Return bbox of octant.
bool walkToNeighbour(const point &facePoint, const direction faceID, label &nodeI, direction &octant) const
Walk tree to neighbouring node. Return false if edge of tree.
static word faceString(const direction faceID)
Debug: return verbose the bounding box faces.
void divide(const autoPtr< DynamicList< label > > &indices, const treeBoundBox &bb, contentListList &result) const
Split list of indices into 8 bins.
contentListList contents_
List of all contents (referenced by those nodes that are contents)
friend Ostream & operator<<(Ostream &os, const node &n)
label countElements(const labelBits index) const
Count number of elements on this and sublevels.
Non-pointer based hierarchical recursive searching. Storage is dynamic, so elements can be deleted.
label facePoint(const int facei, const block &block, const label i, const label j)
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)
Version of OSstream which prints a prefix on each line.
static scalar perturbTol_
Relative peturbation tolerance. Determines when point is.
bool remove(const label index)
Remove an object from the tree.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
label removeIndex(const label nodIndex, const label index)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
void findBox(const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const
Find all elements intersecting box.
friend Istream & operator>>(Istream &is, node &n)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
volumeType getVolumeType(const label nodeI, const point &) const
Search cached volume type.
DynamicList< autoPtr< DynamicList< label > > > contentListList
TemplateName(blendedSchemeBase)
const Type & shapes() const
Reference to shape.
static scalar & perturbTol()
Get the perturbation tolerance.
static labelBits emptyPlusOctant(const direction octant)
From empty to subNodes_ entry.
dynamicIndexedOctree(const Type &shapes, const treeBoundBox &bb, const label maxLevels, const scalar maxLeafRatio, const scalar maxDuplicity)
Construct from shapes.
volumeType calcVolumeType(const label nodeI) const
Determine inside/outside per node (mixed if cannot be.
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.
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.
static bool isEmpty(const labelBits i)
const List< node > & nodes() const
List of all nodes.
errorManip< error > abort(error &err)
const Type shapes_
Underlying shapes for geometric queries.
autoPtr< dynamicIndexedOctree< Type > > clone() const
Clone.
void recursiveSubDivision(const treeBoundBox &subBb, const label contentI, const label parentIndex, const label octant, label &nLevels)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
PackedList< 2 > nodeTypes_
Per node per octant whether is fully inside/outside/mixed.
friend bool operator==(const node &a, const node &b)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void writeTreeInfo() const
treeBoundBox bb_
Bounding box of this node.
Tree node. Has up pointer and down pointers.
bool insertIndex(const label nodIndex, const label index, label &nLevels)
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label parent_
Parent node (index into nodes_ of tree)
A 1D vector of objects of type <T> with a fixed size <Size>.
const scalar maxLeafRatio_
static labelBits contentPlusOctant(const label i, const direction octant)
From index into contents_ to subNodes_ entry.
label nLevelsMax_
Current number of levels in the tree.
const treeBoundBox & bb() const
Top bounding box.
bool walkToParent(const label nodeI, const direction octant, label &parentNodeI, label &parentOctant) const
Walk to parent of node+octant.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
bool write(Ostream &os) const
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void findNearest(const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint) const
Find nearest point to line.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
static label getNode(const labelBits i)
static bool isNode(const labelBits i)
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.
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.
const contentListList & contents() const
List of all contents (referenced by those nodes that are.
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.