Main Page   Class Hierarchy   Compound List   File List   Compound Members  

nurbsS_sp.h

00001 /*=============================================================================
00002         File: nurbsS_sp.h
00003      Purpose:       
00004     Revision: $Id: nurbsS_sp.h,v 1.3 2003/01/13 19:42:05 philosophil Exp $
00005   Created by: Philippe Lavoie          (8 May, 1998)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1997 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 #ifndef _nurbs_nurbsS_sp_h_
00026 #define _nurbs_nurbsS_sp_h_
00027 
00028 #include "nurbs.h"
00029 #include "nurbsS.h"
00030 
00033 namespace PLib {
00034 
00048 template <class T, int N>
00049 class NurbsSurfaceSP : public NurbsSurface<T,N>{
00050 public:
00051   NurbsSurfaceSP(); 
00052   NurbsSurfaceSP(const NurbsSurface<T,N>& nS); 
00053   NurbsSurfaceSP(const NurbsSurfaceSP<T,N>& nS); 
00054   NurbsSurfaceSP(int DegU, int DegV, const Vector<T>& Uk, const Vector<T>& Vk, const Matrix< HPoint_nD<T,N> >& Cp);  
00055   NurbsSurfaceSP(int DegU, int DegV, Vector<T>& Uk, Vector<T>& Vk, Matrix< Point_nD<T,N> >& Cp, Matrix<T>& W)  ; 
00056 
00057 
00058   virtual NurbsSurface<T,N>& operator=(const NurbsSurface<T,N>& a) ;
00059   virtual NurbsSurfaceSP<T,N>& operator=(const NurbsSurfaceSP<T,N>& a) ;
00060   
00061   virtual void resizeKeep(int Pu, int Pv, int DegU, int DegV) ;
00062   
00063 
00064   virtual void refineKnots(const Vector<T>& nU, const Vector<T>& nV) ;
00065   virtual void refineKnotU(const Vector<T>& X);
00066   virtual void refineKnotV(const Vector<T>& X);
00067   
00068   virtual void mergeKnots(const Vector<T>& nU, const Vector<T>& nV) ;
00069   virtual void mergeKnotU(const Vector<T>& X);
00070   virtual void mergeKnotV(const Vector<T>& X);
00071 
00072   virtual int read(ifstream &fin);
00073 
00074   
00075   virtual void degreeElevateU(int tU);
00076   virtual void degreeElevateV(int tV);
00077 
00078   NurbsSurfaceSP<T,N> generateParallel(T d) const ; 
00079 
00080 
00081   void modSurfCPby(int i, int j, const HPoint_nD<T,N>& a) 
00082     { P(i,j) +=  a / (maxU[i]*maxV[j]) ;  }
00083   void modSurfCP(int i, int j, const HPoint_nD<T,N>& a) 
00084     { modSurfCPby(i,j,a-surfP(i,j)) ;  }
00085 
00086   void modOnlySurfCPby(int i, int j, const HPoint_nD<T,N>& a) ;
00087   void modOnlySurfCP(int i, int j, const HPoint_nD<T,N>& a) 
00088     { modOnlySurfCPby(i,j,a-surfP(i,j)) ;  }
00089 
00090   T maxAtUV(int i, int j) const 
00091     { return maxAtU_[i]*maxAtV_[j] ; }
00092   T maxAtU(int i) const 
00093     { return maxAtU_[i] ; }
00094   T maxAtV(int i) const 
00095     { return maxAtV_[i] ; }
00096 
00097   HPoint_nD<T,N> surfP(int i,int j) const  
00098     { return hpointAt(maxAtU_[i],maxAtV_[j]); }
00099 
00100   void updateMaxUV() 
00101     { updateMaxU() ; updateMaxV() ; }
00102   void updateMaxU() ;
00103   void updateMaxV() ;
00104 
00105   int okMax() 
00106     { return (maxU.n()<=1)?0:1 ; }
00107 
00108 protected:
00109 
00110   Vector<T> maxU ; 
00111   Vector<T> maxV ; 
00112   Vector<T> maxAtU_ ; 
00113   Vector<T> maxAtV_ ; 
00114 };
00115 
00116 
00126 template <class T, int N>
00127 inline NurbsSurfaceSP<T,N>::NurbsSurfaceSP() : NurbsSurface<T,N>() { 
00128   ;
00129 }
00130 
00140 template <class T, int N>
00141 inline NurbsSurfaceSP<T,N>::NurbsSurfaceSP(const NurbsSurface<T,N>& nS)  : NurbsSurface<T,N>(nS) { 
00142   updateMaxUV() ; 
00143 }
00144 
00154 template <class T, int N>
00155 inline NurbsSurfaceSP<T,N>::NurbsSurfaceSP(const NurbsSurfaceSP<T,N>& nS)  : NurbsSurface<T,N>(nS) { 
00156   maxU = nS.maxU ; 
00157   maxV = nS.maxV ; 
00158   maxAtU_ = nS.maxAtU_ ; 
00159   maxAtV_ = nS.maxAtV_ ; 
00160 }
00161 
00175 template <class T, int N>
00176 inline NurbsSurfaceSP<T,N>::NurbsSurfaceSP(int DegU, int DegV, const Vector<T>& Uk, const Vector<T>& Vk, const Matrix< HPoint_nD<T,N> >& Cp)  : NurbsSurface<T,N>(DegU,DegV,Uk,Vk,Cp) { 
00177   updateMaxUV() ; 
00178 }
00179 
00194 template <class T, int N>
00195 inline NurbsSurfaceSP<T,N>::NurbsSurfaceSP(int DegU, int DegV, Vector<T>& Uk, Vector<T>& Vk, Matrix< Point_nD<T,N> >& Cp, Matrix<T>& W)  : NurbsSurface<T,N>(DegU,DegV,Uk,Vk,Cp,W) { 
00196   updateMaxUV() ; 
00197 }
00198 
00208 template <class T, int N>
00209 inline NurbsSurface<T,N>& 
00210 NurbsSurfaceSP<T,N>::operator=(const NurbsSurface<T,N>& a) { 
00211   NurbsSurface<T,N>::operator=(a) ; 
00212   updateMaxUV() ; 
00213   return *this ; 
00214 }
00215 
00224 template <class T, int N>
00225 inline  NurbsSurfaceSP<T,N>& 
00226 NurbsSurfaceSP<T,N>::operator=(const NurbsSurfaceSP<T,N>& a) { 
00227   NurbsSurface<T,N>::operator=(a) ;  
00228   maxU = a.maxU ; 
00229   maxV = a.maxV ; 
00230   maxAtU_ = a.maxAtU_ ; 
00231   maxAtV_ = a.maxAtV_ ;  
00232   return *this ; 
00233 }
00234 
00247 template <class T, int N>
00248 inline void 
00249 NurbsSurfaceSP<T,N>::resizeKeep(int Pu, int Pv, int DegU, int DegV) { 
00250   NurbsSurface<T,N>::resizeKeep(Pu,Pv,DegU,DegV) ; 
00251   updateMaxUV() ; 
00252 }
00253 
00264 template <class T, int N>
00265 inline void 
00266 NurbsSurfaceSP<T,N>::refineKnots(const Vector<T>& nU, const Vector<T>& nV) {
00267   NurbsSurface<T,N>::refineKnots(nU,nV) ;
00268   updateMaxUV() ;
00269 }
00270   
00280 template <class T, int N>
00281 inline void 
00282 NurbsSurfaceSP<T,N>::refineKnotU(const Vector<T>& X){
00283   NurbsSurface<T,N>::refineKnotU(X) ;
00284   updateMaxU() ;
00285 }
00286 
00296 template <class T, int N>
00297 inline void 
00298 NurbsSurfaceSP<T,N>::refineKnotV(const Vector<T>& X){
00299   NurbsSurface<T,N>::refineKnotV(X) ;
00300   updateMaxV() ;
00301 }
00302 
00303   
00304 /*
00305   \fn virtual void NurbsSurfaceSP<T,N>::mergeKnots(const Vector<T>& nU, const Vector<T>& nV)
00306   \brief Merge a knot vector in the U and V direction
00307   
00308   \param nU  the knot to merge with in the U direction
00309   \param nV  the knot to merge with in the V direction
00310 
00311   \author Philippe Lavoie
00312 */
00313 template <class T, int N>
00314 inline void 
00315 NurbsSurfaceSP<T,N>::mergeKnots(const Vector<T>& nU, const Vector<T>& nV) {
00316   NurbsSurface<T,N>::mergeKnots(nU,nV) ;
00317   updateMaxUV() ;
00318 }
00319 
00320 
00321 /*
00322   \fn virtual void NurbsSurfaceSP<T,N>::mergeKnotU(const Vector<T>& X)
00323   \brief Merge a knot vector in the U direction
00324   
00325   \param X  the knot to merge with
00326 
00327   \author Philippe Lavoie
00328 */
00329 template <class T, int N>
00330 inline void 
00331 NurbsSurfaceSP<T,N>::mergeKnotU(const Vector<T>& X){
00332   NurbsSurface<T,N>::mergeKnotU(X) ;
00333   updateMaxU() ;
00334 }
00335 
00336 
00337 /*
00338   \fn virtual void NurbsSurfaceSP<T,N>::mergeKnotV(const Vector<T>& X)
00339   \brief Merge a knot vector in the V direction
00340   
00341   \param X  the knot to merge with
00342 
00343   \author Philippe Lavoie
00344 */
00345 template <class T, int N>
00346 inline void 
00347 NurbsSurfaceSP<T,N>::mergeKnotV(const Vector<T>& X){
00348   NurbsSurface<T,N>::mergeKnotV(X) ;
00349   updateMaxV() ;
00350 }
00351 
00352 /*
00353   \fn virtual int NurbsSurfaceSP<T,N>::read(ifstream &fin)
00354   \brief Reads an input file stream
00355   
00356   \param fin the input file stream
00357 
00358   \author Philippe Lavoie
00359 */
00360 template <class T, int N>
00361 inline int NurbsSurfaceSP<T,N>::read(ifstream &fin) {
00362   int r = NurbsSurface<T,N>::read(fin) ;
00363   updateMaxUV() ; 
00364   return r ; 
00365 }
00366 
00367 /*
00368   \fn virtual void NurbsSurfaceSP<T,N>::degreeElevateU(int tU)
00369   \brief Degree Elevate in the U direction
00370   
00371   \param tU the number of degree to elevate the surface by
00372 
00373   \author Philippe Lavoie
00374 */
00375 template <class T, int N>
00376 inline void NurbsSurfaceSP<T,N>::degreeElevateU(int tU) {
00377   NurbsSurface<T,N>::degreeElevateU(tU);
00378   updateMaxU();
00379 }
00380 
00381 /*
00382   \fn virtual void NurbsSurfaceSP<T,N>::degreeElevateV(int tV) 
00383   \brief Degree Elevate in the V direction
00384   
00385   \param tV the number of degree to elevate the surface by
00386 
00387   \author Philippe Lavoie
00388 */
00389 template <class T, int N>
00390 inline void NurbsSurfaceSP<T,N>::degreeElevateV(int tV) {
00391   NurbsSurface<T,N>::degreeElevateV(tV);
00392   updateMaxV();
00393 }
00394 
00395 typedef NurbsSurfaceSP<float,3> NurbsSurfaceSPf ;
00396 typedef NurbsSurfaceSP<double,3> NurbsSurfaceSPd ;
00397 
00398 } // end namespace
00399 
00400 typedef PLib::NurbsSurfaceSP<float,3> PlNurbsSurfaceSPf ;
00401 typedef PLib::NurbsSurfaceSP<double,3> PlNurbsSurfaceSPd ;
00402 
00403 
00404 #endif

Generated on Tue Jun 24 13:26:58 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002