[vtkusers] Problem using vtkCutter and vtkPlane

Maria Alejandra Zuluaga maria.zuluaga at creatis.insa-lyon.fr
Mon Nov 3 07:19:26 EST 2008


Hi.
I am kind of new to VTK. 
I want to use vtkCutter and vtkPlane to extract planes from a 3D volume
(read with vtkMetaImageReader). The result (a slice) I want to visualize
it and/or save it in a mhd file. 

I used the examples in VTK's documentation but the results are not
coherent. When I visualize I just see two regions and when I sabe the
image I obtain something that does not correspond to the expected slice.
I do not know what am I doing wrong.

Here is my code:

vtkPlane *implicitPlane = vtkPlane::New();
implicitPlane->SetOrigin(0, 0,1 ); 
implicitPlane->SetNormal(0, 0, 1 );
	  
vtkCutter *cutter = vtkCutter::New();
cutter->SetInput(volume);
cutter->SetCutFunction(implicitPlane);
 
cutter->Update();
 
pFilter= vtkProbeFilter::New( ) ;
pFilter->SetInputConnection( cutter->GetOutputPort() );
pFilter->SetSource(volume );  //volume is a vtkIMageData that was read with a vtkMetaImageReader
pFilter->Update( );
 
//This is the code I use to save the image on a mhd file
int sizeIma = 300;
vtkStructuredPoints* stPoints = vtkStructuredPoints::New( );
 
stPoints->GetPointData( )->SetScalars(  pFilter->GetOutput()->GetPointData()->GetScalars()  );
stPoints->SetDimensions( sizeIma, sizeIma, 1 );
stPoints->SetScalarType( volume );
stPoints->SetScalarTypeToShort ();
stPoints->Update();
vtkImageChangeInformation* change = vtkImageChangeInformation::New();
change->SetInput( stPoints );  
change->Update();    
 
vtkImageData* data = change->GetOutput();

//and here what I use to visualize
vtkDataSetMapper* _3DSliceMapper;
vtkActor* _3DSliceActor;
vtkLookupTable* _3DLookUpTable;

_3DSliceMapper = vtkDataSetMapper::New();
_3DSliceActor = vtkActor::New();
_3DLookUpTable = vtkLookupTable::New( );

_3DLookUpTable->SetNumberOfColors( 256 );
_3DLookUpTable->SetTableRange( 0 , 255 );
_3DLookUpTable->Build( );
_3DLookUpTable->SetTableValue( 0  , 1 , 0 , 0 , 1 );
_3DLookUpTable->SetTableValue(128 , 0 , 0 , 1 , 1 );
_3DLookUpTable->SetTableValue(255 , 0 , 1 , 0 , 1 );
_3DSliceMapper->SetLookupTable( _3DLookUpTable );

_3DSliceMapper->SetInput(pFilter->GetOutput());
_3DSliceActor->SetMapper(_3DSliceMapper);

Thanks for any help.

Maria






More information about the vtkusers mailing list