Dabo
Dabo

Reputation: 381

how to combine multiple instances of vtkImageData?

I have multiple instances of vtkImageData representing a window of one large dataset. The instances are adjacent and non-overlapping.

I would like to slice through all the imageData with a single vtkPlaneWidget, so I have to somehow combine the imageData into a single input connection. I also want to be able to efficiently add or remove any instance of vtkImageData from the connection.

Right now I have the vtkImageData in a vtkMultiBlockDataSet. I thought I could filter the data using a filter with the executive vtkCompositeDataPipeline as in the Tcl snippet below.

# propogate the multiblock
MultiBlockDataSet mb
mb SetNumberOfBlocks [llength $image_data_list]
for {set i 0} {$i < [llength $image_data_list]} {incr i} {
    mb SetBlock $i [lindex $image_data_list $i]}
}

vtkSimpleToSimpleImageFilter fltr
vtkCompositeDataPipeline cdp
fltr SetExecutive cdp
fltr SetInput cdp

vtkImagePlaneWidget plane
plane SetInputConnection [fltr GetOutputPort]

However, the plane doesn't seem like the input connection, and moreover I'm not terribly familiar with Vtk, so I'm wondering if this is the most suitable way to do this. Any suggestions?

Upvotes: 1

Views: 1086

Answers (1)

JohnnyQ
JohnnyQ

Reputation: 1611

By not knowing your code and how you read in your data ... one possible way would be to initialize a new vtkImageData object and add your slice data.

(quick example assuming three vtkImageData objects mySlice1, mySlice2 and myTotalSlices)

myTotalSlices->GetPointData->AddArray(mySlice1->GetPointData()->GetScalars());
myTotalSlices->GetPointData->AddArray(mySlice2->GetPointData()->GetScalars());

myTotalSlices->SetExtent(0, 511, 0, 511, 0, 1);
myTotalSlices->Update();

The values in SetExtent are just a example, of course you need to adjust them to fit to your data extent. It would be also possible to remove an array i.e. index based

myTotalSlices->GetPointData->RemoveArray(0);

Upvotes: 3

Related Questions