VMTK
Loading...
Searching...
No Matches
vtkvmtkCurvedMPRImageFilter Class Reference

Creates a multiplanar reconstruction of an image along a centerline path. More...

#include <vtkvmtkCurvedMPRImageFilter.h>

Inheritance diagram for vtkvmtkCurvedMPRImageFilter:
[legend]
Collaboration diagram for vtkvmtkCurvedMPRImageFilter:
[legend]

Public Types

typedef vtkImageAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCurvedMPRImageFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetCenterline (vtkPolyData *)
virtual vtkPolyData * GetCenterline ()
virtual void SetInplaneOutputSpacing (double, double)
void SetInplaneOutputSpacing (double[2])
virtual double * GetInplaneOutputSpacing ()
virtual void GetInplaneOutputSpacing (double &, double &)
virtual void GetInplaneOutputSpacing (double[2])
virtual void SetInplaneOutputSize (int, int)
void SetInplaneOutputSize (int[2])
virtual int * GetInplaneOutputSize ()
virtual void GetInplaneOutputSize (int &, int &)
virtual void GetInplaneOutputSize (int[2])
virtual void SetReslicingBackgroundLevel (double)
virtual double GetReslicingBackgroundLevel ()
virtual void SetFrenetTangentArrayName (const char *)
virtual char * GetFrenetTangentArrayName ()
virtual void SetParallelTransportNormalsArrayName (const char *)
virtual char * GetParallelTransportNormalsArrayName ()
virtual int * GetOutputExtent ()
virtual void GetOutputExtent (int data[6])
virtual double * GetOutputOrigin ()
virtual void GetOutputOrigin (double data[3])
virtual double * GetOutputSpacing ()
virtual void GetOutputSpacing (double data[3])

Static Public Member Functions

static vtkvmtkCurvedMPRImageFilter * New ()
static int IsTypeOf (const char *type)
static vtkvmtkCurvedMPRImageFilter * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkCurvedMPRImageFilter ()
 ~vtkvmtkCurvedMPRImageFilter ()
