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];
174 intersectInfo.setSize(newI);
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]);
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]);
539 vector d(r.refPoint()-near[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)
595 surfPoints.append(samples[i]);
596 surfIndices.append(i);
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();
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A direction and a reference point.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
void size(const label)
Override size to be inconsistent with allocated storage.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
ray planeIntersect(const plane &) const
Return the cutting line between this plane and another.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
A bounding box defined in terms of the points at its extremities.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
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.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
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.
Various functions to operate on Lists.
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
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.
List< scalar > scalarList
A List of scalars.
List< label > labelList
A List of labels.
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.
Accumulates point constraints through successive applications of the applyConstraint function...
dimensioned< scalar > magSqr(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
void setSize(const label)
Reset size of List.
const point & max() const
Maximum describing the bounding box.
vector point
Point is a vector.
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,.
dimensioned< scalar > mag(const dimensioned< Type > &)
const boundBox & bounds() const
Return const reference to boundBox.
static const NamedEnum< volumeType, 4 > names
const point & min() const
Minimum describing the bounding box.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest)
Find the boundBox of the selected surfaces.