added bbox in the header, added missing typenames
This commit is contained in:
parent
446400f6fc
commit
9057e1dcd6
|
|
@ -67,6 +67,8 @@ namespace io {
|
||||||
static void WriteString(FILE *f,const char * in) { unsigned int l = strlen(in); fwrite(&l,4,1,f); fwrite(in,1,l,f);}
|
static void WriteString(FILE *f,const char * in) { unsigned int l = strlen(in); fwrite(&l,4,1,f); fwrite(in,1,l,f);}
|
||||||
static void WriteInt(FILE *f,const unsigned int i) { fwrite(&i,1,4,f);}
|
static void WriteInt(FILE *f,const unsigned int i) { fwrite(&i,1,4,f);}
|
||||||
|
|
||||||
|
static void WriteFloat(FILE *f,const float v) { fwrite(&v,1,sizeof(float),f);}
|
||||||
|
|
||||||
/* save Ocf Vertex Components */
|
/* save Ocf Vertex Components */
|
||||||
template <typename OpenMeshType,typename CONT>
|
template <typename OpenMeshType,typename CONT>
|
||||||
struct SaveVertexOcf{
|
struct SaveVertexOcf{
|
||||||
|
|
@ -260,6 +262,11 @@ namespace io {
|
||||||
WriteString(F(),"SIZE_VECTOR_VERTS");
|
WriteString(F(),"SIZE_VECTOR_VERTS");
|
||||||
WriteInt(F(),vertSize);
|
WriteInt(F(),vertSize);
|
||||||
|
|
||||||
|
WriteString(F(),"BOUNDING_BOX");
|
||||||
|
float float_value;
|
||||||
|
for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.min[i]; WriteFloat(F(),float_value);}
|
||||||
|
for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.max[i]; WriteFloat(F(),float_value);}
|
||||||
|
|
||||||
WriteString(F(),"end_header");
|
WriteString(F(),"end_header");
|
||||||
/* end header */
|
/* end header */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,7 @@ namespace io {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadInt(FILE *f, unsigned int & i){ fread(&i,1,4,f);}
|
static void ReadInt(FILE *f, unsigned int & i){ fread(&i,1,4,f);}
|
||||||
|
static void ReadFloat(FILE *f, float & v){ fread(&v,1,sizeof(float),f);}
|
||||||
|
|
||||||
|
|
||||||
static int LoadVertexOcfMask( FILE * f){
|
static int LoadVertexOcfMask( FILE * f){
|
||||||
|
|
@ -443,35 +444,35 @@ namespace io {
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_QUALITY_OCF")) {
|
if( s == std::string("HAS_FACE_QUALITY_OCF")) {
|
||||||
face.EnableQuality();
|
face.EnableQuality();
|
||||||
fread((void*)&face.QV[0],sizeof(FaceType::QualityType),face.size(),f);
|
fread((void*)&face.QV[0],sizeof(typename FaceType::QualityType),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// face color
|
// face color
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_COLOR_OCF")) {
|
if( s == std::string("HAS_FACE_COLOR_OCF")) {
|
||||||
face.EnableColor();
|
face.EnableColor();
|
||||||
fread((void*)&face.CV[0],sizeof(FaceType::ColorType),face.size(),f);
|
fread((void*)&face.CV[0],sizeof(typename FaceType::ColorType),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// face normal
|
// face normal
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_NORMAL_OCF")) {
|
if( s == std::string("HAS_FACE_NORMAL_OCF")) {
|
||||||
face.EnableNormal();
|
face.EnableNormal();
|
||||||
fread((void*)&face.NV[0],sizeof(FaceType::NormalType),face.size(),f);
|
fread((void*)&face.NV[0],sizeof(typename FaceType::NormalType),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// face mark
|
// face mark
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_MARK_OCF")) {
|
if( s == std::string("HAS_FACE_MARK_OCF")) {
|
||||||
face.EnableMark();
|
face.EnableMark();
|
||||||
fread((void*)&face.MV[0],sizeof(FaceType::MarkType),face.size(),f);
|
fread((void*)&face.MV[0],sizeof(typename FaceType::MarkType),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// face wedgetexcoord
|
// face wedgetexcoord
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_WEDGETEXCOORD_OCF")) {
|
if( s == std::string("HAS_FACE_WEDGETEXCOORD_OCF")) {
|
||||||
face.EnableWedgeTex();
|
face.EnableWedgeTex();
|
||||||
fread((void*)&face.WTV[0],sizeof(FaceType::WedgeTexCoordType),face.size(),f);
|
fread((void*)&face.WTV[0],sizeof(typename FaceType::WedgeTexCoordType),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -479,28 +480,28 @@ namespace io {
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_FFADJACENCY_OCF")) {
|
if( s == std::string("HAS_FACE_FFADJACENCY_OCF")) {
|
||||||
face.EnableFFAdjacency();
|
face.EnableFFAdjacency();
|
||||||
fread((void*)&face.AF[0],sizeof(face::vector_ocf<FaceType>::AdjTypePack),face.size(),f);
|
fread((void*)&face.AF[0],sizeof(typename face::vector_ocf<FaceType>::AdjTypePack),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vertex-face adjacency
|
// vertex-face adjacency
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_VFADJACENCY_OCF")) {
|
if( s == std::string("HAS_FACE_VFADJACENCY_OCF")) {
|
||||||
face.EnableVFAdjacency();
|
face.EnableVFAdjacency();
|
||||||
fread((void*)&face.AV[0],sizeof(face::vector_ocf<FaceType>::AdjTypePack),face.size(),f);
|
fread((void*)&face.AV[0],sizeof(typename face::vector_ocf<FaceType>::AdjTypePack),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// face WedgeColor
|
// face WedgeColor
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_WEDGECOLOR_OCF")) {
|
if( s == std::string("HAS_FACE_WEDGECOLOR_OCF")) {
|
||||||
face.EnableWedgeColor();
|
face.EnableWedgeColor();
|
||||||
fread((void*)&face.WCV[0],sizeof(face::vector_ocf<FaceType>::WedgeColorTypePack),face.size(),f);
|
fread((void*)&face.WCV[0],sizeof(typename face::vector_ocf<FaceType>::WedgeColorTypePack),face.size(),f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// face WedgeNormal
|
// face WedgeNormal
|
||||||
ReadString(f,s);
|
ReadString(f,s);
|
||||||
if( s == std::string("HAS_FACE_WEDGENORMAL_OCF")) {
|
if( s == std::string("HAS_FACE_WEDGENORMAL_OCF")) {
|
||||||
face.EnableWedgeNormal();
|
face.EnableWedgeNormal();
|
||||||
fread((void*)&face.WNV[0],sizeof(face::vector_ocf<FaceType>::WedgeNormalTypePack),face.size(),f);
|
fread((void*)&face.WNV[0],sizeof(typename face::vector_ocf<FaceType>::WedgeNormalTypePack),face.size(),f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -573,11 +574,15 @@ namespace io {
|
||||||
return error_msg[message_code];
|
return error_msg[message_code];
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
/* Read the info about the mesh. Note: in the header the bounding box is always written/readed
|
||||||
|
as a vcg::Box3f, even if the scalar type is not float. The bounding box of the mesh will
|
||||||
|
be set properly on loading.
|
||||||
|
*/
|
||||||
static bool GetHeader( std::vector<std::string>& fnameV,
|
static bool GetHeader( std::vector<std::string>& fnameV,
|
||||||
std::vector<std::string>& fnameF,
|
std::vector<std::string>& fnameF,
|
||||||
unsigned int & vertSize,
|
unsigned int & vertSize,
|
||||||
unsigned int &faceSize,
|
unsigned int &faceSize,
|
||||||
|
vcg::Box3f & bbox,
|
||||||
int & mask){
|
int & mask){
|
||||||
std::string name;
|
std::string name;
|
||||||
unsigned int nameFsize,nameVsize,i;
|
unsigned int nameFsize,nameVsize,i;
|
||||||
|
|
@ -592,18 +597,25 @@ namespace io {
|
||||||
ReadString(F(), name); ReadInt(F(),nameVsize);
|
ReadString(F(), name); ReadInt(F(),nameVsize);
|
||||||
|
|
||||||
for(i=0; i < nameVsize; ++i)
|
for(i=0; i < nameVsize; ++i)
|
||||||
{ReadString(F(), name) ;fnameV.push_back( name);;mask |= VertexMaskBitFromString(name);}
|
{ReadString(F(), name) ;fnameV.push_back( name);mask |= VertexMaskBitFromString(name);}
|
||||||
mask |= LoadVertexOcfMask(F());
|
mask |= LoadVertexOcfMask(F());
|
||||||
|
|
||||||
ReadString(F(),name); ReadInt(F(),vertSize);
|
ReadString(F(),name); ReadInt(F(),vertSize);
|
||||||
|
|
||||||
|
ReadString(F(),name);
|
||||||
|
float float_value;
|
||||||
|
for(unsigned int i =0; i < 2; ++i){ReadFloat(F(),float_value); bbox.min[i]=float_value;}
|
||||||
|
for(unsigned int i =0; i < 2; ++i){ReadFloat(F(),float_value); bbox.max[i]=float_value;}
|
||||||
|
|
||||||
ReadString(F(),name);
|
ReadString(F(),name);
|
||||||
assert(strstr( name.c_str(),"end_header")!=NULL);
|
assert(strstr( name.c_str(),"end_header")!=NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GetHeader(char * filename,std::vector<std::string>& nameV, std::vector<std::string>& nameF, int & vertSize, int &faceSize,int & mask){
|
|
||||||
|
static bool GetHeader(char * filename,std::vector<std::string>& nameV, std::vector<std::string>& nameF, unsigned int & vertSize, unsigned int &faceSize,vcg::Box3f & bbox,int & mask){
|
||||||
F() = fopen(filename,"rb");
|
F() = fopen(filename,"rb");
|
||||||
return GetHeader(F(),nameV, nameF, vertSize, faceSize,mask);
|
return GetHeader(nameV, nameF, vertSize, faceSize,bbox,mask);
|
||||||
fclose(F());
|
fclose(F());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -612,7 +624,8 @@ namespace io {
|
||||||
std::vector<std::string> nameV;
|
std::vector<std::string> nameV;
|
||||||
std::vector<std::string> nameF;
|
std::vector<std::string> nameF;
|
||||||
int vertSize, faceSize;
|
int vertSize, faceSize;
|
||||||
GetHeader(f,nameV,nameF,vertSize, faceSize, mask);
|
vcg::Box3f bbox;
|
||||||
|
GetHeader(f,nameV,nameF,vertSize, faceSize, bbox, mask);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -628,7 +641,7 @@ namespace io {
|
||||||
unsigned int vertSize,faceSize;
|
unsigned int vertSize,faceSize;
|
||||||
|
|
||||||
/* read the header */
|
/* read the header */
|
||||||
GetHeader(fnameV, fnameF, vertSize, faceSize,mask);
|
GetHeader(fnameV, fnameF, vertSize, faceSize,m.bbox,mask);
|
||||||
|
|
||||||
/* read the mesh type */
|
/* read the mesh type */
|
||||||
OpenMeshType::FaceType::Name(nameF);
|
OpenMeshType::FaceType::Name(nameF);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue