From 80a3172c779b806e8d816701d527de995874899f Mon Sep 17 00:00:00 2001 From: papush! Date: Tue, 8 Mar 2022 14:25:59 +0100 Subject: [PATCH] refactor surface point filter --- src/project_surface_points_on_poly.cc | 28 +++++++++++++-------------- src/surface_points_filter.cc | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/project_surface_points_on_poly.cc b/src/project_surface_points_on_poly.cc index 0dc3899..5375bda 100644 --- a/src/project_surface_points_on_poly.cc +++ b/src/project_surface_points_on_poly.cc @@ -41,27 +41,27 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData( vtkInformationVector **inputVector, vtkInformationVector *outputVector) { (void) request; - vtkUnstructuredGrid* us = vtkUnstructuredGrid::GetData(inputVector[0]); - vtkPolyData* pd = vtkPolyData::GetData(inputVector[1]); + vtkUnstructuredGrid* tetMesh = vtkUnstructuredGrid::GetData(inputVector[0]); + vtkPolyData* polyMesh = vtkPolyData::GetData(inputVector[1]); vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector); - output->CopyStructure(us); - output->GetPointData()->PassData(us->GetPointData()); - output->GetCellData()->PassData(us->GetCellData()); + output->CopyStructure(tetMesh); + output->GetPointData()->PassData(tetMesh->GetPointData()); + output->GetCellData()->PassData(tetMesh->GetCellData()); /* Generate cell links, these tell us which cell a point belongs to. */ vtkNew links; - links->BuildLinks(pd); + links->BuildLinks(polyMesh); vtkNew kdTree; - kdTree->BuildLocatorFromPoints(pd->GetPoints()); + kdTree->BuildLocatorFromPoints(polyMesh->GetPoints()); - vtkIdTypeArray *externalPoints = - vtkIdTypeArray::SafeDownCast(us->GetFieldData()->GetArray("external_points")); - for (vtkIdType i = 0; i < externalPoints->GetNumberOfTuples(); i++) { + vtkIdTypeArray *surfacePoints = + vtkIdTypeArray::SafeDownCast(tetMesh->GetFieldData()->GetArray("surface_points")); + for (vtkIdType i = 0; i < surfacePoints->GetNumberOfTuples(); i++) { double p[3]; - us->GetPoint(externalPoints->GetTuple1(i), p); + tetMesh->GetPoint(surfacePoints->GetTuple1(i), p); double dist2; vtkIdType closest = kdTree->FindClosestPoint(p, dist2); vtkIdType *cellIds = links->GetCells(closest); @@ -73,7 +73,7 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData( for (vtkIdType j = 0; j < nCells; j++) { vtkIdType cellId = cellIds[j]; double direction[3]; - double dist = pointTriangleDistance(p, pd->GetCell(cellId), direction); + double dist = pointTriangleDistance(p, polyMesh->GetCell(cellId), direction); /* Find the closest one. */ if (dist < min_dist) { min_dist = dist; @@ -85,8 +85,8 @@ vtkTypeBool ProjectSurfacePointsOnPoly::RequestData( vtkMath::MultiplyScalar(min_direction, min_dist); vtkMath::Subtract(p, min_direction, p); - us->GetPoints()->SetPoint(externalPoints->GetTuple1(i), p); - us->Modified(); + tetMesh->GetPoints()->SetPoint(surfacePoints->GetTuple1(i), p); + tetMesh->Modified(); } return true; diff --git a/src/surface_points_filter.cc b/src/surface_points_filter.cc index 4579d23..e87f625 100644 --- a/src/surface_points_filter.cc +++ b/src/surface_points_filter.cc @@ -52,7 +52,7 @@ vtkTypeBool SurfacePointsFilter::RequestData( /* Create an array to store the IDs of external points. */ vtkNew externalPoints; - externalPoints->SetName("external_points"); + externalPoints->SetName("surface_points"); externalPoints->SetNumberOfComponents(1); vtkNew isExternal; isExternal->SetName("bl");