refactoring

This commit is contained in:
iasonmanolas 2021-12-30 17:29:34 +02:00
parent 3770720fb8
commit 86495cdb6f
3 changed files with 90 additions and 86 deletions

View File

@ -974,9 +974,9 @@ public:
countE++;
else
{
vertVisited[fi->V0(i)] = true;
vertVisited[fi->V1(i)] = true;
}
vertVisited[fi->V(i)] = true;
vertVisited[fi->V(i)] = true;
}
}
}
// Third Loop, count the number of referenced vertexes that are completely surrounded by faux edges.

View File

@ -77,7 +77,7 @@ public:
Pos(FaceType * fp, int zp, VertexType * vp)
{
f=fp; z=zp; v=vp;
assert((vp==fp->V0(zp))||(vp==fp->V1(zp)));
assert((vp == fp->V(zp)) || (vp == fp->V(zp)));
}
Pos(FaceType * fp, int zp){f=fp; z=zp; v=f->V(zp);}
Pos(FaceType * fp, VertexType * vp)

View File

@ -69,34 +69,42 @@ class ExporterPLY
}
public:
typedef ::vcg::ply::PropDescriptor PropDescriptor ;
typedef typename SaveMeshType::ConstVertexPointer VertexPointer;
typedef typename SaveMeshType::ScalarType ScalarType;
typedef typename SaveMeshType::VertexType VertexType;
typedef typename SaveMeshType::FaceType FaceType;
typedef typename SaveMeshType::ConstFacePointer FacePointer;
typedef typename SaveMeshType::ConstVertexIterator VertexIterator;
typedef typename SaveMeshType::ConstFaceIterator FaceIterator;
typedef typename SaveMeshType::ConstEdgeIterator EdgeIterator;
typedef typename vcg::Shot<ScalarType>::ScalarType ShotScalarType;
typedef ::vcg::ply::PropDescriptor PropDescriptor;
typedef typename SaveMeshType::ConstVertexPointer VertexPointer;
typedef typename SaveMeshType::ScalarType ScalarType;
typedef typename SaveMeshType::VertexType VertexType;
typedef typename SaveMeshType::FaceType FaceType;
typedef typename SaveMeshType::FacePointer FacePointer;
typedef typename SaveMeshType::ConstVertexIterator VertexIterator;
typedef typename SaveMeshType::ConstFaceIterator FaceIterator;
typedef typename SaveMeshType::ConstEdgeIterator EdgeIterator;
typedef typename vcg::Shot<ScalarType>::ScalarType ShotScalarType;
static int Save(const SaveMeshType &m, const char * filename, bool binary=true)
{
PlyInfo pi;
return Save(m,filename,binary,pi);
}
static int Save(const SaveMeshType &m, const char *filename, bool binary = true)
{
PlyInfo pi;
return Save(m, filename, binary, pi);
}
static int Save(const SaveMeshType &m, const char * filename, int savemask, bool binary = true, CallBackPos *cb=0 )
{
PlyInfo pi;
pi.mask=savemask;
return Save(m,filename,binary,pi,cb);
}
static int Save(const SaveMeshType &m,
const char *filename,
int savemask,
bool binary = true,
CallBackPos *cb = 0)
{
PlyInfo pi;
pi.mask = savemask;
return Save(m, filename, binary, pi, cb);
}
static int Save(const SaveMeshType &m, const char * filename, bool binary, const PlyInfo &pi, CallBackPos *cb=0) // V1.0
{
FILE * fpout;
const char * hbin = "binary_little_endian";
static int Save(const SaveMeshType &m,
const char *filename,
bool binary,
const PlyInfo &pi,
CallBackPos *cb = 0) // V1.0
{
FILE *fpout;
const char * hbin = "binary_little_endian";
const char * hasc = "ascii";
const char * h;
//Coord ScalarType
@ -630,28 +638,26 @@ public:
}
/*vcg::tri::*/
// this assert triggers when the vn != number of vertexes in vert that are not deleted.
assert(j==m.vn);
assert(j == m.vn);
unsigned char b3char = 3;
unsigned char b9char = 9;
unsigned char b6char = 6;
FacePointer fp;
int vv[3];
FaceIterator fi;
int fcnt=0;
for(j=0,fi=m.face.begin();fi!=m.face.end();++fi)
{
//((m.vn+m.fn) != 0) all vertices and faces have been marked as deleted but the are still in the vert/face vectors
if(cb && ((j%1000)==0) && ((m.vn+m.fn) != 0))
(*cb)( 100*(m.vn+j)/(m.vn+m.fn), "Saving Vertices");
unsigned char b3char = 3;
unsigned char b9char = 9;
unsigned char b6char = 6;
int vv[3];
FaceIterator fi;
int fcnt = 0;
j = 0;
for (fi = m.face.begin(); fi != m.face.end(); ++fi) {
//((m.vn+m.fn) != 0) all vertices and faces have been marked as deleted but the are still in the vert/face vectors
if (cb && ((j % 1000) == 0) && ((m.vn + m.fn) != 0))
(*cb)(100 * (m.vn + j) / (m.vn + m.fn), "Saving Vertices");
fp=&(*fi);
if( ! fp->IsD() )
{ fcnt++;
if(binary)
{
vv[0]=indices[fp->cV(0)];
vv[1]=indices[fp->cV(1)];
auto fp = &(*fi);
if (!fp->IsD()) {
fcnt++;
if (binary) {
vv[0] = indices[fp->cV(0)];
vv[1]=indices[fp->cV(1)];
vv[2]=indices[fp->cV(2)];
fwrite(&b3char,sizeof(char),1,fpout);
fwrite(vv,sizeof(int),3,fpout);
@ -768,12 +774,11 @@ public:
default : assert(0);
}
}
}
}
else // ***** ASCII *****
{
fprintf(fpout,"%d " ,fp->VN());
for(int k=0;k<fp->VN();++k)
}
} else // ***** ASCII *****
{
fprintf(fpout, "%d ", fp->VN());
for(int k=0;k<fp->VN();++k)
fprintf(fpout,"%d ",indices[fp->cV(k)]);
if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS ))
@ -861,45 +866,44 @@ public:
case ply::T_SHORT : ti=*( (short *) (((char *)fp)+pi.FaceDescriptorVec[i].offset1)); fprintf(fpout,"%i ",ti); break;
case ply::T_CHAR : ti=*( (char *) (((char *)fp)+pi.FaceDescriptorVec[i].offset1)); fprintf(fpout,"%i ",ti); break;
case ply::T_UCHAR : ti=*( (unsigned char *) (((char *)fp)+pi.FaceDescriptorVec[i].offset1)); fprintf(fpout,"%i ",ti); break;
default : assert(0);
}
}
}
default:
assert(0);
}
}
}
fprintf(fpout,"\n");
}
}
}
assert(fcnt==m.fn);
int eauxvv[2];
if( pi.mask & Mask::IOM_EDGEINDEX )
{
int ecnt=0;
for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
{
if( ! ei->IsD() )
{
++ecnt;
if(binary)
fprintf(fpout, "\n");
}
}
}
assert(fcnt == m.fn);
int eauxvv[2];
if (pi.mask & Mask::IOM_EDGEINDEX) {
int ecnt = 0;
for (EdgeIterator ei = m.edge.begin(); ei != m.edge.end(); ++ei) {
if (!ei->IsD()) {
++ecnt;
if(binary)
{
eauxvv[0]=indices[ei->cV(0)];
eauxvv[1]=indices[ei->cV(1)];
fwrite(eauxvv,sizeof(int),2,fpout);
}
else // ***** ASCII *****
fprintf(fpout,"%d %d \n", indices[ei->cV(0)], indices[ei->cV(1)]);
}
}
assert(ecnt==m.en);
}
int result = 0;
if (ferror(fpout)) result = ply::E_STREAMERROR;
fclose(fpout);
return result;
}
fprintf(fpout, "%d %d \n", indices[ei->cV(0)], indices[ei->cV(1)]);
}
}
assert(ecnt == m.en);
}
int result = 0;
if (ferror(fpout))
result = ply::E_STREAMERROR;
fclose(fpout);
return result;
}
static const char *ErrorMsg(int error)
{
static const char *ErrorMsg(int error)
{
static std::vector<std::string> ply_error_msg;
if(ply_error_msg.empty())
{