34 namespace searchableSurfaces
59 void Foam::searchableSurfaces::box::projectOntoCoordPlane
67 info.rawPoint()[dir] = planePt[dir];
69 if (planePt[dir] ==
min()[dir])
73 else if (planePt[dir] ==
max()[dir])
75 info.setIndex(dir*2+1);
80 <<
"Point on plane " << planePt
81 <<
" is not on coordinate " <<
min()[dir]
92 const scalar nearestDistSqr
108 bool outside =
false;
115 if (info.rawPoint()[dir] <
min()[dir])
117 projectOntoCoordPlane(dir,
min(), info);
120 else if (info.rawPoint()[dir] >
max()[dir])
122 projectOntoCoordPlane(dir,
max(), info);
125 else if (info.rawPoint()[dir] > bbMid[dir])
127 near[dir] =
max()[dir];
131 near[dir] =
min()[dir];
142 if (dist.x() < dist.y())
144 if (dist.x() < dist.z())
147 projectOntoCoordPlane(
vector::X, near, info);
151 projectOntoCoordPlane(
vector::Z, near, info);
156 if (dist.y() < dist.z())
158 projectOntoCoordPlane(
vector::Y, near, info);
162 projectOntoCoordPlane(
vector::Z, near, info);
170 if (
magSqr(info.rawPoint() - sample) > nearestDistSqr)
194 <<
"Illegal bounding box specification : "
214 <<
"Illegal bounding box specification : "
232 if (regions_.empty())
235 regions_[0] =
"region0";
251 ctrs[i] = fcs[i].centre(pts);
273 const face&
f = fcs[i];
275 centres[i] =
f.centre(pts);
278 const point& pt = pts[
f[fp]];
302 const scalar nearestDistSqr
305 return findNearest(midpoint(), sample, nearestDistSqr);
312 const scalar nearestDistSqr
315 const point bbMid(midpoint());
319 bool outside =
false;
328 projectOntoCoordPlane(dir,
min(), info);
333 projectOntoCoordPlane(dir,
max(), info);
336 else if (info.
rawPoint()[dir] > bbMid[dir])
338 near[dir] =
max()[dir];
342 near[dir] =
min()[dir];
355 sortedDist[0] = dist[0];
356 sortedDist[1] = dist[1];
357 sortedDist[2] = dist[2];
361 projectOntoCoordPlane(sortedDist.
indices()[0], near, info);
363 projectOntoCoordPlane(sortedDist.
indices()[1], near, info);
401 if (posBits(start) == 0)
403 if (posBits(end) == 0)
411 foundInter = intersects(end, start, info.
rawPoint());
417 foundInter = intersects(start, end, info.
rawPoint());
440 if (info.
index() == -1)
444 <<
" on segment " << start << end
445 <<
" should be on face of " << *
this
460 return findLine(start, end);
464 void Foam::searchableSurfaces::box::findNearest
473 const point bbMid(midpoint());
477 info[i] = findNearest(bbMid,
samples[i], nearestDistSqr[i]);
493 info[i] = findLine(start[i], end[i]);
509 info[i] = findLineAny(start[i], end[i]);
521 info.setSize(start.
size());
537 +
vector(rootVSmall,rootVSmall,rootVSmall)
552 while (((pt-start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
562 || (inter.
index() == hits.
last().index())
569 pt = inter.
hitPoint() + smallVec[pointi];
576 info[pointi].clear();
631 if (pt[dir] <
min()[dir] || pt[dir] >
max()[dir])
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
InfoProxy< IOobject > info() const
Return info proxy.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const Point & hitPoint() const
Return hit point.
const Point & rawPoint() const
Return point with no checking.
label index() const
Return index.
bool hit() const
Is there a hit.
void setIndex(const label index)
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void sort()
(stable) sort the list (if changed after construction time)
T & last()
Return the last element of the list.
static const direction nComponents
Number of components in this vector space.
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.
point midpoint() const
The midpoint of the bounding box.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
A face is a list of labels corresponding to mesh vertices.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const boundBox & bounds() const
Return const reference to boundBox.
Surface geometry with a rectangular box shape, aligned with the coordinate axes, which can be used wi...
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual ~box()
Destructor.
box(const IOobject &io, const treeBoundBox &bb)
Construct from components.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
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.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
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.
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.
bool contains(const point &) const
Contains point or other bounding box?
static const FixedList< vector, 6 > faceNormals
Per face the unit normal.
static const faceList faces
Face to point addressing.
tmp< pointField > points() const
Vertex coordinates. In octant coding.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
addToRunTimeSelectionTable(searchableSurface, box, dictionary)
defineTypeNameAndDebug(box, 0)
addBackwardCompatibleToRunTimeSelectionTable(searchableSurface, box, dictionary, searchableBox, "searchableBox")
errorManipArg< error, int > exit(error &err, const int errNo=1)
PointIndexHit< point > pointIndexHit
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void cmptMag(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
scalarField samples(nIntervals, 0)