Added a missing #include<wrap/io_trimesh/io_mask.h>

This commit is contained in:
Paolo Cignoni 2015-03-18 22:25:53 +00:00
parent 4d74a93851
commit 9d093af774
1 changed files with 48 additions and 49 deletions

View File

@ -24,8 +24,7 @@
#ifndef __VCGLIB_IMPORT_STL #ifndef __VCGLIB_IMPORT_STL
#define __VCGLIB_IMPORT_STL #define __VCGLIB_IMPORT_STL
#include <stdio.h> #include <stdio.h>
#include <wrap/callback.h> #include <wrap/io_trimesh/io_mask.h>
#include <vcg/space/color4.h>
namespace vcg { namespace vcg {
namespace tri { namespace tri {
@ -61,20 +60,20 @@ public:
}; };
enum STLError { enum STLError {
E_NOERROR, // 0 E_NOERROR, // 0
// Errori di open // Errori di open
E_CANTOPEN, // 1 E_CANTOPEN, // 1
E_UNESPECTEDEOF // 2 E_UNESPECTEDEOF // 2
}; };
static const char *ErrorMsg(int error) static const char *ErrorMsg(int error)
{ {
static const char * stl_error_msg[] = static const char * stl_error_msg[] =
{ {
"No errors", "No errors",
"Can't open file", "Can't open file",
"Premature End of file", "Premature End of file",
}; };
if(error>2 || error<0) return "Unknown error"; if(error>2 || error<0) return "Unknown error";
else return stl_error_msg[error]; else return stl_error_msg[error];
@ -124,7 +123,7 @@ static bool IsSTLColored(const char * filename, bool &magicsMode)
if(attr!=0) if(attr!=0)
{ {
if(Color4b::FromUnsignedR5G5B5(attr) != Color4b(Color4b::White)) if(Color4b::FromUnsignedR5G5B5(attr) != Color4b(Color4b::White))
return true; return true;
} }
} }
@ -192,7 +191,7 @@ static int OpenBinary( OpenMeshType &m, const char * filename, int &loadMask, Ca
FaceIterator fi=Allocator<OpenMeshType>::AddFaces(m,facenum); FaceIterator fi=Allocator<OpenMeshType>::AddFaces(m,facenum);
VertexIterator vi=Allocator<OpenMeshType>::AddVertices(m,facenum*3); VertexIterator vi=Allocator<OpenMeshType>::AddVertices(m,facenum*3);
// For each triangle read the normal, the three coords and a short set to zero // For each triangle read the normal, the three coords and a short set to zero
for(int i=0;i<facenum;++i) for(int i=0;i<facenum;++i)
{ {
unsigned short attr; unsigned short attr;
Point3f norm; Point3f norm;
@ -227,10 +226,10 @@ static int OpenBinary( OpenMeshType &m, const char * filename, int &loadMask, Ca
{ {
return E_CANTOPEN; return E_CANTOPEN;
} }
long currentPos = ftell(fp); long currentPos = ftell(fp);
fseek(fp,0L,SEEK_END); fseek(fp,0L,SEEK_END);
long fileLen = ftell(fp); long fileLen = ftell(fp);
fseek(fp,currentPos,SEEK_SET); fseek(fp,currentPos,SEEK_SET);
m.Clear(); m.Clear();
@ -239,37 +238,37 @@ static int OpenBinary( OpenMeshType &m, const char * filename, int &loadMask, Ca
STLFacet f; STLFacet f;
int cnt=0; int cnt=0;
int lineCnt=0; int lineCnt=0;
int ret; int ret;
/* Read a single facet from an ASCII .STL file */ /* Read a single facet from an ASCII .STL file */
while(!feof(fp)) while(!feof(fp))
{ {
if(cb && (++cnt)%1000) cb( int(double(ftell(fp))*100.0/fileLen), "STL Mesh Loading"); if(cb && (++cnt)%1000) cb( int(double(ftell(fp))*100.0/fileLen), "STL Mesh Loading");
ret=fscanf(fp, "%*s %*s %f %f %f\n", &f.n.X(), &f.n.Y(), &f.n.Z()); // --> "facet normal 0 0 0" ret=fscanf(fp, "%*s %*s %f %f %f\n", &f.n.X(), &f.n.Y(), &f.n.Z()); // --> "facet normal 0 0 0"
if(ret!=3) if(ret!=3)
{ {
// we could be in the case of a multiple solid object, where after a endfaced instead of another facet we have to skip two lines: // we could be in the case of a multiple solid object, where after a endfaced instead of another facet we have to skip two lines:
// endloop // endloop
// endfacet // endfacet
//endsolid <- continue on ret==0 will skip this line //endsolid <- continue on ret==0 will skip this line
//solid ascii <- and this one. //solid ascii <- and this one.
// facet normal 0.000000e+000 7.700727e-001 -6.379562e-001 // facet normal 0.000000e+000 7.700727e-001 -6.379562e-001
lineCnt++; lineCnt++;
continue; continue;
} }
ret=fscanf(fp, "%*s %*s"); // --> "outer loop" ret=fscanf(fp, "%*s %*s"); // --> "outer loop"
ret=fscanf(fp, "%*s %f %f %f\n", &f.v[0].X(), &f.v[0].Y(), &f.v[0].Z()); // --> "vertex x y z" ret=fscanf(fp, "%*s %f %f %f\n", &f.v[0].X(), &f.v[0].Y(), &f.v[0].Z()); // --> "vertex x y z"
if(ret!=3) if(ret!=3)
return E_UNESPECTEDEOF; return E_UNESPECTEDEOF;
ret=fscanf(fp, "%*s %f %f %f\n", &f.v[1].X(), &f.v[1].Y(), &f.v[1].Z()); // --> "vertex x y z" ret=fscanf(fp, "%*s %f %f %f\n", &f.v[1].X(), &f.v[1].Y(), &f.v[1].Z()); // --> "vertex x y z"
if(ret!=3) if(ret!=3)
return E_UNESPECTEDEOF; return E_UNESPECTEDEOF;
ret=fscanf(fp, "%*s %f %f %f\n", &f.v[2].X(), &f.v[2].Y(), &f.v[2].Z()); // --> "vertex x y z" ret=fscanf(fp, "%*s %f %f %f\n", &f.v[2].X(), &f.v[2].Y(), &f.v[2].Z()); // --> "vertex x y z"
if(ret!=3) if(ret!=3)
return E_UNESPECTEDEOF; return E_UNESPECTEDEOF;
ret=fscanf(fp, "%*s"); // --> "endloop" ret=fscanf(fp, "%*s"); // --> "endloop"
ret=fscanf(fp, "%*s"); // --> "endfacet" ret=fscanf(fp, "%*s"); // --> "endfacet"
lineCnt+=7; lineCnt+=7;
if(feof(fp)) break; if(feof(fp)) break;
FaceIterator fi=Allocator<OpenMeshType>::AddFaces(m,1); FaceIterator fi=Allocator<OpenMeshType>::AddFaces(m,1);
VertexIterator vi=Allocator<OpenMeshType>::AddVertices(m,3); VertexIterator vi=Allocator<OpenMeshType>::AddVertices(m,3);