<div dir="ltr">Thanks David. I have thoroughly looked through that file format document but with no luck. It the mean time, I have tried the xml format and while my ascii writer (both in legacy and xml versions) work, I'm hopeless when it comes to the binary version.<div>
<br></div><div>It seems that (for xml binary) pv is confused (well, actually I'm also!). What exactly should the offset values be? Initially I thought they are simply the size of the DataArray you are writing, but then I loaded my ascii version and saved it as a binary file. Comparing the two, it seems pv adds another variable of sizeof(int). What exactly is this? I cannot find any hint in the file-format document or anywhere online!</div>
<div><br></div><div>I can send my code again if someone is willing to take a look.</div><div><br></div><div>Thanks<br><br><div class="gmail_quote">On Thu, May 17, 2012 at 8:20 AM, David E DeMarle <span dir="ltr"><<a href="mailto:dave.demarle@kitware.com" target="_blank">dave.demarle@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Something is wrong with this binary file. Paraview opens up other<br>
binary files just fine, but 3.8 and newer versions of paraview don't<br>
open up this one.<br>
<br>
ParaView appears to failing near vtkDataSetSurfaceFilter.cxx:1097<br>
where it is trying to process the cells.<br>
<br>
Try these to diagnose the specific problem:<br>
* take a closer look at <a href="http://www.vtk.org/VTK/img/file-formats.pdf" target="_blank">http://www.vtk.org/VTK/img/file-formats.pdf</a><br>
* load this in a simple vtk program that loads and then renders the<br>
data under a debugger<br>
* change your writer to convert this binary file to the corresponding<br>
ascii version.<br>
<br>
David E DeMarle<br>
Kitware, Inc.<br>
R&D Engineer<br>
21 Corporate Drive<br>
Clifton Park, NY 12065-8662<br>
Phone: <a href="tel:518-881-4909" value="+15188814909">518-881-4909</a><br>
<div><div class="h5"><br>
<br>
On Wed, May 16, 2012 at 2:49 PM, Mohammad Mirzadeh <<a href="mailto:mirzadeh@gmail.com">mirzadeh@gmail.com</a>> wrote:<br>
> If it helps, here's the source code and attached is a sample binary file:<br>
><br>
> void QuadTree::writeBinaryVTK(string file_name, vtk_data_format format){<br>
><br>
><br>
> CaslInt num_of_nodes, num_of_cells, num_of_leaf_cells;<br>
><br>
> CaslInt node_of_cell[4];<br>
><br>
> const QuadCell *cell = this -> get_cells();<br>
><br>
> const QuadNode *node = this -> get_nodes();<br>
><br>
> double x, y, z;<br>
><br>
><br>
> CaslInt i_max, j_max;<br>
><br>
> CaslInt i_min, j_min;<br>
><br>
><br>
><br>
><br>
> num_of_cells = this -> number_of_cells();<br>
><br>
> num_of_nodes = this -> number_of_nodes();<br>
><br>
><br>
> ofstream binWriter(file_name.c_str(), ios::binary);<br>
><br>
><br>
> binWriter << "# vtk DataFile Version 2.0 \n";<br>
><br>
> binWriter << "Quadtree Mesh \n";<br>
><br>
> binWriter << "BINARY \n";<br>
><br>
> binWriter << "DATASET UNSTRUCTURED_GRID \n";<br>
><br>
> binWriter << "POINTS " << number_of_nodes() << " double \n";<br>
><br>
><br>
> for (CaslInt n=0; n<num_of_nodes; n++){<br>
><br>
> x = this -> x_fr_i(node[n].i);<br>
><br>
> y = this -> y_fr_j(node[n].j);<br>
><br>
> z = 0.0;<br>
><br>
><br>
> binWriter.write((char*)&x, sizeof(double));<br>
><br>
> binWriter.write((char*)&y, sizeof(double));<br>
><br>
> binWriter.write((char*)&z, sizeof(double));<br>
><br>
> }<br>
><br>
><br>
> num_of_leaf_cells = 0;<br>
><br>
> for (CaslInt n=0; n<num_of_cells; n++){<br>
><br>
> if ( cell[n].is_leaf() ) num_of_leaf_cells++;<br>
><br>
> }<br>
><br>
> binWriter << "\n";<br>
><br>
> binWriter << "CELLS " << num_of_leaf_cells << " " << 5*num_of_leaf_cells<br>
> << "\n";<br>
><br>
><br>
> for (CaslInt n=0; n<num_of_cells; n++){<br>
><br>
> if ( cell[n].is_leaf() ){<br>
><br>
> i_min = cell[n].imin;<br>
><br>
> j_min = cell[n].jmin;<br>
><br>
> i_max = cell[n].imax();<br>
><br>
> j_max = cell[n].jmax();<br>
><br>
><br>
><br>
> node_of_cell[0] = this -> get_node_by_coordinates(i_min,j_min);<br>
><br>
> node_of_cell[1] = this -> get_node_by_coordinates(i_max,j_min);<br>
><br>
> node_of_cell[2] = this -> get_node_by_coordinates(i_max,j_max);<br>
><br>
> node_of_cell[3] = this -> get_node_by_coordinates(i_min,j_max);<br>
><br>
><br>
> int num_of_childs = 4;<br>
><br>
> binWriter.write((char*)&num_of_childs, sizeof(int));<br>
><br>
> binWriter.write((char*)&node_of_cell[0], sizeof(int)*4);<br>
><br>
> }<br>
><br>
> }<br>
><br>
> binWriter << "\n";<br>
><br>
> binWriter << "CELL_TYPES " << num_of_leaf_cells << "\n";<br>
><br>
><br>
> int cell_type = 9;<br>
><br>
> for (CaslInt n=0; n<num_of_leaf_cells; n++)<br>
> binWriter.write((char*)&cell_type, sizeof(int));<br>
><br>
><br>
> binWriter << "\n";<br>
><br>
><br>
> switch (format){<br>
><br>
> case POINT_DATA:{<br>
><br>
> binWriter << "POINT_DATA " << num_of_nodes << "\n";<br>
><br>
> break;<br>
><br>
> }<br>
><br>
><br>
> case CELL_DATA:{<br>
><br>
> binWriter << "CELL_DATA " << num_of_cells << "\n";<br>
><br>
> break;<br>
><br>
> }<br>
><br>
><br>
> }<br>
><br>
> binWriter.close();<br>
><br>
> }<br>
><br>
> void QuadTree::writeBinaryVTK(ArrayV<double> &F, string data_name, string<br>
> file_name){<br>
><br>
><br>
> ofstream binWriter(file_name.c_str(), ios::app | ios::binary);<br>
><br>
><br>
> binWriter << "SCALARS " << data_name << " double \n";<br>
><br>
> binWriter << "LOOKUP_TABLE default \n";<br>
><br>
><br>
> double *pF = (double*)F;<br>
><br>
> binWriter.write((char*)pF, sizeof(double)*F.size());<br>
><br>
><br>
> binWriter.close();<br>
><br>
> }<br>
><br>
><br>
><br>
><br>
> On Tue, May 15, 2012 at 2:25 PM, Mohammad Mirzadeh <<a href="mailto:mirzadeh@gmail.com">mirzadeh@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi guys,<br>
>><br>
>> I have a problem getting pv open my binary file. It basically segfaults<br>
>> and terminates without any information. When I run in gdb I get:<br>
>><br>
>> ERROR: In /build/buildd/paraview-3.8.1/VTK/IO/vtkDataReader.cxx, line 1910<br>
>> vtkUnstructuredGridReader (0x19f6890): Unsupported data type: 1<br>
>><br>
>> Program received signal SIGBUS, Bus error.<br>
>> 0x00007fffeaeb6597 in<br>
>> vtkDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet*, vtkPolyData*)<br>
>> ()<br>
>> from /usr/lib/paraview/libvtkGraphics.so.pv3.8<br>
>><br>
>> Program terminated with signal SIGBUS, Bus error.<br>
>><br>
>> Is there something wrong with my data file? I could send a sample file if<br>
>> needed. I basically followed <a href="http://www.vtk.org/VTK/img/file-formats.pdf" target="_blank">http://www.vtk.org/VTK/img/file-formats.pdf</a> to<br>
>> write the binary format.<br>
>><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <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:<br>
> <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://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
><br>
</blockquote></div><br></div></div>