added a missing const (otherwise clang would not compile)
This commit is contained in:
parent
ce4b264dfd
commit
eeccd23f71
|
@ -131,7 +131,7 @@ namespace io {
|
||||||
assert(new_pa.second);
|
assert(new_pa.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
T::template AddAttrib<0>(m,name,s,data);
|
T::template AddAttrib<0>(m,name,s,data);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(s == sizeof(A)){
|
if(s == sizeof(A)){
|
||||||
|
@ -158,7 +158,7 @@ namespace io {
|
||||||
assert(new_pa.second);
|
assert(new_pa.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
T::template AddAttrib<1>(m,name,s,data);
|
T::template AddAttrib<1>(m,name,s,data);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if(s == sizeof(A)){
|
if(s == sizeof(A)){
|
||||||
|
@ -183,7 +183,7 @@ namespace io {
|
||||||
assert(new_pa.second);
|
assert(new_pa.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
T::template AddAttrib<2>(m,name,s,data);
|
T::template AddAttrib<2>(m,name,s,data);
|
||||||
break;
|
break;
|
||||||
default: assert(0);break;
|
default: assert(0);break;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ namespace io {
|
||||||
*/
|
*/
|
||||||
template <class MeshType> struct K {
|
template <class MeshType> struct K {
|
||||||
template <int VoF>
|
template <int VoF>
|
||||||
static void AddAttrib(MeshType &/*m*/, const char * /*name*/, unsigned int /*s*/, void * /*data*/){
|
static void AddAttrib(MeshType &/*m*/, const char * /*name*/, unsigned int /*s*/, void * /*data*/){
|
||||||
// if yohu got this your attribute is larger than 1048576. Honestly...
|
// if yohu got this your attribute is larger than 1048576. Honestly...
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -242,25 +242,25 @@ namespace io {
|
||||||
class ImporterVMI: public AttrAll<OpenMeshType,A0,A1,A2,A3,A4>
|
class ImporterVMI: public AttrAll<OpenMeshType,A0,A1,A2,A3,A4>
|
||||||
{
|
{
|
||||||
|
|
||||||
static void ReadString(std::string & out){
|
static void ReadString(std::string & out){
|
||||||
unsigned int l; Read(&l,4,1);
|
unsigned int l; Read(&l,4,1);
|
||||||
char * buf = new char[l+1];
|
char * buf = new char[l+1];
|
||||||
Read(buf,1,l);buf[l]='\0';
|
Read(buf,1,l);buf[l]='\0';
|
||||||
out = std::string(buf);
|
out = std::string(buf);
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadInt( unsigned int & i){ Read(&i,1,4);}
|
static void ReadInt( unsigned int & i){ Read(&i,1,4);}
|
||||||
static void ReadFloat( float & v){ Read(&v,1,sizeof(float));}
|
static void ReadFloat( float & v){ Read(&v,1,sizeof(float));}
|
||||||
|
|
||||||
|
|
||||||
static int LoadVertexOcfMask( ){
|
static int LoadVertexOcfMask( ){
|
||||||
int mask =0;
|
int mask =0;
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
// vertex quality
|
// vertex quality
|
||||||
ReadString( s);
|
ReadString( s);
|
||||||
if( s == std::string("HAS_VERTEX_QUALITY_OCF")) mask |= Mask::IOM_VERTQUALITY;
|
if( s == std::string("HAS_VERTEX_QUALITY_OCF")) mask |= Mask::IOM_VERTQUALITY;
|
||||||
|
|
||||||
// vertex color
|
// vertex color
|
||||||
ReadString( s);
|
ReadString( s);
|
||||||
|
@ -276,7 +276,7 @@ namespace io {
|
||||||
|
|
||||||
// vertex texcoord
|
// vertex texcoord
|
||||||
ReadString( s);
|
ReadString( s);
|
||||||
if( s == std::string("HAS_VERTEX_TEXCOORD_OCF")) mask |= Mask::IOM_VERTTEXCOORD;
|
if( s == std::string("HAS_VERTEX_TEXCOORD_OCF")) mask |= Mask::IOM_VERTTEXCOORD;
|
||||||
|
|
||||||
// vertex-face adjacency
|
// vertex-face adjacency
|
||||||
ReadString( s);
|
ReadString( s);
|
||||||
|
@ -294,7 +294,7 @@ namespace io {
|
||||||
ReadString( s);
|
ReadString( s);
|
||||||
if( s == std::string("HAS_VERTEX_RADIUS_OCF")) mask |= Mask::IOM_VERTRADIUS;
|
if( s == std::string("HAS_VERTEX_RADIUS_OCF")) mask |= Mask::IOM_VERTRADIUS;
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MeshType, typename CONT>
|
template <typename MeshType, typename CONT>
|
||||||
|
@ -309,7 +309,7 @@ namespace io {
|
||||||
template <typename MeshType>
|
template <typename MeshType>
|
||||||
struct
|
struct
|
||||||
LoadVertexOcf<MeshType,vertex::vector_ocf<typename OpenMeshType::VertexType> >{
|
LoadVertexOcf<MeshType,vertex::vector_ocf<typename OpenMeshType::VertexType> >{
|
||||||
typedef typename OpenMeshType::VertexType VertexType;
|
typedef typename OpenMeshType::VertexType VertexType;
|
||||||
LoadVertexOcf( FILE * f, vertex::vector_ocf<typename OpenMeshType::VertexType> & vert){
|
LoadVertexOcf( FILE * f, vertex::vector_ocf<typename OpenMeshType::VertexType> & vert){
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
|
@ -427,14 +427,14 @@ namespace io {
|
||||||
// face WedgeNormal
|
// face WedgeNormal
|
||||||
ReadString( s);
|
ReadString( s);
|
||||||
if( s == std::string("HAS_FACE_WEDGENORMAL_OCF")) mask |= Mask::IOM_WEDGNORMAL;
|
if( s == std::string("HAS_FACE_WEDGENORMAL_OCF")) mask |= Mask::IOM_WEDGNORMAL;
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* partial specialization for vector_ocf */
|
/* partial specialization for vector_ocf */
|
||||||
template <typename MeshType>
|
template <typename MeshType>
|
||||||
struct LoadFaceOcf< MeshType, face::vector_ocf<typename OpenMeshType::FaceType> >{
|
struct LoadFaceOcf< MeshType, face::vector_ocf<typename OpenMeshType::FaceType> >{
|
||||||
typedef typename OpenMeshType::FaceType FaceType;
|
typedef typename OpenMeshType::FaceType FaceType;
|
||||||
LoadFaceOcf( face::vector_ocf<FaceType> & face){
|
LoadFaceOcf( face::vector_ocf<FaceType> & face){
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
|
@ -612,15 +612,15 @@ namespace io {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool GetHeader(const char * filename,std::vector<std::string>& nameV, std::vector<std::string>& nameF, unsigned int & vertSize, unsigned int &faceSize,vcg::Box3f & bbox,int & mask){
|
static bool GetHeader(const 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");
|
||||||
bool res = GetHeader(nameV, nameF, vertSize, faceSize,bbox,mask);
|
bool res = GetHeader(nameV, nameF, vertSize, faceSize,bbox,mask);
|
||||||
fclose(F());
|
fclose(F());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char * & In_mem(){static char * in_mem; return in_mem;}
|
static const char * & In_mem(){static const char * in_mem; return in_mem;}
|
||||||
static unsigned int & In_mode(){static unsigned int in_mode = 0; return in_mode;}
|
static unsigned int & In_mode(){static unsigned int in_mode = 0; return in_mode;}
|
||||||
|
|
||||||
|
|
||||||
|
@ -639,10 +639,10 @@ namespace io {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool LoadMask(const char * f, int & mask){
|
static bool LoadMask(const char * f, int & mask){
|
||||||
std::vector<std::string> nameV;
|
std::vector<std::string> nameV;
|
||||||
std::vector<std::string> nameF;
|
std::vector<std::string> nameF;
|
||||||
unsigned int vertSize, faceSize;
|
unsigned int vertSize, faceSize;
|
||||||
vcg::Box3f bbox;
|
vcg::Box3f bbox;
|
||||||
F() = fopen(f,"rb");
|
F() = fopen(f,"rb");
|
||||||
In_mode() = 1;
|
In_mode() = 1;
|
||||||
|
@ -681,36 +681,36 @@ namespace io {
|
||||||
static int Deserialize(OpenMeshType &m, int & mask)
|
static int Deserialize(OpenMeshType &m, int & mask)
|
||||||
{
|
{
|
||||||
typedef typename OpenMeshType::VertexType VertexType;
|
typedef typename OpenMeshType::VertexType VertexType;
|
||||||
typedef typename OpenMeshType::FaceType FaceType;
|
typedef typename OpenMeshType::FaceType FaceType;
|
||||||
typename OpenMeshType::FaceIterator fi;
|
typename OpenMeshType::FaceIterator fi;
|
||||||
typename OpenMeshType::VertexIterator vi;
|
typename OpenMeshType::VertexIterator vi;
|
||||||
|
|
||||||
std::vector<std::string> nameF,nameV,fnameF,fnameV;
|
std::vector<std::string> nameF,nameV,fnameF,fnameV;
|
||||||
unsigned int vertSize,faceSize;
|
unsigned int vertSize,faceSize;
|
||||||
|
|
||||||
/* read the header */
|
/* read the header */
|
||||||
vcg::Box3f lbbox;
|
vcg::Box3f lbbox;
|
||||||
GetHeader(fnameV, fnameF, vertSize, faceSize,lbbox,mask);
|
GetHeader(fnameV, fnameF, vertSize, faceSize,lbbox,mask);
|
||||||
m.bbox.Import(lbbox);
|
m.bbox.Import(lbbox);
|
||||||
/* read the mesh type */
|
/* read the mesh type */
|
||||||
OpenMeshType::FaceType::Name(nameF);
|
OpenMeshType::FaceType::Name(nameF);
|
||||||
OpenMeshType::VertexType::Name(nameV);
|
OpenMeshType::VertexType::Name(nameV);
|
||||||
|
|
||||||
/* check if the type is the very same, otherwise return */
|
/* check if the type is the very same, otherwise return */
|
||||||
if(fnameV != nameV) return VMI_INCOMPATIBLE_VERTEX_TYPE;
|
if(fnameV != nameV) return VMI_INCOMPATIBLE_VERTEX_TYPE;
|
||||||
if(fnameF != nameF) return VMI_INCOMPATIBLE_FACE_TYPE;
|
if(fnameF != nameF) return VMI_INCOMPATIBLE_FACE_TYPE;
|
||||||
|
|
||||||
void * offsetV = 0,*offsetF = 0;
|
void * offsetV = 0,*offsetF = 0;
|
||||||
|
|
||||||
if(vertSize!=0)
|
if(vertSize!=0)
|
||||||
/* read the address of the first vertex */
|
/* read the address of the first vertex */
|
||||||
Read(&offsetV,sizeof( void *),1 );
|
Read(&offsetV,sizeof( void *),1 );
|
||||||
|
|
||||||
if(faceSize!=0)
|
if(faceSize!=0)
|
||||||
/* read the address of the first face */
|
/* read the address of the first face */
|
||||||
Read(&offsetF,sizeof( void *),1 );
|
Read(&offsetF,sizeof( void *),1 );
|
||||||
|
|
||||||
/* read the object mesh */
|
/* read the object mesh */
|
||||||
Read(&m.shot,sizeof(Shot<typename OpenMeshType::ScalarType>),1 );
|
Read(&m.shot,sizeof(Shot<typename OpenMeshType::ScalarType>),1 );
|
||||||
Read(&m.vn,sizeof(int),1 );
|
Read(&m.vn,sizeof(int),1 );
|
||||||
Read(&m.fn,sizeof(int),1 );
|
Read(&m.fn,sizeof(int),1 );
|
||||||
|
@ -723,10 +723,10 @@ namespace io {
|
||||||
m.vert.resize(vertSize);
|
m.vert.resize(vertSize);
|
||||||
|
|
||||||
|
|
||||||
size_t read = 0;
|
size_t read = 0;
|
||||||
/* load the vertices */
|
/* load the vertices */
|
||||||
if(vertSize>0){
|
if(vertSize>0){
|
||||||
read=Read((void*)& m.vert[0],sizeof(VertexType),vertSize );
|
read=Read((void*)& m.vert[0],sizeof(VertexType),vertSize );
|
||||||
LoadVertexOcf<OpenMeshType,VertContainer>(F(),m.vert);
|
LoadVertexOcf<OpenMeshType,VertContainer>(F(),m.vert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,8 +734,8 @@ namespace io {
|
||||||
m.face.resize(faceSize);
|
m.face.resize(faceSize);
|
||||||
if(faceSize>0){
|
if(faceSize>0){
|
||||||
/* load the faces */
|
/* load the faces */
|
||||||
read = Read((void*)& m.face[0],sizeof(FaceType),faceSize );
|
read = Read((void*)& m.face[0],sizeof(FaceType),faceSize );
|
||||||
LoadFaceOcf<OpenMeshType,FaceContainer>(m.face);
|
LoadFaceOcf<OpenMeshType,FaceContainer>(m.face);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -745,23 +745,23 @@ namespace io {
|
||||||
|
|
||||||
ReadString( _trash); ReadInt( n);
|
ReadString( _trash); ReadInt( n);
|
||||||
|
|
||||||
for(size_t ia = 0 ; ia < n; ++ia){
|
for(size_t ia = 0 ; ia < n; ++ia){
|
||||||
ReadString(_trash); ReadString(_string);
|
ReadString(_trash); ReadString(_string);
|
||||||
ReadString(_trash); ReadInt(sz);
|
ReadString(_trash); ReadInt(sz);
|
||||||
|
|
||||||
void * data = Malloc(sz*m.vert.size());
|
void * data = Malloc(sz*m.vert.size());
|
||||||
Read(data,sz,m.vert.size());
|
Read(data,sz,m.vert.size());
|
||||||
AttrAll<OpenMeshType,A0,A1,A2,A3,A4>::template AddAttrib<0>(m,_string.c_str(),sz,data);
|
AttrAll<OpenMeshType,A0,A1,A2,A3,A4>::template AddAttrib<0>(m,_string.c_str(),sz,data);
|
||||||
Free(data);
|
Free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load the per face attributes */
|
/* load the per face attributes */
|
||||||
ReadString(_trash); ReadInt( n);
|
ReadString(_trash); ReadInt( n);
|
||||||
for(size_t ia = 0 ; ia < n; ++ia){
|
for(size_t ia = 0 ; ia < n; ++ia){
|
||||||
ReadString(_trash); ReadString( _string);
|
ReadString(_trash); ReadString( _string);
|
||||||
ReadString(_trash); ReadInt( sz);
|
ReadString(_trash); ReadInt( sz);
|
||||||
void * data = Malloc(sz*m.face.size());
|
void * data = Malloc(sz*m.face.size());
|
||||||
Read(data,sz,m.face.size() );
|
Read(data,sz,m.face.size() );
|
||||||
AttrAll<OpenMeshType,A0,A1,A2,A3,A4>::template AddAttrib<1>(m,_string.c_str(),sz,data);
|
AttrAll<OpenMeshType,A0,A1,A2,A3,A4>::template AddAttrib<1>(m,_string.c_str(),sz,data);
|
||||||
Free(data);
|
Free(data);
|
||||||
}
|
}
|
||||||
|
@ -772,7 +772,7 @@ namespace io {
|
||||||
ReadString( _trash); ReadString( _string);
|
ReadString( _trash); ReadString( _string);
|
||||||
ReadString( _trash); ReadInt( sz);
|
ReadString( _trash); ReadInt( sz);
|
||||||
void * data = Malloc(sz);
|
void * data = Malloc(sz);
|
||||||
Read(data,1,sz );
|
Read(data,1,sz );
|
||||||
AttrAll<OpenMeshType,A0,A1,A2,A3,A4>::template AddAttrib<2>(m,_string.c_str(),sz,data);
|
AttrAll<OpenMeshType,A0,A1,A2,A3,A4>::template AddAttrib<2>(m,_string.c_str(),sz,data);
|
||||||
Free(data);
|
Free(data);
|
||||||
}
|
}
|
||||||
|
@ -785,14 +785,14 @@ namespace io {
|
||||||
(*vi).VFp() = (*vi).VFp()-(FaceType*)offsetF+ &m.face[0];
|
(*vi).VFp() = (*vi).VFp()-(FaceType*)offsetF+ &m.face[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FaceVectorHasFVAdjacency(m.face))
|
if(FaceVectorHasFVAdjacency(m.face))
|
||||||
for(fi = m.face.begin(); fi != m.face.end(); ++fi){
|
for(fi = m.face.begin(); fi != m.face.end(); ++fi){
|
||||||
(*fi).V(0) = (*fi).V(0)-(VertexType*)offsetV+ &m.vert[0];
|
(*fi).V(0) = (*fi).V(0)-(VertexType*)offsetV+ &m.vert[0];
|
||||||
(*fi).V(1) = (*fi).V(1)-(VertexType*)offsetV+ &m.vert[0];
|
(*fi).V(1) = (*fi).V(1)-(VertexType*)offsetV+ &m.vert[0];
|
||||||
(*fi).V(2) = (*fi).V(2)-(VertexType*)offsetV+ &m.vert[0];
|
(*fi).V(2) = (*fi).V(2)-(VertexType*)offsetV+ &m.vert[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FaceVectorHasFFAdjacency(m.face))
|
if(FaceVectorHasFFAdjacency(m.face))
|
||||||
for(fi = m.face.begin(); fi != m.face.end(); ++fi){
|
for(fi = m.face.begin(); fi != m.face.end(); ++fi){
|
||||||
(*fi).FFp(0) = (*fi).FFp(0)-(FaceType*)offsetF+ &m.face[0];
|
(*fi).FFp(0) = (*fi).FFp(0)-(FaceType*)offsetF+ &m.face[0];
|
||||||
(*fi).FFp(1) = (*fi).FFp(1)-(FaceType*)offsetF+ &m.face[0];
|
(*fi).FFp(1) = (*fi).FFp(1)-(FaceType*)offsetF+ &m.face[0];
|
||||||
|
@ -801,7 +801,7 @@ namespace io {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return VMI_NO_ERROR; // zero is the standard (!) code of success
|
return VMI_NO_ERROR; // zero is the standard (!) code of success
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end class
|
}; // end class
|
||||||
|
|
Loading…
Reference in New Issue