31 #include "PointHitTemplate.H"
40 template<
class>
class FaceList,
44 template <
class ToPatch>
49 const ToPatch& targetPatch,
57 if (projectionDirection.size() !=
nPoints())
61 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
62 "projectPoints(const PrimitivePatch& "
63 ", const Field<PointType>&) const"
64 ) <<
"Projection direction field does not correspond to "
65 <<
"patch points." <<
endl
66 <<
"Size: " << projectionDirection.size()
67 <<
" Number of points: " <<
nPoints()
71 const labelList& slavePointOrder = localPointOrder();
73 const labelList& slaveMeshPoints = meshPoints();
79 if (targetPatch.size() == 0)
85 const labelListList& masterFaceFaces = targetPatch.faceFaces();
87 const ToPatch& masterFaces = targetPatch;
94 forAll (masterFaceCentres, faceI)
96 masterFaceCentres[faceI] =
110 Info<<
"N-squared projection set for all points" <<
endl;
114 label nNSquaredSearches = 0;
116 forAll (slavePointOrder, pointI)
119 const label curLocalPointLabel = slavePointOrder[pointI];
121 const PointType& curPoint =
122 points_[slaveMeshPoints[curLocalPointLabel]];
124 const PointType& curProjectionDir =
125 projectionDirection[curLocalPointLabel];
129 boolList visitedTargetFace(targetPatch.size(),
false);
130 bool doNSquaredSearch =
false;
132 bool foundEligible =
false;
134 scalar sqrDistance = GREAT;
140 doNSquaredSearch =
true;
147 doNSquaredSearch =
false;
151 masterFaces[curFace].ray
160 visitedTargetFace[curFace] =
true;
164 result[curLocalPointLabel] =
objectHit(
true, curFace);
176 foundEligible =
true;
177 result[curLocalPointLabel] =
objectHit(
false, curFace);
186 PointType missPlanePoint =
187 curPoint + curProjectionDir*curHit.
distance();
189 const labelList& masterNbrs = masterFaceFaces[curFace];
192 magSqr(missPlanePoint - masterFaceCentres[curFace]);
201 - masterFaceCentres[masterNbrs[nbrI]]
207 curFace = masterNbrs[nbrI];
211 if (visitedTargetFace[curFace])
215 doNSquaredSearch =
true;
220 if (debug)
Info<<
".";
224 if (doNSquaredSearch || !foundEligible)
230 Info<<
"p " << curLocalPointLabel <<
": ";
234 result[curLocalPointLabel] =
objectHit(
false, -1);
235 scalar minMissDistance = GREAT;
236 scalar minHitDistance = GREAT;
237 bool hitFound =
false;
239 forAll (masterFaces, faceI)
242 masterFaces[faceI].ray
257 if (hitDist < minHitDistance)
259 result[curLocalPointLabel] =
objectHit(
true, faceI);
263 minHitDistance = hitDist;
272 if (missDist < minMissDistance)
274 minMissDistance = missDist;
276 result[curLocalPointLabel] =
objectHit(
false, faceI);
284 Info<< result[curLocalPointLabel]
285 <<
" hit = " << minHitDistance
286 <<
" miss = " << minMissDistance <<
nl;
291 if (debug)
Info<<
"x";
297 Info<<
nl <<
"Executed " << nNSquaredSearches
298 <<
" n-squared searches out of total of "
309 template<
class>
class FaceList,
313 template <
class ToPatch>
318 const ToPatch& targetPatch,
326 if (projectionDirection.size() != this->size())
330 "labelList PrimitivePatch<Face, FaceList, PointField, PointType>::"
331 "projectFaceCentres(const PrimitivePatch& "
332 ", const Field<PointType>&) const"
333 ) <<
"Projection direction field does not correspond to patch faces."
334 <<
endl <<
"Size: " << projectionDirection.size()
335 <<
" Number of points: " << this->size()
344 const labelListList& masterFaceFaces = targetPatch.faceFaces();
346 const ToPatch& masterFaces = targetPatch;
350 forAll (masterFaceCentres, faceI)
352 masterFaceCentres[faceI] =
353 masterFaces[faceI].centre(masterPoints);
360 if (targetPatch.size() == 0)
378 label nNSquaredSearches = 0;
380 forAll (slaveFaceOrder, faceI)
383 const label curLocalFaceLabel = slaveFaceOrder[faceI];
385 const point& curFaceCentre =
386 slaveFaces[curLocalFaceLabel].centre(slaveGlobalPoints);
388 const vector& curProjectionDir =
389 projectionDirection[curLocalFaceLabel];
393 boolList visitedTargetFace(targetPatch.size(),
false);
394 bool doNSquaredSearch =
false;
396 bool foundEligible =
false;
398 scalar sqrDistance = GREAT;
402 if (faceI == 0 || nSquaredProjection_() > 0)
404 doNSquaredSearch =
true;
411 doNSquaredSearch =
false;
415 masterFaces[curFace].ray
424 visitedTargetFace[curFace] =
true;
428 result[curLocalFaceLabel] =
objectHit(
true, curFace);
440 foundEligible =
true;
441 result[curLocalFaceLabel] =
objectHit(
false, curFace);
449 PointType missPlanePoint =
450 curFaceCentre + curProjectionDir*curHit.
distance();
453 magSqr(missPlanePoint - masterFaceCentres[curFace]);
455 const labelList& masterNbrs = masterFaceFaces[curFace];
464 - masterFaceCentres[masterNbrs[nbrI]]
470 curFace = masterNbrs[nbrI];
474 if (visitedTargetFace[curFace])
478 doNSquaredSearch =
true;
483 if (debug)
Info<<
".";
487 if (doNSquaredSearch || !foundEligible)
493 Info<<
"p " << curLocalFaceLabel <<
": ";
497 result[curLocalFaceLabel] =
objectHit(
false, -1);
498 scalar minMissDistance = GREAT;
499 scalar minHitDistance = GREAT;
500 bool hitFound =
false;
502 forAll (masterFaces, faceI)
505 masterFaces[faceI].ray
520 if (hitDist < minHitDistance)
522 result[curLocalFaceLabel] =
objectHit(
true, faceI);
526 minHitDistance = hitDist;
535 if (missDist < minMissDistance)
537 minMissDistance = missDist;
539 result[curLocalFaceLabel] =
objectHit(
false, faceI);
547 Info <<
"r = " << result[curLocalFaceLabel] <<
nl;
552 if (debug)
Info<<
"x";
558 Info<<
nl <<
"Executed " << nNSquaredSearches
559 <<
" n-squared searches out of total of "
560 << this->size() <<
endl;