From 86495cdb6f744f1b311bcb373f0cdf18f21b921c Mon Sep 17 00:00:00 2001 From: iasonmanolas Date: Thu, 30 Dec 2021 17:29:34 +0200 Subject: [PATCH] refactoring --- vcg/complex/algorithms/clean.h | 6 +- vcg/simplex/face/pos.h | 2 +- wrap/io_trimesh/export_ply.h | 168 +++++++++++++++++---------------- 3 files changed, 90 insertions(+), 86 deletions(-) diff --git a/vcg/complex/algorithms/clean.h b/vcg/complex/algorithms/clean.h index ce4151fc..eb5d6c1e 100644 --- a/vcg/complex/algorithms/clean.h +++ b/vcg/complex/algorithms/clean.h @@ -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. diff --git a/vcg/simplex/face/pos.h b/vcg/simplex/face/pos.h index b745e95f..bcab427a 100644 --- a/vcg/simplex/face/pos.h +++ b/vcg/simplex/face/pos.h @@ -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) diff --git a/wrap/io_trimesh/export_ply.h b/wrap/io_trimesh/export_ply.h index c69106b2..06090603 100644 --- a/wrap/io_trimesh/export_ply.h +++ b/wrap/io_trimesh/export_ply.h @@ -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 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 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;kVN();++k) + } + } else // ***** ASCII ***** + { + fprintf(fpout, "%d ", fp->VN()); + for(int k=0;kVN();++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 ply_error_msg; if(ply_error_msg.empty()) {