Don't know how to save a file with 3D content

Hi everyone!

I have a piece of code that compute a 3D shape. when I run this code, as a result it gives me a .raw file that I can't open it in any software. I know a raw file is a bunch of 3D coordinates but I can't convert it to other 3D formats so I could see it in software like Meshlab or Blender.

How I could save my object in other forms of 3d formats so it would be easy for me to see it?( like .off format)
This is my code. I need to save the "shape" before writnig it to a binary file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  // Compute 3D shape
    Space3D<double,1> space;
    if(cfg.error1)
    	space=GD_projection_by_sumOut(cameras,silhouettes,cfg.sizeX,cfg.sizeY,cfg.sizeZ,cfg.voxel_size,offset,cfg.e_lambda,0.03,cfg.max_it,cfg.dt,cfg.alpha);
    else
        space=GDok_dtOpt_partFixed_SPOTsphOut_fasterN(cameras,silhouettes,cfg.sizeX,cfg.sizeY,cfg.sizeZ,cfg.voxel_size,offset,cfg.e_lambda,0.03,cfg.max_it,cfg.dt,cfg.alpha);
    
   
    Volume<double> shape(space.size_x(),space.size_y(),space.size_z());
    shape=space.volume();
  
    // Write volume in a binary file 
    FILE *fw=NULL;
    double val;
    fw=fopen(cfg.out_file.c_str(),"w+");
    if(fw==NULL)
        cout << "Not enough memory file\n" << endl; 
    int nz=0,no=0;
    for(z=0; z < space.size_z(); z++)
        for(y=0; y < space.size_y(); y++)
            for(x=0; x < space.size_x(); x++)
            {
                val=shape[x][y][z];
                fwrite(&val,sizeof(double),1,fw);
                if(val==1) no++;
                if(val==0) nz++;
		if(space.volume()[x][y][z]>0.5) space.volume()[x][y][z]=1;
		else space.volume()[x][y][z]=0;
            }
    cout << "Number of voxels: " << space.size_z()*space.size_y()*space.size_x() << " to1: " << no << " to0: " << nz << endl;
    fclose(fw);

	
    // Write projection images
    write_projections(space,cameras);
    
    return 0;
}
Topic archived. No new replies allowed.