template<class T>
void FillSlice (T *outReslicePtr, T *outputImagePtr, int *resliceUpdateExtent, int *outExtent, vtkIdType *outputInc, int slice)
virtual int RequestUpdateExtent (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
virtual int RequestInformation (vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) override

Protected Attributes

vtkPolyData * Centerline
double InplaneOutputSpacing [2]
int InplaneOutputSize [2]
double ReslicingBackgroundLevel
int OutputExtent [6]
double OutputOrigin [3]
double OutputSpacing [3]
char * FrenetTangentArrayName
char * ParallelTransportNormalsArrayName

Detailed Description

Creates a multiplanar reconstruction of an image along a centerline path.

This filter resamples an input image into a stack of 2D slices perpendicular to a centerline path, producing a "curved" multiplanar reconstruction (MPR) volume in which the out-of-plane (z) axis follows the centerline instead of a straight line. For each point of the first line/polyline cell found in Centerline, a reslicing plane is built from the local Frenet tangent (FrenetTangentArrayName, defining the through-plane direction) and a parallel-transported normal (ParallelTransportNormalsArrayName, defining the in-plane "up" direction, with their cross product giving the remaining in-plane axis); vtkImageReslice is then used to cubic-interpolate one square slice of InplaneOutputSize pixels and InplaneOutputSpacing spacing, centered on the centerline point, using ReslicingBackgroundLevel for samples that fall outside the input image. The resulting slices are stacked, one per centerline point, into the output image, whose out-of-plane spacing is the distance between the first two centerline points.

This is the filter behind the vmtkimagecurvedmpr pype script, used to "straighten" a tortuous vessel image along its centerline (e.g. the FrenetTangent/ParallelTransportNormals arrays produced by vtkvmtkCenterlineAttributesFilter) for inspection or measurement without the foreshortening/obliquity of a single straight reformat.

See also
vtkvmtkCenterlineAttributesFilter

Definition at line 49 of file vtkvmtkCurvedMPRImageFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkImageAlgorithm vtkvmtkCurvedMPRImageFilter::Superclass

Definition at line 54 of file vtkvmtkCurvedMPRImageFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkCurvedMPRImageFilter()

vtkvmtkCurvedMPRImageFilter::vtkvmtkCurvedMPRImageFilter ( )
protected

Definition at line 10 of file vtkvmtkCurvedMPRImageFilter.cxx.

11{
12 this->Centerline = NULL;
13 this->InplaneOutputSpacing[0] = 1.0;
14 this->InplaneOutputSpacing[1] = 1.0;
15 this->InplaneOutputSize[0] = 100;
16 this->InplaneOutputSize[1] = 100;
17 this->ReslicingBackgroundLevel = 0.0;
18
19 for (int i = 0;i<6;i++)
20 {
21 this->OutputExtent[i] = 0;
22 }
23 for (int i = 0;i<3;i++)
24 {
25 this->OutputOrigin[i] = 0.0;
26 }
27 for (int i = 0;i<3;i++)
28 {
29 this->OutputSpacing[i] = 0.0;
30 }
31
32 this->FrenetTangentArrayName = NULL;
34}

◆ ~vtkvmtkCurvedMPRImageFilter()

vtkvmtkCurvedMPRImageFilter::~vtkvmtkCurvedMPRImageFilter ( )
protected

Definition at line 37 of file vtkvmtkCurvedMPRImageFilter.cxx.

38{
39 if (this->Centerline)
40 {
41 this->Centerline->Delete();
42 this->Centerline = NULL;
43 }
44
45 if (this->FrenetTangentArrayName)
46 {
47 delete[] this->FrenetTangentArrayName;
48 this->FrenetTangentArrayName = NULL;
49 }
50
52 {
55 }
56}

Member Function Documentation

◆ New()

vtkvmtkCurvedMPRImageFilter * vtkvmtkCurvedMPRImageFilter::New ( )
static

◆ IsTypeOf()

int vtkvmtkCurvedMPRImageFilter::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkCurvedMPRImageFilter::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkCurvedMPRImageFilter * vtkvmtkCurvedMPRImageFilter::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCurvedMPRImageFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCurvedMPRImageFilter * vtkvmtkCurvedMPRImageFilter::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkCurvedMPRImageFilter::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 393 of file vtkvmtkCurvedMPRImageFilter.cxx.

394{
395 this->Superclass::PrintSelf(os,indent);
396
397 os << indent << "Centerline: " << this->Centerline << "\n";
398
399 os << indent << "InplaneOutputSpacing: (" << this->InplaneOutputSpacing[0] << " " << this->InplaneOutputSpacing[1] << ")\n";
400 os << indent << "InplaneOutputSize: (" << this->InplaneOutputSize[0] << " " << this->InplaneOutputSize[1] << ")\n";
401 os << indent << "OutputSpacing: (" << this->OutputSpacing[0] << ", "
402 << this->OutputSpacing[1] << ", " << this->OutputSpacing[2] << ")\n";
403 os << indent << "ReslicingBackgroundLevel: (" << this->ReslicingBackgroundLevel << ")\n";
404 os << indent << "OutputExtent: (" << this->OutputExtent[0] << ", "
405 << this->OutputExtent[1] << ", " << this->OutputExtent[2] << ")\n";
406 os << indent << "OutputExtent(3-5): (" << this->OutputExtent[3] << ", "
407 << this->OutputExtent[4] << ", " << this->OutputExtent[5] << ")\n";
408 os << indent << "OutputOrigin: (" << this->OutputOrigin[0] << ", "
409 << this->OutputOrigin[1] << ", " << this->OutputOrigin[2] << ")\n";
410 os << indent << "OutputSpacing: (" << this->OutputSpacing[0] << ", "
411 << this->OutputSpacing[1] << ", " << this->OutputSpacing[2] << ")\n";
412}

◆ SetCenterline()

virtual void vtkvmtkCurvedMPRImageFilter::SetCenterline ( vtkPolyData * )
virtual

Set/Get the centerline along which the MPR should be made

◆ GetCenterline()

virtual vtkPolyData * vtkvmtkCurvedMPRImageFilter::GetCenterline ( )
virtual

Set/Get the centerline along which the MPR should be made

◆ SetInplaneOutputSpacing() [1/2]

virtual void vtkvmtkCurvedMPRImageFilter::SetInplaneOutputSpacing ( double ,
double  )
virtual

Set/Get the Inplane Output Spacing

◆ SetInplaneOutputSpacing() [2/2]

void vtkvmtkCurvedMPRImageFilter::SetInplaneOutputSpacing ( double [2])

Set/Get the Inplane Output Spacing

◆ GetInplaneOutputSpacing() [1/3]

virtual double * vtkvmtkCurvedMPRImageFilter::GetInplaneOutputSpacing ( )
virtual

Set/Get the Inplane Output Spacing

◆ GetInplaneOutputSpacing() [2/3]

virtual void vtkvmtkCurvedMPRImageFilter::GetInplaneOutputSpacing ( double & ,
double &  )
virtual

Set/Get the Inplane Output Spacing

◆ GetInplaneOutputSpacing() [3/3]

virtual void vtkvmtkCurvedMPRImageFilter::GetInplaneOutputSpacing ( double [2])
virtual

Set/Get the Inplane Output Spacing

◆ SetInplaneOutputSize() [1/2]

virtual void vtkvmtkCurvedMPRImageFilter::SetInplaneOutputSize ( int ,
int  )
virtual

Set/Get the Inplane Output Size

◆ SetInplaneOutputSize() [2/2]

void vtkvmtkCurvedMPRImageFilter::SetInplaneOutputSize ( int [2])

Set/Get the Inplane Output Size

◆ GetInplaneOutputSize() [1/3]

virtual int * vtkvmtkCurvedMPRImageFilter::GetInplaneOutputSize ( )
virtual

Set/Get the Inplane Output Size

◆ GetInplaneOutputSize() [2/3]

virtual void vtkvmtkCurvedMPRImageFilter::GetInplaneOutputSize ( int & ,
int &  )
virtual

Set/Get the Inplane Output Size

◆ GetInplaneOutputSize() [3/3]

virtual void vtkvmtkCurvedMPRImageFilter::GetInplaneOutputSize ( int [2])
virtual

Set/Get the Inplane Output Size

◆ SetReslicingBackgroundLevel()

virtual void vtkvmtkCurvedMPRImageFilter::SetReslicingBackgroundLevel ( double )
virtual

Set/Get the Back Ground Level of the Resliced Data

◆ GetReslicingBackgroundLevel()

virtual double vtkvmtkCurvedMPRImageFilter::GetReslicingBackgroundLevel ( )
virtual

Set/Get the Back Ground Level of the Resliced Data

◆ SetFrenetTangentArrayName()

virtual void vtkvmtkCurvedMPRImageFilter::SetFrenetTangentArrayName ( const char * )
virtual

Set/Get the name of the FrenetTangentArray Commonly named "FrenetTangent".

◆ GetFrenetTangentArrayName()

virtual char * vtkvmtkCurvedMPRImageFilter::GetFrenetTangentArrayName ( )
virtual

Set/Get the name of the FrenetTangentArray Commonly named "FrenetTangent".

◆ SetParallelTransportNormalsArrayName()

virtual void vtkvmtkCurvedMPRImageFilter::SetParallelTransportNormalsArrayName ( const char * )
virtual

Set/Get the name of the TransportNormalsArray Commonly named "ParallelTransportNormals".

◆ GetParallelTransportNormalsArrayName()

virtual char * vtkvmtkCurvedMPRImageFilter::GetParallelTransportNormalsArrayName ( )
virtual

Set/Get the name of the TransportNormalsArray Commonly named "ParallelTransportNormals".

◆ GetOutputExtent() [1/2]

virtual int * vtkvmtkCurvedMPRImageFilter::GetOutputExtent ( )
virtual

Get the new OutputExtent, the inplane output extent is set by SetInplaneOutputSize, the out-of-plane extent is defined by the number of centerline-points

◆ GetOutputExtent() [2/2]

virtual void vtkvmtkCurvedMPRImageFilter::GetOutputExtent ( int data[6])
virtual

Get the new OutputExtent, the inplane output extent is set by SetInplaneOutputSize, the out-of-plane extent is defined by the number of centerline-points

◆ GetOutputOrigin() [1/2]

virtual double * vtkvmtkCurvedMPRImageFilter::GetOutputOrigin ( )
virtual

Get the output origin. The point (0,0,0) is situated in the middle of the first MPR image (at the place of the centerline)The Output Origin is defined by the InplaneOutputSpacing and the InplaneOutputSize

◆ GetOutputOrigin() [2/2]

virtual void vtkvmtkCurvedMPRImageFilter::GetOutputOrigin ( double data[3])
virtual

Get the output origin. The point (0,0,0) is situated in the middle of the first MPR image (at the place of the centerline)The Output Origin is defined by the InplaneOutputSpacing and the InplaneOutputSize

◆ GetOutputSpacing() [1/2]

virtual double * vtkvmtkCurvedMPRImageFilter::GetOutputSpacing ( )
virtual

Get the output spacing, the inplane output spacing is set by SetInplaneOutputSpacing, the out-of-plane spacing is defined by the distance between the first two centerline-points

◆ GetOutputSpacing() [2/2]

virtual void vtkvmtkCurvedMPRImageFilter::GetOutputSpacing ( double data[3])
virtual

Get the output spacing, the inplane output spacing is set by SetInplaneOutputSpacing, the out-of-plane spacing is defined by the distance between the first two centerline-points

◆ FillSlice()

template<class T>
void vtkvmtkCurvedMPRImageFilter::FillSlice ( T * outReslicePtr,
T * outputImagePtr,
int * resliceUpdateExtent,
int * outExtent,
vtkIdType * outputInc,
int slice )
protected

Definition at line 184 of file vtkvmtkCurvedMPRImageFilter.cxx.

185{
186 //write result to the new dataset
187 int size = (outExtent[1]-outExtent[0]+1)*(outExtent[3]-outExtent[2]+1);
188 for(int i=0; i<size; i++)
189 {
190 outputImagePtr[i + (slice-outExtent[4]) * outputInc[2]] = outReslicePtr[i];
191 }
192}

◆ RequestUpdateExtent()

int vtkvmtkCurvedMPRImageFilter::RequestUpdateExtent ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

This method is called by the superclass and sets the update extent of the input image to the wholeextent

Definition at line 60 of file vtkvmtkCurvedMPRImageFilter.cxx.

64{
65 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
66
67 // always request the whole extent
68 inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
69 inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()),6);
70 return 1;
71}

