fix
This commit is contained in:
parent
56b426948c
commit
6c2e3e8a89
@ -82,17 +82,24 @@ static void moveSurfacePoint(vtkUnstructuredGrid *tetMesh,
|
|||||||
tetMesh->GetPoint(pointId, point);
|
tetMesh->GetPoint(pointId, point);
|
||||||
double direction[3];
|
double direction[3];
|
||||||
double distance;
|
double distance;
|
||||||
|
|
||||||
|
double radiusScale = 5.;
|
||||||
|
|
||||||
closestPolyMeshPoint(polyMesh, point, kdTree, links, direction, &distance);
|
closestPolyMeshPoint(polyMesh, point, kdTree, links, direction, &distance);
|
||||||
vtkNew<vtkIdList> affectedPoints;
|
vtkNew<vtkIdList> affectedPoints;
|
||||||
kdTree->FindPointsWithinRadius(distance * 2, point, affectedPoints);
|
kdTree->FindPointsWithinRadius(distance * radiusScale, point, affectedPoints);
|
||||||
for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) {
|
|
||||||
|
if(distance > 0) for (vtkIdType j = 0; j < affectedPoints->GetNumberOfIds(); j++) {
|
||||||
vtkIdType affectedPointId = affectedPoints->GetId(j);
|
vtkIdType affectedPointId = affectedPoints->GetId(j);
|
||||||
double affectedPoint[3];
|
double affectedPoint[3];
|
||||||
tetMesh->GetPoint(affectedPointId, affectedPoint);
|
tetMesh->GetPoint(affectedPointId, affectedPoint);
|
||||||
double dist2 = vtkMath::Distance2BetweenPoints(affectedPoint, point);
|
double dist2 = vtkMath::Distance2BetweenPoints(affectedPoint, point);
|
||||||
|
if(dist2 > (distance * radiusScale) * (distance * radiusScale)) continue;
|
||||||
|
|
||||||
double motion[3] = {direction[0], direction[1], direction[2]};
|
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);
|
vtkMath::MultiplyScalar(motion, factor);
|
||||||
|
//std::cout << std::sqrt(dist2) << " " << (distance * radiusScale) << " " << factor << "\n";
|
||||||
motionVectors[affectedPointId * 3 + 0] += motion[0];
|
motionVectors[affectedPointId * 3 + 0] += motion[0];
|
||||||
motionVectors[affectedPointId * 3 + 1] += motion[1];
|
motionVectors[affectedPointId * 3 + 1] += motion[1];
|
||||||
motionVectors[affectedPointId * 3 + 2] += motion[2];
|
motionVectors[affectedPointId * 3 + 2] += motion[2];
|
||||||
@ -143,14 +150,18 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData(
|
|||||||
if (i == surfacePoints->GetValue(j)) skip = true;
|
if (i == surfacePoints->GetValue(j)) skip = true;
|
||||||
}
|
}
|
||||||
if (skip) continue;
|
if (skip) continue;
|
||||||
|
|
||||||
|
if(numberOfAffectors[i] != 0) {
|
||||||
double point[3];
|
double point[3];
|
||||||
tetMesh->GetPoint(i, point);
|
tetMesh->GetPoint(i, point);
|
||||||
double *motion = motionVectors.data() + i;
|
double *motion = motionVectors.data() + (i * 3);
|
||||||
|
|
||||||
vtkMath::MultiplyScalar(motion, 1. / numberOfAffectors[i]);
|
vtkMath::MultiplyScalar(motion, 1. / numberOfAffectors[i]);
|
||||||
vtkMath::Subtract(point, motion, point);
|
vtkMath::Subtract(point, motion, point);
|
||||||
tetMesh->GetPoints()->SetPoint(i, point);
|
tetMesh->GetPoints()->SetPoint(i, point);
|
||||||
tetMesh->Modified();
|
tetMesh->Modified();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user