diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index da1c31dc69..cb0dbd703b 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -2183,54 +2183,59 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits pointIndexHitAndFeature(edHit, featureHit) ); } -// else if (firstPass) -// { -// label hitIndex = nearestEdgeHit.index(); -// -// // Calc new edge location -//// Foam::point newPt = -//// 0.5 -//// *( -//// nearestEdgeHit.hitPoint() -//// + edHit.hitPoint() -//// ); -// -// pointIndexHit pHitOld = -// edgeLocationTreePtr_().findNearest -// ( -// nearestEdgeHit.hitPoint(), GREAT -// ); -// -// pointIndexHit pHitNew = -// edgeLocationTreePtr_().findNearest -// ( -// edHit.hitPoint(), GREAT -// ); -// -// if -// ( -// pHitNew.hitPoint() - pHitOld.hitPoint() -// ) -// { -// edHit.setPoint(pHit.hitPoint()); -// -// featureEdgeHits[hitIndex] = -// pointIndexHitAndFeature(edHit, featureHit); -// -// existingEdgeLocations_[hitIndex] = -// edHit.hitPoint(); -// -// // Change edge location in featureEdgeHits -// // remove index from edge tree -// // reinsert new point into tree -// edgeLocationTreePtr_().remove(hitIndex); -// edgeLocationTreePtr_().insert -// ( -// hitIndex, -// hitIndex + 1 -// ); -// } -// } + else if (firstPass) + { + label hitIndex = nearestEdgeHit.index(); + + // Calc new edge location + Foam::point newPt = + 0.5 + *( + nearestEdgeHit.hitPoint() + + edHit.hitPoint() + ); + + pointIndexHit pHitOld = + edgeLocationTreePtr_().findNearest + ( + nearestEdgeHit.hitPoint(), GREAT + ); + + pointIndexHit pHitNew = + edgeLocationTreePtr_().findNearest + ( + edHit.hitPoint(), GREAT + ); + + if + ( + magSqr(pHitNew.hitPoint() - edHit.hitPoint()) + < magSqr + ( + pHitOld.hitPoint() + - nearestEdgeHit.hitPoint() + ) + ) + { + edHit.setPoint(edHit.hitPoint()); + + featureEdgeHits[hitIndex] = + pointIndexHitAndFeature(edHit, featureHit); + + existingEdgeLocations_[hitIndex] = + edHit.hitPoint(); + + // Change edge location in featureEdgeHits + // remove index from edge tree + // reinsert new point into tree + edgeLocationTreePtr_().remove(hitIndex); + edgeLocationTreePtr_().insert + ( + hitIndex, + hitIndex + 1 + ); + } + } } } }