◆ RequestData()

int vtkvmtkCurvedMPRImageFilter::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

This method is called by the superclass and sets the update extent of the input image to the wholeextent

Definition at line 195 of file vtkvmtkCurvedMPRImageFilter.cxx.

199{
200 // get the info objects
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()));
205
206 if (!this->Centerline)
207 {
208 vtkErrorMacro(<<"Centerline not set");
209 return 1;
210 }
211
212 if (inputImage == NULL)
213 {
214 vtkErrorMacro(<< "RequestData: InputImageData is not set.");
215 return 1;
216 }
217
218 //check if everything is all right
219 if (inputImage == NULL || outputImage==NULL)
220 {
221 if (outputImage)
222 {
223 int outputExtent[6] = {0,-1,0,-1,0,-1};
224 outputImage->SetExtent(outputExtent);
225 if (this->GetOutputInformation(0))
226 {
227 this->GetOutputInformation(0)->Set(
228 vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
229 this->GetOutputInformation(0)->Get(
230 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()), 6);
231 }
232 outputImage->AllocateScalars(outInfo);
233 }
234
235 }
236
237 //check if FrenetTangent s are available
238 if ( this->FrenetTangentArrayName == NULL)
239 {
240 vtkErrorMacro(<< "RequestData: FrenetTangentArrayName is not set.");
241 return 1;
242 }
243
244 vtkDataArray* frenetArray = this->Centerline->GetPointData()->GetArray(this->FrenetTangentArrayName);
245 if (!frenetArray)
246 {
247 vtkErrorMacro(<< "RequestData: InputPolyData does not contain an array with the specified FrenetTangentArrayName.");
248 return 1;
249 }
250
251 //check if ParallelTransportNormals are available
252 if ( this->ParallelTransportNormalsArrayName == NULL)
253 {
254 vtkErrorMacro(<< "RequestData: ParallelTransportNormalsArrayName is not set.");
255 return 1;
256 }
257
258 //check if a Centerline is available
259 vtkDataArray* parallelArray = this->Centerline->GetPointData()->GetArray(this->ParallelTransportNormalsArrayName);
260 if (!parallelArray)
261 {
262 vtkErrorMacro(<< "RequestData: InputPolyData does not contain an array with the specified ParallelTransportNormalsArrayName.");
263 return 1;
264 }
265
266 int firstLineInCells;
267 vtkCell* line = NULL;
268 //get the first line in the vktPolyData
269 for (firstLineInCells=0; firstLineInCells<this->Centerline->GetNumberOfCells(); firstLineInCells++)
270 {
271 line = this->Centerline->GetCell(firstLineInCells);
272 if (line->GetCellType() == VTK_LINE || line->GetCellType() == VTK_POLY_LINE)
273 {
274 break;
275 }
276 }
277
278 if (!line || (!(firstLineInCells < (int) this->Centerline->GetNumberOfCells())))
279 {
280 vtkErrorMacro(<< "RequestData: no line in input vtkPolyData.");
281 return 1;
282 }
283
284 if (line->GetNumberOfPoints() < 2)
285 {
286 vtkErrorMacro(<< "RequestData: Too few points in Centerline.");
287 return 1;
288 }
289
290 vtkPoints* linePoints = line->GetPoints();
291
292 int outExtent[6];
293 outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), outExtent);
294
295 outputImage->SetExtent(outExtent);
296 if (this->GetOutputInformation(0))
297 {
298 this->GetOutputInformation(0)->Set(
299 vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
300 this->GetOutputInformation(0)->Get(
301 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()), 6);
302 }
303
304 vtkDataArray* frenetTangentArray = this->Centerline->GetPointData()->GetArray(this->FrenetTangentArrayName);
305 vtkDataArray* parallelTransportNormalsArray = this->Centerline->GetPointData()->GetArray(this->ParallelTransportNormalsArrayName);
306
307 //start computing
308 int inExtent[6];
309 inInfoImage->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), inExtent);
310
311 // if the input extent is empty then exit
312 if (inExtent[1] < inExtent[0] ||
313 inExtent[3] < inExtent[2] ||
314 inExtent[5] < inExtent[4])
315 {
316 return 1;
317 }
318
319 vtkImageReslice* reslice = vtkImageReslice::New();
320 reslice->SetOutputDimensionality(2);
321 reslice->SetInputData(inputImage);
322 reslice->SetInterpolationModeToCubic();
323 //turn off transformation of the input spacing, origin and extent, so we can define what we want
324 reslice->TransformInputSamplingOff();
325 //set the value of the voxels that are out of the input data
326 reslice->SetBackgroundLevel(this->ReslicingBackgroundLevel);
327 //set the outputspacing
328 //reslice->SetOutputSpacing(this->OutputSpacing[0],this->OutputSpacing[1],this->OutputSpacing[2]);
329 reslice->SetOutputSpacing(this->OutputSpacing);
330// going to MPR
331 for (int slice=outExtent[4]; slice<(outExtent[5] + 1);slice++)
332 {// for each slice (or point on the line)
333 double centerSlice[3];
334 linePoints->GetPoint(slice,centerSlice);
335
336 // To calculate the outputorigin & the necessary transform
337 // the vectors are retrieved from the array's
338 //t is the vector in the direction of the Centerline, so along the z-axis in the MPR volume
339 double t[3];
340 frenetTangentArray->GetTuple(slice,t);
341
342 //p is a normal of the Centerline, directed to the 'North' direction of the inputvolume,in the MPR volume this will be along the x-axis
343 double p[3];
344 parallelTransportNormalsArray->GetTuple(slice,p);
345
346 double tp[3];
347 //tp is the crossproduct of t and p, and will be directed to the 'West' direction of the inputvolume,in the MPR volume this will be along the y-axis
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]);
351
352 //set the axis of the first slice according to the vectors of the first point in the line
353 reslice->SetResliceAxesDirectionCosines(p[0],p[1],p[2],tp[0],tp[1],tp[2],t[0],t[1],t[2]);
354 // the firstPoint on the Centerline corresponds to the origin of the output axes unit vectors
355 reslice->SetResliceAxesOrigin(centerSlice[0],centerSlice[1],centerSlice[2]);
356 //the outputextent will be one slice
357 reslice->SetOutputExtent(this->OutputExtent[0],this->OutputExtent[1],this->OutputExtent[2],this->OutputExtent[3],0,0);
358 //the outputorigin in the input coordinate system is set to zero
359 double outputorigin[3];
360 outputorigin[0] = 0.0;
361 outputorigin[1] = 0.0;
362 outputorigin[2] = 0.0;
363
364 reslice->SetOutputOrigin(this->OutputOrigin);
365 reslice->Update();
366
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;
374
375 vtkIdType outputInc[3];
376 outputImage->GetIncrements(outputInc);
377
378 int scalarType = reslice->GetOutput()->GetScalarType();
379 switch (scalarType)
380 {
381 vtkTemplateMacro(
382 FillSlice(
383 static_cast<VTK_TT*>(reslice->GetOutput()->GetScalarPointerForExtent(resliceUpdateExtent)),
384 static_cast<VTK_TT*>(outputImage->GetScalarPointerForExtent(outExtent)),
385 resliceUpdateExtent, outExtent, outputInc, slice));
386 }
387 }// for each slice
388
389 reslice->Delete();
390 return 1;
391}
void FillSlice(T *outReslicePtr, T *outputImagePtr, int *resliceUpdateExtent, int *outExtent, vtkIdType *outputInc, int slice)

