108 FixedList<vector, 6> normals;
109 normals[faceId::left] =
vector(-1, 0, 0);
110 normals[faceId::right] =
vector( 1, 0, 0);
111 normals[faceId::bottom] =
vector( 0, -1, 0);
112 normals[faceId::top] =
vector( 0, 1, 0);
113 normals[faceId::back] =
vector( 0, 0, -1);
114 normals[faceId::front] =
vector( 0, 0, 1);
128 <<
"cannot find bounding box for zero-sized pointField, "
129 <<
"returning zero" <<
endl;
147 <<
"cannot find bounding box for zero-sized pointField, "
148 <<
"returning zero" <<
endl;
164 points[octant] = corner(octant);
173 return subBbox(midpoint(), octant);
186 <<
"octant should be [0..7]"
195 if (octant & octantBit::rightHalf)
204 if (octant & octantBit::topHalf)
213 if (octant & octantBit::frontHalf)
228 const point& overallStart,
256 for (
label i = 0; i < 4; ++i)
263 ptOnFaces = faceBits(pt);
267 if ((ptBits & endBits) != 0)
270 ptOnFaces = faceBits(pt);
274 if (ptBits & faceBit::left)
279 scalar
s = (
min().x() - overallStart.
x())/overallVec.
x();
281 pt.
y() = overallStart.
y() + overallVec.
y()*
s;
282 pt.
z() = overallStart.
z() + overallVec.
z()*
s;
291 else if (ptBits & faceBit::right)
296 scalar
s = (
max().x() - overallStart.
x())/overallVec.
x();
298 pt.
y() = overallStart.
y() + overallVec.
y()*
s;
299 pt.
z() = overallStart.
z() + overallVec.
z()*
s;
306 else if (ptBits & faceBit::bottom)
311 scalar
s = (
min().y() - overallStart.
y())/overallVec.
y();
312 pt.
x() = overallStart.
x() + overallVec.
x()*
s;
314 pt.
z() = overallStart.
z() + overallVec.
z()*
s;
321 else if (ptBits & faceBit::top)
326 scalar
s = (
max().y() - overallStart.
y())/overallVec.
y();
327 pt.
x() = overallStart.
x() + overallVec.
x()*
s;
329 pt.
z() = overallStart.
z() + overallVec.
z()*
s;
336 else if (ptBits & faceBit::back)
341 scalar
s = (
min().z() - overallStart.
z())/overallVec.
z();
342 pt.
x() = overallStart.
x() + overallVec.
x()*
s;
343 pt.
y() = overallStart.
y() + overallVec.
y()*
s;
351 else if (ptBits & faceBit::front)
356 scalar
s = (
max().z() - overallStart.
z())/overallVec.
z();
357 pt.
x() = overallStart.
x() + overallVec.
x()*
s;
358 pt.
y() = overallStart.
y() + overallVec.
y()*
s;
381 return intersects(start, end-start, start, end, pt, ptBits);
391 if (pt[cmpt] <
min()[cmpt])
395 else if (pt[cmpt] ==
min()[cmpt])
404 if (pt[cmpt] >
max()[cmpt])
408 else if (pt[cmpt] ==
max()[cmpt])
426 if (pt.
x() ==
min().
x())
428 faceBits |= faceBit::left;
430 else if (pt.
x() ==
max().
x())
432 faceBits |= faceBit::right;
435 if (pt.
y() ==
min().
y())
437 faceBits |= faceBit::bottom;
439 else if (pt.
y() ==
max().
y())
441 faceBits |= faceBit::top;
444 if (pt.
z() ==
min().z())
446 faceBits |= faceBit::back;
448 else if (pt.
z() ==
max().z())
450 faceBits |= faceBit::front;
460 if (pt.
x() <
min().
x())
462 posBits |= faceBit::left;
464 else if (pt.
x() >
max().
x())
466 posBits |= faceBit::right;
469 if (pt.
y() <
min().
y())
471 posBits |= faceBit::bottom;
473 else if (pt.
y() >
max().
y())
475 posBits |= faceBit::top;
478 if (pt.
z() <
min().z())
480 posBits |= faceBit::back;
482 else if (pt.
z() >
max().z())
484 posBits |= faceBit::front;
497 scalar nearX, nearY, nearZ;
498 scalar farX, farY, farZ;
533 nearest =
point(nearX, nearY, nearZ);
534 furthest =
point(farX, farY, farZ);
541 calcExtremities(pt, near, far);
557 point nearThis, farThis;
560 calcExtremities(pt, nearThis, farThis);
562 const scalar minDistThis =
563 sqr(nearThis.
x() - pt.
x())
564 +
sqr(nearThis.
y() - pt.
y())
565 +
sqr(nearThis.
z() - pt.
z());
566 const scalar maxDistThis =
567 sqr(farThis.
x() - pt.
x())
568 +
sqr(farThis.
y() - pt.
y())
569 +
sqr(farThis.
z() - pt.
z());
575 point nearOther, farOther;
580 const scalar minDistOther =
581 sqr(nearOther.
x() - pt.
x())
582 +
sqr(nearOther.
y() - pt.
y())
583 +
sqr(nearOther.
z() - pt.
z());
584 const scalar maxDistOther =
585 sqr(farOther.
x() - pt.
x())
586 +
sqr(farOther.
y() - pt.
y())
587 +
sqr(farOther.
z() - pt.
z());
592 if (maxDistThis < minDistOther)
597 else if (minDistThis > maxDistOther)
614 Info<<
"Dumping bounding box " << *
this <<
" as lines to obj file "
621 const point& pt = bbPoints[i];
623 str<<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
630 str<<
"l " <<
e[0]+1 <<
' ' <<
e[1]+1 <<
nl;
657 return os << static_cast<const boundBox&>(bb);
663 return is >>
static_cast<boundBox&
>(bb);
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> with a fixed size <Size>.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const fileName & name() const
Return the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const
Return true if the UList is empty (ie, size() is zero)
A bounding box defined in terms of the points at its extremities.
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling file names.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Standard boundBox + extra functionality for use in octree.
void writeOBJ(const fileName &fName) const
void calcExtremities(const point &pt, point &nearest, point &furthest) const
Calculate nearest and furthest (to point) vertex coords of.
scalar maxDist(const point &) const
Returns distance point to furthest away corner.
label distanceCmp(const point &, const treeBoundBox &other) const
Compare distance to point with other bounding box.
direction faceBits(const point &) const
Code position of point on bounding box faces.
treeBoundBox subBbox(const direction) const
Sub box given by octant number. Midpoint calculated.
static const edgeList edges
Edge to point addressing.
bool contains(const point &) const
Contains point or other 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,.
static const treeBoundBox invertedBox
As per boundBox::invertedBox, but with great instead of vGreat.
static const treeBoundBox greatBox
As per boundBox::greatBox, but with great instead of vGreat.
static const FixedList< vector, 6 > faceNormals
Per face the unit normal.
static const faceList faces
Face to point addressing.
direction posBits(const point &) const
Position of point relative to bounding box.
treeBoundBox()
Construct null setting points to zero.
tmp< pointField > points() const
Vertex coordinates. In octant coding.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define WarningInFunction
Report a warning using Foam::Warning.
bool operator!=(const particle &, const particle &)
Istream & operator>>(Istream &, pointEdgeDist &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const Foam::label edgesArray[12][2]
const Foam::label facesArray[6][4]