69 vtkInformation *vtkNotUsed(request),
70 vtkInformationVector **inputVector,
71 vtkInformationVector *outputVector)
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
76 vtkPolyData *input = vtkPolyData::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkPolyData *output = vtkPolyData::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
83 vtkErrorMacro(<<
"DistanceToSpheresArrayName not set.");
89 vtkErrorMacro(<<
"Spheres not set");
93 int numberOfInputPoints = input->GetNumberOfPoints();
95 output->DeepCopy(input);
100 bool createArray = !distanceToSpheresArray;
104 distanceToSpheresArray = vtkDoubleArray::New();
106 distanceToSpheresArray->SetNumberOfComponents(1);
107 distanceToSpheresArray->SetNumberOfTuples(numberOfInputPoints);
110 output->GetPointData()->AddArray(distanceToSpheresArray);
113 int numberOfSpheres = this->
Spheres->GetNumberOfPoints();
115 vtkDataArray* scalarArray = this->
Spheres->GetPointData()->GetScalars();
119 double point[3], sphereCenter[3];
120 double sphereRadius = 0.;
121 double distanceToSpheres;
122 for (
int i=0; i<numberOfInputPoints; i++)
124 distanceToSpheres=distanceToSpheresArray->GetComponent(i,0);
125 input->GetPoint(i,point);
126 for (
int j=0; j<numberOfSpheres; j++)
128 this->
Spheres->GetPoint(j,sphereCenter);
129 if (scalarArray) sphereRadius = scalarArray->GetComponent(j,0);
130 double newDist = sqrt(vtkMath::Distance2BetweenPoints(point,sphereCenter)) - sphereRadius;
131 if (newDist<0.) newDist = 0.;
134 if (newDist<this->
MinDistance) newDist = this->MinDistance;
135 if (newDist>maxd) newDist = maxd;
136 if (newDist<distanceToSpheres) distanceToSpheres = newDist;
138 distanceToSpheresArray->SetComponent(i,0,distanceToSpheres);
141 if (createArray) distanceToSpheresArray->Delete();