71 <<
"No bounding box for zero-sized pointField" <<
nl;
78 const UList<point>&
points,
82 boundBox(
points, indices, false)
84 if (
points.empty() || indices.empty())
87 <<
"No bounding box for zero-sized pointField" <<
nl;
97 auto&
pts = tpts.ref();
101 pts[octant] = corner(octant);
117 <<
"octant:" << int(octant) <<
" should be [0..7]" 124 treeBoundBox bb(mid);
166 treeBoundBox bb(*
this);
170 case LEFT : bb.max().x() = mid;
break;
171 case RIGHT : bb.min().x() = mid;
break;
173 case BOTTOM : bb.max().y() = mid;
break;
174 case TOP : bb.min().y() = mid;
break;
176 case BACK : bb.max().z() = mid;
break;
177 case FRONT : bb.min().z() = mid;
break;
182 <<
"face:" << int(whichFace) <<
" should be [0..5]" 198 (whichFace == faceId::LEFT || whichFace == faceId::RIGHT)
200 : (whichFace == faceId::BOTTOM || whichFace == faceId::TOP)
205 scalar mid = 0.5*(
min()[cmpt] +
max()[cmpt]);
207 return subHalf(mid, whichFace);
213 return subBbox(centre(), octant);
226 point subMin = centre();
227 point subMax = subMin;
229 if (octant & RIGHTHALF)
231 subMax.x() =
max().x();
235 subMin.x() =
min().x();
238 if (octant & TOPHALF)
240 subMax.y() =
max().y();
244 subMin.y() =
min().y();
247 if (octant & FRONTHALF)
249 subMax.z() =
max().z();
253 subMin.z() =
min().z();
257 return box_box_overlaps(subMin, subMax, bb.
min(), bb.
max());
263 const point& overallStart,
298 ptOnFaces = faceBits(pt);
302 if ((ptBits & endBits) != 0)
305 ptOnFaces = faceBits(pt);
309 if (ptBits & LEFTBIT)
314 scalar
s = (
min().x() - overallStart.x())/overallVec.x();
316 pt.y() = overallStart.y() + overallVec.y()*
s;
317 pt.z() = overallStart.z() + overallVec.z()*
s;
326 else if (ptBits & RIGHTBIT)
331 scalar
s = (
max().x() - overallStart.x())/overallVec.x();
333 pt.y() = overallStart.y() + overallVec.y()*
s;
334 pt.z() = overallStart.z() + overallVec.z()*
s;
341 else if (ptBits & BOTTOMBIT)
346 scalar
s = (
min().y() - overallStart.y())/overallVec.y();
347 pt.x() = overallStart.x() + overallVec.x()*
s;
349 pt.z() = overallStart.z() + overallVec.z()*
s;
356 else if (ptBits & TOPBIT)
361 scalar
s = (
max().y() - overallStart.y())/overallVec.y();
362 pt.x() = overallStart.x() + overallVec.x()*
s;
364 pt.z() = overallStart.z() + overallVec.z()*
s;
371 else if (ptBits & BACKBIT)
376 scalar
s = (
min().z() - overallStart.z())/overallVec.z();
377 pt.x() = overallStart.x() + overallVec.x()*
s;
378 pt.y() = overallStart.y() + overallVec.y()*
s;
386 else if (ptBits & FRONTBIT)
391 scalar
s = (
max().z() - overallStart.z())/overallVec.z();
392 pt.x() = overallStart.x() + overallVec.x()*
s;
393 pt.y() = overallStart.y() + overallVec.y()*
s;
416 return intersects(start,
end-start, start,
end, pt, ptBits);
424 for (
direction cmpt=0; cmpt < point::nComponents; ++cmpt)
426 if (pt[cmpt] <
min()[cmpt])
430 else if (pt[cmpt] ==
min()[cmpt])
439 if (pt[cmpt] >
max()[cmpt])
443 else if (pt[cmpt] ==
max()[cmpt])
462 if (pt.x() ==
min().x())
466 else if (pt.x() ==
max().x())
471 if (pt.y() ==
min().y())
475 else if (pt.y() ==
max().y())
480 if (pt.z() ==
min().z())
484 else if (pt.z() ==
max().z())
497 if (pt.x() <
min().x())
501 else if (pt.x() >
max().x())
506 if (pt.y() <
min().y())
510 else if (pt.y() >
max().y())
515 if (pt.z() <
min().z())
519 else if (pt.z() >
max().z())
535 for (
direction cmpt=0; cmpt < point::nComponents; ++cmpt)
543 nearest[cmpt] =
min()[cmpt];
544 furthest[cmpt] =
max()[cmpt];
548 nearest[cmpt] =
max()[cmpt];
549 furthest[cmpt] =
min()[cmpt];
558 calcExtremities(pt, near, far);
574 point nearThis, farThis;
577 calcExtremities(pt, nearThis, farThis);
579 const scalar minDistThis = pt.distSqr(nearThis);
580 const scalar maxDistThis = pt.distSqr(farThis);
586 point nearOther, farOther;
591 const scalar minDistOther = pt.distSqr(nearOther);
592 const scalar maxDistOther = pt.distSqr(farOther);
597 if (maxDistThis < minDistOther)
602 else if (minDistThis > maxDistOther)
619 return os << static_cast<const boundBox&>(bb);
625 return is >>
static_cast<boundBox&
>(bb);
direction faceBits(const point &pt) const
Code position of point on bounding box faces.
treeBoundBox subHalf(const direction whichFace) const
Sub-box half for given face.
bool subOverlaps(const direction octant, const boundBox &bb) const
Does sub-octant overlap/touch boundingBox?
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
A bounding box defined in terms of min/max extrema points.
label distanceCmp(const point &pt, const treeBoundBox &other) const
Compare distance to point with other bounding box.
const point & min() const noexcept
Minimum describing the bounding box.
static const faceList faces
Face to point addressing, using octant corner points.
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
direction posBits(const point &pt) const
Position of point relative to bounding box.
const point & max() const noexcept
Maximum describing the bounding box.
bool intersects(const point &overallStart, const vector &overallVec, const point &start, const point &end, point &pt, direction &ptBits) const
Intersects segment; set point to intersection position and face,.
Istream & operator>>(Istream &, directionInfo &)
static const edgeList edges
Edge to point addressing, using octant corner points.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
treeBoundBox subBbox(const direction octant) const
Sub-box of given octant. Midpoint calculated.
treeBoundBox()=default
Default construct: an inverted bounding box.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
void calcExtremities(const point &pt, point &nearest, point &furthest) const
Calculate nearest and furthest (to point) vertex coords of.
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
scalar maxDist(const point &pt) const
Returns distance point to furthest away corner.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
PtrList< volScalarField > & Y
tmp< pointField > points() const
Vertex coordinates. In octant coding.
Standard boundBox with extra functionality for use in octree.
A class for managing temporary objects.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))