80void Foam::searchableBox::projectOntoCoordPlane
88 info.point()[dir] = planePt[dir];
91 if (planePt[dir] ==
min()[dir])
95 else if (planePt[dir] ==
max()[dir])
97 info.setIndex(dir*2+1);
102 <<
"Point on plane " << planePt
103 <<
" is not on coordinate " <<
min()[dir]
104 <<
" nor " <<
max()[dir] <<
nl
115 const scalar nearestDistSqr
131 bool outside =
false;
138 if (info.point()[dir] <
min()[dir])
140 projectOntoCoordPlane(dir,
min(), info);
143 else if (info.point()[dir] >
max()[dir])
145 projectOntoCoordPlane(dir,
max(), info);
148 else if (info.point()[dir] > bbMid[dir])
150 near[dir] =
max()[dir];
154 near[dir] =
min()[dir];
167 if (dist.x() < dist.y())
169 if (dist.x() < dist.z())
176 if (dist.y() < dist.z())
182 projectOntoCoordPlane(projNorm, near, info);
188 if (info.point().distSqr(sample) > nearestDistSqr)
200Foam::searchableBox::searchableBox
212 <<
"Illegal bounding box specification : "
221Foam::searchableBox::searchableBox
227 searchableSurface(
io),
235 <<
"Illegal bounding box specification : "
248 if (regions_.empty())
251 regions_[0] =
"region0";
260 auto& ctrs = tctrs.ref();
267 ctrs[i] = fcs[i].centre(
pts);
281 radiusSqr.setSize(size());
289 const face&
f = fcs[i];
291 centres[i] =
f.centre(
pts);
292 for (
const label pointi :
f)
296 radiusSqr[i] =
Foam::max(radiusSqr[i], centres[i].distSqr(pt));
314 const scalar nearestDistSqr
324 const scalar nearestDistSqr
327 const point bbMid(centre());
331 bool outside =
false;
338 if (info.point()[dir] <
min()[dir])
340 projectOntoCoordPlane(dir,
min(), info);
343 else if (info.point()[dir] >
max()[dir])
345 projectOntoCoordPlane(dir,
max(), info);
348 else if (info.point()[dir] > bbMid[dir])
350 near[dir] =
max()[dir];
354 near[dir] =
min()[dir];
367 sortedDist[0] = dist[0];
368 sortedDist[1] = dist[1];
369 sortedDist[2] = dist[2];
373 projectOntoCoordPlane(sortedDist.indices()[0], near, info);
375 projectOntoCoordPlane(sortedDist.indices()[1], near, info);
381 if (info.point().distSqr(sample) > nearestDistSqr)
394 treeBoundBox& tightest,
413 if (posBits(start) == 0)
415 if (posBits(end) == 0)
423 foundInter = intersects(end, start, info.point());
429 foundInter = intersects(start, end, info.point());
440 if (info.point()[dir] ==
min()[dir])
442 info.setIndex(2*dir);
445 else if (info.point()[dir] ==
max()[dir])
447 info.setIndex(2*dir+1);
452 if (info.index() == -1)
455 <<
"point " << info.point()
456 <<
" on segment " << start <<
end
457 <<
" should be on face of " << *
this
476void Foam::searchableBox::findNearest
485 const point bbMid(centre());
489 info[i] = findNearest(bbMid,
samples[i], nearestDistSqr[i]);
498 List<pointIndexHit>& info
501 info.setSize(start.size());
514 List<pointIndexHit>& info
517 info.setSize(start.size());
530 List<List<pointIndexHit>>& info
533 info.setSize(start.size());
536 DynamicList<pointIndexHit> hits;
561 point pt = inter.hitPoint() + smallVec[pointi];
563 while (((pt-start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
573 || (inter.index() == hits.last().index())
580 pt = inter.hitPoint() + smallVec[pointi];
583 info[pointi].transfer(hits);
587 info[pointi].clear();
599 region.setSize(
info.size());
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
Minimal example by using system/controlDict.functions:
readOption
Enumeration defining read preferences.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void setSize(label n)
Alias for resize().
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
const point_type & hitPoint() const
Return hit point. Fatal if not hit.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const noexcept
Return the list of sorted indices. Updated every sort.
void sort()
Forward (stable) sort the list (if changed after construction).
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
static constexpr direction nComponents
Number of components in this vector space.
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
const point & max() const noexcept
Maximum describing the bounding box.
const point & min() const noexcept
Minimum describing the bounding box.
bool good() const
Bounding box is non-inverted.
point centre() const
The centre (midpoint) of the bounding box.
static const FixedList< vector, 6 > faceNormals
The unit normal per face.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A face is a list of labels corresponding to mesh vertices.
Searching on bounding box.
virtual label size() const
Range of local indices that can be returned.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside) for points.
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
virtual tmp< pointField > points() const
Get the points that define the surface.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual const boundBox & bounds() const
Return const reference to boundBox.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Standard boundBox with extra functionality for use in octree.
static const faceList faces
Face to point addressing, using octant corner points.
tmp< pointField > points() const
Vertex coordinates. In octant coding.
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,.
treeBoundBox()=default
Default construct: an inverted bounding box.
bool contains(const vector &dir, const point &) const
Contains point (inside or on edge) and moving in direction.
direction posBits(const point &pt) const
Position of point relative to bounding box.
@ OUTSIDE
A location outside the volume.
@ INSIDE
A location inside the volume.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
List< face > faceList
List of faces.
static void readBoxDim(const dictionary &dict, treeBoundBox &bb)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
line< point, const point & > linePointRef
A line using referred points.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)