Go to the documentation of this file.
35 #ifndef indexedOctree_H
36 #define indexedOctree_H
53 template<
class Type>
class indexedOctree;
54 template<
class Type> Ostream&
operator<<(Ostream&,
const indexedOctree<Type>&);
72 public indexedOctreeName
100 return is >>
n.bb_ >>
n.parent_ >>
n.subNodes_;
152 const scalar nearestDistSqr,
188 const label compactLevel,
206 template<
class FindNearestOp>
213 label& nearestShapeI,
217 const FindNearestOp& fnOp
223 const label parentNodeI,
233 const bool pushInside
243 const bool pushInside
291 template<
class FindIntersectOp>
295 const point& treeStart,
306 const FindIntersectOp& fiOp
310 template<
class FindIntersectOp>
314 const point& treeStart,
315 const point& treeEnd,
316 const label startNodeI,
318 const FindIntersectOp& fiOp,
319 const bool verbose =
false
323 template<
class FindIntersectOp>
329 const FindIntersectOp& fiOp
346 const scalar radiusSqr,
351 template<
class CompareOp>
354 const scalar nearDist,
427 const label maxLevels,
428 const scalar maxLeafRatio,
429 const scalar maxDuplicity
450 const Type&
shapes()
const
528 const scalar nearestDistSqr
536 template<
class FindNearestOp>
540 const scalar nearestDistSqr,
542 const FindNearestOp& fnOp
546 template<
class FindNearestOp>
552 scalar& nearestDistSqr,
553 label& nearestShapeI,
556 const FindNearestOp& fnOp
573 template<
class FindNearestOp>
580 const FindNearestOp& fnOp
598 template<
class FindIntersectOp>
603 const FindIntersectOp& fiOp
607 template<
class FindIntersectOp>
612 const FindIntersectOp& fiOp
625 const scalar radiusSqr
648 const vector& outsideNormal,
658 const scalar nearestDistSqr,
664 template<
class CompareOp>
667 const scalar nearDist,
680 const bool printContents,
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
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 FindIntersectOp &fiOp) const
Traverse a node. If intersects a triangle return first.
static void findNear(const scalar nearDist, const bool okOrder, const indexedOctree< Type > &tree1, const labelBits index1, const treeBoundBox &bb1, const indexedOctree< Type > &tree2, const labelBits index2, const treeBoundBox &bb2, CompareOp &cop)
label parent_
Parent node (index into nodes_ of tree)
A class for handling words, derived from string.
indexedOctree(const Type &shapes)
Construct null.
friend Istream & operator>>(Istream &is, node &n)
A 29bits label and 3bits direction packed into single label.
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 isContent(const labelBits i)
label countElements(const labelBits index) const
Count number of elements on this and sublevels.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Standard boundBox + extra functionality for use in octree.
static bool isNode(const labelBits i)
Tree node. Has up pointer and down pointers.
const List< node > & nodes() const
List of all nodes.
const Type & shapes() const
Reference to shape.
treeBoundBox bb_
Bounding box of this node.
static labelBits contentPlusOctant(const label i, const direction octant)
From index into contents_ to subNodes_ entry.
static word faceString(const direction faceID)
Debug: return verbose the bounding box faces.
static label getNode(const labelBits i)
bool walkToNeighbour(const point &facePoint, const direction faceID, label &nodeI, direction &octant) const
Walk tree to neighbouring node. Return false if edge of tree.
PackedList< 2 > nodeTypes_
Per node per octant whether is fully inside/outside/mixed.
autoPtr< indexedOctree< Type > > clone() const
Clone.
static scalar & perturbTol()
Get the perturbation tolerance.
const Type shapes_
Underlying shapes for geometric queries.
labelListList contents_
List of all contents (referenced by those nodes that are contents)
label facePoint(const int facei, const block &block, const label i, const label j)
void splitNodes(const label minSize, DynamicList< node > &nodes, DynamicList< labelList > &contents) const
Split any contents node with more than minSize elements.
Version of OSstream which prints a prefix on each line.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
void findBox(const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const
Find all elements intersecting box.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static scalar perturbTol_
Relative peturbation tolerance. Determines when point is.
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
pointIndexHit findLine(const bool findAny, const point &treeStart, const point &treeEnd, const label startNodeI, const direction startOctantI, const FindIntersectOp &fiOp, const bool verbose=false) const
Find any or nearest intersection.
friend bool operator!=(const node &a, const node &b)
static label compactContents(DynamicList< node > &nodes, DynamicList< labelList > &contents, const label compactLevel, const label nodeI, const label level, List< labelList > &compactedContents, label &compactI)
volumeType calcVolumeType(const label nodeI) const
Determine inside/outside per node (mixed if cannot be.
const labelListList & contents() const
List of all contents (referenced by those nodes that are.
Non-pointer based hierarchical recursive searching.
TemplateName(blendedSchemeBase)
List< node > nodes_
List of all nodes.
Ostream & operator<<(Ostream &, const edgeMesh &)
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.
void writeOBJ(const label nodeI, const direction octant) const
Dump node+octant to an obj file.
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.
errorManip< error > abort(error &err)
static direction getOctant(const labelBits i)
void divide(const labelList &indices, const treeBoundBox &bb, labelListList &result) const
Split list of indices into 8 bins.
static point pushPoint(const treeBoundBox &, const point &, const bool pushInside)
Helper: take a point on/close to face of bb and push it.
friend Ostream & operator<<(Ostream &os, const node &n)
const treeBoundBox & bb() const
Top bounding box.
static bool isEmpty(const labelBits i)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static label getContent(const labelBits i)
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A 1D vector of objects of type <T> with a fixed size <Size>.
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
void findNearest(const label nodeI, const linePointRef &ln, treeBoundBox &tightest, label &nearestShapeI, point &linePoint, point &nearestPoint, const FindNearestOp &fnOp) const
Find nearest point to line.
volumeType getVolumeType(const label nodeI, const point &) const
Search cached volume type.
static labelBits nodePlusOctant(const label i, const direction octant)
From index into nodes_ to subNodes_ entry.
bool walkToParent(const label nodeI, const direction octant, label &parentNodeI, label &parentOctant) const
Walk to parent of node+octant.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
treeBoundBox subBbox(const label parentNodeI, const direction octant) const
Return bbox of octant.
static labelBits emptyPlusOctant(const direction octant)
From empty to subNodes_ entry.
friend bool operator==(const node &a, const node &b)
void findSphere(const label nodeI, const point ¢re, const scalar radiusSqr, labelHashSet &elements) const
Find all elements intersecting sphere.
bool write(Ostream &os) const