Hello, help, my binary file is imported into paraview, it crashes,
FILE* fp;
char filename[1024];
cols = 10;
int num_nodes = 1, list_nodes = 1, cell_type = 1;
for (i = 0; i < nn; i++) {
sprintf(filename, "c:\\00yf\\dh_v\\bin-time%d.vtk", i);
fp = fopen(filename, "wb");
if (fp == NULL) {
printf("File open error!\n");
return 0; //等价退出
}
else
{
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "points cloud\n");
fprintf(fp, "BINARY\n");
fprintf(fp, "DATASET UNSTRUCTURED_GRID\n");
fprintf(fp, "POINTS %d float\n", cols);
for (j = 0; j < cols; j++) {
fwrite(&xx[i * cols + j], sizeof(float), 1, fp);
fwrite(&yy[i * cols + j], sizeof(float), 1, fp);
fwrite(&zz[i * cols + j], sizeof(float), 1, fp);
}
fprintf(fp, "\nCELLS %d %d\n",cols,cols*2);
for (j = 0; j < cols; j++) {
fwrite(&num_nodes, sizeof(int), 1, fp);
fwrite(&j, sizeof(int), 1, fp);
}
fprintf(fp, "\nCELL_TYPES %d\n",cols);
for (j = 0; j < cols; j++) {
fwrite(&cell_type, sizeof(int), 1, fp);
}
}
}