From 6efdd91ecc2ffe905af8225102d2e14e3c00e5d0 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 13 Feb 2014 15:52:17 +0000 Subject: [PATCH] Many small changes to remove useless annoying warnings. --- vcg/complex/algorithms/bitquad_support.h | 15 +- vcg/complex/algorithms/update/topology.h | 212 ++++---- vcg/simplex/face/topology.h | 25 +- vcg/space/deprecated_point3.h | 647 +++++++++++------------ wrap/io_trimesh/export_vmi.h | 459 ++++++++-------- wrap/io_trimesh/import_vmi.h | 3 + 6 files changed, 674 insertions(+), 687 deletions(-) diff --git a/vcg/complex/algorithms/bitquad_support.h b/vcg/complex/algorithms/bitquad_support.h index de1a1d5e..6887b6d6 100644 --- a/vcg/complex/algorithms/bitquad_support.h +++ b/vcg/complex/algorithms/bitquad_support.h @@ -230,7 +230,8 @@ static ScalarType EdgeLenghtVariationIfVertexRotated(const FaceType &f, int w0) pi = pf->cFFi( pi ); pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) ); pf = t; - assert(guard++<100); + guard++; + assert(guard<100); } while (pf != &f); assert (na == n); return (after-before); @@ -251,8 +252,6 @@ static ScalarType QuadQualityVariationIfVertexRotated(const FaceType &f, int w0) // rotate arond vertex const FaceType* pf = &f; int pi = w0; - int nb = 0; // vertex valency - int na = 0; std::vector s; // 1 star around v do { // ScalarType triEdge = (pf->P0(pi) - pf->P1(pi) ).Norm(); @@ -272,7 +271,8 @@ static ScalarType QuadQualityVariationIfVertexRotated(const FaceType &f, int w0) pi = pf->cFFi( pi ); pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) ); pf = t; - assert(guard++<100); + guard++; + assert(guard<100); } while (pf != &f); assert(s.size()%2==0); @@ -285,7 +285,6 @@ static ScalarType QuadQualityVariationIfVertexRotated(const FaceType &f, int w0) after+=quadQuality( s[h]->P(),s[i]->P(),s[j]->P(),f.P(w0) ); } - assert (na == nb); return (after-before); } @@ -595,7 +594,8 @@ static bool IsDoubletFF(const FaceType& f, int wedge){ pi = pf->cFFi( pi ); pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) ); pf = t; - assert(guard++<100); + guard++; + assert(guard<100); } while (pf != &f); return (res == 2); } @@ -631,7 +631,8 @@ static bool IsSingletFF(const FaceType& f, int wedge){ pi = pf->cFFi( pi ); pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) ); pf = t; - assert(guard++<100); + guard++; + assert(guard<100); } while (pf != &f); return (res == 1); } diff --git a/vcg/complex/algorithms/update/topology.h b/vcg/complex/algorithms/update/topology.h index cf150879..05bf224a 100644 --- a/vcg/complex/algorithms/update/topology.h +++ b/vcg/complex/algorithms/update/topology.h @@ -113,38 +113,38 @@ public: static void FillEdgeVector(MeshType &m, std::vector &e, bool includeFauxEdge=true) { - FaceIterator pf; - typename std::vector::iterator p; + FaceIterator pf; + typename std::vector::iterator p; - // Alloco il vettore ausiliario - //e.resize(m.fn*3); - FaceIterator fi; - int n_edges = 0; - for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN(); - e.resize(n_edges); + // Alloco il vettore ausiliario + //e.resize(m.fn*3); + FaceIterator fi; + int n_edges = 0; + for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN(); + e.resize(n_edges); - p = e.begin(); - for(pf=m.face.begin();pf!=m.face.end();++pf) - if( ! (*pf).IsD() ) - for(int j=0;j<(*pf).VN();++j) - if(includeFauxEdge || !(*pf).IsF(j)) - { - (*p).Set(&(*pf),j); - ++p; - } + p = e.begin(); + for(pf=m.face.begin();pf!=m.face.end();++pf) + if( ! (*pf).IsD() ) + for(int j=0;j<(*pf).VN();++j) + if(includeFauxEdge || !(*pf).IsF(j)) + { + (*p).Set(&(*pf),j); + ++p; + } - if(includeFauxEdge) assert(p==e.end()); - else e.resize(p-e.begin()); + if(includeFauxEdge) assert(p==e.end()); + else e.resize(p-e.begin()); } static void FillUniqueEdgeVector(MeshType &m, std::vector &Edges, bool includeFauxEdge=true) { - FillEdgeVector(m,Edges,includeFauxEdge); - sort(Edges.begin(), Edges.end()); // Lo ordino per vertici + FillEdgeVector(m,Edges,includeFauxEdge); + sort(Edges.begin(), Edges.end()); // Lo ordino per vertici - typename std::vector< PEdge>::iterator newEnd = std::unique(Edges.begin(), Edges.end()); + typename std::vector< PEdge>::iterator newEnd = std::unique(Edges.begin(), Edges.end()); - Edges.resize(newEnd-Edges.begin()); + Edges.resize(newEnd-Edges.begin()); } /*! \brief Initialize the edge vector all the edges that can be inferred from current face vector, setting up all the current adjacency relations @@ -365,57 +365,57 @@ static void FaceFaceFromTexCoord(MeshType &m) if( m.fn == 0 ) return; // e.resize(m.fn*3); // Alloco il vettore ausiliario - FaceIterator fi; - int n_edges = 0; - for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN(); - e.resize(n_edges); + FaceIterator fi; + int n_edges = 0; + for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN(); + e.resize(n_edges); - p = e.begin(); - for(pf=m.face.begin();pf!=m.face.end();++pf) // Lo riempio con i dati delle facce - if( ! (*pf).IsD() ) - for(int j=0;j<(*pf).VN();++j) - { - if( (*pf).WT(j) != (*pf).WT((*pf).Next(j))) - { - (*p).Set(&(*pf),j); - ++p; - } - } + p = e.begin(); + for(pf=m.face.begin();pf!=m.face.end();++pf) // Lo riempio con i dati delle facce + if( ! (*pf).IsD() ) + for(int j=0;j<(*pf).VN();++j) + { + if( (*pf).WT(j) != (*pf).WT((*pf).Next(j))) + { + (*p).Set(&(*pf),j); + ++p; + } + } - e.resize(p-e.begin()); // remove from the end of the edge vector the unitiailized ones - //assert(p==e.end()); // this formulation of the assert argument is not really correct, will crash on visual studio - sort(e.begin(), e.end()); + e.resize(p-e.begin()); // remove from the end of the edge vector the unitiailized ones + //assert(p==e.end()); // this formulation of the assert argument is not really correct, will crash on visual studio + sort(e.begin(), e.end()); - int ne = 0; // number of real edges - typename std::vector::iterator pe,ps; - ps = e.begin();pe=e.begin(); - //for(ps = e.begin(),pe=e.begin();pe<=e.end();++pe) // Scansione vettore ausiliario - do - { - if( pe==e.end() || (*pe) != (*ps) ) // Trovo blocco di edge uguali - { - typename std::vector::iterator q,q_next; - for (q=ps;q=0); - assert((*q).z< 3); - q_next = q; - ++q_next; - assert((*q_next).z>=0); - assert((*q_next).z< (*q_next).f->VN()); - (*q).f->FFp(q->z) = (*q_next).f; // Collegamento in lista delle facce - (*q).f->FFi(q->z) = (*q_next).z; - } - assert((*q).z>=0); - assert((*q).z< (*q).f->VN()); - (*q).f->FFp((*q).z) = ps->f; - (*q).f->FFi((*q).z) = ps->z; - ps = pe; - ++ne; // Aggiorno il numero di edge - } - if(pe==e.end()) break; - ++pe; - } while(true); + int ne = 0; // number of real edges + typename std::vector::iterator pe,ps; + ps = e.begin();pe=e.begin(); + //for(ps = e.begin(),pe=e.begin();pe<=e.end();++pe) // Scansione vettore ausiliario + do + { + if( pe==e.end() || (*pe) != (*ps) ) // Trovo blocco di edge uguali + { + typename std::vector::iterator q,q_next; + for (q=ps;q=0); + assert((*q).z< 3); + q_next = q; + ++q_next; + assert((*q_next).z>=0); + assert((*q_next).z< (*q_next).f->VN()); + (*q).f->FFp(q->z) = (*q_next).f; // Collegamento in lista delle facce + (*q).f->FFi(q->z) = (*q_next).z; + } + assert((*q).z>=0); + assert((*q).z< (*q).f->VN()); + (*q).f->FFp((*q).z) = ps->f; + (*q).f->FFi((*q).z) = ps->z; + ps = pe; + ++ne; // Aggiorno il numero di edge + } + if(pe==e.end()) break; + ++pe; + } while(true); } @@ -429,42 +429,40 @@ static void TestVertexFace(MeshType &m) assert(tri::HasPerVertexVFAdjacency(m)); - FaceIterator fi; - for(fi=m.face.begin();fi!=m.face.end();++fi) - { - if (!(*fi).IsD()) - { - numVertex[(*fi).V0(0)]++; - numVertex[(*fi).V1(0)]++; - numVertex[(*fi).V2(0)]++; - } - } + FaceIterator fi; + for(fi=m.face.begin();fi!=m.face.end();++fi) + { + if (!(*fi).IsD()) + { + numVertex[(*fi).V0(0)]++; + numVertex[(*fi).V1(0)]++; + numVertex[(*fi).V2(0)]++; + } + } - VertexIterator vi; - vcg::face::VFIterator VFi; + VertexIterator vi; + vcg::face::VFIterator VFi; - for(vi=m.vert.begin();vi!=m.vert.end();++vi) - { - if (!vi->IsD()) - if(vi->VFp()!=0) // unreferenced vertices MUST have VF == 0; - { - int num=0; - assert(vi->VFp() >= &*m.face.begin()); - assert(vi->VFp() <= &m.face.back()); - VFi.f=vi->VFp(); - VFi.z=vi->VFi(); - while (!VFi.End()) - { - num++; - assert(!VFi.F()->IsD()); - assert((VFi.F()->V(VFi.I()))==&(*vi)); - ++VFi; - } - int num1=numVertex[&(*vi)]; - assert(num==num1); - /*assert(num>1);*/ - } - } + for(vi=m.vert.begin();vi!=m.vert.end();++vi) + { + if (!vi->IsD()) + if(vi->VFp()!=0) // unreferenced vertices MUST have VF == 0; + { + int num=0; + assert(vi->VFp() >= &*m.face.begin()); + assert(vi->VFp() <= &m.face.back()); + VFi.f=vi->VFp(); + VFi.z=vi->VFi(); + while (!VFi.End()) + { + num++; + assert(!VFi.F()->IsD()); + assert((VFi.F()->V(VFi.I()))==&(*vi)); + ++VFi; + } + assert(num==numVertex[&(*vi)]); + } + } } /// \brief Test correctness of FFtopology (only for 2Manifold Meshes!) @@ -496,8 +494,8 @@ static void TestFaceFace(MeshType &m) assert( (ffv1i==v0i) || (ffv1i==v1i) ); } - } - } + } + } } /// Auxiliairy data structure for computing edge edge adjacency information. diff --git a/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index 0a7b5443..d32ca755 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -239,8 +239,9 @@ void FFDetach(FaceType & f, const int e) { assert(FFCorrectness(f,e)); assert(!IsBorder(f,e)); // Never try to detach a border edge! - int complexity; - assert(complexity=ComplexSize(f,e)); + int complexity=ComplexSize(f,e); + (void) complexity; + assert(complexity>0); Pos< FaceType > FirstFace(&f,e); // Build the half edge Pos< FaceType > LastFace(&f,e); // Build the half edge @@ -343,13 +344,14 @@ void FFSetBorder(FaceType * &f1, int z1) template void AssertAdj(FaceType & f) { - assert(f.FFp(0)->FFp(f.FFi(0))==&f); - assert(f.FFp(1)->FFp(f.FFi(1))==&f); - assert(f.FFp(2)->FFp(f.FFi(2))==&f); + (void)f; + assert(f.FFp(0)->FFp(f.FFi(0))==&f); + assert(f.FFp(1)->FFp(f.FFi(1))==&f); + assert(f.FFp(2)->FFp(f.FFi(2))==&f); - assert(f.FFp(0)->FFi(f.FFi(0))==0); - assert(f.FFp(1)->FFi(f.FFi(1))==1); - assert(f.FFp(2)->FFi(f.FFi(2))==2); + assert(f.FFp(0)->FFi(f.FFi(0))==0); + assert(f.FFp(1)->FFi(f.FFi(1))==1); + assert(f.FFp(2)->FFi(f.FFi(2))==2); } /** @@ -435,11 +437,10 @@ void SwapEdge(FaceType &f, const int z) * Basic link conditions * */ -template -bool FFLinkCondition(typename MeshType::FaceType &f, const int z) +template +bool FFLinkCondition(FaceType &f, const int z) { - typedef typename MeshType::FaceType FaceType; - typedef typename MeshType::VertexType VertexType; + typedef typename FaceType::VertexType VertexType; typedef typename vcg::face::Pos< FaceType > PosType; VertexType *v0=f.V0(z); diff --git a/vcg/space/deprecated_point3.h b/vcg/space/deprecated_point3.h index 033c7309..7de8f55c 100644 --- a/vcg/space/deprecated_point3.h +++ b/vcg/space/deprecated_point3.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -105,7 +105,7 @@ namespace vcg { /** The templated class for representing a point in 3D space. The class is templated over the ScalarType class that is used to represent coordinates. All the usual - operator overloading (* + - ...) is present. + operator overloading (* + - ...) is present. */ template class Box3; @@ -113,86 +113,86 @@ template class Point3 { protected: /// The only data member. Hidden to user. - P3ScalarType _v[3]; + P3ScalarType _v[3]; public: - typedef P3ScalarType ScalarType; - enum {Dimension = 3}; - - + typedef P3ScalarType ScalarType; + enum {Dimension = 3}; + + //@{ - /** @name Standard Constructors and Initializers + /** @name Standard Constructors and Initializers No casting operators have been introduced to avoid automatic unattended (and costly) conversion between different point types **/ inline Point3 () { } - inline Point3 ( const P3ScalarType nx, const P3ScalarType ny, const P3ScalarType nz ) - { - _v[0] = nx; - _v[1] = ny; - _v[2] = nz; - } - inline Point3 ( Point3 const & p ) - { - _v[0]= p._v[0]; - _v[1]= p._v[1]; - _v[2]= p._v[2]; - } - inline Point3 ( const P3ScalarType nv[3] ) - { - _v[0] = nv[0]; - _v[1] = nv[1]; - _v[2] = nv[2]; - } - inline Point3 & operator =( Point3 const & p ) - { - _v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2]; - return *this; - } - inline void SetZero() - { - _v[0] = 0; - _v[1] = 0; - _v[2] = 0; - } - - /// Padding function: give a default 0 value to all the elements that are not in the [0..2] range. - /// Useful for managing in a consistent way object that could have point2 / point3 / point4 - inline P3ScalarType Ext( const int i ) const - { - if(i>=0 && i<=2) return _v[i]; - else return 0; - } + inline Point3 ( const P3ScalarType nx, const P3ScalarType ny, const P3ScalarType nz ) + { + _v[0] = nx; + _v[1] = ny; + _v[2] = nz; + } + inline Point3 ( Point3 const & p ) + { + _v[0]= p._v[0]; + _v[1]= p._v[1]; + _v[2]= p._v[2]; + } + inline Point3 ( const P3ScalarType nv[3] ) + { + _v[0] = nv[0]; + _v[1] = nv[1]; + _v[2] = nv[2]; + } + inline Point3 & operator =( Point3 const & p ) + { + _v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2]; + return *this; + } + inline void SetZero() + { + _v[0] = 0; + _v[1] = 0; + _v[2] = 0; + } - template - inline void Import( const Point3 & b ) - { - _v[0] = P3ScalarType(b[0]); - _v[1] = P3ScalarType(b[1]); - _v[2] = P3ScalarType(b[2]); - } - template - inline void FromEigenVector( const EigenVector & b ) - { - _v[0] = P3ScalarType(b[0]); - _v[1] = P3ScalarType(b[1]); - _v[2] = P3ScalarType(b[2]); - } - template - inline void ToEigenVector( EigenVector & b ) const - { - b[0]=_v[0] ; - b[1]=_v[1] ; - b[2]=_v[2] ; - } - template + /// Padding function: give a default 0 value to all the elements that are not in the [0..2] range. + /// Useful for managing in a consistent way object that could have point2 / point3 / point4 + inline P3ScalarType Ext( const int i ) const + { + if(i>=0 && i<=2) return _v[i]; + else return 0; + } + + template + inline void Import( const Point3 & b ) + { + _v[0] = P3ScalarType(b[0]); + _v[1] = P3ScalarType(b[1]); + _v[2] = P3ScalarType(b[2]); + } + template + inline void FromEigenVector( const EigenVector & b ) + { + _v[0] = P3ScalarType(b[0]); + _v[1] = P3ScalarType(b[1]); + _v[2] = P3ScalarType(b[2]); + } + template + inline void ToEigenVector( EigenVector & b ) const + { + b[0]=_v[0] ; + b[1]=_v[1] ; + b[2]=_v[2] ; + } + template static inline Point3 Construct( const Point3 & b ) { return Point3(P3ScalarType(b[0]),P3ScalarType(b[1]),P3ScalarType(b[2])); } - template + template static inline Point3 Construct( const Q & P0, const Q & P1, const Q & P2) { return Point3(P3ScalarType(P0),P3ScalarType(P1),P3ScalarType(P2)); @@ -207,227 +207,227 @@ public: //@{ - /** @name Data Access. + /** @name Data Access. access to data is done by overloading of [] or explicit naming of coords (x,y,z)**/ - inline P3ScalarType & operator [] ( const int i ) - { - assert(i>=0 && i<3); - return _v[i]; - } - inline const P3ScalarType & operator [] ( const int i ) const - { - assert(i>=0 && i<3); - return _v[i]; - } - inline const P3ScalarType &X() const { return _v[0]; } - inline const P3ScalarType &Y() const { return _v[1]; } - inline const P3ScalarType &Z() const { return _v[2]; } - inline P3ScalarType &X() { return _v[0]; } - inline P3ScalarType &Y() { return _v[1]; } - inline P3ScalarType &Z() { return _v[2]; } - inline const P3ScalarType * V() const - { - return _v; - } - inline P3ScalarType * V() - { - return _v; - } - inline P3ScalarType & V( const int i ) - { - assert(i>=0 && i<3); - return _v[i]; - } - inline const P3ScalarType & V( const int i ) const - { - assert(i>=0 && i<3); - return _v[i]; - } + inline P3ScalarType & operator [] ( const int i ) + { + assert(i>=0 && i<3); + return _v[i]; + } + inline const P3ScalarType & operator [] ( const int i ) const + { + assert(i>=0 && i<3); + return _v[i]; + } + inline const P3ScalarType &X() const { return _v[0]; } + inline const P3ScalarType &Y() const { return _v[1]; } + inline const P3ScalarType &Z() const { return _v[2]; } + inline P3ScalarType &X() { return _v[0]; } + inline P3ScalarType &Y() { return _v[1]; } + inline P3ScalarType &Z() { return _v[2]; } + inline const P3ScalarType * V() const + { + return _v; + } + inline P3ScalarType * V() + { + return _v; + } + inline P3ScalarType & V( const int i ) + { + assert(i>=0 && i<3); + return _v[i]; + } + inline const P3ScalarType & V( const int i ) const + { + assert(i>=0 && i<3); + return _v[i]; + } //@} //@{ - /** @name Classical overloading of operators - Note + /** @name Classical overloading of operators + Note **/ - inline Point3 operator + ( Point3 const & p) const - { - return Point3( _v[0]+p._v[0], _v[1]+p._v[1], _v[2]+p._v[2] ); - } - inline Point3 operator - ( Point3 const & p) const - { - return Point3( _v[0]-p._v[0], _v[1]-p._v[1], _v[2]-p._v[2] ); - } - inline Point3 operator * ( const P3ScalarType s ) const - { - return Point3( _v[0]*s, _v[1]*s, _v[2]*s ); - } - inline Point3 operator / ( const P3ScalarType s ) const - { - return Point3( _v[0]/s, _v[1]/s, _v[2]/s ); - } - /// Dot product - inline P3ScalarType operator * ( Point3 const & p ) const - { - return ( _v[0]*p._v[0] + _v[1]*p._v[1] + _v[2]*p._v[2] ); - } - inline P3ScalarType dot( const Point3 & p ) const { return (*this) * p; } - /// Cross product - inline Point3 operator ^ ( Point3 const & p ) const - { - return Point3 - ( - _v[1]*p._v[2] - _v[2]*p._v[1], - _v[2]*p._v[0] - _v[0]*p._v[2], - _v[0]*p._v[1] - _v[1]*p._v[0] - ); - } + inline Point3 operator + ( Point3 const & p) const + { + return Point3( _v[0]+p._v[0], _v[1]+p._v[1], _v[2]+p._v[2] ); + } + inline Point3 operator - ( Point3 const & p) const + { + return Point3( _v[0]-p._v[0], _v[1]-p._v[1], _v[2]-p._v[2] ); + } + inline Point3 operator * ( const P3ScalarType s ) const + { + return Point3( _v[0]*s, _v[1]*s, _v[2]*s ); + } + inline Point3 operator / ( const P3ScalarType s ) const + { + return Point3( _v[0]/s, _v[1]/s, _v[2]/s ); + } + /// Dot product + inline P3ScalarType operator * ( Point3 const & p ) const + { + return ( _v[0]*p._v[0] + _v[1]*p._v[1] + _v[2]*p._v[2] ); + } + inline P3ScalarType dot( const Point3 & p ) const { return (*this) * p; } + /// Cross product + inline Point3 operator ^ ( Point3 const & p ) const + { + return Point3 + ( + _v[1]*p._v[2] - _v[2]*p._v[1], + _v[2]*p._v[0] - _v[0]*p._v[2], + _v[0]*p._v[1] - _v[1]*p._v[0] + ); + } - inline Point3 & operator += ( Point3 const & p) - { - _v[0] += p._v[0]; - _v[1] += p._v[1]; - _v[2] += p._v[2]; - return *this; - } - inline Point3 & operator -= ( Point3 const & p) - { - _v[0] -= p._v[0]; - _v[1] -= p._v[1]; - _v[2] -= p._v[2]; - return *this; - } - inline Point3 & operator *= ( const P3ScalarType s ) - { - _v[0] *= s; - _v[1] *= s; - _v[2] *= s; - return *this; - } - inline Point3 & operator /= ( const P3ScalarType s ) - { - _v[0] /= s; - _v[1] /= s; - _v[2] /= s; - return *this; - } - // Norme - inline P3ScalarType Norm() const - { + inline Point3 & operator += ( Point3 const & p) + { + _v[0] += p._v[0]; + _v[1] += p._v[1]; + _v[2] += p._v[2]; + return *this; + } + inline Point3 & operator -= ( Point3 const & p) + { + _v[0] -= p._v[0]; + _v[1] -= p._v[1]; + _v[2] -= p._v[2]; + return *this; + } + inline Point3 & operator *= ( const P3ScalarType s ) + { + _v[0] *= s; + _v[1] *= s; + _v[2] *= s; + return *this; + } + inline Point3 & operator /= ( const P3ScalarType s ) + { + _v[0] /= s; + _v[1] /= s; + _v[2] /= s; + return *this; + } + // Norme + inline P3ScalarType Norm() const + { return math::Sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] ); - } - inline P3ScalarType SquaredNorm() const - { - return ( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] ); - } - // Scalatura differenziata - inline Point3 & Scale( const P3ScalarType sx, const P3ScalarType sy, const P3ScalarType sz ) - { - _v[0] *= sx; - _v[1] *= sy; - _v[2] *= sz; - return *this; - } - inline Point3 & Scale( const Point3 & p ) - { - _v[0] *= p._v[0]; - _v[1] *= p._v[1]; - _v[2] *= p._v[2]; - return *this; - } + } + inline P3ScalarType SquaredNorm() const + { + return ( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] ); + } + // Scalatura differenziata + inline Point3 & Scale( const P3ScalarType sx, const P3ScalarType sy, const P3ScalarType sz ) + { + _v[0] *= sx; + _v[1] *= sy; + _v[2] *= sz; + return *this; + } + inline Point3 & Scale( const Point3 & p ) + { + _v[0] *= p._v[0]; + _v[1] *= p._v[1]; + _v[2] *= p._v[2]; + return *this; + } - // Normalizzazione - inline Point3 & Normalize() - { - P3ScalarType n = P3ScalarType(math::Sqrt(_v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2])); - if (n > P3ScalarType(0)) { _v[0] /= n; _v[1] /= n; _v[2] /= n; } - return *this; - } + // Normalizzazione + inline Point3 & Normalize() + { + P3ScalarType n = P3ScalarType(math::Sqrt(_v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2])); + if (n > P3ScalarType(0)) { _v[0] /= n; _v[1] /= n; _v[2] /= n; } + return *this; + } - // for compatibility with eigen port - inline Point3 & normalized() { return Normalize(); } - - /** - * Convert to polar coordinates from cartesian coordinates. - * - * Theta is the azimuth angle and ranges between [0, 2PI) degrees. - * Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] degrees. - * - * /note Note that instead of the classical polar angle, which ranges between - * 0 and PI degrees we opt for the elevation angle to obtain a more - * intuitive spherical coordinate system. - */ - void ToPolarRad(P3ScalarType &ro, P3ScalarType &theta, P3ScalarType &phi) const - { - ro = Norm(); - theta = (P3ScalarType)atan2(_v[2], _v[0]); - phi = (P3ScalarType)asin(_v[1]/ro); - } + // for compatibility with eigen port + inline Point3 & normalized() { return Normalize(); } - /** - * Convert from polar coordinates to cartesian coordinates. - * - * Theta is the azimuth angle and ranges between [0, 2PI) radians. - * Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] radians. - * - * \note Note that instead of the classical polar angle, which ranges between - * 0 and PI degrees, we opt for the elevation angle to obtain a more - * intuitive spherical coordinate system. - */ + /** + * Convert to polar coordinates from cartesian coordinates. + * + * Theta is the azimuth angle and ranges between [0, 2PI) degrees. + * Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] degrees. + * + * /note Note that instead of the classical polar angle, which ranges between + * 0 and PI degrees we opt for the elevation angle to obtain a more + * intuitive spherical coordinate system. + */ + void ToPolarRad(P3ScalarType &ro, P3ScalarType &theta, P3ScalarType &phi) const + { + ro = Norm(); + theta = (P3ScalarType)atan2(_v[2], _v[0]); + phi = (P3ScalarType)asin(_v[1]/ro); + } + + /** + * Convert from polar coordinates to cartesian coordinates. + * + * Theta is the azimuth angle and ranges between [0, 2PI) radians. + * Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] radians. + * + * \note Note that instead of the classical polar angle, which ranges between + * 0 and PI degrees, we opt for the elevation angle to obtain a more + * intuitive spherical coordinate system. + */ void FromPolarRad(const P3ScalarType &ro, const P3ScalarType &theta, const P3ScalarType &phi) - { + { _v[0]= ro*cos(theta)*cos(phi); _v[1]= ro*sin(phi); _v[2]= ro*sin(theta)*cos(phi); - } - + } + Box3 GetBBox(Box3 &bb) const; //@} //@{ - /** @name Comparison Operators. + /** @name Comparison Operators. Note that the reverse z prioritized ordering, useful in many situations. **/ inline bool operator == ( Point3 const & p ) const - { - return _v[0]==p._v[0] && _v[1]==p._v[1] && _v[2]==p._v[2]; - } - inline bool operator != ( Point3 const & p ) const - { - return _v[0]!=p._v[0] || _v[1]!=p._v[1] || _v[2]!=p._v[2]; - } - inline bool operator < ( Point3 const & p ) const - { - return (_v[2]!=p._v[2])?(_v[2] ( Point3 const & p ) const - { - return (_v[2]!=p._v[2])?(_v[2]>p._v[2]): - (_v[1]!=p._v[1])?(_v[1]>p._v[1]): - (_v[0]>p._v[0]); - } - inline bool operator <= ( Point3 const & p ) const - { - return (_v[2]!=p._v[2])?(_v[2]< p._v[2]): - (_v[1]!=p._v[1])?(_v[1]< p._v[1]): - (_v[0]<=p._v[0]); - } - inline bool operator >= ( Point3 const & p ) const - { - return (_v[2]!=p._v[2])?(_v[2]> p._v[2]): - (_v[1]!=p._v[1])?(_v[1]> p._v[1]): - (_v[0]>=p._v[0]); - } + { + return _v[0]==p._v[0] && _v[1]==p._v[1] && _v[2]==p._v[2]; + } + inline bool operator != ( Point3 const & p ) const + { + return _v[0]!=p._v[0] || _v[1]!=p._v[1] || _v[2]!=p._v[2]; + } + inline bool operator < ( Point3 const & p ) const + { + return (_v[2]!=p._v[2])?(_v[2] ( Point3 const & p ) const + { + return (_v[2]!=p._v[2])?(_v[2]>p._v[2]): + (_v[1]!=p._v[1])?(_v[1]>p._v[1]): + (_v[0]>p._v[0]); + } + inline bool operator <= ( Point3 const & p ) const + { + return (_v[2]!=p._v[2])?(_v[2]< p._v[2]): + (_v[1]!=p._v[1])?(_v[1]< p._v[1]): + (_v[0]<=p._v[0]); + } + inline bool operator >= ( Point3 const & p ) const + { + return (_v[2]!=p._v[2])?(_v[2]> p._v[2]): + (_v[1]!=p._v[1])?(_v[1]> p._v[1]): + (_v[0]>=p._v[0]); + } - - inline Point3 operator - () const - { - return Point3 ( -_v[0], -_v[1], -_v[2] ); - } + + inline Point3 operator - () const + { + return Point3 ( -_v[0], -_v[1], -_v[2] ); + } //@} }; // end class definition @@ -436,11 +436,11 @@ inline bool operator == ( Point3 const & p ) const template inline P3ScalarType Angle( Point3 const & p1, Point3 const & p2 ) { - P3ScalarType w = p1.Norm()*p2.Norm(); - if(w==0) return -1; - P3ScalarType t = (p1*p2)/w; - if(t>1) t = 1; - else if(t<-1) t = -1; + P3ScalarType w = p1.Norm()*p2.Norm(); + if(w==0) return -1; + P3ScalarType t = (p1*p2)/w; + if(t>1) t = 1; + else if(t<-1) t = -1; return (P3ScalarType) acos(t); } @@ -448,11 +448,11 @@ inline P3ScalarType Angle( Point3 const & p1, Point3 template inline P3ScalarType AngleN( Point3 const & p1, Point3 const & p2 ) { - P3ScalarType w = p1*p2; - if(w>1) - w = 1; - else if(w<-1) - w=-1; + P3ScalarType w = p1*p2; + if(w>1) + w = 1; + else if(w<-1) + w=-1; return (P3ScalarType) acos(w); } @@ -460,7 +460,7 @@ inline P3ScalarType AngleN( Point3 const & p1, Point3 inline P3ScalarType Norm( Point3 const & p ) { - return p.Norm(); + return p.Norm(); } template @@ -503,52 +503,52 @@ P3ScalarType ApproximateGeodesicDistance(const Point3& p0, const P } - // Dot product preciso numericamente (solo double!!) - // Implementazione: si sommano i prodotti per ordine di esponente - // (prima le piu' grandi) + // Dot product preciso numericamente (solo double!!) + // Implementazione: si sommano i prodotti per ordine di esponente + // (prima le piu' grandi) template double stable_dot ( Point3 const & p0, Point3 const & p1 ) { - P3ScalarType k0 = p0._v[0]*p1._v[0]; - P3ScalarType k1 = p0._v[1]*p1._v[1]; - P3ScalarType k2 = p0._v[2]*p1._v[2]; + P3ScalarType k0 = p0._v[0]*p1._v[0]; + P3ScalarType k1 = p0._v[1]*p1._v[1]; + P3ScalarType k2 = p0._v[2]*p1._v[2]; - int exp0,exp1,exp2; + int exp0,exp1,exp2; - frexp( double(k0), &exp0 ); - frexp( double(k1), &exp1 ); - frexp( double(k2), &exp2 ); + frexp( double(k0), &exp0 ); + frexp( double(k1), &exp1 ); + frexp( double(k2), &exp2 ); - if( exp0 P3ScalarType PSDist( const Point3 & p, - const Point3 & v1, - const Point3 & v2, - Point3 & q ) + const Point3 & v1, + const Point3 & v2, + Point3 & q ) { Point3 e = v2-v1; P3ScalarType t = ((p-v1)*e)/e.SquaredNorm(); if(t<0) t = 0; - else if(t>1) t = 1; - q = v1+e*t; + else if(t>1) t = 1; + q = v1+e*t; return Distance(p,q); } @@ -556,31 +556,30 @@ P3ScalarType PSDist( const Point3 & p, template void GetUV( Point3 &n,Point3 &u, Point3 &v, Point3 up=(Point3(0,1,0)) ) { - n.Normalize(); - const double LocEps=double(1e-7); - u=n^up; + n.Normalize(); + const double LocEps=double(1e-7); + u=n^up; double len = u.Norm(); - if(len < LocEps) - { - if(fabs(n[0])(1,0,0); // x is the min - else up=Point3(0,0,1); // z is the min - }else { - if(fabs(n[1])(0,1,0); // y is the min - else up=Point3(0,0,1); // z is the min - } - u=n^up; - } - u.Normalize(); - v=n^u; - v.Normalize(); - Point3 uv=u^v; + if(len < LocEps) + { + if(fabs(n[0])(1,0,0); // x is the min + else up=Point3(0,0,1); // z is the min + }else { + if(fabs(n[1])(0,1,0); // y is the min + else up=Point3(0,0,1); // z is the min + } + u=n^up; + } + u.Normalize(); + v=n^u; + v.Normalize(); } template inline Point3 Abs(const Point3 & p) { - return (Point3(math::Abs(p[0]), math::Abs(p[1]), math::Abs(p[2]))); + return (Point3(math::Abs(p[0]), math::Abs(p[1]), math::Abs(p[2]))); } // probably a more uniform naming should be defined... template diff --git a/wrap/io_trimesh/export_vmi.h b/wrap/io_trimesh/export_vmi.h index 6a1aa37d..78ed4404 100644 --- a/wrap/io_trimesh/export_vmi.h +++ b/wrap/io_trimesh/export_vmi.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -19,53 +19,36 @@ * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * -****************************************************************************/ - -/**************************************************************************** - History - - $Log: not supported by cvs2svn $ - Revision 1.1 2007/02/14 01:20:37 ganovelli - working draft of VCG Mesh Image importer and exporter. Does not consider optional attributes. The mesh atributes are only vn and fn (no bbox, texture coordiantes) - - - ****************************************************************************/ #ifndef __VCGLIB_EXPORT_VMI #define __VCGLIB_EXPORT_VMI - + /* - VMI VCG Mesh Image. - The vmi image file consists of a header containing the description of the vertex and face type, - the length of vectors containing vertices of faces and the memory image of the object mesh as it is when - passed to the function Save(SaveMeshType m). - NOTE: THIS IS NOT A FILE FORMAT. IT IS ONLY USEFUL FOR DUMPING MESH IMAGES FOR DEBUG PURPOSE. - Example of use: say you are running a time consuming mesh processing and you want to save intermediate - state, but no file format support all the attributes you need in your vertex/face type. - NOTE2: At the present if you add members to your TriMesh these will NOT be saved. More precisely, this file and - import_vmi must be updated to reflect changes in vcg/complex/trimesh/base.h - */ + VMI VCG Mesh Image. + The vmi image file consists of a header containing the description of the vertex and face type, + the length of vectors containing vertices of faces and the memory image of the object mesh as it is when + passed to the function Save(SaveMeshType m). + NOTE: THIS IS NOT A FILE FORMAT. IT IS ONLY USEFUL FOR DUMPING MESH IMAGES FOR DEBUG PURPOSE. + Example of use: say you are running a time consuming mesh processing and you want to save intermediate + state, but no file format support all the attributes you need in your vertex/face type. + NOTE2: At the present if you add members to your TriMesh these will NOT be saved. More precisely, this file and + import_vmi must be updated to reflect changes in vcg/complex/trimesh/base.h + */ #include -//#include -//#include -//#include -//#include namespace vcg { namespace tri { namespace io { - template struct PlaceHolderType{ char A[N];}; + template struct PlaceHolderType{ char A[N];}; - - - template - class ExporterVMI - { + template + class ExporterVMI + { static char * & Out_mem(){static char * out_mem; return out_mem;} @@ -83,178 +66,180 @@ namespace io { case 1: return fwrite_mem(src, size,count); break; case 2: return fwrite(src, size,count, F() ); break; } + assert(0); + return 0; } static void WriteString( const char * in) { unsigned int l = strlen(in); WriteOut(&l,4,1 ); WriteOut(in,1,l );} - static void WriteInt (const unsigned int i) { WriteOut(&i,1,4 );} + static void WriteInt (const unsigned int i) { WriteOut(&i,1,4 );} - static void WriteFloat( const float v) { WriteOut(&v,1,sizeof(float) );} + static void WriteFloat( const float v) { WriteOut(&v,1,sizeof(float) );} - /* save Ocf Vertex Components */ - template - struct SaveVertexOcf{ + /* save Ocf Vertex Components */ + template + struct SaveVertexOcf{ SaveVertexOcf( const CONT & /*vert*/, bool only_header){ - // do nothing, it is a std::vector - if(only_header){ - WriteString( "NOT_HAS_VERTEX_QUALITY_OCF"); - WriteString( "NOT_HAS_VERTEX_COLOR_OCF"); - WriteString( "NOT_HAS_VERTEX_NORMAL_OCF"); - WriteString( "NOT_HAS_VERTEX_MARK_OCF"); - WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF"); - WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF"); - WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF"); - WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF"); - WriteString( "NOT_HAS_VERTEX_RADIUS_OCF"); - } - } - }; + // do nothing, it is a std::vector + if(only_header){ + WriteString( "NOT_HAS_VERTEX_QUALITY_OCF"); + WriteString( "NOT_HAS_VERTEX_COLOR_OCF"); + WriteString( "NOT_HAS_VERTEX_NORMAL_OCF"); + WriteString( "NOT_HAS_VERTEX_MARK_OCF"); + WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF"); + WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF"); + WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF"); + WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF"); + WriteString( "NOT_HAS_VERTEX_RADIUS_OCF"); + } + } + }; - /* partial specialization for vector_ocf */ - template - struct SaveVertexOcf >{ - typedef typename MeshType::VertexType VertexType; - SaveVertexOcf( const vertex::vector_ocf & vert, bool only_header){ + /* partial specialization for vector_ocf */ + template + struct SaveVertexOcf >{ + typedef typename MeshType::VertexType VertexType; + SaveVertexOcf( const vertex::vector_ocf & vert, bool only_header){ if( VertexType::HasQualityOcf() && vert.IsQualityEnabled()){ - WriteString( "HAS_VERTEX_QUALITY_OCF"); + WriteString( "HAS_VERTEX_QUALITY_OCF"); if(!only_header) WriteOut(&vert.QV[0],sizeof(typename VertexType::QualityType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_QUALITY_OCF"); + }else WriteString( "NOT_HAS_VERTEX_QUALITY_OCF"); if( VertexType::HasColorOcf() && vert.IsColorEnabled()){ - WriteString( "HAS_VERTEX_COLOR_OCF"); + WriteString( "HAS_VERTEX_COLOR_OCF"); if(!only_header) WriteOut(&vert.CV[0],sizeof(typename VertexType::ColorType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_COLOR_OCF"); + }else WriteString( "NOT_HAS_VERTEX_COLOR_OCF"); if( VertexType::HasNormalOcf() && vert.IsNormalEnabled()){ - WriteString( "HAS_VERTEX_NORMAL_OCF"); + WriteString( "HAS_VERTEX_NORMAL_OCF"); if(!only_header) WriteOut(&vert.NV[0],sizeof(typename VertexType::NormalType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_NORMAL_OCF"); + }else WriteString( "NOT_HAS_VERTEX_NORMAL_OCF"); if( VertexType::HasMarkOcf() && vert.IsMarkEnabled()){ WriteString( "HAS_VERTEX_MARK_OCF"); if(!only_header) WriteOut(&vert.MV[0],sizeof(typename VertexType::MarkType),vert.size() ); }else WriteString( "NOT_HAS_VERTEX_MARK_OCF"); - if( VertexType::HasTexCoordOcf() && vert.IsTexCoordEnabled()){ - WriteString( "HAS_VERTEX_TEXCOORD_OCF"); + if( VertexType::HasTexCoordOcf() && vert.IsTexCoordEnabled()){ + WriteString( "HAS_VERTEX_TEXCOORD_OCF"); if(!only_header) WriteOut(&vert.TV[0],sizeof(typename VertexType::TexCoordType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF"); + }else WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF"); - if( VertexType::HasVFAdjacencyOcf() && vert.IsVFAdjacencyEnabled()){ - WriteString( "HAS_VERTEX_VFADJACENCY_OCF"); + if( VertexType::HasVFAdjacencyOcf() && vert.IsVFAdjacencyEnabled()){ + WriteString( "HAS_VERTEX_VFADJACENCY_OCF"); if(!only_header) WriteOut(&vert.AV[0],sizeof(typename vertex::vector_ocf::VFAdjType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF"); + }else WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF"); - if( VertexType::HasCurvatureOcf() && vert.IsCurvatureEnabled()){ - WriteString( "HAS_VERTEX_CURVATURE_OCF"); + if( VertexType::HasCurvatureOcf() && vert.IsCurvatureEnabled()){ + WriteString( "HAS_VERTEX_CURVATURE_OCF"); if(!only_header) WriteOut(&vert.CuV[0],sizeof(typename VertexType::CurvatureType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF"); + }else WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF"); - if( VertexType::HasCurvatureDirOcf() && vert.IsCurvatureDirEnabled()){ - WriteString( "HAS_VERTEX_CURVATUREDIR_OCF"); + if( VertexType::HasCurvatureDirOcf() && vert.IsCurvatureDirEnabled()){ + WriteString( "HAS_VERTEX_CURVATUREDIR_OCF"); if(!only_header) WriteOut(&vert.CuDV[0],sizeof(typename VertexType::CurvatureDirType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF"); + }else WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF"); - if( VertexType::HasRadiusOcf() && vert.IsRadiusEnabled()){ - WriteString( "HAS_VERTEX_RADIUS_OCF"); + if( VertexType::HasRadiusOcf() && vert.IsRadiusEnabled()){ + WriteString( "HAS_VERTEX_RADIUS_OCF"); if(!only_header) WriteOut(&vert.RadiusV[0],sizeof(typename VertexType::RadiusType),vert.size() ); - }else WriteString( "NOT_HAS_VERTEX_RADIUS_OCF"); + }else WriteString( "NOT_HAS_VERTEX_RADIUS_OCF"); - } - }; + } + }; - /* save Ocf Face Components */ - template - struct SaveFaceOcf{ + /* save Ocf Face Components */ + template + struct SaveFaceOcf{ SaveFaceOcf( const CONT & /*face*/, bool only_header){ - // it is a std::vector - if(only_header){ - WriteString( "NOT_HAS_FACE_QUALITY_OCF"); - WriteString( "NOT_HAS_FACE_COLOR_OCF"); - WriteString( "NOT_HAS_FACE_NORMAL_OCF"); - WriteString( "NOT_HAS_FACE_MARK_OCF"); - WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF"); - WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF"); - WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF"); - WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF"); - WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF"); - } - } - }; + // it is a std::vector + if(only_header){ + WriteString( "NOT_HAS_FACE_QUALITY_OCF"); + WriteString( "NOT_HAS_FACE_COLOR_OCF"); + WriteString( "NOT_HAS_FACE_NORMAL_OCF"); + WriteString( "NOT_HAS_FACE_MARK_OCF"); + WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF"); + WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF"); + WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF"); + WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF"); + WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF"); + } + } + }; - /* partial specialization for vector_ocf */ - template - struct SaveFaceOcf< MeshType, face::vector_ocf >{ - typedef typename MeshType::FaceType FaceType; - SaveFaceOcf( const face::vector_ocf & face, bool only_header){ + /* partial specialization for vector_ocf */ + template + struct SaveFaceOcf< MeshType, face::vector_ocf >{ + typedef typename MeshType::FaceType FaceType; + SaveFaceOcf( const face::vector_ocf & face, bool only_header){ - if( FaceType::HasQualityOcf() && face.IsQualityEnabled()){ - WriteString( "HAS_FACE_QUALITY_OCF"); + if( FaceType::HasQualityOcf() && face.IsQualityEnabled()){ + WriteString( "HAS_FACE_QUALITY_OCF"); if(!only_header) WriteOut(&face.QV[0],sizeof(typename FaceType::QualityType),face.size() ); - }else WriteString( "NOT_HAS_FACE_QUALITY_OCF"); + }else WriteString( "NOT_HAS_FACE_QUALITY_OCF"); - if( FaceType::HasColorOcf() && face.IsColorEnabled()){ - WriteString( "HAS_FACE_COLOR_OCF"); + if( FaceType::HasColorOcf() && face.IsColorEnabled()){ + WriteString( "HAS_FACE_COLOR_OCF"); if(!only_header) WriteOut(&face.CV[0],sizeof(typename FaceType::ColorType),face.size() ); - }else WriteString( "NOT_HAS_FACE_COLOR_OCF"); + }else WriteString( "NOT_HAS_FACE_COLOR_OCF"); - if( FaceType::HasNormalOcf() && face.IsNormalEnabled()){ - WriteString( "HAS_FACE_NORMAL_OCF"); + if( FaceType::HasNormalOcf() && face.IsNormalEnabled()){ + WriteString( "HAS_FACE_NORMAL_OCF"); if(!only_header) WriteOut(&face.NV[0],sizeof(typename FaceType::NormalType),face.size() ); - }else WriteString( "NOT_HAS_FACE_NORMAL_OCF"); + }else WriteString( "NOT_HAS_FACE_NORMAL_OCF"); - if( FaceType::HasMarkOcf() && face.IsMarkEnabled()){ - WriteString( "HAS_FACE_MARK_OCF"); + if( FaceType::HasMarkOcf() && face.IsMarkEnabled()){ + WriteString( "HAS_FACE_MARK_OCF"); if(!only_header) WriteOut(&face.MV[0],sizeof(typename FaceType::MarkType),face.size() ); - }else WriteString( "NOT_HAS_FACE_MARK_OCF"); + }else WriteString( "NOT_HAS_FACE_MARK_OCF"); - if( FaceType::HasWedgeTexCoordOcf() && face.IsWedgeTexCoordEnabled()){ - WriteString( "HAS_FACE_WEDGETEXCOORD_OCF"); + if( FaceType::HasWedgeTexCoordOcf() && face.IsWedgeTexCoordEnabled()){ + WriteString( "HAS_FACE_WEDGETEXCOORD_OCF"); if(!only_header) WriteOut(&face.WTV[0],sizeof(typename FaceType::WedgeTexCoordType),face.size() ); - }else WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF"); + }else WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF"); - if( FaceType::HasFFAdjacencyOcf() && face.IsFFAdjacencyEnabled()){ - WriteString( "HAS_FACE_FFADJACENCY_OCF"); + if( FaceType::HasFFAdjacencyOcf() && face.IsFFAdjacencyEnabled()){ + WriteString( "HAS_FACE_FFADJACENCY_OCF"); if(!only_header) WriteOut(&face.AF[0],sizeof(typename face::vector_ocf::AdjTypePack),face.size() ); - }else WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF"); + }else WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF"); - if( FaceType::HasVFAdjacencyOcf() && face.IsVFAdjacencyEnabled()){ - WriteString( "HAS_FACE_VFADJACENCY_OCF"); + if( FaceType::HasVFAdjacencyOcf() && face.IsVFAdjacencyEnabled()){ + WriteString( "HAS_FACE_VFADJACENCY_OCF"); if(!only_header) WriteOut(&face.AV[0],sizeof(typename face::vector_ocf::AdjTypePack),face.size() ); - }else WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF"); + }else WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF"); - if( FaceType::HasWedgeColorOcf() && face.IsWedgeColorEnabled()){ - WriteString( "HAS_FACE_WEDGECOLOR_OCF"); + if( FaceType::HasWedgeColorOcf() && face.IsWedgeColorEnabled()){ + WriteString( "HAS_FACE_WEDGECOLOR_OCF"); if(!only_header) WriteOut(&face.WCV[0],sizeof(typename face::vector_ocf::WedgeColorTypePack),face.size() ); - }else WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF"); + }else WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF"); - if( FaceType::HasWedgeNormalOcf() && face.IsWedgeNormalEnabled()){ - WriteString( "HAS_FACE_WEDGENORMAL_OCF"); + if( FaceType::HasWedgeNormalOcf() && face.IsWedgeNormalEnabled()){ + WriteString( "HAS_FACE_WEDGENORMAL_OCF"); if(!only_header) WriteOut(&face.WNV[0],sizeof(typename face::vector_ocf::WedgeNormalTypePack),face.size() ); - }else WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF"); - } - }; + }else WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF"); + } + }; - static FILE *& F(){static FILE * f; return f;} + static FILE *& F(){static FILE * f; return f;} - typedef typename SaveMeshType::FaceContainer FaceContainer; - typedef typename SaveMeshType::FaceIterator FaceIterator; - typedef typename SaveMeshType::VertContainer VertContainer; - typedef typename SaveMeshType::VertexIterator VertexIterator; - typedef typename SaveMeshType::VertexType VertexType; - typedef typename SaveMeshType::FaceType FaceType; + typedef typename SaveMeshType::FaceContainer FaceContainer; + typedef typename SaveMeshType::FaceIterator FaceIterator; + typedef typename SaveMeshType::VertContainer VertContainer; + typedef typename SaveMeshType::VertexIterator VertexIterator; + typedef typename SaveMeshType::VertexType VertexType; + typedef typename SaveMeshType::FaceType FaceType; typedef SimpleTempDataBase STDBv; typedef SimpleTempDataBase STDBf; - // typedef typename SaveMeshType::Attribute STDBm; - - /* save Ocf Components */ + // typedef typename SaveMeshType::Attribute STDBm; + + /* save Ocf Components */ - public: + public: static int Save(const SaveMeshType &m,const char * filename){ Out_mode() = 2; @@ -279,53 +264,53 @@ namespace io { static int Serialize(const SaveMeshType &m){ - unsigned int i; - unsigned int vertSize,faceSize; + unsigned int i; + unsigned int vertSize,faceSize; std::vector nameF,nameV; - SaveMeshType::FaceType::Name(nameF); - SaveMeshType::VertexType::Name(nameV); - vertSize = m.vert.size(); - faceSize = m.face.size(); + SaveMeshType::FaceType::Name(nameF); + SaveMeshType::VertexType::Name(nameV); + vertSize = m.vert.size(); + faceSize = m.face.size(); - /* write header */ - WriteString( "FACE_TYPE"); - WriteInt( nameF.size()); + /* write header */ + WriteString( "FACE_TYPE"); + WriteInt( nameF.size()); - for(i=0; i < nameF.size(); ++i) WriteString( nameF[i].c_str()); - SaveFaceOcf( m.face,true); - WriteString( "SIZE_VECTOR_FACES"); - WriteInt( faceSize ); + for(i=0; i < nameF.size(); ++i) WriteString( nameF[i].c_str()); + SaveFaceOcf( m.face,true); + WriteString( "SIZE_VECTOR_FACES"); + WriteInt( faceSize ); - WriteString( "VERTEX_TYPE"); - WriteInt( nameV.size()); + WriteString( "VERTEX_TYPE"); + WriteInt( nameV.size()); - for(i=0; i < nameV.size(); ++i) WriteString( nameV[i].c_str()); - SaveVertexOcf( m.vert,true); + for(i=0; i < nameV.size(); ++i) WriteString( nameV[i].c_str()); + SaveVertexOcf( m.vert,true); - WriteString( "SIZE_VECTOR_VERTS"); - WriteInt( vertSize); + WriteString( "SIZE_VECTOR_VERTS"); + WriteInt( vertSize); - WriteString( "BOUNDING_BOX"); - float float_value; - for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.min[i]; WriteFloat( float_value);} - for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.max[i]; WriteFloat( float_value);} + WriteString( "BOUNDING_BOX"); + float float_value; + for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.min[i]; WriteFloat( float_value);} + for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.max[i]; WriteFloat( float_value);} - WriteString( "end_header"); - /* end header */ + WriteString( "end_header"); + /* end header */ if(vertSize!=0){ void * offsetV = (void*) &m.vert[0]; - /* write the address of the first vertex */ + /* write the address of the first vertex */ WriteOut(&offsetV,sizeof(void *),1 ); - } + } - if(faceSize!=0){ + if(faceSize!=0){ void * offsetF= (void*)&m.face[0]; - /* write the address of the first face */ + /* write the address of the first face */ WriteOut(&offsetF,sizeof( void *),1 ); - } + } - /* save the object mesh */ + /* save the object mesh */ WriteOut(&m.shot,sizeof(Shot),1 ); WriteOut(&m.vn,sizeof(int),1 ); WriteOut(&m.fn,sizeof(int),1 ); @@ -333,99 +318,99 @@ namespace io { WriteOut(&m.bbox,sizeof(Box3),1 ); WriteOut(&m.C(),sizeof(Color4b),1 ); - unsigned int written; + unsigned int written; - if(vertSize!=0){ - /* save the vertices */ + if(vertSize!=0){ + /* save the vertices */ written = WriteOut((void*)&m.vert[0],sizeof(typename SaveMeshType::VertexType),m.vert.size() ); - SaveVertexOcf( m.vert,false); - } + SaveVertexOcf( m.vert,false); + } - if(faceSize!=0){ - /* save the faces */ + if(faceSize!=0){ + /* save the faces */ written = WriteOut((void*)&m.face[0],sizeof(typename SaveMeshType::FaceType),faceSize ); - SaveFaceOcf( m.face,false); + SaveFaceOcf( m.face,false); - } + } - - /* save the attributes */ + + /* save the attributes */ typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; - - /* save the per vertex attributes */ - { - typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; - unsigned int n_named_attr = 0; - for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty(); - WriteString( "N_PER_VERTEX_ATTRIBUTES"); WriteInt ( n_named_attr); - for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai) - if(!(*ai)._name.empty()) - { - STDBv * stdb = (STDBv *) (*ai)._handle; + /* save the per vertex attributes */ + { + typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; + unsigned int n_named_attr = 0; + for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty(); - WriteString( "PER_VERTEX_ATTR_NAME"); - WriteString( (*ai)._name.c_str() ); + WriteString( "N_PER_VERTEX_ATTRIBUTES"); WriteInt ( n_named_attr); + for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai) + if(!(*ai)._name.empty()) + { + STDBv * stdb = (STDBv *) (*ai)._handle; - WriteString( "PER_VERTEX_ATTR_SIZE"); - WriteInt( stdb->SizeOf()); + WriteString( "PER_VERTEX_ATTR_NAME"); + WriteString( (*ai)._name.c_str() ); + + WriteString( "PER_VERTEX_ATTR_SIZE"); + WriteInt( stdb->SizeOf()); WriteOut(stdb->DataBegin(),m.vert.size(),stdb->SizeOf() ); - } - } + } + } - /* save the per face attributes */ - { - typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; - unsigned int n_named_attr = 0; - for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty(); + /* save the per face attributes */ + { + typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; + unsigned int n_named_attr = 0; + for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty(); - WriteString( "N_PER_FACE_ATTRIBUTES"); - WriteInt ( n_named_attr); + WriteString( "N_PER_FACE_ATTRIBUTES"); + WriteInt ( n_named_attr); - for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai) - if(!(*ai)._name.empty()) - { - STDBf * stdb = (STDBf *) (*ai)._handle; + for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai) + if(!(*ai)._name.empty()) + { + STDBf * stdb = (STDBf *) (*ai)._handle; - WriteString( "PER_FACE_ATTR_NAME"); - WriteString( (*ai)._name.c_str()); + WriteString( "PER_FACE_ATTR_NAME"); + WriteString( (*ai)._name.c_str()); - WriteString( "PER_FACE_ATTR_SIZE"); - WriteInt( stdb->SizeOf()); + WriteString( "PER_FACE_ATTR_SIZE"); + WriteInt( stdb->SizeOf()); WriteOut(stdb->DataBegin(),m.face.size(),stdb->SizeOf() ); - } - } + } + } - ///* save the per mesh attributes */ - { - typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; - unsigned int n_named_attr = 0; - for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty(); - WriteString( "N_PER_MESH_ATTRIBUTES"); WriteInt( n_named_attr); - for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai) - if(!(*ai)._name.empty()) - { + ///* save the per mesh attributes */ + { + typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai; + unsigned int n_named_attr = 0; + for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty(); + WriteString( "N_PER_MESH_ATTRIBUTES"); WriteInt( n_named_attr); + for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai) + if(!(*ai)._name.empty()) + { SimpleTempDataBase * handle = (SimpleTempDataBase *) (*ai)._handle ; - - WriteString( "PER_MESH_ATTR_NAME"); - WriteString( (*ai)._name.c_str()); - WriteString( "PER_MESH_ATTR_SIZE"); - WriteInt( handle->SizeOf()); + WriteString( "PER_MESH_ATTR_NAME"); + WriteString( (*ai)._name.c_str()); + + WriteString( "PER_MESH_ATTR_SIZE"); + WriteInt( handle->SizeOf()); WriteOut(handle->DataBegin(),1,handle->SizeOf() ); - } - } + } + } - // fflush(F()); + // fflush(F()); return 0; - } + } static const char *ErrorMsg(int error) { static std::vector off_error_msg; @@ -439,7 +424,7 @@ namespace io { if(error>1 || error<0) return "Unknown error"; else return off_error_msg[error].c_str(); } - }; // end class + }; // end class } // end Namespace tri } // end Namespace io diff --git a/wrap/io_trimesh/import_vmi.h b/wrap/io_trimesh/import_vmi.h index f67b6802..bde2243e 100644 --- a/wrap/io_trimesh/import_vmi.h +++ b/wrap/io_trimesh/import_vmi.h @@ -128,6 +128,7 @@ namespace io { m.vert_attr.erase(res); pa._padding = padd; std::pair new_pa = m.vert_attr.insert(pa); + (void)new_pa; assert(new_pa.second); } else @@ -155,6 +156,7 @@ namespace io { m.face_attr.erase(res); pa._padding = padd; std::pair new_pa = m.face_attr.insert(pa); + (void)new_pa; assert(new_pa.second); } else @@ -180,6 +182,7 @@ namespace io { m.mesh_attr.erase(res); pa._padding = padd; std::pair new_pa = m.mesh_attr.insert(pa); + (void)new_pa; assert(new_pa.second); } else