Go to the documentation of this file.
7 #pragma warning(disable:4996)
78 #if defined(__APPLE__) || defined(__CELLOS_LV2__)
79 #define stricmp(a, b) strcasecmp((a), (b))
88 virtual int ParseLine(
int lineno,
int argc,
const char **argv) =0;
127 for (
int i=0; i<256; i++)
140 void SetFile(
const char *fname);
153 const char **
GetArglist(
char *source,
int &count);
196 inline char *
AddHard(
int &argc,
const char **argv,
char *foo);
197 inline bool IsHard(
char c);
224 FILE *fph = fopen(fname,
"rb");
227 fseek(fph,0L,SEEK_END);
229 fseek(fph,0L,SEEK_SET);
232 mData = (
char *) malloc(
sizeof(
char)*(
mLen+1));
310 if (
EOS(*foo) )
break;
348 if ( *foo ) *foo = 32;
379 ret = callback->
ParseLine(lineno, argc, argv );
388 if ( !
mData )
return 0;
400 if ( *foo == 10 || *foo == 13 )
412 if ( *foo == 10 ) foo++;
445 const char **ret = 0;
447 static const char *argv[
MAXARGS];
457 if (
EOS(*foo) )
break;
495 if ( *foo ) *foo = 32;
566 int ParseLine(
int lineno,
int argc,
const char **argv);
602 static const char *
GetArg(
const char **argv,
int i,
int argc)
604 const char * ret = 0;
605 if ( i < argc ) ret = argv[i];
622 int index = atoi( face )-1;
624 const char *texel = strstr(face,
"/");
628 int tindex = atoi( texel+1) - 1;
630 if ( tindex >=0 && tindex < (
int)(
mTexels.size()/2) )
632 const double *t = &
mTexels[tindex*2];
639 const char *normal = strstr(texel+1,
"/");
642 int nindex = atoi( normal+1 ) - 1;
644 if (nindex >= 0 && nindex < (
int)(
mNormals.size()/3) )
646 const double *n = &
mNormals[nindex*3];
655 if ( index >= 0 && index < (
int)(
mVerts.size()/3) )
658 const double *p = &
mVerts[index*3];
673 const char *foo = argv[0];
676 if ( strcmp(argv[0],
"v") == 0 && argc == 4 )
678 double vx = (double) atof( argv[1] );
679 double vy = (double) atof( argv[2] );
680 double vz = (double) atof( argv[3] );
685 else if ( strcmp(argv[0],
"vt") == 0 && argc == 3 )
687 double tx = (double) atof( argv[1] );
688 double ty = (double) atof( argv[2] );
692 else if ( strcmp(argv[0],
"vn") == 0 && argc == 4 )
694 double normalx = (double) atof(argv[1]);
695 double normaly = (double) atof(argv[2]);
696 double normalz = (double) atof(argv[3]);
701 else if ( strcmp(argv[0],
"f") == 0 && argc >= 4 )
707 for (
int i=1; i<argc; i++)
713 #if 0 // not currently implemented
723 for (
int i=0; i<vcount; i++)
737 for (
int i=2; i<(vcount-1); i++)
767 for (
int i=0; i<vcount; i++)
769 if ( v[0] == p[0] && v[1] == p[1] && v[2] == p[2] )
return i;
814 unsigned int ret = 0;
843 else if( obj.
mVerts.size() > 0 ) {
int LoadMesh(const char *fname, GeometryInterface *callback)
unsigned int loadObj(const char *fname)
virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3)
void SetSourceData(char *data, int len)
double ComputeNormal(const Vector3d< double > &A, const Vector3d< double > &B, const Vector3d< double > &C)
bool IsNonSeparator(char c)
int Parse(InPlaceParserInterface *callback)
InPlaceParser(char *data, int len)
virtual int ParseLine(int lineno, int argc, const char **argv)=0
GeometryInterface * mCallback
int ParseLine(int lineno, int argc, const char **argv)
std::vector< int > IntVector
static const char * GetArg(const char **argv, int i, int argc)
int ProcessLine(int lineno, char *line, InPlaceParserInterface *callback)
bool IsWhiteSpace(char c)
void DefaultSymbols(void)
char * AddHard(int &argc, const char **argv, char *foo)
void SetQuoteChar(char c)
void SetFile(const char *fname)
char * SkipSpaces(char *foo)
int GetIndex(const double *p)
InPlaceParser(const char *fname)
const IntVector & GetIndices(void) const
void ClearHardSeparator(char c)
void GetVertex(GeometryVertex &v, const char *face) const
std::vector< double > FloatVector
void SetHardSeparator(char c)
void SetCommentSymbol(char c)
virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3)
const FloatVector & GetVertices(void) const
const char ** GetArglist(char *source, int &count)