(partial) ply const correctness
This commit is contained in:
parent
a1e1ba882f
commit
0a2ed11ac2
|
@ -114,16 +114,16 @@ public:
|
||||||
typedef SimpleTempData<STL_CONT, ATTR_TYPE> SimpTempDataType;
|
typedef SimpleTempData<STL_CONT, ATTR_TYPE> SimpTempDataType;
|
||||||
typedef ATTR_TYPE AttrType;
|
typedef ATTR_TYPE AttrType;
|
||||||
|
|
||||||
STL_CONT &c;
|
const STL_CONT &c;
|
||||||
VectorNBW<ATTR_TYPE> data;
|
VectorNBW<ATTR_TYPE> data;
|
||||||
int padding;
|
int padding;
|
||||||
|
|
||||||
SimpleTempData(STL_CONT &_c) : c(_c), padding(0)
|
SimpleTempData(const STL_CONT &_c) : c(_c), padding(0)
|
||||||
{
|
{
|
||||||
data.reserve(c.capacity());
|
data.reserve(c.capacity());
|
||||||
data.resize(c.size());
|
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.reserve(c.capacity());
|
||||||
data.resize(c.size());
|
data.resize(c.size());
|
||||||
|
@ -142,11 +142,13 @@ public:
|
||||||
// access to data
|
// 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::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[](const typename STL_CONT::iterator &cont) { return data[&(*cont) - &*c.begin()]; }
|
||||||
ATTR_TYPE &operator[](size_t i) { return data[i]; }
|
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::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[](const typename STL_CONT::iterator &cont) const { return data[&(*cont) - &*c.begin()]; }
|
||||||
const ATTR_TYPE &operator[](size_t i) const { return data[i]; }
|
const ATTR_TYPE &operator[](size_t i) const { return data[i]; }
|
||||||
|
|
||||||
|
|
|
@ -49,30 +49,35 @@ template <class TT> class EmptyCore: public TT {
|
||||||
public:
|
public:
|
||||||
typedef int FlagType;
|
typedef int FlagType;
|
||||||
int &Flags() { assert(0); static int dummyflags(0); return dummyflags; }
|
int &Flags() { assert(0); static int dummyflags(0); return dummyflags; }
|
||||||
|
int Flags() const { return 0; }
|
||||||
int cFlags() const { return 0; }
|
int cFlags() const { return 0; }
|
||||||
static bool HasFlags() { return false; }
|
static bool HasFlags() { return false; }
|
||||||
|
|
||||||
typedef vcg::Point3f CoordType;
|
typedef vcg::Point3f CoordType;
|
||||||
typedef CoordType::ScalarType ScalarType;
|
typedef CoordType::ScalarType ScalarType;
|
||||||
CoordType &P() { assert(0); static CoordType coord(0, 0, 0); return coord; }
|
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; }
|
CoordType cP() const { assert(0); static CoordType coord(0, 0, 0); assert(0); return coord; }
|
||||||
static bool HasCoord() { return false; }
|
static bool HasCoord() { return false; }
|
||||||
inline bool IsCoordEnabled() const { return TT::VertexType::HasCoord();}
|
inline bool IsCoordEnabled() const { return TT::VertexType::HasCoord();}
|
||||||
|
|
||||||
typedef vcg::Point3s NormalType;
|
typedef vcg::Point3s NormalType;
|
||||||
NormalType &N() { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
|
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; }
|
NormalType cN() const { assert(0); static NormalType dummy_normal(0, 0, 0); return dummy_normal; }
|
||||||
static bool HasNormal() { return false; }
|
static bool HasNormal() { return false; }
|
||||||
inline bool IsNormalEnabled() const { return TT::VertexType::HasNormal();}
|
inline bool IsNormalEnabled() const { return TT::VertexType::HasNormal();}
|
||||||
|
|
||||||
typedef float QualityType;
|
typedef float QualityType;
|
||||||
QualityType &Q() { assert(0); static QualityType dummyQuality(0); return dummyQuality; }
|
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; }
|
QualityType cQ() const { assert(0); static QualityType dummyQuality(0); return dummyQuality; }
|
||||||
static bool HasQuality() { return false; }
|
static bool HasQuality() { return false; }
|
||||||
inline bool IsQualityEnabled() const { return TT::VertexType::HasQuality();}
|
inline bool IsQualityEnabled() const { return TT::VertexType::HasQuality();}
|
||||||
|
|
||||||
typedef vcg::Color4b ColorType;
|
typedef vcg::Color4b ColorType;
|
||||||
ColorType &C() { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
|
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; }
|
ColorType cC() const { static ColorType dumcolor(vcg::Color4b::White); assert(0); return dumcolor; }
|
||||||
static bool HasColor() { return false; }
|
static bool HasColor() { return false; }
|
||||||
inline bool IsColorEnabled() const { return TT::VertexType::HasColor();}
|
inline bool IsColorEnabled() const { return TT::VertexType::HasColor();}
|
||||||
|
@ -80,18 +85,21 @@ public:
|
||||||
typedef int MarkType;
|
typedef int MarkType;
|
||||||
void InitIMark() { }
|
void InitIMark() { }
|
||||||
int cIMark() const { assert(0); static int tmp=-1; return tmp;}
|
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;}
|
int &IMark() { assert(0); static int tmp=-1; return tmp;}
|
||||||
static bool HasMark() { return false; }
|
static bool HasMark() { return false; }
|
||||||
inline bool IsMarkEnabled() const { return TT::VertexType::HasMark();}
|
inline bool IsMarkEnabled() const { return TT::VertexType::HasMark();}
|
||||||
|
|
||||||
typedef ScalarType RadiusType;
|
typedef ScalarType RadiusType;
|
||||||
RadiusType &R() { static ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; }
|
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; }
|
RadiusType cR() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; }
|
||||||
static bool HasRadius() { return false; }
|
static bool HasRadius() { return false; }
|
||||||
inline bool IsRadiusEnabled() const { return TT::VertexType::HasRadius();}
|
inline bool IsRadiusEnabled() const { return TT::VertexType::HasRadius();}
|
||||||
|
|
||||||
typedef vcg::TexCoord2<float,1> TexCoordType;
|
typedef vcg::TexCoord2<float,1> TexCoordType;
|
||||||
TexCoordType &T() { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; }
|
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; }
|
TexCoordType cT() const { static TexCoordType dummy_texcoord; assert(0); return dummy_texcoord; }
|
||||||
static bool HasTexCoord() { return false; }
|
static bool HasTexCoord() { return false; }
|
||||||
inline bool IsTexCoordEnabled() const { return TT::VertexType::HasTexCoord();}
|
inline bool IsTexCoordEnabled() const { return TT::VertexType::HasTexCoord();}
|
||||||
|
@ -151,17 +159,23 @@ public:
|
||||||
typedef Point2f CurvatureType;
|
typedef Point2f CurvatureType;
|
||||||
float &Kh() { static float dummy = 0.f; assert(0);return dummy;}
|
float &Kh() { static float dummy = 0.f; assert(0);return dummy;}
|
||||||
float &Kg() { 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 cKh() const { static float dummy = 0.f; assert(0); return dummy;}
|
||||||
float cKg() const { static float dummy = 0.f; assert(0); return dummy;}
|
float cKg() const { static float dummy = 0.f; assert(0); return dummy;}
|
||||||
|
|
||||||
typedef CurvatureDirBaseType<float> CurvatureDirType;
|
typedef CurvatureDirBaseType<float> CurvatureDirType;
|
||||||
CurVecType &PD1() {static CurVecType v(0,0,0); assert(0);return v;}
|
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 &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 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;}
|
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 &K1() { static ScalarType v = 0.0;assert(0);return v;}
|
||||||
CurScalarType &K2() { 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 cK1() const {static ScalarType v = 0.0;assert(0);return v;}
|
||||||
CurScalarType cK2() const {static ScalarType v = 0.0;assert(0);return v;}
|
CurScalarType cK2() const {static ScalarType v = 0.0;assert(0);return v;}
|
||||||
|
|
||||||
|
|
|
@ -70,30 +70,30 @@ namespace vcg {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef ::vcg::ply::PropDescriptor PropDescriptor ;
|
typedef ::vcg::ply::PropDescriptor PropDescriptor ;
|
||||||
typedef typename SaveMeshType::VertexPointer VertexPointer;
|
typedef typename SaveMeshType::ConstVertexPointer VertexPointer;
|
||||||
typedef typename SaveMeshType::ScalarType ScalarType;
|
typedef typename SaveMeshType::ScalarType ScalarType;
|
||||||
typedef typename SaveMeshType::VertexType VertexType;
|
typedef typename SaveMeshType::VertexType VertexType;
|
||||||
typedef typename SaveMeshType::FaceType FaceType;
|
typedef typename SaveMeshType::FaceType FaceType;
|
||||||
typedef typename SaveMeshType::FacePointer FacePointer;
|
typedef typename SaveMeshType::ConstFacePointer FacePointer;
|
||||||
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
typedef typename SaveMeshType::ConstVertexIterator VertexIterator;
|
||||||
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
typedef typename SaveMeshType::ConstFaceIterator FaceIterator;
|
||||||
typedef typename SaveMeshType::EdgeIterator EdgeIterator;
|
typedef typename SaveMeshType::ConstEdgeIterator EdgeIterator;
|
||||||
typedef typename vcg::Shot<ScalarType>::ScalarType ShotScalarType;
|
typedef typename vcg::Shot<ScalarType>::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;
|
PlyInfo pi;
|
||||||
return Save(m,filename,binary,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;
|
PlyInfo pi;
|
||||||
pi.mask=savemask;
|
pi.mask=savemask;
|
||||||
return Save(m,filename,binary,pi,cb);
|
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;
|
FILE * fpout;
|
||||||
const char * hbin = "binary_little_endian";
|
const char * hbin = "binary_little_endian";
|
||||||
|
@ -437,14 +437,20 @@ namespace vcg {
|
||||||
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS) )
|
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS) )
|
||||||
fwrite(&(vp->Flags()),sizeof(int),1,fpout);
|
fwrite(&(vp->Flags()),sizeof(int),1,fpout);
|
||||||
|
|
||||||
if( HasPerVertexColor(m) && (pi.mask & Mask::IOM_VERTCOLOR) )
|
if( HasPerVertexColor(m) && (pi.mask & Mask::IOM_VERTCOLOR) ){
|
||||||
fwrite(&( vp->C() ),sizeof(char),4,fpout);
|
auto c = vp->C();
|
||||||
|
fwrite(&c,sizeof(char),4,fpout);
|
||||||
|
}
|
||||||
|
|
||||||
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) ){
|
||||||
fwrite(&( vp->Q() ),sizeof(typename VertexType::QualityType),1,fpout);
|
auto q = vp->Q();
|
||||||
|
fwrite(&q, sizeof(typename VertexType::QualityType),1,fpout);
|
||||||
|
}
|
||||||
|
|
||||||
if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) ){
|
||||||
fwrite(&( vp->R() ),sizeof(typename VertexType::RadiusType),1,fpout);
|
auto r = vp->R();
|
||||||
|
fwrite(&r,sizeof(typename VertexType::RadiusType),1,fpout);
|
||||||
|
}
|
||||||
|
|
||||||
if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) )
|
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]);
|
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) )
|
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))
|
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS))
|
||||||
fprintf(fpout,"%d ",vp->Flags());
|
fprintf(fpout,"%d ",vp->Flags());
|
||||||
|
@ -571,8 +577,10 @@ namespace vcg {
|
||||||
fwrite(&b3char,sizeof(char),1,fpout);
|
fwrite(&b3char,sizeof(char),1,fpout);
|
||||||
fwrite(vv,sizeof(int),3,fpout);
|
fwrite(vv,sizeof(int),3,fpout);
|
||||||
|
|
||||||
if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS) )
|
if(HasPerFaceFlags(m)&&( pi.mask & Mask::IOM_FACEFLAGS) ){
|
||||||
fwrite(&(fp->Flags()),sizeof(int),1,fpout);
|
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...
|
if( HasPerVertexTexCoord(m) && (!HasPerWedgeTexCoord(m)) && (pi.mask & Mask::IOM_WEDGTEXCOORD) ) // Note that you can save VT as WT if you really want it...
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue