[Paraview] Questions about writing a reader plugin

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed Apr 1 08:13:41 EDT 2009


You've started the correct way, since you are writing a reader that
produces a vtkImageData, you should indeed begin by subclassing
vtkImageAlgorithm. Now, if you look that the implementation of
vtkImageAlgorithm, you'll see that it overloads both the
FillInputPortInformation and FillOutputPortInformation and fills it up
so that the executive knows that this algorithm requires and produces
vtkImageData. So you don;'t need to override either of the two
methods.

Since this is a reader, it will take no input. To tell the executive
that, you simply need to call

this->SetNumberOfInputPorts(0);

in the constructor of your class.

Utkarsh

2009/4/1 shenyanwen <shenyanwen at gmail.com>:
> Hello, everyone!
> I am writing my custom reader for my data format.I wrote it and Built it
> with some errors!
> So I have some questions to ask for help!
> Basic information:
> My output data type is vtkImageData, so my code was deriven form
> vtkImageAlgorithm
> 1.Should I use FillInputPortInformation or FillOutputPortInformation like
> below
>
> int vtkMyPluginReader::FillOutputPortInformation(int, vtkInformation *info)
> {
>     info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkImageData");
>     return 1;
> }
>
> or
>
> int vtkMyPluginReader::FillInputPortInformation(int, vtkInformation *info)
> {
>   info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkImageAlgorithm");
>   return 1;
> }
> Which one is right when I am writing a reader NOT a filter?
>
> 2.My header is like that below. Is that enough for a reader?:
> //----------------------------------------------------------------------------
> #ifndef __vtkMyPluginReader_h_
> #define __vtkMyPluginReader_h_
>
> #include "vtkImageAlgorithm.h"
> #include "vtkMyPlugin.h"               //Needed for read actual META_DATA
>
> class VTK_EXPORT vtkMyPluginReader : public vtkImageAlgorithm
> {
> public:
>     static vtkMyPluginReader *New();
>     vtkTypeRevisionMacro(vtkMyPluginReader, vtkImageAlgorithm);
>     void PrintSelf(ostream& os, vtkIndent indent);
>
>     vtkSetStringMacro( FileName );
>     vtkGetStringMacro( FileName );
>
>     virtual int ReadMetaData(vtkInformation *outInfo);//Get the actual data
> from a data file
>
> protected:
>     vtkMyPluginReader();
>     ~vtkMyPluginReader();
>
>     virtual int RequestData(vtkInformation *, vtkInformationVector **,
>                             vtkInformationVector *);
>
>     virtual int RequestInformation(vtkInformation *, vtkInformationVector
> **,
>                                    vtkInformationVector *);
>
>     virtual int FillOutputPortInformation(int, vtkInformation *);
>
> public:
>     vtkMyplugin pluginfile;
>     char *FileName;
>
> private:
>     vtkMyPluginReader(const vtkMyPluginReader&);      //Not implemented
>     void operator=(const vtkMyPluginReader&);   //Not implemented
> };
> #endif
> //----------------------------------------------------------------------------
>
>
> Thank you so much for helping me!
>
> -Seven
> --
> shenyanwen at gmail.com
> Mobile Phone:13476177952
> Tel: 027-87558144
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
>


More information about the ParaView mailing list