38 #ifndef Foam_indexedOctree_H 39 #define Foam_indexedOctree_H 56 template<
class Type>
class indexedOctree;
57 template<
class Type> Ostream& operator<<(Ostream&, const indexedOctree<Type>&);
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
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,
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.
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
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 List is empty (ie, size() is zero)
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.
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...
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.