Extended comment, changed load and save replacing dangerous write and read of the object mesh as whole with saving of its few members

This commit is contained in:
ganovelli 2008-08-01 10:03:05 +00:00
parent 3712ddfd50
commit cff47a9ac3
2 changed files with 28 additions and 10 deletions

View File

@ -39,8 +39,13 @@
VMI VCG Mesh Image. VMI VCG Mesh Image.
The vmi image file consists of a header containing the description of the vertex and face type, The vmi image file consists of a header containing the description of the vertex and face type,
the length of vectors containing vertices of faces and the memory image of the object mesh as it is when the length of vectors containing vertices of faces and the memory image of the object mesh as it is when
passed to the function Save(SaveMeshType m) passed to the function Save(SaveMeshType m).
*/ NOTE: THIS IS NOT A FILE FORMAT. IT IS ONLY USEFUL FOR DUMPING MESH IMAGES FOR DEBUG PURPOSE.
Example of use: say you are running a time consuming mesh processing and you want to save intermediate
state, but no file format support all the attributes you need in your vertex/face type.
NOTE2: At the present if you add members to your TriMesh these will NOT be saved. More precisely, this file and
import_vmi must be updated to reflect changes in vcg/complex/trimesh/base.h
*/
namespace vcg { namespace vcg {
namespace tri { namespace tri {
@ -84,7 +89,13 @@ namespace io {
fwrite(&offsetF,sizeof( int),1,f); fwrite(&offsetF,sizeof( int),1,f);
/* save the object mesh */ /* save the object mesh */
fwrite(&m,sizeof(SaveMeshType),1,f); fwrite(&m.camera,sizeof(Camera<SaveMeshType::ScalarType>),1,f);
fwrite(&m.shot,sizeof(Shot<SaveMeshType::ScalarType>),1,f);
fwrite(&m.vn,sizeof(int),1,f);
fwrite(&m.fn,sizeof(int),1,f);
fwrite(&m.imark,sizeof(int),1,f);
fwrite(&m.bbox,sizeof(Box3<SaveMeshType::ScalarType>),1,f);
fwrite(&m.C(),sizeof(Color4b),1,f);
int written; int written;
/* save the vertices */ /* save the vertices */

View File

@ -40,6 +40,12 @@
The vmi image file consists of a header containing the description of the vertex and face type, The vmi image file consists of a header containing the description of the vertex and face type,
the length of vectors containing vertices of faces and the memory image of the object mesh as it is when the length of vectors containing vertices of faces and the memory image of the object mesh as it is when
passed to the function Save(SaveMeshType m) passed to the function Save(SaveMeshType m)
NOTE: THIS IS NOT A FILE FORMAT. IT IS ONLY USEFUL FOR DUMPING MESH IMAGES FOR DEBUG PURPOSE.
Example of use: say you are running a time consuming mesh processing and you want to save intermediate
state, but no file format support all the attributes you need in your vertex/face type.
NOTE2: At the present if you add members to your TriMesh these will NOT be saved. More precisely, this file and
import_vmi must be updated to reflect changes in vcg/complex/trimesh/base.h
*/ */
namespace vcg { namespace vcg {
@ -111,14 +117,15 @@ namespace io {
fread(&offsetF,sizeof( int),1,f); fread(&offsetF,sizeof( int),1,f);
/* read the object mesh */ /* read the object mesh */
fread(&m,sizeof(OpenMeshType),1,f); fread(&m.camera,sizeof(Camera<OpenMeshType::ScalarType>),1,f);
fread(&m.shot,sizeof(Shot<OpenMeshType::ScalarType>),1,f);
/* overwrite che container because they could be inconsistent */ fread(&m.vn,sizeof(int),1,f);
OpenMeshType::VertContainer tvc; fread(&m.fn,sizeof(int),1,f);
OpenMeshType::FaceContainer tfc; fread(&m.imark,sizeof(int),1,f);
memcpy(&m.vert,&tvc,sizeof(OpenMeshType::VertContainer)); fread(&m.bbox,sizeof(Box3<OpenMeshType::ScalarType>),1,f);
memcpy(&m.face,&tfc,sizeof(OpenMeshType::FaceContainer)); fread(&m.C(),sizeof(Color4b),1,f);
/* resize the vector of vertices */
m.vert.resize(vertSize); m.vert.resize(vertSize);
int read; int read;