<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Dear Developers and Users,<br>
<br>
I'll warming up this issue again since there was no echo last time.<br>
<br>
Can somebody confirm the buggy behaviour of the following code:<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkPolyData.h><br>
#include <vtkPointData.h><br>
#include <vtkMultiBlockDataSet.h><br>
#include <vtkXMLMultiBlockDataWriter.h><br>
#include <vtkXMLMultiBlockDataReader.h><br>
#include <vtkStringArray.h><br>
#include <sys/stat.h><br>
#include <sstream><br>
<br>
int main(int, char *[])<br>
{<br>
/**<br>
* notes:<br>
* -> it works with ascii writer configuration for any M,N.<br>
* -> with binary writer configuration it segfaults for
higher M,N<br>
* -> {N=100,M=1} works. {N=100,M=10} fails. {N=1000,M=1}
fails.<br>
*/<br>
const unsigned int N = 1000; // number of points<br>
const unsigned int M = 1; // number of characters in the string<br>
<br>
std::string filename = "test_output.vtm";<br>
std::stringstream mystring;<br>
struct stat buffer;<br>
<br>
vtkSmartPointer<vtkPoints> points =<br>
vtkSmartPointer<vtkPoints>::New();<br>
vtkSmartPointer<vtkStringArray> stringAttribute =<br>
vtkSmartPointer<vtkStringArray>::New();<br>
vtkSmartPointer<vtkPolyData> mypolydata =<br>
vtkSmartPointer<vtkPolyData>::New();<br>
vtkSmartPointer<vtkMultiBlockDataSet> multiBDS =<br>
vtkSmartPointer<vtkMultiBlockDataSet>::New ();<br>
vtkSmartPointer<vtkXMLMultiBlockDataWriter> writer =<br>
vtkSmartPointer<vtkXMLMultiBlockDataWriter>::New();<br>
vtkSmartPointer<vtkMultiBlockDataSet> multiBDS_read =<br>
vtkSmartPointer<vtkMultiBlockDataSet>::New ();<br>
vtkSmartPointer<vtkXMLMultiBlockDataReader> reader =<br>
vtkSmartPointer<vtkXMLMultiBlockDataReader>::New();<br>
<br>
stringAttribute->SetNumberOfComponents(1);<br>
reader->SetFileName(filename.c_str());<br>
writer->SetFileName(filename.c_str());<br>
writer->SetDataModeToBinary(); // segfault<br>
//writer->SetDataModeToAscii(); // works<br>
<br>
// create some points:<br>
for (int k=0; k<N; ++k) {<br>
points->InsertNextPoint(0.0, 0.0, 0.0);<br>
}<br>
<br>
// create some string attributes:<br>
for (int k=0; k<N; ++k) {<br>
for (int i=0; i<M; ++i) {<br>
mystring << "x";<br>
}<br>
stringAttribute->InsertNextValue(mystring.str().c_str());<br>
}<br>
<br>
// assemble and write to file:<br>
mypolydata->SetPoints(points);<br>
mypolydata->GetPointData()->AddArray(stringAttribute);<br>
multiBDS->SetBlock(0,mypolydata);<br>
writer->SetInput(multiBDS);<br>
writer->Write();<br>
<br>
//now read the file again:<br>
if (stat (filename.c_str(), &buffer) == 0) {<br>
reader->Update();<br>
multiBDS_read->ShallowCopy(reader->GetOutput());<br>
}<br>
else {<br>
std::cout<<"file not found."<<std::endl;<br>
}<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
thank you.<br>
Simon<br>
<div class="moz-forward-container"><br>
<br>
-------- Forwarded Message --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Subject:
</th>
<td>Re: [vtkusers] segfault when vtkXMLMultiBlockDataReader
reads a .vtm binary mode - bug?</td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">Date: </th>
<td>Tue, 04 Nov 2014 22:34:01 +0100</td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">From: </th>
<td>Tanaka Simon <a class="moz-txt-link-rfc2396E" href="mailto:tanakas@gmx.ch"><tanakas@gmx.ch></a></td>
</tr>
<tr>
<th nowrap="nowrap" valign="BASELINE" align="RIGHT">To: </th>
<td>VTK Users <a class="moz-txt-link-rfc2396E" href="mailto:vtkusers@vtk.org"><vtkusers@vtk.org></a>,
<a class="moz-txt-link-abbreviated" href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>Dear Developers,
can somebody confirm the buggy behaviour?
i attached a yet simplified code to reproduce the segfault.
thanks
simon
btw: i use ubuntu 14.04 and gcc 4.7
On 03.11.2014 11:19, Tanaka Simon wrote:
> Dear Developers,
>
> Hello VTK users and developers,
>
> I attached a simple program which segfaults. please also have a look
> at the comments in the code.
>
> i want to:
> 1) write a vtkMultiBlockDataSet to a file
> 2) load it
>
> it only segfaults if the writer is set to binary mode, and only if the
> data exceeds a certain size. in ascii mode, everything is fine.
>
>
> this might be related:
> <a class="moz-txt-link-freetext" href="http://www.paraview.org/Bug/print_bug_page.php?bug_id=13294">http://www.paraview.org/Bug/print_bug_page.php?bug_id=13294</a>
>
>
> can you confirm that behaviour? what am i doing wrong? and if it is a
> bug, how can i work around?
>
> thank you very much
> simon
</pre>
<br>
</div>
<br>
</body>
</html>