[vtkusers] Output extent gets lost in custom image algorithm
Maarten Beek
beekmaarten at yahoo.com
Wed Jan 8 16:36:44 EST 2014
Hi all,
I am trying to create a new vtk algorithm.
Inside this algorithm is a small rendering pipeline.
I create the output in RequestDataObject(), set the update extent and allocate memory, but the extent seems to be lost in RequestData().
RequestData() works fine when I set the extent in this function, which means that the memory allocated in RequestDataObject() is still allocated.
So I am wondering where (and why?) the extent is re-set to (0, -1, 0, -1, 0, -1)?
Thanks - Maarten
code:
int X::RequestDataObject()
{
vtkInformation* info = outVector->GetInformationObject(0);
vtkImageData* output = vtkImageData::safeDownCast(info->Get(vtkDataObject::DATA_OBJECT()));
if(!output)
{
output = vtkImageData::New();
info->Set(vtkDataObject::DATA_OBJECT(), output);
output->Delete();
}
if( check to determine whether update extent needs updating )
{
info->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), extent, 6);
AllocateOutputData(info->Get(vtkDataObject::DATA_OBJECT()), info); // sets extent for vtkImageData object
}
}
int X::RequestData()
{
vtkInformation* info = outVector->GetInformationObject(0);
vtkImageData* output = vtkImageData::safeDownCast(info->Get(vtkDataObject::DATA_OBJECT()));
this->InternalRenderWindow->Render();
this->InternalRenderWindow->WaitForCompletion();
int size[2];
size[0] = this->InternalRenderWindow->GetSize()[0];
size[1] = this->InternalRenderWindow->GetSize()[1];
// hack required
{
int extent[6];
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), extent);
output->SetExtent(extent);
}
vtkFloatArray* data = vtkFloatArray::SafeDownCast(output->GetPointData()->GetScalars());
this->InternalRenderWindow->GetRBGAPixelData(0, 0, size[0]-1, size[1]-1, 1, data);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140108/6b66d97b/attachment.htm>
More information about the vtkusers
mailing list