◆ RequestInformation()

int vtkvmtkCurvedMPRImageFilter::RequestInformation ( vtkInformation * vtkNotUsedrequest,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotectedvirtual

This method is called by the superclass and sets the update extent of the input image to the wholeextent

Definition at line 75 of file vtkvmtkCurvedMPRImageFilter.cxx.

79{
80 // get the info objects
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()));
85
86 if (!this->Centerline)
87 {
88 vtkErrorMacro(<<"Centerline not set");
89 return 1;
90 }
91
92 //Check if the inputs are NULL
93 if (inputImage == NULL || this->Centerline == NULL || outputImage==NULL)
94 {
95 if (outputImage)
96 {
97 int outputExtent[6] = {0,-1,0,-1,0,-1};
98 outputImage->SetExtent(outputExtent);
99 if (this->GetOutputInformation(0))
100 {
101 this->GetOutputInformation(0)->Set(
102 vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
103 this->GetOutputInformation(0)->Get(
104 vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()), 6);
105 }
106 outputImage->AllocateScalars(outInfo);
107
108 }
109 if ( inputImage == NULL)
110 {
111 vtkErrorMacro(<< "RequestInformation: InputImageData is not set.");
112 return 1;
113 }
114 else //Centerline==NULL
115 {
116 vtkErrorMacro(<< "RequestInformation: Centerline is not set.");
117 return 1;
118 }
119 }
120
121 int firstLineInCells;
122 vtkCell* line = NULL;
123 //get the first line in the vktPolyData
124 for (firstLineInCells=0; firstLineInCells < this->Centerline->GetNumberOfCells(); firstLineInCells++)
125 {
126 line = this->Centerline->GetCell(firstLineInCells);
127 if (line->GetCellType() == VTK_LINE || line->GetCellType() == VTK_POLY_LINE)
128 {
129 break;
130 }
131 }
132 if (!line || (!(firstLineInCells < (int) this->Centerline->GetNumberOfCells())))
133 {
134 vtkErrorMacro(<< "RequestInformation: no line in input vtkPolyData.");
135 return 1;
136 }
137
138 vtkPoints* linePoints = line->GetPoints();
139
140 int numberOfLinePoints = linePoints->GetNumberOfPoints();
141
142 if (numberOfLinePoints < 2)
143 {
144 vtkErrorMacro(<< "RequestInformation: Too few points in Centerline.");
145 return 1;
146 }
147
148 int inDataExtent[6];
149 double inDataOrigin[3];
150 inInfoImage->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), inDataExtent);
151
152 inputImage->GetSpacing(this->OutputSpacing);
153 inputImage->GetOrigin(inDataOrigin);
154
155 this->OutputExtent[0] = 0;
156 this->OutputExtent[1] = this->InplaneOutputSize[0]-1;
157 this->OutputExtent[2] = 0;
158 this->OutputExtent[3] = this->InplaneOutputSize[1]-1;
159 this->OutputExtent[4] = 0;
160 this->OutputExtent[5] = numberOfLinePoints-1;
161
162 double firstPoint[3], secondPoint[3], zspace;
163 linePoints->GetPoint(0,firstPoint);
164 linePoints->GetPoint(1,secondPoint);
165
166 zspace = sqrt(vtkMath::Distance2BetweenPoints(firstPoint,secondPoint));
167
168 this->OutputSpacing[0]= this->InplaneOutputSpacing[0];
169 this->OutputSpacing[1]= this->InplaneOutputSpacing[1];
170 this->OutputSpacing[2]= zspace;
171
172 this->OutputOrigin[0]=-1*((this->OutputExtent[1]-this->OutputExtent[0])/2)*this->OutputSpacing[0];
173 this->OutputOrigin[1]=-1*((this->OutputExtent[3]-this->OutputExtent[2])/2)*this->OutputSpacing[1];
174 this->OutputOrigin[2]=0;
175
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);
179
180 return 1;
181}

