38 #ifndef Foam_indexedOctree_H 39 #define Foam_indexedOctree_H 57 template<
class Type>
class indexedOctree;
58 template<
class Type> Ostream& operator<<(Ostream&, const indexedOctree<Type>&);
119 return is >>
n.bb_ >>
n.parent_ >>
n.subNodes_;
132 return (i.val() == 0);
138 return (i.val() < 0);
144 return (i.val() > 0);
162 static label
getNode(
const labelBits i)
247 const bool writeLinesOnly =
false 308 static label compactContents
312 const label compactLevel,
321 volumeType calcVolumeType(
const label nodeI)
const;
330 template<
class FindNearestOp>
337 label& nearestShapeI,
341 const FindNearestOp& fnOp
347 const label parentNodeI,
353 static point pushPoint
357 const bool pushInside
362 static point pushPoint
367 const bool pushInside
375 static point pushPointIntoFace
409 template<
class FindIntersectOp>
413 const point& treeStart,
424 const FindIntersectOp& fiOp
428 template<
class FindIntersectOp>
432 const point& treeStart,
433 const point& treeEnd,
434 const label startNodeI,
436 const FindIntersectOp& fiOp,
437 const bool verbose =
false 441 template<
class FindIntersectOp>
447 const FindIntersectOp& fiOp
465 const scalar radiusSqr,
470 template<
class CompareOp>
473 const scalar nearDist,
488 label countElements(
const labelBits index)
const;
491 label countLeafs(
const label nodeI)
const;
499 const bool leavesOnly,
500 const bool writeLinesOnly =
false 504 void writeOBJ(
const label nodeI,
const direction octant)
const;
527 const label maxLevels,
528 const scalar maxLeafRatio,
529 const scalar maxDuplicity
573 return nodes_[0].bb_;
585 const scalar nearestDistSqr
593 template<
class FindNearestOp>
597 const scalar nearestDistSqr,
599 const FindNearestOp& fnOp
603 template<
class FindNearestOp>
609 scalar& nearestDistSqr,
610 label& nearestShapeI,
613 const FindNearestOp& fnOp
630 template<
class FindNearestOp>
637 const FindNearestOp& fnOp
655 template<
class FindIntersectOp>
660 const FindIntersectOp& fiOp
664 template<
class FindIntersectOp>
669 const FindIntersectOp& fiOp
696 const scalar radiusSqr
705 const scalar radiusSqr
714 const scalar radiusSqr,
739 const vector& outsideNormal,
745 template<
class CompareOp>
748 const scalar nearDist,
764 const bool printContents,
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
static label getNode(const labelBits i)
Return real (dereferenced) index for a parent node.
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
static void writeOBJ(Ostream &os, const treeBoundBox &bb, label &vertIndex, const bool writeLinesOnly=false)
Write treeBoundBox in OBJ format.
treeBoundBox bb_
Bounding box of this node.
static const treeBoundBox & null() noexcept
The null treeBoundBox is the same as an inverted box.
const List< node > & nodes() const noexcept
List of all nodes.
bool overlaps(const treeBoundBox &bb) const
True if any shapes overlap the bounding box.
const List< labelList > & contents() const noexcept
List of all contents (referenced by those nodes that are contents)
A 1D vector of objects of type <T> with a fixed length <N>.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
static scalar perturbTol_
Relative perturbation tolerance.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
const Type & shapes() const noexcept
Reference to shape.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
friend bool operator!=(const node &a, const node &b)
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
label parent_
Parent node (index into flat list addressing for tree)
ClassName("indexedOctree")
Runtime type information.
labelBits findNode(const label nodeI, const point &) const
Find deepest node (as parent+octant) containing point. Starts.
static bool isEmpty(labelBits i) noexcept
An empty node - no content.
static label getContent(labelBits i)
Return real (dereferenced) index for a content node.
static bool isContent(labelBits i) noexcept
Node with content (leaf)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Version of OSstream that prints a prefix on each line.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
static labelBits nodePlusOctant(label i, direction octant)
From index into nodes_ to subNodes_ entry.
A class for handling words, derived from Foam::string.
friend Ostream & operator<<(Ostream &os, const node &n)
PackedList< 2 > & nodeTypes() const noexcept
Per node, per octant whether is fully inside/outside/mixed.
const treeBoundBox & bb() const
Top bounding box.
errorManip< error > abort(error &err)
static direction getOctant(labelBits i) noexcept
Return sub-node direction/octant.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
indexedOctree(const Type &shapes)
Construct null.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void print(prefixOSstream &, const bool printContents, const label) const
Print tree. Either print all indices (printContent = true) or.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
label facePoint(const int facei, const block &block, const label i, const label j)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
OBJstream os(runTime.globalPath()/outputName)
autoPtr< indexedOctree< Type > > clone() const
Clone.
friend Istream & operator>>(Istream &is, node &n)
static constexpr direction nChildren
Has exactly 8 sub-nodes (octants)
Template invariant parts for indexedOctree.
static bool isNode(labelBits i) noexcept
A parent node.
const labelList & findIndices(const point &) const
Find the shape indices that occupy the result of findNode.
static labelBits contentPlusOctant(label i, direction octant)
From index into contents_ to subNodes_ entry.
Non-pointer based hierarchical recursive searching.
Standard boundBox with extra functionality for use in octree.
indexedOctreeBase()=default
Default construct.
A 29bits (or 61bits) integer label with 3bits direction (eg, octant) packed into single label...
static labelBits emptyPlusOctant(direction octant)
From empty to subNodes_ entry.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
label val() const noexcept
Return the integer value.
FixedList< labelBits, 8 > subNodes_
IDs of the 8 nodes on all sides of the mid point.
label nLeafs() const
Return the number of leaf nodes.
friend bool operator==(const node &a, const node &b)
bool write(Ostream &os) const
Tree node. Has up pointer and down pointers.