[Paraview] pv 3.8 segfaults on opening raw binary files
Mohammad Mirzadeh
mirzadeh at gmail.com
Wed May 16 14:49:36 EDT 2012
If it helps, here's the source code and attached is a sample binary file:
void QuadTree::writeBinaryVTK(string file_name, vtk_data_format format){
CaslInt num_of_nodes, num_of_cells, num_of_leaf_cells;
CaslInt node_of_cell[4];
const QuadCell *cell = this -> get_cells();
const QuadNode *node = this -> get_nodes();
double x, y, z;
CaslInt i_max, j_max;
CaslInt i_min, j_min;
num_of_cells = this -> number_of_cells();
num_of_nodes = this -> number_of_nodes();
ofstream binWriter(file_name.c_str(), ios::binary);
binWriter << "# vtk DataFile Version 2.0 \n";
binWriter << "Quadtree Mesh \n";
binWriter << "BINARY \n";
binWriter << "DATASET UNSTRUCTURED_GRID \n";
binWriter << "POINTS " << number_of_nodes() << " double \n";
for (CaslInt n=0; n<num_of_nodes; n++){
x = this -> x_fr_i(node[n].i);
y = this -> y_fr_j(node[n].j);
z = 0.0;
binWriter.write((char*)&x, sizeof(double));
binWriter.write((char*)&y, sizeof(double));
binWriter.write((char*)&z, sizeof(double));
}
num_of_leaf_cells = 0;
for (CaslInt n=0; n<num_of_cells; n++){
if ( cell[n].is_leaf() ) num_of_leaf_cells++;
}
binWriter << "\n";
binWriter << "CELLS " << num_of_leaf_cells << " " <<
5*num_of_leaf_cells << "\n";
for (CaslInt n=0; n<num_of_cells; n++){
if ( cell[n].is_leaf() ){
i_min = cell[n].imin;
j_min = cell[n].jmin;
i_max = cell[n].imax();
j_max = cell[n].jmax();
node_of_cell[0] = this -> get_node_by_coordinates(i_min,j_min);
node_of_cell[1] = this -> get_node_by_coordinates(i_max,j_min);
node_of_cell[2] = this -> get_node_by_coordinates(i_max,j_max);
node_of_cell[3] = this -> get_node_by_coordinates(i_min,j_max);
int num_of_childs = 4;
binWriter.write((char*)&num_of_childs, sizeof(int));
binWriter.write((char*)&node_of_cell[0], sizeof(int)*4);
}
}
binWriter << "\n";
binWriter << "CELL_TYPES " << num_of_leaf_cells << "\n";
int cell_type = 9;
for (CaslInt n=0; n<num_of_leaf_cells; n++)
binWriter.write((char*)&cell_type, sizeof(int));
binWriter << "\n";
switch (format){
case POINT_DATA:{
binWriter << "POINT_DATA " << num_of_nodes << "\n";
break;
}
case CELL_DATA:{
binWriter << "CELL_DATA " << num_of_cells << "\n";
break;
}
}
binWriter.close();
}
void QuadTree::writeBinaryVTK(ArrayV<double> &F, string data_name,
string file_name){
ofstream binWriter(file_name.c_str(), ios::app | ios::binary);
binWriter << "SCALARS " << data_name << " double \n";
binWriter << "LOOKUP_TABLE default \n";
double *pF = (double*)F;
binWriter.write((char*)pF, sizeof(double)*F.size());
binWriter.close();
}
On Tue, May 15, 2012 at 2:25 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:
> Hi guys,
>
> I have a problem getting pv open my binary file. It basically segfaults
> and terminates without any information. When I run in gdb I get:
>
> ERROR: In /build/buildd/paraview-3.8.1/VTK/IO/vtkDataReader.cxx, line 1910
> vtkUnstructuredGridReader (0x19f6890): Unsupported data type: 1
>
> Program received signal SIGBUS, Bus error.
> 0x00007fffeaeb6597 in
> vtkDataSetSurfaceFilter::UnstructuredGridExecute(vtkDataSet*, vtkPolyData*)
> ()
> from /usr/lib/paraview/libvtkGraphics.so.pv3.8
>
> Program terminated with signal SIGBUS, Bus error.
>
> Is there something wrong with my data file? I could send a sample file if
> needed. I basically followed http://www.vtk.org/VTK/img/file-formats.pdf to
> write the binary format.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120516/98097b7b/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin.vtk
Type: application/octet-stream
Size: 561 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120516/98097b7b/attachment-0001.obj>
More information about the ParaView
mailing list