55{
56 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
57 vtkInformation *outInfo = outputVector->GetInformationObject(0);
58
59 vtkPolyData *input = vtkPolyData::SafeDownCast(
60 inInfo->Get(vtkDataObject::DATA_OBJECT()));
61 vtkPolyData *output = vtkPolyData::SafeDownCast(
62 outInfo->Get(vtkDataObject::DATA_OBJECT()));
63
64 vtkIdType i;
65 vtkIdType cellId;
66 int subId;
67 double point[3], closestPoint[3];
68 double pcoords[3];
69 double distance2;
70 vtkCellLocator *locator;
71 vtkGenericCell *genericCell;
72
74 {
75 vtkErrorMacro(<<"No reference surface!");
76 return 1;
77 }
78
79 int numberOfPoints = input->GetNumberOfPoints();
80
81 output->DeepCopy(input);
82
83 vtkPointData* outputPointData = output->GetPointData();
85
86 outputPointData->InterpolateAllocate(referencePointData,numberOfPoints);
87
89
90 locator = vtkCellLocator::New();
91 genericCell = vtkGenericCell::New();
92
94 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);
101 {
102 double* weights = new double[genericCell->GetNumberOfPoints()];
103 genericCell->EvaluatePosition(closestPoint,NULL,subId,pcoords,distance2,weights);
104 outputPointData->InterpolatePoint(referencePointData,i,genericCell->GetPointIds(),weights);
105 delete[] weights;
106 }
107 else
108 {
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))
114 {
115 pointId = genericCell->GetPointId(subId+1);
116 }
117 outputPointData->CopyData(referencePointData,pointId,i);
118 }
119 }
120
121 locator->Delete();
122 genericCell->Delete();
123
124 return 1;
125}