[Paraview-developers] ITK reader in ParaView

Sebastien Jourdain sebastien.jourdain at kitware.com
Mon Mar 12 12:07:19 EDT 2012


The issue seems to be related to the fact you explicitly say that the
output will have some float scalar where you seems to have a tuple 3
of unsigned char.

On Mon, Mar 12, 2012 at 12:01 PM, Joe Ping-Lin Hsiao <phsiao at cs.unc.edu> wrote:
> I wrapped the ITK reader in vtkImageAlgorithm, and I can read files
> without any trouble. However, I got the warning of "Cannot volume
> render since no point (or cell) data available. " when I switched the
> representation to volume. The information tab (attached) looks fine. I
> wonder what I have missed. Here is the code in my reader:
>
> int MyReader::RequestInformation (
>    vtkInformation * vtkNotUsed(request),
>    vtkInformationVector ** vtkNotUsed( inputVector ),
>    vtkInformationVector *outputVector)
> {
>    this->GetOutput()->SetNumberOfScalarComponents(1);
>    this->GetOutput()->SetScalarType(VTK_FLOAT);
>    return 1;
> }
>
> int MyReader::RequestData(
>    vtkInformation *vtkNotUsed(request),
>    vtkInformationVector **vtkNotUsed(inputVector),
>    vtkInformationVector *outputVector)
> {
>
>    // get the info object
>    vtkInformation *outInfo = outputVector->GetInformationObject(0);
>
>    // get the ouptut
>    vtkImageData *output = vtkImageData::SafeDownCast(
>                outInfo->Get(vtkDataObject::DATA_OBJECT()));
>
>    output->SetExtent(outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
>    output->AllocateScalars();
>
>    if (!this->FileName)
>    {
>        vtkErrorMacro(<< "A FileName must be specified.");
>        return 0;
>    }
>    if (output->GetScalarType() != VTK_FLOAT)
>    {
>        vtkErrorMacro("Execute: This source only outputs floats.");
>        return 1;
>    }
>
>    typedef itk::RGBPixel<unsigned char>     PixelType;
>    const   unsigned int        Dimension = 3;
>
>    typedef itk::Image< PixelType, Dimension >   ImageType;
>    typedef itk::ImageFileReader< ImageType >    ReaderType;
>    typedef itk::ImageToVTKImageFilter< ImageType > ConnectorType;
>
>    ReaderType::Pointer reader = ReaderType::New();
>    ConnectorType::Pointer connector = ConnectorType::New();
>
>    reader->SetFileName(FileName);
>    connector->SetInput(reader->GetOutput());
>    connector->Update();
>    output->ShallowCopy(connector->GetOutput());
>    output->GetPointData()->GetScalars()->SetName("Elevation");
>
>    return 1;
> }
>
> Thanks,
> Joe
>
> On Mon, Mar 12, 2012 at 10:38 AM, Sebastien Jourdain
> <sebastien.jourdain at kitware.com> wrote:
>> I'm pretty sure, you'll need to wrap itk::ImageFileReader into a
>> vtkObject class and follow VTK constraints so you can use it inside
>> the XML proxy definition.
>>
>> Seb
>>
>> On Mon, Mar 12, 2012 at 10:21 AM, Joe Ping-Lin Hsiao <phsiao at cs.unc.edu> wrote:
>>> Hi,
>>>
>>> I'd like to take advantage of itk::ImageFileReader to read Bio-Formats
>>> files in ParaView, and I wonder if there is any easy way to do that.
>>>
>>> I have success reading Bio-Formats files in ITK examples. Then I took
>>> MyPNGReader example in ParaView as a template, and replaced the string
>>> "vtkPNGReader" with "itk::ImageFileReader" in the server xml. The
>>> plugin loaded fine, but I got an error of "Failed to create
>>> itk::ImageFileReader" when I tried to load a file.
>>>
>>> Does anybody know a good place to start?
>>>
>>> Thanks,
>>> Joe
>>> _______________________________________________
>>> Paraview-developers mailing list
>>> Paraview-developers at paraview.org
>>> http://public.kitware.com/mailman/listinfo/paraview-developers


More information about the Paraview-developers mailing list