38#ifndef Foam_indexedOctree_H
39#define Foam_indexedOctree_H
118 return is >>
n.bb_ >>
n.parent_ >>
n.subNodes_;
131 return (i.val() == 0);
137 return (i.val() < 0);
143 return (i.val() > 0);
161 static label
getNode(
const labelBits i)
246 const bool writeLinesOnly =
false
307 static label compactContents
311 const label compactLevel,
320 volumeType calcVolumeType(
const label nodeI)
const;
329 template<
class FindNearestOp>
336 label& nearestShapeI,
340 const FindNearestOp& fnOp
346 const label parentNodeI,
352 static point pushPoint
356 const bool pushInside
361 static point pushPoint
366 const bool pushInside
374 static point pushPointIntoFace
408 template<
class FindIntersectOp>
412 const point& treeStart,
423 const FindIntersectOp& fiOp
427 template<
class FindIntersectOp>
431 const point& treeStart,
432 const point& treeEnd,
433 const label startNodeI,
435 const FindIntersectOp& fiOp,
436 const bool verbose =
false
440 template<
class FindIntersectOp>
446 const FindIntersectOp& fiOp
464 const scalar radiusSqr,
469 template<
class CompareOp>
472 const scalar nearDist,
487 label countElements(
const labelBits index)
const;
490 label countLeafs(
const label nodeI)
const;
498 const bool leavesOnly,
499 const bool writeLinesOnly =
false
503 void writeOBJ(
const label nodeI,
const direction octant)
const;
526 const label maxLevels,
527 const scalar maxLeafRatio,
528 const scalar maxDuplicity
566 const treeBoundBox&
bb()
const
572 return nodes_[0].bb_;
584 const scalar nearestDistSqr
592 template<
class FindNearestOp>
596 const scalar nearestDistSqr,
598 const FindNearestOp& fnOp
602 template<
class FindNearestOp>
608 scalar& nearestDistSqr,
609 label& nearestShapeI,
612 const FindNearestOp& fnOp
629 template<
class FindNearestOp>
636 const FindNearestOp& fnOp
654 template<
class FindIntersectOp>
659 const FindIntersectOp& fiOp
663 template<
class FindIntersectOp>
668 const FindIntersectOp& fiOp
695 const scalar radiusSqr
704 const scalar radiusSqr
713 const scalar radiusSqr,
738 const vector& outsideNormal,
744 template<
class CompareOp>
747 const scalar nearDist,
763 const bool printContents,
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A 1D vector of objects of type <T> with a fixed length <N>.
Minimal example by using system/controlDict.functions:
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Tree node. Has up pointer and down pointers.
static constexpr direction nChildren
Has exactly 8 sub-nodes (octants).
friend Ostream & operator<<(Ostream &os, const node &n)
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
label parent_
Parent node (index into flat list addressing for tree).
friend bool operator!=(const node &a, const node &b)
friend Istream & operator>>(Istream &is, node &n)
treeBoundBox bb_
Bounding box of this node.
friend bool operator==(const node &a, const node &b)
static labelBits contentPlusOctant(label i, direction octant)
From index into contents_ to subNodes_ entry.
static label getNode(const labelBits i)
Return real (dereferenced) index for a parent node.
static bool isNode(labelBits i) noexcept
A parent node.
static scalar perturbTol(scalar tol) noexcept
Set the perturbation tolerance, return the old value.
indexedOctreeBase()=default
Default construct.
ClassName("indexedOctree")
Runtime type information.
static labelBits nodePlusOctant(label i, direction octant)
From index into nodes_ to subNodes_ entry.
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
static direction getOctant(labelBits i) noexcept
Return sub-node direction/octant.
static labelBits emptyPlusOctant(direction octant)
From empty to subNodes_ entry.
static void writeOBJ(Ostream &os, const treeBoundBox &bb, label &vertIndex, const bool writeLinesOnly=false)
Write treeBoundBox in OBJ format.
static bool isContent(labelBits i) noexcept
Node with content (leaf).
static scalar perturbTol_
Relative perturbation tolerance.
static bool isEmpty(labelBits i) noexcept
An empty node - no content.
static label getContent(labelBits i)
Return real (dereferenced) index for a content node.
Non-pointer based hierarchical recursive searching.
labelList findSphere(const point ¢re, const scalar radiusSqr) const
Find indices of all shapes inside or overlapping a bounding sphere (i.e. all shapes not outside a sph...
pointIndexHit findLine(const point &start, const point &end, const FindIntersectOp &fiOp) const
Find nearest intersection of line between start and end.
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
void writeOBJ(Ostream &os) const
Write (non-empty) tree boxes in OBJ format.
const List< node > & nodes() const noexcept
List of all nodes.
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
pointIndexHit findNearest(const point &sample, const scalar nearestDistSqr, const FindNearestOp &fnOp) const
Calculate nearest point on nearest shape.
const treeDataIndirectTriSurface & shapes() const noexcept
pointIndexHit findNearest(const point &sample, const scalar nearestDistSqr) const
volumeType getVolumeType(const point &) const
Determine type (inside/outside/mixed) for point. unknown if.
labelList findBox(const treeBoundBox &bb) const
Find indices of all shapes inside or overlapping a bounding box (i.e. all shapes not outside box).
void findNear(const scalar nearDist, const indexedOctree< Type > &tree2, CompareOp &cop) const
Find near pairs and apply CompareOp to them.
const treeBoundBox & bb() const
Top bounding box.
bool overlaps(const treeBoundBox &bb) const
True if any shapes overlap the bounding box.
indexedOctree(const Type &shapes, const List< node > &nodes, const List< labelList > &contents)
Construct from components.
pointIndexHit findNearest(const linePointRef &ln, treeBoundBox &tightest, point &linePoint, const FindNearestOp &fnOp) const
indexedOctree(const Type &shapes, const treeBoundBox &bb, const label maxLevels, const scalar maxLeafRatio, const scalar maxDuplicity)
Construct from shapes.
indexedOctree(const Type &shapes)
Construct null.
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
bool write(Ostream &os) const
label findSphere(const point ¢re, const scalar radiusSqr, labelHashSet &elements) const
Find indices of all shapes inside or overlapping a bounding sphere (i.e. all shapes not outside spher...
const List< labelList > & contents() const noexcept
List of all contents (referenced by those nodes that are contents).
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
autoPtr< indexedOctree< Type > > clone() const
Clone.
bool overlaps(const point ¢re, const scalar radiusSqr) const
True if any shapes overlap the bounding sphere.
void findNearest(const label nodeI, const point &, scalar &nearestDistSqr, label &nearestShapeI, point &nearestPoint, const FindNearestOp &fnOp) const
Low level: calculate nearest starting from subnode.
indexedOctree(const Type &shapes, Istream &is)
Construct from Istream.
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
pointIndexHit findLineAny(const point &start, const point &end, const FindIntersectOp &fiOp) const
Find any intersection of line between start and end.
PackedList< 2 > & nodeTypes() const noexcept
Per node, per octant whether is fully inside/outside/mixed.
label findBox(const treeBoundBox &bb, labelHashSet &elements) const
Find indices of all shapes inside or overlapping a bounding box (i.e. all shapes not outside box).
pointIndexHit findNearest(const linePointRef &ln, treeBoundBox &tightest, point &linePoint) const
Find nearest to line.
label nLeafs() const
Return the number of leaf nodes.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
A 29bits (or 61bits) integer label with 3bits direction (eg, octant) packed into single label.
label val() const noexcept
Return the integer value.
Version of OSstream that prints a prefix on each line.
Standard boundBox with extra functionality for use in octree.
static const treeBoundBox & null() noexcept
The null treeBoundBox is the same as an inverted box.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
A class for handling words, derived from Foam::string.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
label facePoint(const int facei, const block &block, const label i, const label j)
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
line< point, const point & > linePointRef
A line using referred points.
errorManip< error > abort(error &err)
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
UList< label > labelUList
A UList of labels.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.