This commit is contained in:
CookieKastanie 2022-03-10 22:09:21 +01:00
parent 56b426948c
commit 6c2e3e8a89

View File

@ -82,17 +82,24 @@ static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
tetMesh->GetPoint(pointId, point);
double direction[3];
double distance;
double radiusScale = 5.;
closestPolyMeshPoint(polyMesh, point, kdTree, links, direction, &distance);
vtkNew<vtkIdList> affectedPoints;
kdTree->FindPointsWithinRadius(distance * 2, point, affectedPoints);
for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) {
kdTree->FindPointsWithinRadius(distance * radiusScale, point, affectedPoints);
if(distance > 0) for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) {
vtkIdType affectedPointId = affectedPoints->GetId(j);
double affectedPoint[3];
tetMesh->GetPoint(affectedPointId, affectedPoint);
double dist2 = vtkMath::Distance2BetweenPoints(affectedPoint, point);
if(dist2 > (distance * radiusScale) * (distance * radiusScale)) continue;
double motion[3] = {direction[0], direction[1], direction[2]};
double factor = 1 - std::sqrt(dist2) / (distance * 2);
double factor = 1. - std::sqrt(dist2) / (distance * radiusScale);
vtkMath::MultiplyScalar(motion, factor);
//std::cout << std::sqrt(dist2) << " " << (distance * radiusScale) << " " << factor << "\n";
motionVectors[affectedPointId * 3 + 0] += motion[0];
motionVectors[affectedPointId * 3 + 1] += motion[1];
motionVectors[affectedPointId * 3 + 2] += motion[2];
@ -143,13 +150,17 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
if (i == surfacePoints->GetValue(j)) skip = true;
}
if (skip) continue;
double point[3];
tetMesh->GetPoint(i, point);
double *motion = motionVectors.data() + i;
vtkMath::MultiplyScalar(motion, 1. / numberOfAffectors[i]);
vtkMath::Subtract(point, motion, point);
tetMesh->GetPoints()->SetPoint(i, point);
tetMesh->Modified();
if(numberOfAffectors[i] != 0) {
double point[3];
tetMesh->GetPoint(i, point);
double *motion = motionVectors.data() + (i * 3);
vtkMath::MultiplyScalar(motion, 1. / numberOfAffectors[i]);
vtkMath::Subtract(point, motion, point);
tetMesh->GetPoints()->SetPoint(i, point);
tetMesh->Modified();
}
}
return true;