56{
57 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
58 vtkInformation *outInfo = outputVector->GetInformationObject(0);
59
60 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
61 inInfo->Get(vtkDataObject::DATA_OBJECT()));
62 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
63 outInfo->Get(vtkDataObject::DATA_OBJECT()));
64
65 vtkIdType i;
66 vtkIdType cellId;
67 int subId;
68 double point[3], closestPoint[3];
69 double pcoords[3];
70 double distance2;
71 vtkCellLocator *locator;
72 vtkGenericCell *genericCell;
73
75 {
76 vtkErrorMacro(<<"No reference mesh!");
77 return 1;
78 }
79
80 int numberOfPoints = input->GetNumberOfPoints();
81
82 output->DeepCopy(input);
83
84 vtkPointData* outputPointData = output->GetPointData();
85 vtkPointData* referencePointData = this->
ReferenceMesh->GetPointData();
86
87 outputPointData->InterpolateAllocate(referencePointData,numberOfPoints);
88
89 locator = vtkCellLocator::New();
90 genericCell = vtkGenericCell::New();
91
93 locator->BuildLocator();
95
96 for (i=0; i<numberOfPoints; i++)
97 {
98 input->GetPoint(i,point);
99 locator->FindClosestPoint(point,closestPoint,genericCell,cellId,subId,distance2);
100 double* weights = new double[genericCell->GetNumberOfPoints()];
101 genericCell->EvaluatePosition(closestPoint,NULL,subId,pcoords,distance2,weights);
102
103 outputPointData->InterpolatePoint(referencePointData,i,genericCell->GetPointIds(),weights);
104
105 delete[] weights;
106 }
107
108 locator->Delete();
109 genericCell->Delete();
110
111 return 1;
112}