76 vtkInformation * vtkNotUsed(request),
77 vtkInformationVector **inputVector,
78 vtkInformationVector *outputVector)
81 vtkInformation* outInfo = outputVector->GetInformationObject(0);
82 vtkImageData *outputImage = vtkImageData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
83 vtkInformation *inInfoImage = inputVector[0]->GetInformationObject(0);
84 vtkImageData *inputImage = vtkImageData::SafeDownCast(inInfoImage->Get(vtkDataObject::DATA_OBJECT()));
88 vtkErrorMacro(<<
"Centerline not set");
93 if (inputImage == NULL || this->
Centerline == NULL || outputImage==NULL)
97 int outputExtent[6] = {0,-1,0,-1,0,-1};
98 outputImage->SetExtent(outputExtent);
99 if (this->GetOutputInformation(0))
101 this->GetOutputInformation(0)->Set(
102 vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
103 this->GetOutputInformation(0)->Get(
104 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()), 6);
106 outputImage->AllocateScalars(outInfo);
109 if ( inputImage == NULL)
111 vtkErrorMacro(<<
"RequestInformation: InputImageData is not set.");
116 vtkErrorMacro(<<
"RequestInformation: Centerline is not set.");
121 int firstLineInCells;
122 vtkCell* line = NULL;
124 for (firstLineInCells=0; firstLineInCells < this->
Centerline->GetNumberOfCells(); firstLineInCells++)
126 line = this->
Centerline->GetCell(firstLineInCells);
127 if (line->GetCellType() == VTK_LINE || line->GetCellType() == VTK_POLY_LINE)
132 if (!line || (!(firstLineInCells < (
int) this->
Centerline->GetNumberOfCells())))
134 vtkErrorMacro(<<
"RequestInformation: no line in input vtkPolyData.");
138 vtkPoints* linePoints = line->GetPoints();
140 int numberOfLinePoints = linePoints->GetNumberOfPoints();
142 if (numberOfLinePoints < 2)
144 vtkErrorMacro(<<
"RequestInformation: Too few points in Centerline.");
149 double inDataOrigin[3];
150 inInfoImage->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), inDataExtent);
153 inputImage->GetOrigin(inDataOrigin);
162 double firstPoint[3], secondPoint[3], zspace;
163 linePoints->GetPoint(0,firstPoint);
164 linePoints->GetPoint(1,secondPoint);
166 zspace = sqrt(vtkMath::Distance2BetweenPoints(firstPoint,secondPoint));
176 outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),this->
OutputExtent,6);
177 outInfo->Set(vtkDataObject::SPACING(),this->
OutputSpacing,3);
178 outInfo->Set(vtkDataObject::ORIGIN(),this->
OutputOrigin,3);
196 vtkInformation* vtkNotUsed( request ),
197 vtkInformationVector** inputVector,
198 vtkInformationVector* outputVector)
201 vtkInformation* outInfo = outputVector->GetInformationObject(0);
202 vtkImageData *outputImage = vtkImageData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
203 vtkInformation *inInfoImage = inputVector[0]->GetInformationObject(0);
204 vtkImageData *inputImage = vtkImageData::SafeDownCast(inInfoImage->Get(vtkDataObject::DATA_OBJECT()));
208 vtkErrorMacro(<<
"Centerline not set");
212 if (inputImage == NULL)
214 vtkErrorMacro(<<
"RequestData: InputImageData is not set.");
219 if (inputImage == NULL || outputImage==NULL)
223 int outputExtent[6] = {0,-1,0,-1,0,-1};
224 outputImage->SetExtent(outputExtent);
225 if (this->GetOutputInformation(0))
227 this->GetOutputInformation(0)->Set(
228 vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
229 this->GetOutputInformation(0)->Get(
230 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()), 6);
232 outputImage->AllocateScalars(outInfo);
240 vtkErrorMacro(<<
"RequestData: FrenetTangentArrayName is not set.");
247 vtkErrorMacro(<<
"RequestData: InputPolyData does not contain an array with the specified FrenetTangentArrayName.");
254 vtkErrorMacro(<<
"RequestData: ParallelTransportNormalsArrayName is not set.");
262 vtkErrorMacro(<<
"RequestData: InputPolyData does not contain an array with the specified ParallelTransportNormalsArrayName.");
266 int firstLineInCells;
267 vtkCell* line = NULL;
269 for (firstLineInCells=0; firstLineInCells<this->
Centerline->GetNumberOfCells(); firstLineInCells++)
271 line = this->
Centerline->GetCell(firstLineInCells);
272 if (line->GetCellType() == VTK_LINE || line->GetCellType() == VTK_POLY_LINE)
278 if (!line || (!(firstLineInCells < (
int) this->
Centerline->GetNumberOfCells())))
280 vtkErrorMacro(<<
"RequestData: no line in input vtkPolyData.");
284 if (line->GetNumberOfPoints() < 2)
286 vtkErrorMacro(<<
"RequestData: Too few points in Centerline.");
290 vtkPoints* linePoints = line->GetPoints();
293 outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), outExtent);
295 outputImage->SetExtent(outExtent);
296 if (this->GetOutputInformation(0))
298 this->GetOutputInformation(0)->Set(
299 vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
300 this->GetOutputInformation(0)->Get(
301 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()), 6);
309 inInfoImage->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), inExtent);
312 if (inExtent[1] < inExtent[0] ||
313 inExtent[3] < inExtent[2] ||
314 inExtent[5] < inExtent[4])
319 vtkImageReslice* reslice = vtkImageReslice::New();
320 reslice->SetOutputDimensionality(2);
321 reslice->SetInputData(inputImage);
322 reslice->SetInterpolationModeToCubic();
324 reslice->TransformInputSamplingOff();
331 for (
int slice=outExtent[4]; slice<(outExtent[5] + 1);slice++)
333 double centerSlice[3];
334 linePoints->GetPoint(slice,centerSlice);
340 frenetTangentArray->GetTuple(slice,t);
344 parallelTransportNormalsArray->GetTuple(slice,p);
348 tp[0] = (t[1]*p[2]- t[2]*p[1]);
349 tp[1] = (t[2]*p[0]- t[0]*p[2]);
350 tp[2] = (t[0]*p[1]- t[1]*p[0]);
353 reslice->SetResliceAxesDirectionCosines(p[0],p[1],p[2],tp[0],tp[1],tp[2],t[0],t[1],t[2]);
355 reslice->SetResliceAxesOrigin(centerSlice[0],centerSlice[1],centerSlice[2]);
359 double outputorigin[3];
360 outputorigin[0] = 0.0;
361 outputorigin[1] = 0.0;
362 outputorigin[2] = 0.0;
367 int resliceUpdateExtent[6];
368 resliceUpdateExtent[0] = outExtent[0];
369 resliceUpdateExtent[1] = outExtent[1];
370 resliceUpdateExtent[2] = outExtent[2];
371 resliceUpdateExtent[3] = outExtent[3];
372 resliceUpdateExtent[4] = 0;
373 resliceUpdateExtent[5] = 0;
375 vtkIdType outputInc[3];
376 outputImage->GetIncrements(outputInc);
378 int scalarType = reslice->GetOutput()->GetScalarType();
383 static_cast<VTK_TT*
>(reslice->GetOutput()->GetScalarPointerForExtent(resliceUpdateExtent)),
384 static_cast<VTK_TT*
>(outputImage->GetScalarPointerForExtent(outExtent)),
385 resliceUpdateExtent, outExtent, outputInc, slice));