From adb799a0a2f6c51e407752add09eb8beddc18d58 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 24 Mar 2021 19:15:10 +0100 Subject: [PATCH] fix const correctnes of face/component.h --- vcg/complex/algorithms/harmonic.h | 8 +++--- vcg/complex/algorithms/isotropic_remeshing.h | 4 +-- vcg/simplex/face/component.h | 26 ++++++++++---------- vcg/simplex/face/pos.h | 26 ++++++++++++++++---- wrap/io_trimesh/export_3ds.h | 2 +- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/vcg/complex/algorithms/harmonic.h b/vcg/complex/algorithms/harmonic.h index ec9a67cd..2c83d103 100644 --- a/vcg/complex/algorithms/harmonic.h +++ b/vcg/complex/algorithms/harmonic.h @@ -235,19 +235,19 @@ public: ScalarT cotB = 0; // Get the edge (a pair of vertices) - VertexType * v0 = f.cV(edge); - VertexType * v1 = f.cV((edge+1)%f.VN()); + const VertexType * v0 = f.cV(edge); + const VertexType * v1 = f.cV((edge+1)%f.VN()); if (fp != NULL && fp != &f) { // not a border edge - VertexType * vb = fp->cV((f.cFFi(edge)+2)%fp->VN()); + const VertexType * vb = fp->cV((f.cFFi(edge)+2)%fp->VN()); ScalarT angleB = ComputeAngle(v0, vb, v1); cotB = vcg::math::Cos(angleB) / vcg::math::Sin(angleB); } - VertexType * va = f.cV((edge+2)%f.VN()); + const VertexType * va = f.cV((edge+2)%f.VN()); ScalarT angleA = ComputeAngle(v0, va, v1); cotA = vcg::math::Cos(angleA) / vcg::math::Sin(angleA); diff --git a/vcg/complex/algorithms/isotropic_remeshing.h b/vcg/complex/algorithms/isotropic_remeshing.h index 264e7c08..5b7ac9ec 100644 --- a/vcg/complex/algorithms/isotropic_remeshing.h +++ b/vcg/complex/algorithms/isotropic_remeshing.h @@ -813,7 +813,7 @@ private: { if (faces[i]->IsFaceEdgeS(VtoE(vIdxes[i], (vIdxes[i]+1)%3)) && !vcg::tri::IsMarked(*params.m, faces[i]->cV1(vIdxes[i]))) { - vcg::tri::Mark(*params.m,faces[i]->cV1(vIdxes[i])); + vcg::tri::Mark(*params.m,faces[i]->V1(vIdxes[i])); incidentFeatures++; CoordType movingEdgeVector0 = (faces[i]->cP1(vIdxes[i]) - faces[i]->cP(vIdxes[i])).Normalize(); if (std::fabs(movingEdgeVector0 * dEdgeVector) < .9f || !p.IsEdgeS()) @@ -821,7 +821,7 @@ private: } if (faces[i]->IsFaceEdgeS(VtoE(vIdxes[i], (vIdxes[i]+2)%3)) && !vcg::tri::IsMarked(*params.m, faces[i]->cV2(vIdxes[i]))) { - vcg::tri::Mark(*params.m,faces[i]->cV2(vIdxes[i])); + vcg::tri::Mark(*params.m,faces[i]->V2(vIdxes[i])); incidentFeatures++; CoordType movingEdgeVector1 = (faces[i]->cP2(vIdxes[i]) - faces[i]->cP(vIdxes[i])).Normalize(); if (std::fabs(movingEdgeVector1 * dEdgeVector) < .9f || !p.IsEdgeS()) diff --git a/vcg/simplex/face/component.h b/vcg/simplex/face/component.h index 5ac8b3d6..0ab89fb6 100644 --- a/vcg/simplex/face/component.h +++ b/vcg/simplex/face/component.h @@ -40,15 +40,15 @@ namespace face { template class EmptyCore: public T { public: - inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } - inline typename T::VertexType * &FVp( const int i ) { return this->V(i); } - inline typename T::VertexType * FVp( const int i ) const { return this->cV(i); } - inline typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } - inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline typename T::CoordType P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } - inline typename T::CoordType cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::VertexType * &V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } + inline const typename T::VertexType * V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } + inline const typename T::VertexType * cV( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; } + inline typename T::VertexType * &FVp( const int i ) { return this->V(i); } + inline const typename T::VertexType * FVp( const int i ) const { return this->cV(i); } + inline const typename T::VertexType * cFVp( const int i ) const { return this->cV(i); } + inline typename T::CoordType &P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::CoordType P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } + inline typename T::CoordType cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; } static bool HasVertexRef() { return false; } static bool HasFVAdjacency() { return false; } @@ -200,7 +200,7 @@ public: inline typename T::VertexType * &V( const int j ) { assert(j>=0 && j<3); return v[j]; } /// \brief The pointer to the i-th vertex inline const typename T::VertexType * V (const int j) const { assert(j>=0 && j<3); return v[j]; } - inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; } + inline const typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; } inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } /// \brief Shortcut: the position of the i-th vertex (equivalent to \c V(i)->P() ) inline const CoordType &P( const int j ) const { assert(j>=0 && j<3); return v[j]->P(); } @@ -212,9 +212,9 @@ public: inline const typename T::VertexType * V0( const int j ) const { return V(j);} /** \brief Return the pointer to the j-th vertex of the face. */ inline const typename T::VertexType * V1( const int j ) const { return V((j+1)%3);} /** \brief Return the pointer to the ((j+1)%3)-th vertex of the face. */ inline const typename T::VertexType * V2( const int j ) const { return V((j+2)%3);} /** \brief Return the pointer to the ((j+2)%3)-th vertex of the face. */ - inline typename T::VertexType * cV0( const int j ) const { return cV(j);} - inline typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);} - inline typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);} + inline const typename T::VertexType * cV0( const int j ) const { return cV(j);} + inline const typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);} + inline const typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);} inline CoordType & P0( const int j ) { return V(j)->P();} inline CoordType & P1( const int j ) { return V((j+1)%3)->P();} diff --git a/vcg/simplex/face/pos.h b/vcg/simplex/face/pos.h index a20d4ac3..436226d1 100644 --- a/vcg/simplex/face/pos.h +++ b/vcg/simplex/face/pos.h @@ -219,15 +219,22 @@ public: } /// return the vertex that it should have if we make FlipV; - VertexType *VFlip() const + VertexType *VFlip() { - assert(f->cV(f->Prev(z))!=v && (f->cV(f->Next(z))==v || f->cV(z)==v)); - if(f->cV(f->Next(z))==v) return f->cV(z); - else return f->cV(f->Next(z)); + assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v)); + if(f->V(f->Next(z))==v) return f->V(z); + else return f->V(f->Next(z)); } + const VertexType *VFlip() const + { + assert(f->V(f->Prev(z))!=v && (f->V(f->Next(z))==v || f->V(z)==v)); + if(f->V(f->Next(z))==v) return f->V(z); + else return f->V(f->Next(z)); + } + /// return the face that it should have if we make FlipF; - FaceType *FFlip() const + FaceType *FFlip() { // assert( f->FFp(z)->FFp(f->FFi(z))==f ); // assert(f->V(f->Prev(z))!=v); @@ -236,6 +243,15 @@ public: return nf; } + const FaceType *FFlip() const + { + // assert( f->FFp(z)->FFp(f->FFi(z))==f ); + // assert(f->V(f->Prev(z))!=v); + // assert(f->V(f->Next(z))==v || f->V((z+0)%f->VN())==v); + const FaceType *nf=f->FFp(z); + return nf; + } + // Trova il prossimo half-edge di bordo (nhe) // tale che diff --git a/wrap/io_trimesh/export_3ds.h b/wrap/io_trimesh/export_3ds.h index 927cae0f..82424005 100644 --- a/wrap/io_trimesh/export_3ds.h +++ b/wrap/io_trimesh/export_3ds.h @@ -448,7 +448,7 @@ namespace io { /* returns index of the vertex */ - inline static int GetIndexVertex(const SaveMeshType &m, VertexType *p) + inline static int GetIndexVertex(const SaveMeshType &m, const VertexType *p) { return p-&*(m.vert.begin()); }