diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index 979e4357..c1f26fa5 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -114,16 +114,16 @@ public: typedef SimpleTempData SimpTempDataType; typedef ATTR_TYPE AttrType; - STL_CONT &c; + const STL_CONT &c; VectorNBW data; int padding; - SimpleTempData(STL_CONT &_c) : c(_c), padding(0) + SimpleTempData(const STL_CONT &_c) : c(_c), padding(0) { data.reserve(c.capacity()); data.resize(c.size()); }; - SimpleTempData(STL_CONT &_c, const ATTR_TYPE &val) : c(_c) + SimpleTempData(const STL_CONT &_c, const ATTR_TYPE &val) : c(_c) { data.reserve(c.capacity()); data.resize(c.size()); @@ -142,11 +142,13 @@ public: // access to data ATTR_TYPE &operator[](const typename STL_CONT::value_type &v) { return data[&v - &*c.begin()]; } ATTR_TYPE &operator[](const typename STL_CONT::value_type *v) { return data[v - &*c.begin()]; } + ATTR_TYPE &operator[](const typename STL_CONT::const_iterator &cont) { return data[&(*cont) - &*c.begin()]; } ATTR_TYPE &operator[](const typename STL_CONT::iterator &cont) { return data[&(*cont) - &*c.begin()]; } ATTR_TYPE &operator[](size_t i) { return data[i]; } const ATTR_TYPE &operator[](const typename STL_CONT::value_type &v) const { return data[&v - &*c.begin()]; } const ATTR_TYPE &operator[](const typename STL_CONT::value_type *v) const { return data[v - &*c.begin()]; } + const ATTR_TYPE &operator[](const typename STL_CONT::const_iterator &cont) const { return data[&(*cont) - &*c.begin()]; } const ATTR_TYPE &operator[](const typename STL_CONT::iterator &cont) const { return data[&(*cont) - &*c.begin()]; } const ATTR_TYPE &operator[](size_t i) const { return data[i]; } diff --git a/vcg/simplex/vertex/component.h b/vcg/simplex/vertex/component.h index 1914dbbd..f4cab3c9 100644 --- a/vcg/simplex/vertex/component.h +++ b/vcg/simplex/vertex/component.h @@ -49,30 +49,35 @@ template class EmptyCore: public TT { public: typedef int FlagType; int &Flags() { assert(0); static int dummyflags(0); return dummyflags; } + int Flags() const { return 0; } int cFlags() const { return 0; } static bool HasFlags() { return false; } typedef vcg::Point3f CoordType; typedef CoordType::ScalarType ScalarType; CoordType &P() { assert(0); static CoordType coord(0, 0, 0); return coord; } + CoordType P() const { assert(0); static CoordType coord(0, 0, 0); assert(0); return coord; } CoordType cP() const { assert(0); static CoordType coord(0, 0, 0); assert(0); return coord; } static bool HasCoord() { return false; } inline bool IsCoordEnabled() const { return TT::VertexType::HasCoord();} typedef vcg::Point3s NormalType; NormalType &N() { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; } + NormalType N() const { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; } NormalType cN() const { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; } static bool HasNormal() { return false; } inline bool IsNormalEnabled() const { return TT::VertexType::HasNormal();} typedef float QualityType; QualityType &Q() { assert(0); static QualityType dummyQuality(0); return dummyQuality; } + QualityType Q() const { assert(0); static QualityType dummyQuality(0); return dummyQuality; } QualityType cQ() const { assert(0); static QualityType dummyQuality(0); return dummyQuality; } static bool HasQuality() { return false; } inline bool IsQualityEnabled() const { return TT::VertexType::HasQuality();} typedef vcg::Color4b ColorType; ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } + ColorType C() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; } static bool HasColor() { return false; } inline bool IsColorEnabled() const { return TT::VertexType::HasColor();} @@ -80,18 +85,21 @@ public: typedef int MarkType; void InitIMark() { } int cIMark() const { assert(0); static int tmp=-1; return tmp;} + int IMark() const { assert(0); static int tmp=-1; return tmp;} int &IMark() { assert(0); static int tmp=-1; return tmp;} static bool HasMark() { return false; } inline bool IsMarkEnabled() const { return TT::VertexType::HasMark();} typedef ScalarType RadiusType; RadiusType &R() { static ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } + RadiusType R() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } RadiusType cR() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } static bool HasRadius() { return false; } inline bool IsRadiusEnabled() const { return TT::VertexType::HasRadius();} typedef vcg::TexCoord2 TexCoordType; TexCoordType &T() { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; } + TexCoordType T() const { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; } TexCoordType cT() const { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; } static bool HasTexCoord() { return false; } inline bool IsTexCoordEnabled() const { return TT::VertexType::HasTexCoord();} @@ -151,17 +159,23 @@ public: typedef Point2f CurvatureType; float &Kh() { static float dummy = 0.f; assert(0);return dummy;} float &Kg() { static float dummy = 0.f; assert(0);return dummy;} + float Kh() const { static float dummy = 0.f; assert(0); return dummy;} + float Kg() const { static float dummy = 0.f; assert(0); return dummy;} float cKh() const { static float dummy = 0.f; assert(0); return dummy;} float cKg() const { static float dummy = 0.f; assert(0); return dummy;} typedef CurvatureDirBaseType CurvatureDirType; CurVecType &PD1() {static CurVecType v(0,0,0); assert(0);return v;} CurVecType &PD2() {static CurVecType v(0,0,0); assert(0);return v;} + CurVecType PD1() const {static CurVecType v(0,0,0); assert(0);return v;} + CurVecType PD2() const {static CurVecType v(0,0,0); assert(0);return v;} CurVecType cPD1() const {static CurVecType v(0,0,0); assert(0);return v;} CurVecType cPD2() const {static CurVecType v(0,0,0); assert(0);return v;} CurScalarType &K1() { static ScalarType v = 0.0;assert(0);return v;} CurScalarType &K2() { static ScalarType v = 0.0;assert(0);return v;} + CurScalarType K1() const {static ScalarType v = 0.0;assert(0);return v;} + CurScalarType K2() const {static ScalarType v = 0.0;assert(0);return v;} CurScalarType cK1() const {static ScalarType v = 0.0;assert(0);return v;} CurScalarType cK2() const {static ScalarType v = 0.0;assert(0);return v;} diff --git a/wrap/io_trimesh/export_ply.h b/wrap/io_trimesh/export_ply.h index c1f45e01..05364d73 100644 --- a/wrap/io_trimesh/export_ply.h +++ b/wrap/io_trimesh/export_ply.h @@ -70,30 +70,30 @@ namespace vcg { public: typedef ::vcg::ply::PropDescriptor PropDescriptor ; - typedef typename SaveMeshType::VertexPointer VertexPointer; + 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::VertexIterator VertexIterator; - typedef typename SaveMeshType::FaceIterator FaceIterator; - typedef typename SaveMeshType::EdgeIterator EdgeIterator; + 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; - static int Save(SaveMeshType &m, const char * filename, bool binary=true) + static int Save(const SaveMeshType &m, const char * filename, bool binary=true) { PlyInfo pi; return Save(m,filename,binary,pi); } - static int Save(SaveMeshType &m, const char * filename, int savemask, bool binary = true, CallBackPos *cb=0 ) + 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(SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0 + static int Save(const SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0 { FILE * fpout; const char * hbin = "binary_little_endian"; @@ -437,14 +437,20 @@ namespace vcg { if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS) ) fwrite(&(vp->Flags()),sizeof(int),1,fpout); - if( HasPerVertexColor(m) && (pi.mask & Mask::IOM_VERTCOLOR) ) - fwrite(&( vp->C() ),sizeof(char),4,fpout); + if( HasPerVertexColor(m) && (pi.mask & Mask::IOM_VERTCOLOR) ){ + auto c = vp->C(); + fwrite(&c,sizeof(char),4,fpout); + } - if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) ) - fwrite(&( vp->Q() ),sizeof(typename VertexType::QualityType),1,fpout); + if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) ){ + auto q = vp->Q(); + fwrite(&q, sizeof(typename VertexType::QualityType),1,fpout); + } - if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) ) - fwrite(&( vp->R() ),sizeof(typename VertexType::RadiusType),1,fpout); + if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) ){ + auto r = vp->R(); + fwrite(&r,sizeof(typename VertexType::RadiusType),1,fpout); + } if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) ) { @@ -489,7 +495,7 @@ namespace vcg { fprintf(fpout,"%.*g %.*g %.*g " ,DGT,vp->P()[0],DGT,vp->P()[1],DGT,vp->P()[2]); if( HasPerVertexNormal(m) && (pi.mask & Mask::IOM_VERTNORMAL) ) - fprintf(fpout,"%.*g %.*g %.*g " ,DGT,ScalarType(vp->N()[0]),DGT,ScalarType(vp->N()[1]),DGT,ScalarType(vp->N()[2])); + fprintf(fpout,"%.*g %.*g %.*g " ,DGT,ScalarType(vp->N()[0]),DGT,ScalarType(vp->N()[1]),DGT,ScalarType(vp->N()[2])); if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS)) fprintf(fpout,"%d ",vp->Flags()); @@ -571,8 +577,10 @@ namespace vcg { fwrite(&b3char,sizeof(char),1,fpout); fwrite(vv,sizeof(int),3,fpout); - if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS) ) - fwrite(&(fp->Flags()),sizeof(int),1,fpout); + if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS) ){ + auto fl = fp->Flags(); + fwrite(&fl,sizeof(int),1,fpout); + } if( HasPerVertexTexCoord(m) && (!HasPerWedgeTexCoord(m)) && (pi.mask & Mask::IOM_WEDGTEXCOORD) ) // Note that you can save VT as WT if you really want it... {