00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef PLIB_NURBS_NURBS_SP_SOURCE
00027 #define PLIB_NURBS_NURBS_SP_SOURCE
00028 
00029 
00030 
00031 #include <nurbs_sp.h>
00032 
00035 namespace PLib {
00036 
00048 template <class T, int N>
00049 void NurbsCurveSP<T,N>::updateMaxU() {
00050   if(deg_>3){
00051 #ifdef USE_EXCEPTION
00052     throw NurbsInputError();
00053 #else
00054     Error error("NurbsCurveSP") ; 
00055     error << "This class can't handle a curve of degree 4 or higher.\n" ;
00056     error.fatal() ;
00057 #endif
00058   }
00059   else{
00060     maxU.resize(P.n()) ;
00061     maxAt_.resize(P.n()) ;
00062     for(int i=0;i<P.n();++i){
00063       if(!maxInfluence(i,U,deg_,maxAt_[i]))
00064         cerr << "Problem in maxInfluence U!\n" ;
00065       if(i>0)
00066         if(maxAt_[i]<maxAt_[i-1]){
00067 #ifdef USE_EXCEPTION
00068           throw NurbsError();
00069 #else
00070           Error error("Error updating maxU");
00071           error << "HUGE ERROR!\n" ;
00072           error << "Knot = " << U << endl ;
00073           error << " i = " << i << endl ;
00074           error << " deg = " << deg_ << endl ;
00075           error.fatal() ; 
00076 #endif
00077         }
00078       maxU[i] = basisFun(maxAt_[i],i,deg_) ;
00079     }
00080     
00081   }
00082 }
00083 
00103 template <class T, int N>
00104 void NurbsCurveSP<T,N>::modOnlySurfCPby(int i, const HPoint_nD<T,N>& a){
00105   Vector<T> u(2*deg_+3) ;
00106   Vector< Point_nD<T,N> > pts(2*deg_+3) ; 
00107 
00108   int n=0;
00109   for(int j=i-deg_-1;j<=i+deg_+1;++j){
00110     if(j<0)
00111       continue ;
00112     if(j>=P.n())
00113       break ; 
00114     u[n] = maxAt_[j] ;
00115     if( j == i){
00116       pts[n].x() = a.x() ; 
00117       pts[n].y() = a.y() ; 
00118       pts[n].z() = a.z() ; 
00119     }
00120     
00121     
00122     ++n ;
00123   }  
00124 
00125   u.resize(n) ;
00126   pts.resize(n) ; 
00127 
00128   movePoint(u,pts) ;
00129 }
00130 
00131 } 
00132 
00133 
00134 #endif // #define PLIB_NURBS_NURBS_SP_SOURCE
00135 
00136