Improved the compatibility for ply format for faces having the list size (e.g. number of vertexes of a face) as a char instead of a uchar.

Added a couple of new face descriptors, corrected a bug in error reporting function (and restructured) and translated a few comments.
Thanks to Patrick Min for the careful bug reporting
This commit is contained in:
Paolo Cignoni 2005-01-03 10:35:59 +00:00
parent eb2e212382
commit 1e4b447859
3 changed files with 58 additions and 42 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.10 2004/10/07 14:51:10 ganovelli
added setidentity della camera
Revision 1.9 2004/10/07 14:19:06 ganovelli Revision 1.9 2004/10/07 14:19:06 ganovelli
shot/camera io added shot/camera io added
@ -183,7 +186,7 @@ static const PropDescriptor &VertDesc(int i)
static const PropDescriptor &FaceDesc(int i) static const PropDescriptor &FaceDesc(int i)
{ {
const static PropDescriptor qf[10]= const static PropDescriptor qf[12]=
{ {
{"face", "vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_UCHAR,offsetof(LoadPly_FaceAux,size) }, {"face", "vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_UCHAR,offsetof(LoadPly_FaceAux,size) },
{"face", "flags", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,flags), 0,0,0,0,0}, {"face", "flags", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,flags), 0,0,0,0,0},
@ -195,6 +198,8 @@ static const PropDescriptor &FaceDesc(int i)
{"face", "green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,g), 0,0,0,0,0}, {"face", "green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,g), 0,0,0,0,0},
{"face", "blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,b), 0,0,0,0,0}, {"face", "blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,b), 0,0,0,0,0},
{"face", "vertex_index", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_CHAR,offsetof(LoadPly_FaceAux,size) }, {"face", "vertex_index", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_CHAR,offsetof(LoadPly_FaceAux,size) },
{"face", "vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_CHAR,ply::T_CHAR,offsetof(LoadPly_FaceAux,size) },
{"face", "vertex_index", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_CHAR,ply::T_CHAR,offsetof(LoadPly_FaceAux,size) },
}; };
return qf[i]; return qf[i];
} }
@ -241,32 +246,35 @@ static const PropDescriptor &CameraDesc(int i)
/// Standard call for knowing the meaning of an error code /// Standard call for knowing the meaning of an error code
static const char *ErrorMsg(int error) static const char *ErrorMsg(int error)
{ {
const char * ply_error_msg[] = static std::vector<std::string> ply_error_msg;
if(ply_error_msg.empty())
{ {
"No errors", ply_error_msg.resize(PlyInfo::E_MAXPLYINFOERRORS );
"Can't open file", ply_error_msg[ply::E_NOERROR ]="No errors";
"Header not found", ply_error_msg[ply::E_CANTOPEN ]="Can't open file";
"Eof in header", ply_error_msg[ply::E_NOTHEADER ]="Header not found";
"Format not found", ply_error_msg[ply::E_UNESPECTEDEOF ]="Eof in header";
"Syntax error on header", ply_error_msg[ply::E_NOFORMAT ]="Format not found";
"Property without element", ply_error_msg[ply::E_SYNTAX ]="Syntax error on header";
"Bad type name", ply_error_msg[ply::E_PROPOUTOFELEMENT]="Property without element";
"Element not found", ply_error_msg[ply::E_BADTYPENAME ]="Bad type name";
"Property not found", ply_error_msg[ply::E_ELEMNOTFOUND ]="Element not found";
"Bad type on addtoread", ply_error_msg[ply::E_PROPNOTFOUND ]="Property not found";
"Incompatible type", ply_error_msg[ply::E_BADTYPE ]="Bad type on addtoread";
"Bad cast", ply_error_msg[ply::E_INCOMPATIBLETYPE]="Incompatible type";
"No vertex field found", ply_error_msg[ply::E_BADCAST ]="Bad cast";
"No face field found",
"Unespected eof", ply_error_msg[PlyInfo::E_NO_VERTEX ]="No vertex field found";
"Face with more than 3 vertices", ply_error_msg[PlyInfo::E_NO_FACE ]="No face field found";
"Bad vertex index in face", ply_error_msg[PlyInfo::E_SHORTFILE ]="Unespected eof";
"Face with no 6 texture coordinates", ply_error_msg[PlyInfo::E_NO_3VERTINFACE ]="Face with more than 3 vertices";
"Number of color differ from vertices" ply_error_msg[PlyInfo::E_BAD_VERT_INDEX ]="Bad vertex index in face";
}; ply_error_msg[PlyInfo::E_NO_6TCOORD ]="Face with no 6 texture coordinates";
ply_error_msg[PlyInfo::E_DIFFER_COLORS ]="Number of color differ from vertices";
}
if(error>PlyInfo::E_MAXPLYINFOERRORS || error<0) return "Unknown error"; if(error>PlyInfo::E_MAXPLYINFOERRORS || error<0) return "Unknown error";
else return ply_error_msg[error]; else return ply_error_msg[error].c_str();
}; };
@ -350,6 +358,8 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
if( pf.AddToRead(VertDesc(2))==-1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; } if( pf.AddToRead(VertDesc(2))==-1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
if( pf.AddToRead(FaceDesc(0))==-1 ) // Se fallisce si prova anche la sintassi di rapidform con index al posto di indices if( pf.AddToRead(FaceDesc(0))==-1 ) // Se fallisce si prova anche la sintassi di rapidform con index al posto di indices
if( pf.AddToRead(FaceDesc(9))==-1 ) if( pf.AddToRead(FaceDesc(9))==-1 )
if( pf.AddToRead(FaceDesc(10))==-1 )
if( pf.AddToRead(FaceDesc(11))==-1 )
if(pf.AddToRead(TristripDesc(0))==-1) // Se fallisce tutto si prova a vedere se ci sono tristrip alla levoy. if(pf.AddToRead(TristripDesc(0))==-1) // Se fallisce tutto si prova a vedere se ci sono tristrip alla levoy.
{ pi.status = PlyInfo::E_NO_FACE; return pi.status; } { pi.status = PlyInfo::E_NO_FACE; return pi.status; }

View File

@ -31,6 +31,10 @@ of Greg Turk and on the work of Claudio Rocchini
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.6 2004/06/23 15:36:57 cignoni
Restructured management of error, now the standard open for any mesh type return the error code, the default success value is zero
Any import class has a method ErrorMsg that give a verbal description of an error code.
Revision 1.5 2004/06/23 00:06:45 ponchio Revision 1.5 2004/06/23 00:06:45 ponchio
Moved #define LITTLE_MACHINE outside of #ifdef WIN32 (linux on PC is little too). Moved #define LITTLE_MACHINE outside of #ifdef WIN32 (linux on PC is little too).
@ -928,7 +932,7 @@ int PlyElement::AddToRead(
return E_BADTYPE; return E_BADTYPE;
} }
if( islist!= p->islista || stotype1 != p->tipo || if( islist!= p->islist || stotype1 != p->tipo ||
( islist && stotype2!=p->tipoindex) ) ( islist && stotype2!=p->tipoindex) )
{ {
return E_INCOMPATIBLETYPE; return E_INCOMPATIBLETYPE;
@ -3144,7 +3148,7 @@ void PlyFile::compile( PlyProperty * p )
if(format==F_ASCII) if(format==F_ASCII)
{ {
if(p->islista) if(p->islist)
{ {
if(p->bestored) if(p->bestored)
p->cb = cb_read_list_ascii; p->cb = cb_read_list_ascii;
@ -3180,7 +3184,7 @@ void PlyFile::compile( PlyProperty * p )
} }
else else
{ {
if(p->islista) if(p->islist)
{ {
if(p->bestored) if(p->bestored)
{ {
@ -3443,7 +3447,7 @@ int ReadBin ( XFILE * fp, const PlyProperty * pr, void * mem, int fmt )
assert(pr); assert(pr);
// Lettura di una lista // Lettura di una lista
if(pr->islista) if(pr->islist)
{ {
int i,n; int i,n;
@ -3517,7 +3521,7 @@ int ReadAscii( XFILE * fp, const PlyProperty * pr, void * mem, int /*fmt*/ )
// Lettura di una lista // Lettura di una lista
if(pr->islista) if(pr->islist)
{ {
int i,n; int i,n;

View File

@ -30,6 +30,9 @@ of Greg Turk and on the work of Claudio Rocchini
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.2 2004/04/27 13:29:19 turini
*** empty log message ***
Revision 1.1 2004/03/03 15:00:51 cignoni Revision 1.1 2004/03/03 15:00:51 cignoni
Initial commit Initial commit
@ -45,9 +48,8 @@ Initial commit
namespace vcg { namespace vcg {
namespace ply { namespace ply {
// Temporaneo
// Tipi di dato Supportati dal formato ply // Data types supported by the ply format
enum PlyTypes { enum PlyTypes {
T_NOTYPE, T_NOTYPE,
T_CHAR, T_CHAR,
@ -61,10 +63,10 @@ enum PlyTypes {
T_MAXTYPE T_MAXTYPE
}; };
// Codici di errore riportati da GetError // Error codes reported by GetError
enum PlyError { enum PlyError {
E_NOERROR, // 0 E_NOERROR, // 0
// Errori di open // Errors of open(..)
E_CANTOPEN, // 1 E_CANTOPEN, // 1
E_NOTHEADER, // 2 E_NOTHEADER, // 2
E_UNESPECTEDEOF, // 3 E_UNESPECTEDEOF, // 3
@ -72,7 +74,7 @@ enum PlyError {
E_SYNTAX, // 5 E_SYNTAX, // 5
E_PROPOUTOFELEMENT, // 6 E_PROPOUTOFELEMENT, // 6
E_BADTYPENAME, // 7 E_BADTYPENAME, // 7
// Errori di addtoread // Errors of addtoread(..)
E_ELEMNOTFOUND, // 8 E_ELEMNOTFOUND, // 8
E_PROPNOTFOUND, // 9 E_PROPNOTFOUND, // 9
E_BADTYPE, // 10 E_BADTYPE, // 10
@ -81,7 +83,7 @@ enum PlyError {
E_MAXPLYERRORS E_MAXPLYERRORS
}; };
// Tipi di formato di file // file formats supported by the ply format
enum PlyFormat { enum PlyFormat {
F_UNSPECIFIED, F_UNSPECIFIED,
F_ASCII, F_ASCII,
@ -98,7 +100,7 @@ typedef FILE * GZFILE;
// Messaggio di errore // Messaggio di errore
extern const char * ply_error_msg[]; //extern const char * ply_error_msg[];
// TIPO FILE // TIPO FILE
@ -126,7 +128,7 @@ public:
const char *stotypename() const; const char *stotypename() const;
}; };
// Callback di lettura // Reading Callback (used to copy a data prop)
typedef bool (* readelemcb) ( GZFILE fp, void * mem, PropDescriptor * p ); typedef bool (* readelemcb) ( GZFILE fp, void * mem, PropDescriptor * p );
class PlyProperty class PlyProperty
@ -135,7 +137,7 @@ public:
inline PlyProperty() inline PlyProperty()
{ {
tipo = 0; tipo = 0;
islista = 0; islist = 0;
tipoindex = 0; tipoindex = 0;
bestored = 0; bestored = 0;
} }
@ -150,14 +152,14 @@ public:
name = std::string(na); name = std::string(na);
tipo = ti; tipo = ti;
islista = isl; islist = isl;
tipoindex = t2; tipoindex = t2;
bestored = 0; bestored = 0;
} }
std::string name; // Nome della propieta' std::string name; // Nome della propieta'
int tipo; // Tipo di dato int tipo; // Tipo di dato
int islista; // Vero se e' una lista int islist; // Vero se e' una lista
int tipoindex; // Tipo del contatore della lista int tipoindex; // Tipo del contatore della lista
int bestored; // 1 se va storata int bestored; // 1 se va storata