40 template<
class>
class FaceList,
44 template <
class ToPatch>
49 const ToPatch& targetPatch,
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();
78 const labelListList& masterFaceFaces = targetPatch.faceFaces();
80 const ToPatch& masterFaces = targetPatch;
87 forAll (masterFaceCentres, faceI)
89 masterFaceCentres[faceI] =
102 label nNSquaredSearches = 0;
104 forAll (slavePointOrder, pointI)
107 const label curLocalPointLabel = slavePointOrder[pointI];
109 const PointType& curPoint =
110 points_[slaveMeshPoints[curLocalPointLabel]];
112 const PointType& curProjectionDir =
113 projectionDirection[curLocalPointLabel];
117 boolList visitedTargetFace(targetPatch.size(),
false);
118 bool doNSquaredSearch =
false;
120 bool foundEligible =
false;
122 scalar sqrDistance = GREAT;
128 doNSquaredSearch =
true;
135 doNSquaredSearch =
false;
139 masterFaces[curFace].ray
148 visitedTargetFace[curFace] =
true;
152 result[curLocalPointLabel] =
objectHit(
true, curFace);
164 foundEligible =
true;
165 result[curLocalPointLabel] =
objectHit(
false, curFace);
174 PointType missPlanePoint =
175 curPoint + curProjectionDir*curHit.
distance();
177 const labelList& masterNbrs = masterFaceFaces[curFace];
180 magSqr(missPlanePoint - masterFaceCentres[curFace]);
189 - masterFaceCentres[masterNbrs[nbrI]]
195 curFace = masterNbrs[nbrI];
199 if (visitedTargetFace[curFace])
203 doNSquaredSearch =
true;
208 if (debug)
Info<<
".";
214 doNSquaredSearch || !foundEligible
221 Info<<
"p " << curLocalPointLabel <<
": ";
224 result[curLocalPointLabel] =
objectHit(
false, -1);
225 scalar minDistance = GREAT;
227 forAll (masterFaces, faceI)
230 masterFaces[faceI].ray
241 result[curLocalPointLabel] =
objectHit(
true, faceI);
252 if (missDist < minDistance)
254 minDistance = missDist;
256 result[curLocalPointLabel] =
objectHit(
false, faceI);
264 Info << result[curLocalPointLabel] <<
nl;
269 if (debug)
Info<<
"x";
275 Info<<
nl <<
"Executed " << nNSquaredSearches
276 <<
" n-squared searches out of total of "
287 template<
class>
class FaceList,
291 template <
class ToPatch>
296 const ToPatch& targetPatch,
304 if (projectionDirection.
size() != this->size())
308 "labelList PrimitivePatch<Face, FaceList, PointField, PointType>::"
309 "projectFaceCentres(const PrimitivePatch& "
310 ", const Field<PointType>&) const"
311 ) <<
"Projection direction field does not correspond to patch faces."
312 <<
endl <<
"Size: " << projectionDirection.
size()
313 <<
" Number of points: " << this->size()
322 const labelListList& masterFaceFaces = targetPatch.faceFaces();
324 const ToPatch& masterFaces = targetPatch;
326 const typename ToPatch::PointFieldType& masterPoints = targetPatch.points();
328 forAll (masterFaceCentres, faceI)
330 masterFaceCentres[faceI] =
331 masterFaces[faceI].centre(masterPoints);
338 const PointField& slaveGlobalPoints =
points();
349 label nNSquaredSearches = 0;
351 forAll (slaveFaceOrder, faceI)
354 const label curLocalFaceLabel = slaveFaceOrder[faceI];
356 const point& curFaceCentre =
357 slaveFaces[curLocalFaceLabel].centre(slaveGlobalPoints);
359 const vector& curProjectionDir =
360 projectionDirection[curLocalFaceLabel];
364 boolList visitedTargetFace(targetPatch.size(),
false);
365 bool doNSquaredSearch =
false;
367 bool foundEligible =
false;
369 scalar sqrDistance = GREAT;
375 doNSquaredSearch =
true;
382 doNSquaredSearch =
false;
386 masterFaces[curFace].ray
395 visitedTargetFace[curFace] =
true;
399 result[curLocalFaceLabel] =
objectHit(
true, curFace);
411 foundEligible =
true;
412 result[curLocalFaceLabel] =
objectHit(
false, curFace);
420 PointType missPlanePoint =
421 curFaceCentre + curProjectionDir*curHit.
distance();
424 magSqr(missPlanePoint - masterFaceCentres[curFace]);
426 const labelList& masterNbrs = masterFaceFaces[curFace];
435 - masterFaceCentres[masterNbrs[nbrI]]
441 curFace = masterNbrs[nbrI];
445 if (visitedTargetFace[curFace])
449 doNSquaredSearch =
true;
454 if (debug)
Info<<
".";
458 if (doNSquaredSearch || !foundEligible)
464 Info<<
"p " << curLocalFaceLabel <<
": ";
467 result[curLocalFaceLabel] =
objectHit(
false, -1);
468 scalar minDistance = GREAT;
470 forAll (masterFaces, faceI)
473 masterFaces[faceI].ray
484 result[curLocalFaceLabel] =
objectHit(
true, faceI);
495 if (missDist < minDistance)
497 minDistance = missDist;
499 result[curLocalFaceLabel] =
objectHit(
false, faceI);
507 Info << result[curLocalFaceLabel] <<
nl;
512 if (debug)
Info<<
"x";
518 Info<<
nl <<
"Executed " << nNSquaredSearches
519 <<
" n-squared searches out of total of "
520 << this->size() <<
endl;