--- nurbs/hnurbsS_sp.cpp.orig Mon May 13 14:07:46 2002 +++ nurbs/hnurbsS_sp.cpp Fri Dec 1 01:01:28 2006 @@ -43,7 +43,7 @@ */ template void HNurbsSurfaceSP::updateMaxU() { - if(degU>3){ + if(this->degU>3){ #ifdef USE_EXCEPTION throw NurbsError(); #else @@ -53,12 +53,12 @@ #endif } else{ - maxU.resize(P.rows()) ; - maxAtU_.resize(P.rows()) ; - for(int i=0;iP.rows()) ; + maxAtU_.resize(this->P.rows()) ; + for(int i=0;iP.rows();++i){ + if(!maxInfluence(i,this->U,this->degU,maxAtU_[i])) cerr << "Problem in maxInfluence U!\n" ; - maxU[i] = nurbsBasisFun(maxAtU_[i],i,degU,U) ; + maxU[i] = nurbsBasisFun(maxAtU_[i],i,this->degU,this->U) ; } } @@ -78,7 +78,7 @@ */ template void HNurbsSurfaceSP::updateMaxV() { - if(degV>3){ + if(this->degV>3){ #ifdef USE_EXCEPTION throw NurbsError(); #else @@ -88,12 +88,12 @@ #endif } else{ - maxV.resize(P.cols()) ; - maxAtV_.resize(P.cols()) ; - for(int i=0;iP.cols()) ; + maxAtV_.resize(this->P.cols()) ; + for(int i=0;iP.cols();++i){ + if(!maxInfluence(i,this->V,this->degV,maxAtV_[i])) cerr << "Problem in maxInfluence V!\n" ; - maxV[i] = nurbsBasisFun(maxAtV_[i],i,degV,V) ; + maxV[i] = nurbsBasisFun(maxAtV_[i],i,this->degV,this->V) ; } } @@ -113,18 +113,18 @@ */ template void HNurbsSurfaceSP::modSurfCPby(int i, int j, const HPoint_nD& a) { - offset(i,j) += a / (maxU[i]*maxV[j]) ; - if(baseLevel_){ + this->offset(i,j) += a / (maxU[i]*maxV[j]) ; + if(this->baseLevel_){ Point_nD vecOffset ; - vecOffset = offset(i,j).x()*ivec(i,j) + - offset(i,j).y()*jvec(i,j) + - offset(i,j).z()*kvec(i,j) ; - P(i,j).x() = baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; - P(i,j).y() = baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; - P(i,j).z() = baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; + vecOffset = this->offset(i,j).x()*this->ivec(i,j) + + this->offset(i,j).y()*this->jvec(i,j) + + this->offset(i,j).z()*this->kvec(i,j) ; + this->P(i,j).x() = this->baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; + this->P(i,j).y() = this->baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; + this->P(i,j).z() = this->baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; } else - P(i,j) = offset(i,j) ; + this->P(i,j) = this->offset(i,j) ; } /*! @@ -151,24 +151,24 @@ void HNurbsSurfaceSP::modOnlySurfCPby(int i, int j, const HPoint_nD& a){ int k ; - P = offset ; + this->P = this->offset ; // by definition the offset has w = 0 , but this isn't valid for // the control points, increasing the w by 1, will generate a valid surface - if(baseLevel_) - for(k=0;kbaseLevel_) + for(k=0;kP.rows();++k) + for(int l=0;lP.cols();++l) + this->P(k,l).w() += T(1) ; int sizeU, sizeV ; - sizeU = 2*degU+3 ; - if(i-degU-1<0) sizeU += i-degU-1 ; - if(i+degU+1>=P.rows()) sizeU -= i+degU+1-P.rows() ; - - sizeV = 2*degV+3 ; - if(j-degV-1<0) sizeV += j-degV-1 ; - if(j+degV+1>=P.cols()) sizeV -= j+degV+1-P.cols() ; + sizeU = 2*this->degU+3 ; + if(i-this->degU-1<0) sizeU += i-this->degU-1 ; + if(i+this->degU+1>=this->P.rows()) sizeU -= i+this->degU+1-this->P.rows() ; + + sizeV = 2*this->degV+3 ; + if(j-this->degV-1<0) sizeV += j-this->degV-1 ; + if(j+this->degV+1>=this->P.cols()) sizeV -= j+this->degV+1-this->P.cols() ; Vector u(sizeU) ; Vector v(sizeV) ; @@ -179,16 +179,16 @@ int n=0; int nu = 0 ; int nv = 0 ; - for(k=i-degU-1;k<=i+degU+1;++k){ + for(k=i-this->degU-1;k<=i+this->degU+1;++k){ if(k<0) continue ; - if(k>=P.rows()) + if(k>=this->P.rows()) break ; nv = 0 ; - for(int l=j-degV-1;l<=j+degV+1;++l){ + for(int l=j-this->degV-1;l<=j+this->degV+1;++l){ if(l<0) continue ; - if(l>=P.cols()) + if(l>=this->P.cols()) break ; if( k == i && j==l){ pts[n].x() = a.x() ; @@ -216,12 +216,12 @@ pv.resize(n) ; if(NurbsSurface::movePoint(u,v,pts,pu,pv)){ - offset = P ; + this->offset = this->P ; // an offset shouldn't have a weight value. - if(baseLevel_) - for(k=0;kbaseLevel_) + for(k=0;kP.rows();++k) + for(int l=0;lP.cols();++l) + this->offset(k,l).w() -= T(1) ; } updateSurface(); } @@ -262,12 +262,12 @@ HNurbsSurfaceSP* HNurbsSurfaceSP::addLevel(int n, int s) { HNurbsSurfaceSP *newLevel ; - if(nextLevel_) + if(this->nextLevel_) return 0 ; Vector newU,newV ; - splitUV(n,s,n,s,newU,newV) ; + this->splitUV(n,s,n,s,newU,newV) ; newLevel = new HNurbsSurfaceSP(this,newU,newV) ; @@ -289,7 +289,7 @@ HNurbsSurfaceSP* HNurbsSurfaceSP::addLevel() { HNurbsSurfaceSP *newLevel ; - if(nextLevel_) + if(this->nextLevel_) return 0 ; newLevel = new HNurbsSurfaceSP(this) ; @@ -311,23 +311,23 @@ levelP = nS.nextLevel() ; NurbsSurface::operator=(nS) ; - rU = nS.rU ; - rV = nS.rV ; - offset = nS.offset ; + this->rU = nS.rU ; + this->rV = nS.rV ; + this->offset = nS.offset ; updateMaxUV() ; - firstLevel_ = this ; + this->firstLevel_ = this ; if(levelP){ HNurbsSurfaceSP *newLevel ; newLevel = new HNurbsSurfaceSP(this) ; newLevel->copy(*levelP) ; - nextLevel_ = newLevel ; - lastLevel_ = nextLevel_->lastLevel() ; + this->nextLevel_ = newLevel ; + this->lastLevel_ = this->nextLevel_->lastLevel() ; } else{ - lastLevel_ = this ; + this->lastLevel_ = this ; } } @@ -349,55 +349,55 @@ template void HNurbsSurfaceSP::updateSurface(int i0, int j0){ if(i0>=0 && j0>=0){ - if(offset(i0,j0).x()==0.0 && offset(i0,j0).y()==0.0 && offset(i0,j0).z()==0.0) + if(this->offset(i0,j0).x()==0.0 && this->offset(i0,j0).y()==0.0 && this->offset(i0,j0).z()==0.0) return ; } - if(baseLevel_){ - if(initBase()){ - P = baseSurf.ctrlPnts() ; - U = baseSurf.knotU() ; - V = baseSurf.knotV() ; - degU = baseSurf.degreeU() ; - degV = baseSurf.degreeV() ; + if(this->baseLevel_){ + if(this->initBase()){ + this->P = this->baseSurf.ctrlPnts() ; + this->U = this->baseSurf.knotU() ; + this->V = this->baseSurf.knotV() ; + this->degU = this->baseSurf.degreeU() ; + this->degV = this->baseSurf.degreeV() ; updateMaxUV() ; } if(i0>=0 && j0>=0){ Point_nD vecOffset ; - vecOffset = offset(i0,j0).x()*ivec(i0,j0) + - offset(i0,j0).y()*jvec(i0,j0) + - offset(i0,j0).z()*kvec(i0,j0) ; - P(i0,j0).x() = baseSurf.ctrlPnts()(i0,j0).x()+vecOffset.x() ; - P(i0,j0).y() = baseSurf.ctrlPnts()(i0,j0).y()+vecOffset.y() ; - P(i0,j0).z() = baseSurf.ctrlPnts()(i0,j0).z()+vecOffset.z() ; + vecOffset = this->offset(i0,j0).x()*this->ivec(i0,j0) + + this->offset(i0,j0).y()*this->jvec(i0,j0) + + this->offset(i0,j0).z()*this->kvec(i0,j0) ; + this->P(i0,j0).x() = this->baseSurf.ctrlPnts()(i0,j0).x()+vecOffset.x() ; + this->P(i0,j0).y() = this->baseSurf.ctrlPnts()(i0,j0).y()+vecOffset.y() ; + this->P(i0,j0).z() = this->baseSurf.ctrlPnts()(i0,j0).z()+vecOffset.z() ; } else{ - for(int i=0;iP.rows();++i) + for(int j=0;jP.cols();++j){ + if(this->offset(i,j).x() != 0 || + this->offset(i,j).y() != 0 || this->offset(i,j).z() || 0){ Point_nD vecOffset ; - vecOffset = offset(i,j).x()*ivec(i,j) + - offset(i,j).y()*jvec(i,j) + - offset(i,j).z()*kvec(i,j) ; - P(i,j).x() = baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; - P(i,j).y() = baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; - P(i,j).z() = baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; + vecOffset = this->offset(i,j).x()*this->ivec(i,j) + + this->offset(i,j).y()*this->jvec(i,j) + + this->offset(i,j).z()*this->kvec(i,j) ; + this->P(i,j).x() = this->baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; + this->P(i,j).y() = this->baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; + this->P(i,j).z() = this->baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; } } } } else{ if(i0>=0 && j0>=0) - P(i0,j0) = offset(i0,j0) ; + this->P(i0,j0) = this->offset(i0,j0) ; else{ - for(int i=0;iP.rows();++i) + for(int j=0;jP.cols();++j){ + this->P(i,j) = this->offset(i,j) ; } } } - ++updateN ; + ++(this->updateN) ; } /*! @@ -413,7 +413,7 @@ if(!okMax()) updateMaxUV() ; if(upLevel>=0){ - if(level()<=upLevel){ + if(this->level()<=upLevel){ this->updateSurface() ; } } @@ -421,9 +421,9 @@ this->updateSurface() ; } - if(upLevel>level() || upLevel<0){ - if(nextLevel_) - ((HNurbsSurfaceSP*)nextLevel_)->updateLevels(upLevel) ; + if(upLevel>this->level() || upLevel<0){ + if(this->nextLevel_) + ((HNurbsSurfaceSP*)this->nextLevel_)->updateLevels(upLevel) ; } } @@ -458,10 +458,10 @@ if(!fin.read((char*)&du,sizeof(int))) { delete []type ; return 0 ;} if(!fin.read((char*)&dv,sizeof(int))) { delete []type ; return 0 ;} - resize(nu,nv,du,dv) ; + this->resize(nu,nv,du,dv) ; - if(!fin.read((char*)U.memory(),sizeof(T)*U.n())) { delete []type ; return 0 ;} - if(!fin.read((char*)V.memory(),sizeof(T)*V.n())) { delete []type ; return 0 ;} + if(!fin.read((char*)this->U.memory(),sizeof(T)*this->U.n())) { delete []type ; return 0 ;} + if(!fin.read((char*)this->V.memory(),sizeof(T)*this->V.n())) { delete []type ; return 0 ;} if(!r1){ p = new T[3*nu*nv] ; @@ -469,10 +469,10 @@ p2 = p ; for(int i=0;iP(i,j).x() = *(p++) ; + this->P(i,j).y() = *(p++) ; + this->P(i,j).z() = *(p++) ; + this->P(i,j).w() = 1.0 ; } delete []p2 ; } @@ -482,26 +482,26 @@ p2 = p ; for(int i=0;iP(i,j).x() = *(p++) ; + this->P(i,j).y() = *(p++) ; + this->P(i,j).z() = *(p++) ; + this->P(i,j).w() = *(p++) ; } delete []p2 ; } - offset = P ; + this->offset = this->P ; this->updateSurface() ; } else { // reading the offset information int ru,rv ; if(!fin.read((char*)&ru,sizeof(int))) { delete []type ; return 0 ;} if(!fin.read((char*)&rv,sizeof(int))) { delete []type ; return 0 ;} - rU.resize(ru) ; - rV.resize(rv) ; - if(rU.n()>0) - if(!fin.read((char*)rU.memory(),sizeof(T)*rU.n())) { delete []type ; return 0 ;} - if(rV.n()>0) - if(!fin.read((char*)rV.memory(),sizeof(T)*rV.n())) { delete []type ; return 0 ;} + this->rU.resize(ru) ; + this->rV.resize(rv) ; + if(this->rU.n()>0) + if(!fin.read((char*)this->rU.memory(),sizeof(T)*this->rU.n())) { delete []type ; return 0 ;} + if(this->rV.n()>0) + if(!fin.read((char*)this->rV.memory(),sizeof(T)*this->rV.n())) { delete []type ; return 0 ;} if(!fin.read((char*)&nu,sizeof(int))) { delete []type ; return 0 ;} if(!fin.read((char*)&nv,sizeof(int))) { delete []type ; return 0 ;} @@ -509,16 +509,16 @@ p = new T[4*nu*nv] ; if(!fin.read((char*)p,sizeof(T)*4*nu*nv)) { delete []type ; return 0 ;} p2 = p ; - offset.resize(nu,nv) ; + this->offset.resize(nu,nv) ; for(int i=0;ioffset(i,j).x() = *(p++) ; + this->offset(i,j).y() = *(p++) ; + this->offset(i,j).z() = *(p++) ; + this->offset(i,j).w() = *(p++) ; } delete []p2 ; - --baseUpdateN ; + --(this->baseUpdateN) ; this->updateSurface() ; }