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
$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
shot/camera io added
@ -183,7 +186,7 @@ static const PropDescriptor &VertDesc(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", "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", "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_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];
}
@ -241,32 +246,35 @@ static const PropDescriptor &CameraDesc(int i)
/// Standard call for knowing the meaning of an error code
static const char *ErrorMsg(int error)
{
const char * ply_error_msg[] =
{
"No errors",
"Can't open file",
"Header not found",
"Eof in header",
"Format not found",
"Syntax error on header",
"Property without element",
"Bad type name",
"Element not found",
"Property not found",
"Bad type on addtoread",
"Incompatible type",
"Bad cast",
"No vertex field found",
"No face field found",
"Unespected eof",
"Face with more than 3 vertices",
"Bad vertex index in face",
"Face with no 6 texture coordinates",
"Number of color differ from vertices"
};
static std::vector<std::string> ply_error_msg;
if(ply_error_msg.empty())
{
ply_error_msg.resize(PlyInfo::E_MAXPLYINFOERRORS );
ply_error_msg[ply::E_NOERROR ]="No errors";
ply_error_msg[ply::E_CANTOPEN ]="Can't open file";
ply_error_msg[ply::E_NOTHEADER ]="Header not found";
ply_error_msg[ply::E_UNESPECTEDEOF ]="Eof in header";
ply_error_msg[ply::E_NOFORMAT ]="Format not found";
ply_error_msg[ply::E_SYNTAX ]="Syntax error on header";
ply_error_msg[ply::E_PROPOUTOFELEMENT]="Property without element";
ply_error_msg[ply::E_BADTYPENAME ]="Bad type name";
ply_error_msg[ply::E_ELEMNOTFOUND ]="Element not found";
ply_error_msg[ply::E_PROPNOTFOUND ]="Property not found";
ply_error_msg[ply::E_BADTYPE ]="Bad type on addtoread";
ply_error_msg[ply::E_INCOMPATIBLETYPE]="Incompatible type";
ply_error_msg[ply::E_BADCAST ]="Bad cast";
ply_error_msg[PlyInfo::E_NO_VERTEX ]="No vertex field found";
ply_error_msg[PlyInfo::E_NO_FACE ]="No face field found";
ply_error_msg[PlyInfo::E_SHORTFILE ]="Unespected eof";
ply_error_msg[PlyInfo::E_NO_3VERTINFACE ]="Face with more than 3 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";
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(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(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.
{ 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
$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
Moved #define LITTLE_MACHINE outside of #ifdef WIN32 (linux on PC is little too).
@ -928,7 +932,7 @@ int PlyElement::AddToRead(
return E_BADTYPE;
}
if( islist!= p->islista || stotype1 != p->tipo ||
if( islist!= p->islist || stotype1 != p->tipo ||
( islist && stotype2!=p->tipoindex) )
{
return E_INCOMPATIBLETYPE;
@ -3144,7 +3148,7 @@ void PlyFile::compile( PlyProperty * p )
if(format==F_ASCII)
{
if(p->islista)
if(p->islist)
{
if(p->bestored)
p->cb = cb_read_list_ascii;
@ -3180,7 +3184,7 @@ void PlyFile::compile( PlyProperty * p )
}
else
{
if(p->islista)
if(p->islist)
{
if(p->bestored)
{
@ -3443,7 +3447,7 @@ int ReadBin ( XFILE * fp, const PlyProperty * pr, void * mem, int fmt )
assert(pr);
// Lettura di una lista
if(pr->islista)
if(pr->islist)
{
int i,n;
@ -3517,7 +3521,7 @@ int ReadAscii( XFILE * fp, const PlyProperty * pr, void * mem, int /*fmt*/ )
// Lettura di una lista
if(pr->islista)
if(pr->islist)
{
int i,n;

View File

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