<div dir="ltr">Hi <span style="font-family:arial,sans-serif;font-size:13px">Bogdan,</span><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">here are some issue in your code:</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">vtkSmartPointer <vtkPVDReader> pReader = vtkPVDReader::New(); // <== Memory LEAK</span></div><div>// Should be either</div><div>// vtkNew<<span style="font-family:arial,sans-serif;font-size:13px">vtkPVDReader> </span><span style="font-family:arial,sans-serif;font-size:13px">pReader;</span></div><div><font face="arial, sans-serif">// </font><span style="font-family:arial,sans-serif;font-size:13px">vtkSmartPointer<vtkPVDReader> pReader = </span><span style="font-family:arial,sans-serif;font-size:13px">vtkSmartPointer<vtkPVDReader>::New()</span></div><div><font face="arial, sans-serif"><br></font>Then here on a "NULL" object you try to call a method.<br><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">vtkMultiBlockDataSet* pMultiBlockDataSet->DeepCopy(</span><span style="font-family:arial,sans-serif;font-size:13px">vtkMultiBlockDataSet::</span><span style="font-family:arial,sans-serif;font-size:13px">SafeDownCast(pReader-></span><span style="font-family:arial,sans-serif;font-size:13px">GetOutputDataObject(0)));</span><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Should be something like that:</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div>vtkNew<<span style="font-family:arial,sans-serif;font-size:13px"> vtkMultiBlockDataSet </span><span style="font-size:13px;font-family:arial,sans-serif">> </span><span style="font-family:arial,sans-serif;font-size:13px">pMultiBlockDataSet</span><span style="font-size:13px;font-family:arial,sans-serif">;</span><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">pMultiBlockDataSet</span><span style="font-size:13px;font-family:arial,sans-serif">->DeepCopy(</span><span style="font-size:13px;font-family:arial,sans-serif">vtkMultiBlockDataSet::</span><span style="font-size:13px;font-family:arial,sans-serif">SafeDownCast(pReader-></span><span style="font-size:13px;font-family:arial,sans-serif">GetOutputDataObject(0)));</span><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><br></div><div><font face="arial, sans-serif">Then you might have some other issue where pReader output being empty/null, but for that I don't know.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Are you managing your project with CMake? Did you include the necessary file with the proper dependency declaration. This seems to be related to the factory not being properly initialized. You can search the mailing list, Marcus did answer several questions about that.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Seb</font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 23, 2014 at 7:26 AM, Bogdan Daqui Herrera <span dir="ltr"><<a href="mailto:bdaqui@simscale.de" target="_blank">bdaqui@simscale.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
I am attempting to write some code in c++ which uses the vtkPVDReader from the paraview library to read a series of vtm files. However I am encountering some<br>
problems and I am not sure whether there is something I am missing or whether this could be a bug.<br>
<br>
I am trying to use the reader in the following manner:<br>
My Code:<br>
vtkSmartPointer <vtkPVDReader> pReader = vtkPVDReader::New();<br>
pReader->SetForceOutputTypeToMultiBlock(1);<br>
pReader->SetFileName("/some/fileName.pvd");<br>
pReader->Update();<br>
vtkMultiBlockDataSet* pMultiBlockDataSet->DeepCopy(vtkMultiBlockDataSet::SafeDownCast(pReader->GetOutputDataObject(0)));<br>
<br>
Error:<br>
The error occurs at Update() with the following result:<br>
ERROR: In /misc/dn47/SALOME/PRODUCTS/7x/opt/Ubuntu.13.10.64/7.4.0/tmp/ParaView-4.1.0_SRC/ParaViewCore/VTKExtensions/Default<br>
/vtkXMLCollectionReader.cxx, line 316<br>
vtkPVDReader (0x224d9e0): Error creating "vtkXMLMultiBlockDataReader" using vtkPVInstantiator.<br>
Segmentation fault<br>
<br>
Possible error Source<br>
The code concerning line 316 from vtkXMLCollectionReader.cxx is:<br>
<br>
// Use the instantiator to create the reader.<br>
vtkObject* o = vtkPVInstantiator::CreateInstance(rname);<br>
vtkXMLReader* reader = vtkXMLReader::SafeDownCast(o);<br>
this->Internal->Readers[index] = reader;<br>
if(reader)<br>
{<br>
reader->Delete();<br>
}<br>
else<br>
{<br>
// The class was not registered with the instantiator.<br>
vtkErrorMacro("Error creating \"" << rname<br>
<< "\" using vtkPVInstantiator.");<br>
if(o)<br>
{<br>
o->Delete();<br>
}<br>
}<br>
}<br>
<br>
I have isolated the following lines and tested them independently:<br>
vtkObject* o = vtkPVInstantiator::CreateInstance(rname);<br>
vtkXMLReader* reader = vtkXMLReader::SafeDownCast(o);<br>
<br>
The pointer "vtkObject* o" is NULL regardless of the class name I pass to instantiate, and I can imagine something like that happening in the library, too and<br>
causing the segmentation fault, when calling a SafeDownCast(o) (which is NULL).<br>
<br>
<br>
Any suggestions on how to deal with this problem or if you would be so kind to point me to an example for an alternative solution (Could be vtkFileSeriesReader,<br>
but this fails, as well in my case) would be appreciated.<br>
<br>
Kind Regards,<br>
Bogdan<br>
<br>
P.S.: Using the PVDReader from python code works flawlessly, which is also quite confusing, as to why it would fail in the C++ code.<br>
<br>
--<br>
Bogdan Daqui<br>
Software Development<br>
<br>
SimScale GmbH<br>
Lichtenbergstraße 8<br>
85748 Garching bei München<br>
<br>
Phone: +49 (0)89 3398 4078<br>
Email: <a href="mailto:bdaqui@simscale.de">bdaqui@simscale.de</a><br>
<br>
Amtsgericht München, HRB 201813<br>
Geschäftsführer: Vincenz Dölle & David Heiny<br>
<br>
<a href="http://www.simscale.de" target="_blank">http://www.simscale.de</a><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
</blockquote></div><br></div>