41 void Foam::searchableBox::projectOntoCoordPlane
49 info.rawPoint()[dir] = planePt[dir];
51 if (planePt[dir] ==
min()[dir])
55 else if (planePt[dir] ==
max()[dir])
57 info.setIndex(dir*2+1);
62 <<
"Point on plane " << planePt
63 <<
" is not on coordinate " <<
min()[dir]
74 const scalar nearestDistSqr
97 if (info.rawPoint()[dir] <
min()[dir])
99 projectOntoCoordPlane(dir,
min(), info);
102 else if (info.rawPoint()[dir] >
max()[dir])
104 projectOntoCoordPlane(dir,
max(), info);
107 else if (info.rawPoint()[dir] > bbMid[dir])
109 near[dir] =
max()[dir];
113 near[dir] =
min()[dir];
124 if (dist.x() < dist.y())
126 if (dist.x() < dist.z())
129 projectOntoCoordPlane(
vector::X, near, info);
133 projectOntoCoordPlane(
vector::Z, near, info);
138 if (dist.y() < dist.z())
140 projectOntoCoordPlane(
vector::Y, near, info);
144 projectOntoCoordPlane(
vector::Z, near, info);
152 if (
magSqr(info.rawPoint() - sample) > nearestDistSqr)
164 Foam::searchableBox::searchableBox
173 if (!contains(midpoint()))
177 "Foam::searchableBox::searchableBox\n" 179 " const IOobject& io,\n" 180 " const treeBoundBox& bb\n" 182 ) <<
"Illegal bounding box specification : " 186 bounds() =
static_cast<boundBox>(*this);
190 Foam::searchableBox::searchableBox
199 if (!contains(midpoint()))
203 "Foam::searchableBox::searchableBox\n" 205 " const IOobject& io,\n" 206 " const treeBoundBox& bb\n" 208 ) <<
"Illegal bounding box specification : " 212 bounds() =
static_cast<boundBox>(*this);
226 if (regions_.empty())
229 regions_[0] =
"region0";
245 ctrs[i] = fcs[i].centre(pts);
267 const face&
f = fcs[i];
269 centres[i] = f.
centre(pts);
272 const point& pt = pts[f[fp]];
296 const scalar nearestDistSqr
299 return findNearest(midpoint(), sample, nearestDistSqr);
306 const scalar nearestDistSqr
309 const point bbMid(midpoint());
313 bool outside =
false;
322 projectOntoCoordPlane(dir,
min(), info);
327 projectOntoCoordPlane(dir,
max(), info);
330 else if (info.
rawPoint()[dir] > bbMid[dir])
332 near[dir] =
max()[dir];
336 near[dir] =
min()[dir];
349 sortedDist[0] = dist[0];
350 sortedDist[1] = dist[1];
351 sortedDist[2] = dist[2];
355 projectOntoCoordPlane(sortedDist.
indices()[0], near, info);
357 projectOntoCoordPlane(sortedDist.
indices()[1], near, info);
382 "searchableBox::findNearest" 383 "(const linePointRef&, treeBoundBox&, point&)" 399 if (posBits(start) == 0)
401 if (posBits(end) == 0)
409 foundInter = intersects(end, start, info.
rawPoint());
415 foundInter = intersects(start, end, info.
rawPoint());
438 if (info.
index() == -1)
440 FatalErrorIn(
"searchableBox::findLine(const point&, const point&)")
442 <<
" on segment " << start << end
443 <<
" should be on face of " << *
this 458 return findLine(start, end);
462 void Foam::searchableBox::findNearest
471 const point bbMid(midpoint());
475 info[i] = findNearest(bbMid, samples[i], nearestDistSqr[i]);
491 info[i] = findLine(start[i], end[i]);
507 info[i] = findLineAny(start[i], end[i]);
535 +
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL)
550 while (((pt-start[pointI])&dirVec[pointI]) <= magSqrDirVec[pointI])
567 pt = inter.
hitPoint() + smallVec[pointI];
574 info[pointI].
clear();
625 const point& pt = points[pointI];
629 if (pt[dir] <
min()[dir] || pt[dir] >
max()[dir])
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
virtual ~searchableBox()
Destructor.
const Point & rawPoint() const
Return point with no checking.
T & last()
Return the last element of the list.
pointIndexHit findNearestOnEdge(const point &sample, const scalar nearestDistSqr) const
Calculate nearest point on edge.
void clear()
Clear the addressed list, i.e. set the size to zero.
Standard boundBox + extra functionality for use in octree.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
PointIndexHit< point > pointIndexHit
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
bool hit() const
Is there a hit.
A list of keyword definitions, which are a keyword followed by any number of values (e...
tmp< pointField > points() const
Vertex coordinates. In octant coding.
void sort()
(stable) sort the list (if changed after construction time)
label index() const
Return index.
point centre(const pointField &) const
Centre point of face.
vectorField pointField
pointField is a vectorField.
const Point & hitPoint() const
Return hit point.
static faceList faces()
Return faces with correct point order.
A face is a list of labels corresponding to mesh vertices.
Number of components in this vector space.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
A list that is sorted upon construction or when explicitly requested with the sort() method...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
pointIndexHit findLine(const point &start, const point &end) const
Find nearest intersection of line between start and end.
virtual const wordList & regions() const
Names of regions.
static const FixedList< vector, 6 > faceNormals
Per face the unit normal.
Macros for easy insertion into run-time selection tables.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
errorManip< error > abort(error &err)
void setIndex(const label index)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A bounding box defined in terms of the points at its extremities.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
virtual tmp< pointField > points() const
Get the points that define the surface.
Vector< scalar > vector
A scalar version of the templated Vector.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
A class for managing temporary objects.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
defineTypeNameAndDebug(combustionModel, 0)
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.