67 vtkInformation *vtkNotUsed(request),
68 vtkInformationVector **inputVector,
69 vtkInformationVector *outputVector)
71 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
72 vtkInformation *outInfo = outputVector->GetInformationObject(0);
74 vtkPolyData *input = vtkPolyData::SafeDownCast(
75 inInfo->Get(vtkDataObject::DATA_OBJECT()));
76 vtkPolyData *output = vtkPolyData::SafeDownCast(
77 outInfo->Get(vtkDataObject::DATA_OBJECT()));
79 output->CopyStructure(input);
80 output->GetPointData()->PassData(input->GetPointData());
81 output->GetCellData()->PassData(input->GetCellData());
82 output->GetFieldData()->PassData(input->GetFieldData());
92 this->
Stencils->ReallocateOnBuildOff();
95 vtkCellLocator *cellLocator = NULL;
96 double* weights = NULL;
99 weights =
new double[input->GetMaxCellSize()];
100 cellLocator = vtkCellLocator::New();
101 cellLocator->SetDataSet(input);
102 cellLocator->BuildLocator();
105 vtkIdType numberOfPoints = input->GetNumberOfPoints();
107 double displacement[3], stencilPoint[3], weight;
108 double point[3], newPoint[3];
110 vtkIdList* constrainCellIds = vtkIdList::New();
111 constrainCellIds->SetNumberOfIds(input->GetNumberOfPoints());
112 for (vtkIdType pointId=0; pointId<numberOfPoints; pointId++)
114 constrainCellIds->SetId(pointId,0);
120 for (vtkIdType pointId=0; pointId<numberOfPoints; pointId++)
127 displacement[0] = displacement[1] = displacement[2] = 0.0;
129 for (
int j=0; j<numberOfStencilPoints; j++)
131 output->GetPoint(stencil->
GetPointId(j),stencilPoint);
133 displacement[0] += weight * stencilPoint[0];
134 displacement[1] += weight * stencilPoint[1];
135 displacement[2] += weight * stencilPoint[2];
138 output->GetPoint(pointId,point);
139 displacement[0] -= weight * point[0];
140 displacement[1] -= weight * point[1];
141 displacement[2] -= weight * point[2];
145 vtkMath::Normalize(displacement);
157 double closestPoint[3];
160 double dist2, pcoords[3];
161 if (input->GetCell(constrainCellIds->GetId(pointId))->EvaluatePosition(newPoint,closestPoint,subId,pcoords,dist2,weights)==0)
163 cellLocator->FindClosestPoint(newPoint,closestPoint,cellId,subId,dist2);
164 constrainCellIds->SetId(pointId,cellId);
166 newPoint[0] = closestPoint[0];
167 newPoint[1] = closestPoint[1];
168 newPoint[2] = closestPoint[2];
171 output->GetPoints()->SetPoint(pointId,newPoint);
175 constrainCellIds->Delete();
185 cellLocator->Delete();