Member Data Documentation

◆ Centerline

vtkPolyData* vtkvmtkCurvedMPRImageFilter::Centerline
protected

Definition at line 160 of file vtkvmtkCurvedMPRImageFilter.h.

◆ InplaneOutputSpacing

double vtkvmtkCurvedMPRImageFilter::InplaneOutputSpacing[2]
protected

Definition at line 161 of file vtkvmtkCurvedMPRImageFilter.h.

◆ InplaneOutputSize

int vtkvmtkCurvedMPRImageFilter::InplaneOutputSize[2]
protected

Definition at line 162 of file vtkvmtkCurvedMPRImageFilter.h.

◆ ReslicingBackgroundLevel

double vtkvmtkCurvedMPRImageFilter::ReslicingBackgroundLevel
protected

Definition at line 163 of file vtkvmtkCurvedMPRImageFilter.h.

◆ OutputExtent

int vtkvmtkCurvedMPRImageFilter::OutputExtent[6]
protected

Definition at line 164 of file vtkvmtkCurvedMPRImageFilter.h.

◆ OutputOrigin

double vtkvmtkCurvedMPRImageFilter::OutputOrigin[3]
protected

Definition at line 165 of file vtkvmtkCurvedMPRImageFilter.h.

◆ OutputSpacing

double vtkvmtkCurvedMPRImageFilter::OutputSpacing[3]
protected

Definition at line 166 of file vtkvmtkCurvedMPRImageFilter.h.

◆ FrenetTangentArrayName

char* vtkvmtkCurvedMPRImageFilter::FrenetTangentArrayName
protected

Definition at line 167 of file vtkvmtkCurvedMPRImageFilter.h.

◆ ParallelTransportNormalsArrayName

char* vtkvmtkCurvedMPRImageFilter::ParallelTransportNormalsArrayName
protected

Definition at line 168 of file vtkvmtkCurvedMPRImageFilter.h.


The documentation for this class was generated from the following files: