52 vtkInformation *vtkNotUsed(request),
53 vtkInformationVector **inputVector,
54 vtkInformationVector *outputVector)
56 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
57 vtkInformation *outInfo = outputVector->GetInformationObject(0);
59 vtkPolyData *input = vtkPolyData::SafeDownCast(
60 inInfo->Get(vtkDataObject::DATA_OBJECT()));
61 vtkPolyData *output = vtkPolyData::SafeDownCast(
62 outInfo->Get(vtkDataObject::DATA_OBJECT()));
67 double point[3], closestPoint[3];
70 vtkCellLocator *locator;
71 vtkGenericCell *genericCell;
75 vtkErrorMacro(<<
"No reference surface!");
79 int numberOfPoints = input->GetNumberOfPoints();
81 output->DeepCopy(input);
83 vtkPointData* outputPointData = output->GetPointData();
86 outputPointData->InterpolateAllocate(referencePointData,numberOfPoints);
90 locator = vtkCellLocator::New();
91 genericCell = vtkGenericCell::New();
94 locator->BuildLocator();
96 for (i=0; i<numberOfPoints; i++)
98 input->GetPoint(i,point);
99 locator->FindClosestPoint(point,closestPoint,genericCell,cellId,subId,distance2);
102 double* weights =
new double[genericCell->GetNumberOfPoints()];
103 genericCell->EvaluatePosition(closestPoint,NULL,subId,pcoords,distance2,weights);
104 outputPointData->InterpolatePoint(referencePointData,i,genericCell->GetPointIds(),weights);
109 double testPoint0[3], testPoint1[3];
110 vtkIdType pointId = genericCell->GetPointId(subId);
111 input->GetPoint(genericCell->GetPointId(subId),testPoint0);
112 input->GetPoint(genericCell->GetPointId(subId+1),testPoint1);
113 if (vtkMath::Distance2BetweenPoints(closestPoint,testPoint1) < vtkMath::Distance2BetweenPoints(closestPoint,testPoint0))
115 pointId = genericCell->GetPointId(subId+1);
117 outputPointData->CopyData(referencePointData,pointId,i);
122 genericCell->Delete();