[Paraview] Fwd: How to plug into paraview his own writer ?

Cory Quammen cory.quammen at kitware.com
Tue Jun 30 00:08:00 EDT 2015


Hi Franck,

It looks like you've been making progress, so I'll answer your questions
from your second email.



> Question 1 : how to write myWriter.xml ?
>
> 1.1. seems I must set <InputProperty command="SetInputConnection"
> name="Input"> in myWriter.xml. Does this means I will also have to
> implement myWriter::SetInputConnection ?
>

No. Your writer will inherit from subclass of vtkAlgorithm, the class that
defines "SetInputConnection", and you should not need to override it.
XdmfWriter inherits from vtkDataObjectAlgorithm, which itself inherits
vtkAlgorithm.


>
> 1.2. seems I must set <StringVectorProperty name="FileName"
> command="SetFileName"> in myWriter.xml. Does this means I will also have to
> implement myWriter::SetFileName ?
>

Yes, like vtkXdmfWriter.


> Question 2 : how to implement a vtk object ? From here
> http://www.vtk.org/Wiki/VTK/Examples/Developers/vtkObject, it seems that
>
> 2.1. in myWriter.cpp, I need to have :
> #include "vtkObjectFactory.h" // vtkStandardNewMacro
> vtkStandardNewMacro ( myWriter ); // use vtkStandardNewMacro : 1 only
> allowed constructor, omit the copy constructor and operator=
> + suppress copy constructor and operator=
>

Yes.

2.2 in myWriter.hpp, I need to derive from a vtkObject this way (like
> XdmfWriter.cpp does) :
> class myWriter : public vtkDataObjectAlgorithm {
>   public:
>     static myWriter * New (); // Needed to be plugged into paraview
>     vtkTypeMacro ( myWriter, vtkDataObjectAlgorithm ); // Needed to be
> plugged into paraview
> + suppress copy constructor and operator=
>
> Am I correct ?
>

Yes.

Question 3 : in myWriter.cpp, on which method I am supposed to be called
> back (to get focus back) when I click the "save data" button ? Here, how
> can I get data to be saved (data that I can see in paraview viewer before
> to click the save button - I guess this data will be a vtk*).
>

In ParaView, when you choose, File -> Save Data, the data from the selected
Pipeline Browser object will be saved. This will have some kind of data
type, e.g., vtkImageData, vtkPolyData, etc. What kind of data type would
you like your writer to support?

The data should be available in the member function
myWriter::RequestData(). This is where you should write your data.

Finally, myWriter.xml seems OK. myWriter.*pp compile OK. Paraview finds
> myWriter.xml at run time (exporting PV_PLUGIN_PATH) and loads
> libmywriter.so without problem. I see the writer in the "save data" GUI
> (drop down list with different save formats). I save with myWriter, I get a
> (basic) GUI with file name only (no extra parameter) : I crash when I click
> "OK, save" with this error message :
> ERROR: In
> /.../ParaView-v4.3.1-source/ParaViewCore/ServerImplementation/Core/vtkSIProxy.cxx,
> line 307
> vtkSIWriterProxy (0x30143d0): Failed to create myWriter. Aborting for
> debugging purposes.
>
> vtkSIWriterProxy does this at line 303 :
> vtkObjectBase* obj = this->Interpreter->NewInstance(className);
> but obj is NULL.
>
> I get obj is NULL because I missed something in myWriter implementation :
> what did I miss ?
>

Are you running pvserver separately and connecting to it with the client?
If so, make sure PV_PLUGIN_PATH is defined in the environment in which
pvserver is run. Have you tried to load your plugin through the Tools ->
Manage Plugins... dialog?

I hope that helps get you further in writing your data files.

Thanks,
Cory


>
> Can somebody help ? Or even get me some clue ?
>
> FH
>
> -------- Message original --------
> Objet: How to plug into paraview his own writer ?
> Date: 2015-06-12 15:54
> De: houssen <houssen at imap.ipgp.fr>
> À: <paraview at paraview.org>
>
>
> I followed 2 tutorials (
> http://www.itk.org/Wiki/ParaView/Plugin_HowTo#Writing_Plugins,
> http://www.kitware.com/media/html/WritingAParaViewReaderPlug-in.html) but
> I feel like I missed some steps : this is not working.
>
> I need to "catch" data (I can see in 2D/3D paraview viewer) to write them
> into a specific file format. I am looking for the minimal (simplest) way to
> do this : the only writer input is the file name, then I would like to
> understand how to "get data from" paraview (from inside a vtk object I
> guess ?), then I just will have to do the easy part which is to write data
> to a specific format.
>
> My understanding is that, first I need a CMakeLists.txt like :
> ~> more CMakeLists.txt
> FIND_PACKAGE ( ParaView REQUIRED )
> INCLUDE ( ${PARAVIEW_USE_FILE} )
> ADD_PARAVIEW_PLUGIN ( myWriter "1.0" SERVER_MANAGER_XML myWriter.xml
> SERVER_MANAGER_SOURCES myWriter.cpp )
>
> In the same directory, I need a (minimal) myWriter.xml file that looks
> like :
> ~> more myWrite.xml
>  <ServerManagerConfiguration>
>  <ProxyGroup name="WRITERS">
>  <SourceProxy name="MYWRITER" class="MYWRITER" label="my writer">
>  <Documentation short_help="my own writer"/>
>  <InputProperty>
>  <StringVectorProperty name="FileName" command="SETFILENAME"
> number_of_elements="1"/>
>  </InputProperty>
>  <Hints>
>  <WriterFactory extensions="mw" file_description="my written file"/>
>  </Hints>
>  </SourceProxy>
>  </ProxyGroup>
> </ServerManagerConfiguration>
> My understanding is that somehow the xml subscribes my for a specific
> callback I am called back on the "save data" button is cliked in the GUI.
>
> Still, in this same directory, I have myWriter.cpp and myWriter.hpp :
> how to implement them ?
> 1. The myWriter class must define and implement a SetFileName method
> because of the <StringVectorProperty> xml tag in myWriter.xml : right ?
> wrong ?
>    This is the file name (including file path) one sets in the GUI : right
> ? wrong ?
> 2. myWriter is supposed to derive from another class : which one ? where
> to find it ?
> 3. How the myWriter implementation will "catch" data in paraview ? Which
> method to override / re-implement ?
>    When I am called from paraview (triggered by the click on "save data"
> button), I guess I am called on a specific method "myWriter::cbMethod (
> vtkXXX * pDataInParaviewViewer )"
>   What is this method ?
>
> Also, at this step, I export
> PV_PLUGIN_PATH=/mnt/users/houssen/Documents/solve-rel/paraview. When I run
> paraview and use the "save data" button I get this :
> Generic Warning: In
> /.../Programs/ParaView/ParaView-v4.3.1-source/ParaViewCore/ServerManager/Core/vtkSMWriterFactory.cxx,
> line 135
> writers : myWriter has no input property.
> ... But I have an <InputProperty> tag in the xml : what's wrong ?
>
> Can somebody help me on this ?
>
> Franck
>
> Note : I run Ubuntu and paraview-4.3
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150630/7a185a75/attachment.html>


More information about the ParaView mailing list