44 void Foam::searchableSurfacesQueries::mergeHits
49 const List<pointIndexHit>& surfHits,
52 List<pointIndexHit>& allInfo,
63 surfDistSqr[i] =
magSqr(surfHits[i].hitPoint() - start);
82 label next = index + 1;
84 if (next < allDistSqr.size())
94 label sz = allSurfaces.size();
95 allSurfaces.setSize(sz+1);
96 allInfo.setSize(allSurfaces.size());
97 allDistSqr.setSize(allSurfaces.size());
99 for (
label j = sz-1; j > index; --j)
101 allSurfaces[j+1] = allSurfaces[j];
102 allInfo[j+1] = allInfo[j];
103 allDistSqr[j+1] = allDistSqr[j];
106 allSurfaces[index+1] = testI;
107 allInfo[index+1] = surfHits[i];
108 allDistSqr[index+1] = surfDistSqr[i];
138 forAll(surfacesToTest, testI)
141 allSurfaces[surfacesToTest[testI]].findLineAny(p0, p1, intersectInfo);
147 if (intersectInfo[i].hit())
149 hitInfo[hitMap[i]] = intersectInfo[i];
150 hitSurfaces[hitMap[i]] = testI;
156 hitMap[newI] = hitMap[i];
197 hitInfo.setSize(start.
size());
199 if (surfacesToTest.
empty())
205 allSurfaces[surfacesToTest[0]].findLineAll(start, end, hitInfo);
213 labelList& pSurfaces = hitSurfaces[pointi];
221 pDistSqr[i] =
magSqr(pHits[i].hitPoint() - start[pointi]);
226 if (surfacesToTest.
size() > 1)
229 for (
label testI = 1; testI < surfacesToTest.
size(); testI++)
232 allSurfaces[surfacesToTest[testI]].findLineAll
283 forAll(surfacesToTest, testI)
286 allSurfaces[surfacesToTest[testI]].findLine
293 forAll(nearestInfo, pointi)
295 if (nearestInfo[pointi].hit())
297 hit1[pointi] = nearestInfo[pointi];
298 surface1[pointi] = testI;
299 nearest[pointi] = hit1[pointi].hitPoint();
316 if (hit1[pointi].hit())
318 nearest[pointi] = hit1[pointi].hitPoint();
323 nearest[pointi] = end[pointi];
327 forAll(surfacesToTest, testI)
330 allSurfaces[surfacesToTest[testI]].findLine(end, nearest, nearestInfo);
332 forAll(nearestInfo, pointi)
334 if (nearestInfo[pointi].hit())
336 hit2[pointi] = nearestInfo[pointi];
337 surface2[pointi] = testI;
338 nearest[pointi] = hit2[pointi].hitPoint();
359 nearestSurfaces = -1;
366 forAll(surfacesToTest, testI)
368 allSurfaces[surfacesToTest[testI]].findNearest
378 if (hitInfo[pointi].hit())
380 minDistSqr[pointi] =
magSqr
382 hitInfo[pointi].hitPoint()
385 nearestInfo[pointi] = hitInfo[pointi];
386 nearestSurfaces[pointi] = testI;
406 if (regionIndices.
empty())
421 nearestSurfaces = -1;
428 forAll(surfacesToTest, testI)
430 allSurfaces[surfacesToTest[testI]].findNearest
441 if (hitInfo[pointi].hit())
443 minDistSqr[pointi] =
magSqr
445 hitInfo[pointi].hitPoint()
448 nearestInfo[pointi] = hitInfo[pointi];
449 nearestSurfaces[pointi] = testI;
472 allSurfaces[surfacesToTest[0]].findNearest(start, distSqr, info);
473 allSurfaces[surfacesToTest[0]].getNormal(info, normal);
481 near[i] = info[i].hitPoint();
487 if (surfacesToTest.
size() == 1)
494 constraint[i].applyConstraint(normal[i]);
498 else if (surfacesToTest.
size() >= 2)
505 for (
label iter = 0; iter < nIter; iter++)
512 constraint[i].applyConstraint(normal[i]);
518 s.findNearest(near, distSqr, info);
519 s.getNormal(info, normal1);
525 near1[i] = info[i].hitPoint();
532 if (info[pointi].hit())
534 plane pl0(near[pointi], normal[pointi]);
535 plane pl1(near1[pointi], normal1[pointi]);
543 normal[pointi] = normal1[pointi];
544 constraint[pointi].applyConstraint(normal1[pointi]);
549 surfi = surfacesToTest.
fcIndex(surfi);
586 forAll(surfacesToTest, testI)
591 forAll(nearestSurfaces, i)
593 if (nearestSurfaces[i] == testI)
602 allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType);
607 label pointi = surfIndices[i];
608 scalar dist =
mag(
samples[pointi] - nearestInfo[pointi].hitPoint());
614 distance[pointi] = dist;
622 switch (illegalHandling)
626 distance[pointi] = dist;
631 distance[pointi] = -dist;
637 <<
"getVolumeType failure,"
638 <<
" neither INSIDE or OUTSIDE."
639 <<
" point:" << surfPoints[i]
641 << allSurfaces[surfacesToTest[testI]].name()
662 forAll(surfacesToTest, testI)
666 bbPoints[2*testI] = surface.
bounds().
min();
668 bbPoints[2*testI + 1] = surface.
bounds().
max();
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
DynamicField< 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.
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.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
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.
A direction and a reference point.
const point & refPoint() const
const vector & dir() const
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
ray planeIntersect(const plane &) const
Return the cutting line between this plane and another.
Accumulates point constraints through successive applications of the applyConstraint function.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const boundBox & bounds() const
Return const reference to boundBox.
A collection of tools for searchableSurfaces.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest)
Find the boundBox of the selected surfaces.
static void findNearestIntersection(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2)
Find intersections of edge nearest to both endpoints.
static void signedDistance(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, const volumeType illegalHandling, labelList &nearestSurfaces, scalarField &distance)
Find signed distance to nearest surface. Outside is positive.
static void findAnyIntersection(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &)
Find any intersection. Return hit point information and.
static void findAllIntersections(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit >> &surfaceHits)
Find all intersections in order from start to end. Returns for.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
static const NamedEnum< volumeType, 4 > names
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
List< scalar > scalarList
A List of scalars.
vector point
Point is a vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
scalarField samples(nIntervals, 0)