Main Page   Class Hierarchy   Compound List   File List   Compound Members  

specialVcc.h

00001 /*============================================================================
00002         File: specialVcc.h
00003      Purpose: Hides some of the hugly things we have to do to make VC++ happy
00004               when compiling.
00005     Revision: $Id: specialVcc.h,v 1.2 2002/05/13 21:07:45 philosophil Exp $
00006   author Philippe Lavoie          (3 Oct, 1996)
00007  Modified by: 
00008 
00009  Copyright notice:
00010           Copyright (C) 1996-1997 Philippe Lavoie
00011  
00012           This library is free software; you can redistribute it and/or
00013           modify it under the terms of the GNU Library General Public
00014           License as published by the Free Software Foundation; either
00015           version 2 of the License, or (at your option) any later version.
00016  
00017           This library is distributed in the hope that it will be useful,
00018           but WITHOUT ANY WARRANTY; without even the implied warranty of
00019           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020           Library General Public License for more details.
00021  
00022           You should have received a copy of the GNU Library General Public
00023           License along with this library; if not, write to the Free
00024           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025 =============================================================================*/
00026 #ifndef _Matrix_specialVcc_h_
00027 #define _Matrix_specialVcc_h_
00028 
00029 
00030 template <class T,int N> 
00031 double norm(const Point_nD<T,N>& a);
00032 
00033 
00034 template<>
00035 struct Point_nD<float,3> { 
00036   typedef float T;
00037   T data[3] ;
00038   Point_nD()  { x() = y() = z() = 0 ;}
00039   Point_nD(T a)  { x() = y() = z() = a ;}
00040   Point_nD(T X, T Y, T Z)  {x()=X ; y()=Y ; z()=Z ;}
00041   Point_nD(const Point_nD<float,3>& a)  { memcpy((void*)data,(void*)a.data,3*sizeof(T));}
00042 
00043   inline T& x() { return data[0] ; }
00044   inline T& y() { return data[1] ; }
00045   inline T& z() { return data[2] ; }
00046   inline T x() const { return data[0] ; }
00047   inline T y() const { return data[1] ; }
00048   inline T z() const { return data[2] ; }
00049 
00050   Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; z()=v.z() ;  return *this ;} ;
00051   Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; z()+=v.z() ;  return *this;} ;
00052   Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ; z()-=v.z() ;  return *this;} ;
00053   Point_nD& operator*=(T v) {x()*=v ; y()*= v ; z()*= v;  return *this;} ;
00054   Point_nD& operator/=(T v) {x()/=v ; y()/= v ; z()/= v ; return *this;} ;
00055  
00056   Point_nD unitLength() const {
00057         T d = norm(*this) ;
00058     Point_nD<T,3> u(x()/d,y()/d,z()/d) ;
00059     return u ;
00060   }
00061 };
00062 
00063 template<>
00064 struct Point_nD<double,3> { 
00065   typedef double T;
00066   T data[3] ;
00067   Point_nD()  { x() = y() = z() = 0 ;}
00068   Point_nD(T a)  { x() = y() = z() = a ;}
00069   Point_nD(T X, T Y, T Z)  {x()=X ; y()=Y ; z()=Z ;}
00070   Point_nD(const Point_nD<float,3>& a)  { memcpy((void*)data,(void*)a.data,3*sizeof(T));}
00071 
00072   inline T& x() { return data[0] ; }
00073   inline T& y() { return data[1] ; }
00074   inline T& z() { return data[2] ; }
00075   inline T x() const { return data[0] ; }
00076   inline T y() const { return data[1] ; }
00077   inline T z() const { return data[2] ; }
00078 
00079   Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; z()=v.z() ;  return *this ;} ;
00080   Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; z()+=v.z() ;  return *this;} ;
00081   Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ; z()-=v.z() ;  return *this;} ;
00082   Point_nD& operator*=(T v) {x()*=v ; y()*= v ; z()*= v;  return *this;} ;
00083   Point_nD& operator/=(T v) {x()/=v ; y()/= v ; z()/= v ; return *this;} ;
00084  
00085   Point_nD unitLength() const {
00086         T d = norm(*this) ;
00087     Point_nD<T,3> u(x()/d,y()/d,z()/d) ;
00088     return u ;
00089   }
00090 };
00091 
00092 
00093 template<>
00094 struct Point_nD<float,2> { 
00095   typedef float T;
00096   T data[2] ;
00097   Point_nD()  { x() = y() = 0 ;}
00098   Point_nD(T a)  { x() = y() = a ;}
00099   Point_nD(T X, T Y)  {x()=X ; y()=Y ; }
00100   Point_nD(const Point_nD<T,2>& a)  { memcpy((void*)data,(void*)a.data,2*sizeof(T));}
00101 
00102   inline T& x() { return data[0] ; }
00103   inline T& y() { return data[1] ; }
00104   inline T& z() { return dumbVar ; }
00105   inline T x() const { return data[0] ; }
00106   inline T y() const { return data[1] ; }
00107   inline T z() const { return T() ; }
00108  
00109   Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; return *this ;} ;
00110   Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; return *this;} ;
00111   Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ;   return *this;} ;
00112   Point_nD& operator*=(T v) {x()*=v ; y()*= v ; return *this;} ;
00113   Point_nD& operator/=(T v) {x()/=v ; y()/= v ; return *this;} ;
00114  
00115   Point_nD unitLength() const {
00116           T d = norm(*this) ;
00117     Point_nD<T,2> u(x()/d,y()/d) ;
00118     return u ;
00119   }
00120 
00121 protected:
00122   static T dumbVar ; 
00123 };
00124 
00125 template<>
00126 struct Point_nD<double,2> { 
00127   typedef double T;
00128   T data[2] ;
00129   Point_nD()  { x() = y() = 0 ;}
00130   Point_nD(T a)  { x() = y() = a ;}
00131   Point_nD(T X, T Y)  {x()=X ; y()=Y ; }
00132   Point_nD(const Point_nD<T,2>& a)  { memcpy((void*)data,(void*)a.data,2*sizeof(T));}
00133 
00134   inline T& x() { return data[0] ; }
00135   inline T& y() { return data[1] ; }
00136   inline T& z() { return dumbVar ; }
00137   inline T x() const { return data[0] ; }
00138   inline T y() const { return data[1] ; }
00139   inline T z() const { return T() ; }
00140  
00141   Point_nD& operator=(const Point_nD& v) { x()=v.x() ; y()=v.y() ; return *this ;} ;
00142   Point_nD& operator+=(const Point_nD& v) {x()+=v.x() ; y()+= v.y() ; return *this;} ;
00143   Point_nD& operator-=(const Point_nD& v) {x()-=v.x() ; y()-= v.y() ;   return *this;} ;
00144   Point_nD& operator*=(T v) {x()*=v ; y()*= v ; return *this;} ;
00145   Point_nD& operator/=(T v) {x()/=v ; y()/= v ; return *this;} ;
00146  
00147   Point_nD unitLength() const {
00148           T d = norm(*this) ;
00149     Point_nD<T,2> u(x()/d,y()/d) ;
00150     return u ;
00151   }
00152 
00153 protected:
00154   static T dumbVar ; 
00155 };
00156 
00157 
00158 template<>
00159 struct HPoint_nD<float,3> {
00160   typedef float T;
00161   T *data ; 
00162   int created; // usefull to change the data pointer
00163 
00164   HPoint_nD(): data(new T[4]), created(1) { x() = y() = z() = w() = T(); }
00165   HPoint_nD(T *d,int c): data(d), created(c) { ; } 
00166   HPoint_nD(T a): data(new T[4]), created(1) { x() = y() = z() = w() = a; }
00167   HPoint_nD(T X, T Y, T Z, T W):  data(new T[4]), created(1) { x()=X ; y()=Y; z()=Z; w()=W;}
00168   HPoint_nD(const HPoint_nD& a): data(new T[4]), created(1) { memcpy((void*)data,(void*)a.data,4*sizeof(T)); }
00169   HPoint_nD(const Point_nD<T,3>& a): data(new T[4]), created(1) { memcpy((void*)data,(void*)a.data,(3)*sizeof(T));  data[3] = T(1); }
00170   ~HPoint_nD() { if(created) if(data) delete []data ; }
00171 
00172   inline T& x() { return data[0] ;}
00173   inline T x() const { return data[0] ; }
00174   inline T& y() { return data[1] ;}
00175   inline T y() const { return data[1] ;}
00176   inline T& z() { return data[2] ;}
00177   inline T z() const { return data[2] ;}
00178   inline T& w() { return data[3] ;}
00179   inline T w() const { return data[3] ;}
00180   
00181   HPoint_nD<T,3>& operator=(const HPoint_nD<T,3>& v) {
00182     data[0] = v.data[0] ; 
00183     data[1] = v.data[1] ;
00184     data[2] = v.data[2] ;
00185     data[3] = v.data[3] ; 
00186     return *this ;
00187   }
00188   HPoint_nD<T,3>& operator=(const Point_nD<T,3>& v) {x()=v.x() ; y()=v.y() ; z()=v.z() ; w()=1.0 ; return *this;}
00189   HPoint_nD<T,3>& operator=(const T v) { x() = y() = z() = w() = v ; return *this ;} ;
00190   HPoint_nD<T,3>& operator+=(const HPoint_nD<T,3>& v) {
00191     data[0] += v.data[0] ; 
00192     data[1] += v.data[1] ;
00193     data[2] += v.data[2] ;
00194     data[3] += v.data[3] ; 
00195     return *this ;
00196   }
00197   HPoint_nD<T,3>& operator-=(const HPoint_nD<T,3>& v) {
00198     data[0] -= v.data[0] ; 
00199     data[1] -= v.data[1] ;
00200     data[2] -= v.data[2] ;
00201     data[3] -= v.data[3] ; 
00202     return *this ;
00203   }
00204 
00205   HPoint_nD<T,3>& operator*=(T v) {
00206     data[0] *= v ; 
00207     data[1] *= v ;
00208     data[2] *= v ;
00209     data[3] *= v ; 
00210     return *this ;
00211   }
00212   HPoint_nD<T,3>& operator/=(T v)  {
00213     data[0] /= v ; 
00214     data[1] /= v ;
00215     data[2] /= v ;
00216     data[3] /= v ; 
00217     return *this ;
00218   }
00219 
00220 
00221   void move(const Point_nD<T,3>& m) ;
00222 
00223   Point_nD<T,3> projectW() { return Point_nD<T,3>(x(),y(),z()) ; }
00224 };
00225 
00226 //template <class T>
00227 template<>
00228 struct HPoint_nD<double,3> {
00229   typedef double T;
00230   T *data ; 
00231   int created; // usefull to change the data pointer
00232 
00233   HPoint_nD(): data(new T[4]), created(1) { x() = y() = z() = w() = T(); }
00234   HPoint_nD(T *d,int c): data(d), created(c) { ; } 
00235   HPoint_nD(T a): data(new T[4]), created(1) { x() = y() = z() = w() = a; }
00236   HPoint_nD(T X, T Y, T Z, T W):  data(new T[4]), created(1) { x()=X ; y()=Y; z()=Z; w()=W;}
00237   HPoint_nD(const HPoint_nD& a): data(new T[4]), created(1) { memcpy((void*)data,(void*)a.data,4*sizeof(T)); }
00238   HPoint_nD(const Point_nD<T,3>& a): data(new T[4]), created(1) { memcpy((void*)data,(void*)a.data,(3)*sizeof(T));  data[3] = T(1); }
00239   ~HPoint_nD() { if(created) if(data) delete []data ; }
00240 
00241   inline T& x() { return data[0] ;}
00242   inline T x() const { return data[0] ; }
00243   inline T& y() { return data[1] ;}
00244   inline T y() const { return data[1] ;}
00245   inline T& z() { return data[2] ;}
00246   inline T z() const { return data[2] ;}
00247   inline T& w() { return data[3] ;}
00248   inline T w() const { return data[3] ;}
00249   
00250   HPoint_nD<T,3>& operator=(const HPoint_nD<T,3>& v) {
00251     data[0] = v.data[0] ; 
00252     data[1] = v.data[1] ;
00253     data[2] = v.data[2] ;
00254     data[3] = v.data[3] ; 
00255     return *this ;
00256   }
00257 
00258   HPoint_nD<T,3>& operator=(const Point_nD<T,3>& v) {x()=v.x() ; y()=v.y() ; z()=v.z() ; w()=1.0 ; return *this;}
00259   HPoint_nD<T,3>& operator=(const T v) { x() = y() = z() = w() = v ; return *this ;} ;
00260   HPoint_nD<T,3>& operator+=(const HPoint_nD<T,3>& v) {
00261     data[0] += v.data[0] ; 
00262     data[1] += v.data[1] ;
00263     data[2] += v.data[2] ;
00264     data[3] += v.data[3] ; 
00265     return *this ;
00266   }
00267 
00268   HPoint_nD<T,3>& operator-=(const HPoint_nD<T,3>& v) {
00269     data[0] -= v.data[0] ; 
00270     data[1] -= v.data[1] ;
00271     data[2] -= v.data[2] ;
00272     data[3] -= v.data[3] ; 
00273     return *this ;
00274   }
00275   HPoint_nD<T,3>& operator*=(T v) {
00276     data[0] *= v ; 
00277     data[1] *= v ;
00278     data[2] *= v ;
00279     data[3] *= v ; 
00280     return *this ;
00281   }
00282 
00283   HPoint_nD<T,3>& operator/=(T v)  {
00284     data[0] /= v ; 
00285     data[1] /= v ;
00286     data[2] /= v ;
00287     data[3] /= v ; 
00288     return *this ;
00289   }
00290 
00291 
00292   void move(const Point_nD<T,3>& m) ;
00293 
00294   Point_nD<T,3> projectW() { return Point_nD<T,3>(x(),y(),z()) ; }
00295 };
00296 
00297 template<>
00298 struct HPoint_nD<float,2> {
00299   typedef float T;
00300   T *data ; 
00301   int created; // usefull to change the data pointer
00302 
00303   HPoint_nD(): data(new T[3]), created(1) { x() = y() = w() = T(); }
00304   HPoint_nD(T *d,int c): data(d), created(c) { ; } 
00305   HPoint_nD(T a): data(new T[3]), created(1) { x() = y() = w() = a; }
00306   HPoint_nD(T X, T Y, T W):  data(new T[3]), created(1) { x()=X ; y()=Y; w()=W;}
00307   HPoint_nD(T X, T Y, T Z, T W):  data(new T[3]), created(1) { x()=X ; y()=Y; w()=W;}
00308   HPoint_nD(const HPoint_nD& a): data(new T[3]), created(1) { memcpy((void*)data,(void*)a.data,3*sizeof(T)); }
00309   HPoint_nD(const Point_nD<T,2>& a): data(new T[3]), created(1) { memcpy((void*)data,(void*)a.data,(2)*sizeof(T));  data[2] = T(1); }
00310   ~HPoint_nD() { if(created) if(data) delete []data ; }
00311 
00312   inline T& x() { return data[0] ;}
00313   inline T x() const { return data[0] ; }
00314   inline T& y() { return data[1] ;}
00315   inline T y() const { return data[1] ;}
00316   inline T& z() { return  dumbVar;}
00317   inline T z() const { return T(0) ;}
00318   inline T& w() { return data[2] ;}
00319   inline T w() const { return data[2] ;}
00320   
00321 
00322   HPoint_nD<T,2>& operator=(const HPoint_nD<T,2>& v) {
00323     data[0] = v.data[0] ; 
00324     data[1] = v.data[1] ;
00325     data[2] = v.data[2] ;
00326     return *this ;
00327   }
00328 
00329   HPoint_nD<T,2>& operator=(const Point_nD<T,2>& v) {x()=v.x() ; y()=v.y() ; w()=1.0 ; return *this;}
00330   HPoint_nD<T,2>& operator=(const T v) { x() = y() = w() = v ; return *this ;} ;
00331 
00332   HPoint_nD<T,2>& operator*=(T v) {
00333     data[0] *= v ; 
00334     data[1] *= v ;
00335     data[2] *= v ;
00336     return *this ;
00337   }
00338 
00339   HPoint_nD<T,2>& operator/=(T v)  {
00340   data[0] /= v ; 
00341   data[1] /= v ;
00342   data[2] /= v ;
00343   return *this ;
00344 }
00345 
00346   HPoint_nD<T,2>& operator-=(const HPoint_nD<T,2>& v) {
00347     data[0] -= v.data[0] ; 
00348     data[1] -= v.data[1] ;
00349     data[2] -= v.data[2] ;
00350     return *this ;
00351   }
00352 
00353   HPoint_nD<T,2>& operator+=(const HPoint_nD<T,2>& v) ; 
00354 
00355   void move(const Point_nD<T,2>& m) ;
00356   Point_nD<T,2> projectW() { return Point_nD<T,2>(x(),y()) ; }
00357 
00358 protected:
00359   static T dumbVar ;
00360 };
00361 
00362 template<>
00363 struct HPoint_nD<double,2> {
00364   typedef double T;
00365   T *data ; 
00366   int created; // usefull to change the data pointer
00367 
00368   HPoint_nD(): data(new T[3]), created(1) { x() = y() = w() = T(); }
00369   HPoint_nD(T *d,int c): data(d), created(c) { ; } 
00370   HPoint_nD(T a): data(new T[3]), created(1) { x() = y() = w() = a; }
00371   HPoint_nD(T X, T Y, T W):  data(new T[3]), created(1) { x()=X ; y()=Y; w()=W;}
00372   HPoint_nD(T X, T Y, T Z, T W):  data(new T[3]), created(1) { x()=X ; y()=Y; w()=W;}
00373   HPoint_nD(const HPoint_nD& a): data(new T[3]), created(1) { memcpy((void*)data,(void*)a.data,3*sizeof(T)); }
00374   HPoint_nD(const Point_nD<T,2>& a): data(new T[3]), created(1) { memcpy((void*)data,(void*)a.data,(2)*sizeof(T));  data[2] = T(1); }
00375   ~HPoint_nD() { if(created) if(data) delete []data ; }
00376 
00377   inline T& x() { return data[0] ;}
00378   inline T x() const { return data[0] ; }
00379   inline T& y() { return data[1] ;}
00380   inline T y() const { return data[1] ;}
00381   inline T& z() { return  dumbVar;}
00382   inline T z() const { return T(0) ;}
00383   inline T& w() { return data[2] ;}
00384   inline T w() const { return data[2] ;}
00385   
00386 
00387   HPoint_nD<T,2>& operator=(const HPoint_nD<T,2>& v) {
00388     data[0] = v.data[0] ; 
00389     data[1] = v.data[1] ;
00390     data[2] = v.data[2] ;
00391     return *this ;
00392   }
00393 
00394 
00395   HPoint_nD<T,2>& operator=(const Point_nD<T,2>& v) {x()=v.x() ; y()=v.y() ; w()=1.0 ; return *this;}
00396   HPoint_nD<T,2>& operator=(const T v) { x() = y() = w() = v ; return *this ;} ;
00397 
00398   HPoint_nD<T,2>& operator*=(T v) {
00399     data[0] *= v ; 
00400     data[1] *= v ;
00401     data[2] *= v ;
00402     return *this ;
00403   }
00404 
00405   HPoint_nD<T,2>& operator/=(T v)  {
00406     data[0] /= v ; 
00407     data[1] /= v ;
00408     data[2] /= v ;
00409     return *this ;
00410   }
00411  
00412   HPoint_nD<T,2>& operator-=(const HPoint_nD<T,2>& v) {
00413     data[0] -= v.data[0] ; 
00414     data[1] -= v.data[1] ;
00415     data[2] -= v.data[2] ;
00416     return *this ;
00417   }
00418   HPoint_nD<T,2>& operator+=(const HPoint_nD<T,2>& v) ; 
00419 
00420   void move(const Point_nD<T,2>& m) ;
00421   Point_nD<T,2> projectW() { return Point_nD<T,2>(x(),y()) ; }
00422 
00423 protected:
00424   static T dumbVar ;
00425 };
00426 
00427 
00428 
00429 #endif

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