Main Page   Class Hierarchy   Compound List   File List   Compound Members  

hnurbsS.h

00001 /*=============================================================================
00002         File: hnurbsS.h
00003      Purpose:       
00004     Revision: $Id: hnurbsS.h,v 1.3 2003/01/13 19:41:31 philosophil Exp $
00005   Created by: Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1998 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_hnurbsS_h_
00026 #define _nurbs_hnurbsS_h_
00027 
00028 #include "nurbs.h"
00029 #include "nurbsS.h"
00030 #include "vector.h"
00031 
00034 namespace PLib {
00035 
00059 template <class T, int N>
00060 class HNurbsSurface: public NurbsSurface<T,N> {
00061 public:
00062   HNurbsSurface() ; 
00063   HNurbsSurface(const NurbsSurface<T,N>& S) ; 
00064   HNurbsSurface(const HNurbsSurface<T,N>& S) ;
00065   HNurbsSurface(HNurbsSurface<T,N>* base) ;
00066   HNurbsSurface(HNurbsSurface<T,N>* base, const Vector<T>& xU, const Vector<T>& xV) ;
00067   HNurbsSurface(HNurbsSurface<T,N>* base, const HNurbsSurface<T,N> &surf) ;
00068   virtual ~HNurbsSurface() ;
00069 
00070   HNurbsSurface<T,N>* baseLevel() const { return baseLevel_;}
00071   HNurbsSurface<T,N>* nextLevel() const { return nextLevel_;}
00072   HNurbsSurface<T,N>* firstLevel() const { return firstLevel_;}
00073   HNurbsSurface<T,N>* lastLevel() const { return lastLevel_; }
00074 
00075   void splitUV(int nu, int nv, Vector<T> &nU, Vector<T> &nV) ;
00076   void splitUV(int nu, int su, int nv, int sv, Vector<T> &nU, Vector<T> &nV) ;
00077   
00078   virtual HNurbsSurface<T,N>* addLevel(int nsplit) ;
00079   virtual HNurbsSurface<T,N>* addLevel() ;
00080 
00081   virtual void copy(const HNurbsSurface<T,N>& nS) ;
00082 
00083   int modifies(T u, T v) ;
00084 
00085   
00086   HPoint_nD<T,N> operator()(T u, T v) const { return hpointAt(u,v,-1) ; }
00087   HPoint_nD<T,N> hpointAt(T u, T v, int lod=-1) const ;
00088 
00089   void deriveAtH(T u, T v, int, Matrix< HPoint_nD<T,N> >&, int lod=-1) const;
00090   void deriveAt(T u, T v, int, Matrix< Point_nD<T,N> >&, int lod=-1) const;
00091 
00092   int movePointOffset(T u, T v, const Point_nD<T,N>& delta) ; 
00093 
00094   void scale(const Point_nD<T,N>& s) ; 
00095 
00096 
00097   int initBase(int force=0) ;
00098   virtual void updateSurface(int i0=-1, int j0=-1) ;
00099   virtual void updateLevels(int updateLevel=-1) ;
00100 
00101   int isoCurveU(T u, NurbsCurve<T,N>& c,int lod=-1) const ;
00102   int isoCurveV(T v, NurbsCurve<T,N>& c,int lod=-1) const ;
00103 
00104   // I/O functions
00105   int read(const char* filename);
00106   int write(const char* filename) const;
00107   virtual int read(ifstream &fin) ;
00108   int write(ofstream &fout) const ;
00109 
00110   Matrix< HPoint_nD<T,N> > offset ;
00111   Vector<T> rU,rV ;
00112 
00113   int level() const { return level_ ;}
00114 
00115   int maxLevel() const ;
00116 
00117   int modifiedN() const { return updateN ; }
00118 
00119   void refineKnots(const Vector<T>& nU, const Vector<T>& nV) ;
00120   void refineKnotU(const Vector<T>& X) ;
00121   void refineKnotV(const Vector<T>& X) ;
00122 
00123 
00124   void axis(int i, int j, Point_nD<T,N>& xaxis, Point_nD<T,N>& yaxis, Point_nD<T,N>& zaxis)const;
00125 
00126   void setFixedOffsetVector(const Point_nD<T,N> &I, const Point_nD<T,N> &J, const Point_nD<T,N>& K);
00127   void setVariableOffsetVector();
00128 
00129 protected:
00130   NurbsSurface<T,N> baseSurf ;
00131   HNurbsSurface<T,N> *baseLevel_,*nextLevel_,*firstLevel_,*lastLevel_ ;
00132 
00133   Matrix< Point_nD<T,N> > ivec,jvec,kvec ;
00134 
00135   int level_ ;
00136   int updateN,baseUpdateN ;
00137   int update_ ; // indicates that one of the offset point was modified
00138 
00139   T uS_,uE_,vS_,vE_ ;
00140   T uD,vD ; 
00141   int fixedOffset;
00142 };
00143 
00144 template <class T, int N>
00145 inline void 
00146 HNurbsSurface<T,N>::axis(int i, int j, Point_nD<T,N>& xaxis, Point_nD<T,N>& yaxis, Point_nD<T,N>& zaxis) const 
00147 { 
00148   if(baseLevel_) { 
00149     xaxis = ivec(i,j) ; 
00150     yaxis = jvec(i,j) ; 
00151     zaxis = kvec(i,j) ; 
00152   } 
00153   else{
00154     xaxis = Point_nD<T,N>(T(1),T(0),T(0)) ; 
00155     yaxis = Point_nD<T,N>(T(0),T(1),T(0)) ; 
00156     zaxis = Point_nD<T,N>(T(0),T(0),T(1)) ; 
00157   }
00158 }
00159 
00160 typedef HNurbsSurface<float,3> HNurbsSurfacef ;
00161 typedef HNurbsSurface<double,3> HNurbsSurfaced ;
00162 
00163 } // end namespace
00164 
00165 typedef PLib::HNurbsSurface<float,3> PlHNurbsSurfacef ;
00166 typedef PLib::HNurbsSurface<double,3> PlHNurbsSurfaced ;
00167 
00168 
00169 #endif // _nurbs_hnurbsS_h_

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