Added a bunch of 'c' to component members to clarify constant access

This commit is contained in:
Paolo Cignoni 2012-11-15 19:11:28 +00:00
parent 51fe0fb938
commit 8b4d04be7a
6 changed files with 67 additions and 66 deletions

View File

@ -345,9 +345,9 @@ static void Covariance(const MeshType & m, vcg::Point3<ScalarType> & bary, vcg::
for(fi = m.face.begin(); fi != m.face.end(); ++fi)
if(!(*fi).IsD())
{
const CoordType &P0 = (*fi).P(0);
const CoordType &P1 = (*fi).P(1);
const CoordType &P2 = (*fi).P(2);
const CoordType &P0 = (*fi).cP(0);
const CoordType &P1 = (*fi).cP(1);
const CoordType &P2 = (*fi).cP(2);
CoordType n = ((P1-P0)^(P2-P0));
const float da = n.Norm();
n/=da*da;

View File

@ -49,9 +49,9 @@ namespace vcg {
uv1=f->cWT(1).P();
uv2=f->cWT(2).P();
} else {
uv0=f->V(0)->T().P();
uv1=f->V(1)->T().P();
uv2=f->V(2)->T().P();
uv0=f->cV(0)->T().P();
uv1=f->cV(1)->T().P();
uv2=f->cV(2)->T().P();
}
ScalarType AreaUV=((uv1-uv0)^(uv2-uv0))/2.0;
return AreaUV;
@ -60,7 +60,7 @@ namespace vcg {
static ScalarType EdgeLenght3D(const FaceType *f,int e)
{
assert((e>=0)&&(e<3));
ScalarType length=(f->P0(e)-f->P1(e)).Norm();
ScalarType length=(f->cP0(e)-f->cP1(e)).Norm();
return (length);
}
@ -117,9 +117,9 @@ namespace vcg {
static ScalarType AngleRad3D(const FaceType *f,int e)
{
assert((e>=0)&&(e<3));
CoordType p0=f->P((e+2)%3);
CoordType p1=f->P(e);
CoordType p2=f->P((e+1)%3);
CoordType p0=f->cP((e+2)%3);
CoordType p1=f->cP(e);
CoordType p2=f->cP((e+1)%3);
typedef typename CoordType::ScalarType ScalarType;
CoordType dir0=p2-p1;
CoordType dir1=p0-p1;
@ -134,9 +134,9 @@ namespace vcg {
uv1=f->cWT((e+0)%3).P();
uv2=f->cWT((e+1)%3).P();
} else {
uv0=f->V2(e)->T().P();
uv1=f->V0(e)->T().P();
uv2=f->V1(e)->T().P();
uv0=f->cV2(e)->T().P();
uv1=f->cV0(e)->T().P();
uv2=f->cV1(e)->T().P();
}
vcg::Point2<ScalarType> dir0=uv2-uv1;
vcg::Point2<ScalarType> dir1=uv0-uv1;

View File

@ -410,12 +410,12 @@ template <class MeshType> inline int & IMark(MeshType & m){return m.imark;}
/** \brief Check if the vertex incremental mark matches the one of the mesh.
@param m the mesh containing the element
@param v Vertex pointer */
template <class MeshType> inline bool IsMarked(MeshType & m, typename MeshType::ConstVertexPointer v ) { return v->IMark() == m.imark; }
template <class MeshType> inline bool IsMarked(MeshType & m, typename MeshType::ConstVertexPointer v ) { return v->cIMark() == m.imark; }
/** \brief Check if the face incremental mark matches the one of the mesh.
@param m the mesh containing the element
@param f Face pointer */
template <class MeshType> inline bool IsMarked( MeshType & m,typename MeshType::ConstFacePointer f ) { return f->IMark() == m.imark; }
template <class MeshType> inline bool IsMarked( MeshType & m,typename MeshType::ConstFacePointer f ) { return f->cIMark() == m.imark; }
/** \brief Set the vertex incremental mark of the vertex to the one of the mesh.
@param m the mesh containing the element

View File

@ -69,21 +69,21 @@ namespace vcg {
b0 = f.cEdge(1)[1]*(p[2] - f.cP(1)[2]) - f.cEdge(1)[2]*(p[1] - f.cP(1)[1]);
if(b0<=0)
{
b0 = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
b0 = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
if(dist>b0) { dist = b0; return true; }
else return false;
}
b1 = f.cEdge(2)[1]*(p[2] - f.cP(2)[2]) - f.cEdge(2)[2]*(p[1] - f.cP(2)[1]);
if(b1<=0)
{
b1 = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
b1 = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
if(dist>b1) { dist = b1; return true; }
else return false;
}
b2 = f.cEdge(0)[1]*(p[2] - f.cP(0)[2]) - f.cEdge(0)[2]*(p[1] - f.cP(0)[1]);
if(b2<=0)
{
b2 = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
b2 = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
if(dist>b2) { dist = b2; return true; }
else return false;
}
@ -92,10 +92,10 @@ namespace vcg {
if( (b=std::min(b0,std::min(b1,b2)) ) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
if(b==b0) bt = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
else { assert(b==b2);
bt = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
bt = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
}
if(dist>bt) { dist = bt; return true; }
else return false;
@ -106,31 +106,31 @@ namespace vcg {
b0 = f.cEdge(1)[2]*(p[0] - f.cP(1)[0]) - f.cEdge(1)[0]*(p[2] - f.cP(1)[2]);
if(b0<=0)
{
b0 = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
b0 = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
if(dist>b0) { dist = b0; return true; }
else return false;
}
b1 = f.cEdge(2)[2]*(p[0] - f.cP(2)[0]) - f.cEdge(2)[0]*(p[2] - f.cP(2)[2]);
if(b1<=0)
{
b1 = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
b1 = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
if(dist>b1) { dist = b1; return true; }
else return false;
}
b2 = f.cEdge(0)[2]*(p[0] - f.cP(0)[0]) - f.cEdge(0)[0]*(p[2] - f.cP(0)[2]);
if(b2<=0)
{
b2 = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
b2 = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
if(b==b0) bt = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
else { assert(b==b2);
bt = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
bt = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
}
if(dist>bt) { dist = bt; return true; }
else return false;
@ -141,31 +141,31 @@ namespace vcg {
b0 = f.cEdge(1)[0]*(p[1] - f.cP(1)[1]) - f.cEdge(1)[1]*(p[0] - f.cP(1)[0]);
if(b0<=0)
{
b0 = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
b0 = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
if(dist>b0) { dist = b0; return true; }
else return false;
}
b1 = f.cEdge(2)[0]*(p[1] - f.cP(2)[1]) - f.cEdge(2)[1]*(p[0] - f.cP(2)[0]);
if(b1<=0)
{
b1 = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
b1 = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
if(dist>b1) { dist = b1; return true; }
else return false;
}
b2 = f.cEdge(0)[0]*(p[1] - f.cP(0)[1]) - f.cEdge(0)[1]*(p[0] - f.cP(0)[0]);
if(b2<=0)
{
b2 = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
b2 = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
if(b==b0) bt = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
else { assert(b==b2);
bt = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
bt = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
}
if(dist>bt) { dist = bt; return true; }
@ -320,21 +320,21 @@ namespace vcg {
b0 = fEdge[1][1]*(p[2] - f.cP(1)[2]) - fEdge[1][2]*(p[1] - f.cP(1)[1]);
if(b0<=0)
{
b0 = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
b0 = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
if(dist>b0) { dist = b0; return true; }
else return false;
}
b1 = fEdge[2][1]*(p[2] - f.cP(2)[2]) - fEdge[2][2]*(p[1] - f.cP(2)[1]);
if(b1<=0)
{
b1 = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
b1 = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
if(dist>b1) { dist = b1; return true; }
else return false;
}
b2 = fEdge[0][1]*(p[2] - f.cP(0)[2]) - fEdge[0][2]*(p[1] - f.cP(0)[1]);
if(b2<=0)
{
b2 = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
b2 = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
if(dist>b2) { dist = b2; return true; }
else return false;
}
@ -348,9 +348,9 @@ namespace vcg {
if( (b=vcg::math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
else if(b==b2) bt = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
if(b==b0) bt = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
else if(b==b2) bt = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
//printf("Warning area:%g %g %g %g thr:%g bt:%g\n",Area(), b0,b1,b2,EPSILON*Area(),bt);
if(dist>bt) { dist = bt; return true; }
else return false;
@ -364,30 +364,30 @@ namespace vcg {
b0 = fEdge[1][2]*(p[0] - f.cP(1)[0]) - fEdge[1][0]*(p[2] - f.cP(1)[2]);
if(b0<=0)
{
b0 = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
b0 = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
if(dist>b0) { dist = b0; return true; }
else return false;
}
b1 = fEdge[2][2]*(p[0] - f.cP(2)[0]) - fEdge[2][0]*(p[2] - f.cP(2)[2]);
if(b1<=0)
{
b1 = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
b1 = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
if(dist>b1) { dist = b1; return true; }
else return false;
}
b2 = fEdge[0][2]*(p[0] - f.cP(0)[0]) - fEdge[0][0]*(p[2] - f.cP(0)[2]);
if(b2<=0)
{
b2 = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
b2 = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=vcg::math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
else if(b==b2) bt = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
if(b==b0) bt = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
else if(b==b2) bt = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
//printf("Warning area:%g %g %g %g thr:%g bt:%g\n",Area(), b0,b1,b2,EPSILON*Area(),bt);
if(dist>bt) { dist = bt; return true; }
else return false;
@ -401,30 +401,30 @@ namespace vcg {
b0 = fEdge[1][0]*(p[1] - f.cP(1)[1]) - fEdge[1][1]*(p[0] - f.cP(1)[0]);
if(b0<=0)
{
b0 = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
b0 = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
if(dist>b0) { dist = b0; return true; }
else return false;
}
b1 = fEdge[2][0]*(p[1] - f.cP(2)[1]) - fEdge[2][1]*(p[0] - f.cP(2)[0]);
if(b1<=0)
{
b1 = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
b1 = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
if(dist>b1) { dist = b1; return true; }
else return false;
}
b2 = fEdge[0][0]*(p[1] - f.cP(0)[1]) - fEdge[0][1]*(p[0] - f.cP(0)[0]);
if(b2<=0)
{
b2 = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
b2 = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=vcg::math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.V(2)->cP(),f.V(0)->cP(),p);
else if(b==b2) bt = PSDist(q,f.V(0)->cP(),f.V(1)->cP(),p);
if(b==b0) bt = PSDist(q,f.cV(1)->cP(),f.cV(2)->cP(),p);
else if(b==b1) bt = PSDist(q,f.cV(2)->cP(),f.cV(0)->cP(),p);
else if(b==b2) bt = PSDist(q,f.cV(0)->cP(),f.cV(1)->cP(),p);
//printf("Warning area:%g %g %g %g thr:%g bt:%g\n",Area(), b0,b1,b2,EPSILON*Area(),bt);
if(dist>bt) { dist = bt; return true; }

View File

@ -62,12 +62,12 @@ template <class SCALARTYPE>
const Point3<typename VERTEXTYPE::ScalarType> fp = Point3<typename VERTEXTYPE::ScalarType>::Construct(p);
typename VERTEXTYPE::ScalarType md; // distance between v and fp
md = (v.P() - fp).Norm();
md = (v.cP() - fp).Norm();
if (md <= minDist)
{
minDist = (SCALARTYPE)(md); // minDist is updated to the closest distance
q = v.P(); // q is the current closest point
q = v.cP(); // q is the current closest point
return true;
}

View File

@ -282,12 +282,13 @@ namespace vcg {
Segment3<typename TRIANGLETYPE::ScalarType> & sg)
{
typedef typename TRIANGLETYPE::ScalarType T;
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(0),tr.P(1)),sg.P0())){
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(0),tr.P(2)),sg.P1()))
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.cP(0),tr.cP(1)),sg.P0()))
{
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.cP(0),tr.cP(2)),sg.P1()))
return true;
else
{
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(1),tr.P(2)),sg.P1()))
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.cP(1),tr.cP(2)),sg.P1()))
return true;
else assert(0);
return true;
@ -295,9 +296,9 @@ namespace vcg {
}
else
{
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(1),tr.P(2)),sg.P0()))
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.cP(1),tr.cP(2)),sg.P0()))
{
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(0),tr.P(2)),sg.P1()))return true;
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.cP(0),tr.cP(2)),sg.P1()))return true;
assert(0);
return true;
}
@ -308,8 +309,8 @@ namespace vcg {
/// intersection between two triangles
template<typename TRIANGLETYPE>
inline bool IntersectionTriangleTriangle(const TRIANGLETYPE & t0,const TRIANGLETYPE & t1){
return NoDivTriTriIsect(t0.P0(0),t0.P0(1),t0.P0(2),
t1.P0(0),t1.P0(1),t1.P0(2));
return NoDivTriTriIsect(t0.cP(0),t0.cP(1),t0.cP(2),
t1.cP(0),t1.cP(1),t1.cP(2));
}
template<class T>
@ -608,7 +609,7 @@ bool IntersectionSegmentTriangle( const vcg::Segment3<typename TriangleType::Sca
const TriangleType &t,
typename TriangleType::ScalarType & a ,typename TriangleType::ScalarType & b)
{
return IntersectionSegmentTriangle(seg,t.P(0),t.P(1),t.P(2),a,b);
return IntersectionSegmentTriangle(seg,t.cP(0),t.cP(1),t.cP(2),a,b);
}
template<class ScalarType>
@ -727,10 +728,10 @@ public:
ScalarType u;
ScalarType v;
bool bret = IntersectionRayTriangle(ray, Point3<SCALARTYPE>::Construct(f.P(0)), Point3<SCALARTYPE>::Construct(f.P(1)), Point3<SCALARTYPE>::Construct(f.P(2)), t, u, v);
bool bret = IntersectionRayTriangle(ray, Point3<SCALARTYPE>::Construct(f.cP(0)), Point3<SCALARTYPE>::Construct(f.cP(1)), Point3<SCALARTYPE>::Construct(f.cP(2)), t, u, v);
if (BACKFACETEST) {
if (!bret) {
bret = IntersectionRayTriangle(ray, Point3<SCALARTYPE>::Construct(f.P(0)), Point3<SCALARTYPE>::Construct(f.P(2)), Point3<SCALARTYPE>::Construct(f.P(1)), t, u, v);
bret = IntersectionRayTriangle(ray, Point3<SCALARTYPE>::Construct(f.cP(0)), Point3<SCALARTYPE>::Construct(f.cP(2)), Point3<SCALARTYPE>::Construct(f.cP(1)), t, u, v);
}
}
return (bret);