167{
168 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
169 vtkInformation *outInfo = outputVector->GetInformationObject(0);
170
171 vtkPolyData *input = vtkPolyData::SafeDownCast(
172 inInfo->Get(vtkDataObject::DATA_OBJECT()));
173 vtkImageData *output = vtkImageData::SafeDownCast(
174 outInfo->Get(vtkDataObject::DATA_OBJECT()));
175
177 {
178 vtkErrorMacro(<<"Error: RadiusArrayName not specified!");
179 return 1;
180 }
181
182 if (input->GetPointData()->GetArray(this->RadiusArrayName) == NULL)
183 {
184 vtkErrorMacro(<<"Error: RadiusArray with name specified does not exist!");
185 return 1;
186 }
187
188 output->SetExtent(outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
189 output->AllocateScalars(outInfo);
190
191 vtkDoubleArray *functionArray = vtkDoubleArray::SafeDownCast(output->GetPointData()->GetScalars());
193
194 int numberOfOutputPoints = output->GetNumberOfPoints();
195
196#if 0
197 vtkImplicitFunction* function;
199 {
203 function = polyBall;
204 }
205 else
206 {
210 function = polyBall;
211 }
212
213 double point[3];
214 int i;
215 for (i=0; i<numberOfOutputPoints; i++)
216 {
217 output->GetPoint(i,point);
218 double polyBallFunction = function->EvaluateFunction(point);
219 functionArray->SetComponent(i,0,polyBallFunction);
220 }
221
222 function->Delete();
223#endif
224
226 {
228 vtkDoubleArray* radiusArray = vtkDoubleArray::SafeDownCast(input->GetPointData()->GetArray(this->RadiusArrayName));
229 int numberOfInputPoints = input->GetNumberOfPoints();
230 int extent[6];
231 double x[3], p[3], r;
232 double boundingBox0[3], boundingBox1[3];
233 int ijk0[3], ijk1[3], ijk[3];
234 int ijkExtent[6];
235 double pcoords[3];
236 int inBounds0, inBounds1;
237 double radiusFactor = 2.0;
238 output->GetExtent(extent);
239 double sphereFunctionValue, currentSphereFunctionValue;
240 int n;
241 int i, j, k;
242 vtkIdType outputId;
243 for (n=0; n<numberOfInputPoints; n++)
244 {
245 input->GetPoint(n,p);
246 r = radiusArray->GetValue(n);
247 boundingBox0[0] = p[0] - radiusFactor * r;
248 boundingBox0[1] = p[1] - radiusFactor * r;
249 boundingBox0[2] = p[2] - radiusFactor * r;
250 boundingBox1[0] = p[0] + radiusFactor * r;
251 boundingBox1[1] = p[1] + radiusFactor * r;
252 boundingBox1[2] = p[2] + radiusFactor * r;
253 inBounds0 = output->ComputeStructuredCoordinates(boundingBox0,ijk0,pcoords);
254 inBounds1 = output->ComputeStructuredCoordinates(boundingBox1,ijk1,pcoords);
255 if (!inBounds0 && !inBounds1)
256 {
257 continue;
258 }
259 ijkExtent[0] = ijk0[0] < extent[0] ? extent[0] : ijk0[0];
260 ijkExtent[1] = ijk1[0] > extent[1] ? extent[1] : ijk1[0];
261 ijkExtent[2] = ijk0[1] < extent[2] ? extent[2] : ijk0[1];
262 ijkExtent[3] = ijk1[1] > extent[3] ? extent[3] : ijk1[1];
263 ijkExtent[4] = ijk0[2] < extent[4] ? extent[4] : ijk0[2];
264 ijkExtent[5] = ijk1[2] > extent[5] ? extent[5] : ijk1[2];
265 for (k=ijkExtent[4]; k<=ijkExtent[5]; k++)
266 {
267 for (j=ijkExtent[2]; j<=ijkExtent[3]; j++)
268 {
269 for (i=ijkExtent[0]; i<=ijkExtent[1]; i++)
270 {
271 ijk[0] = i;
272 ijk[1] = j;
273 ijk[2] = k;
274 outputId = output->ComputePointId(ijk);
275 output->GetPoint(outputId,x);
276 sphereFunctionValue = ((x[0] - p[0]) * (x[0] - p[0]) + (x[1] - p[1]) * (x[1] - p[1]) + (x[2] - p[2]) * (x[2] - p[2])) - r * r;
277 currentSphereFunctionValue = functionArray->GetComponent(outputId,0);
278 if (sphereFunctionValue < currentSphereFunctionValue)
279 {
280 functionArray->SetComponent(outputId,0,sphereFunctionValue);
281 }
282 }
283 }
284 }
285 }
286 }
287 else
288 {
292 double point[3];
293 int i;
294 for (i=0; i<numberOfOutputPoints; i++)
295 {
296 output->GetPoint(i,point);
298 functionArray->SetComponent(i,0,polyBallLineValue);
299 }
300 }
301
303 {
304 int i;
305 for (i=0; i<numberOfOutputPoints; i++)
306 {
307 double functionValue = functionArray->GetComponent(i,0);
308 functionValue *= -1.0;
309 functionArray->SetComponent(i,0,functionValue);
310 }
311 }
312
313 return 1;
314}
virtual void SetInput(vtkPolyData *)
virtual void SetPolyBallRadiusArrayName(const char *)
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
virtual void SetPolyBallRadiusArrayName(const char *)
static vtkvmtkPolyBall * New()
virtual void SetInput(vtkPolyData *)
#define VTK_VMTK_LARGE_DOUBLE