UCBsplineSurface.h

00001 //===========================================================================
00002 // SINTEF Multilevel B-spline Approximation library - version 1.1
00003 //
00004 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway.
00005 //
00006 // This program is free software; you can redistribute it and/or          
00007 // modify it under the terms of the GNU General Public License            
00008 // as published by the Free Software Foundation version 2 of the License. 
00009 //
00010 // This program is distributed in the hope that it will be useful,        
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00013 // GNU General Public License for more details.                           
00014 //
00015 // You should have received a copy of the GNU General Public License      
00016 // along with this program; if not, write to the Free Software            
00017 // Foundation, Inc.,                                                      
00018 // 59 Temple Place - Suite 330,                                           
00019 // Boston, MA  02111-1307, USA.                                           
00020 //
00021 // Contact information: e-mail: tor.dokken@sintef.no                      
00022 // SINTEF ICT, Department of Applied Mathematics,                         
00023 // P.O. Box 124 Blindern,                                                 
00024 // 0314 Oslo, Norway.                                                     
00025 //
00026 // Other licenses are also available for this software, notably licenses
00027 // for:
00028 // - Building commercial software.                                        
00029 // - Building software whose source code you wish to keep private.        
00030 //===========================================================================
00031 #ifndef UCB_SPLINE_SURFACE
00032 #define UCB_SPLINE_SURFACE
00033 
00034 #include <boost/shared_ptr.hpp>
00035 
00036 #include <UCBtypedef.h>
00037 #include <GenMatrix.h>
00038 
00039 
00040 namespace UCBspl {
00041   
00048   class SplineSurface {
00049     typedef GenMatrix<UCBspl_real> GenMatrixType;
00050     boost::shared_ptr<GenMatrixType> PHI_;
00051 
00052     double umin_;
00053     double vmin_;
00054     double umax_;
00055     double vmax_;
00056     // bool C2_;
00057   public:
00058     
00059 
00063     SplineSurface() {umin_=vmin_=0.0; umax_=vmax_=1.0;} // unit square
00064 
00068     SplineSurface(boost::shared_ptr<GenMatrixType> PHI,
00069                   double umin, double vmin, 
00070                   double umax, double vmax);
00071     
00073     SplineSurface(const SplineSurface& surf);
00074 
00075     ~SplineSurface(){}
00076 
00077 
00079     void init(boost::shared_ptr<GenMatrixType> PHI,
00080               double umin, double vmin, 
00081               double umax, double vmax);
00082 
00084     void getDomain(double& umin, double& vmin, double& umax, double& vmax) const
00085                   {umin = umin_; vmin = vmin_; umax = umax_; vmax = vmax_;}
00086 
00087     // Convenience
00088     double umin() const {return umin_;}
00089     double vmin() const {return vmin_;}
00090     double umax() const {return umax_;}
00091     double vmax() const {return vmax_;}
00092 
00096     double f(double u, double v) const;
00097     
00105     double f(int i, int j) const;
00106         
00110     void normalVector(double u, double v, double& gx, double& gy, double& gz) const;
00111     
00115     void normalVector(int i, int j, double& gx, double& gy, double& gz) const;
00116     
00117     
00118     // The following three functions are not properly tested and are thus
00119     // not tagged for documentation with doxygen
00120     // ------------------------------------------------------------------
00121     
00122     /* Evaluates derivatives in x- and y-direction in position (u,v).
00123     * (u,v) must be inside the domain, see getDomain.
00124     */
00125     void derivatives(double u, double v, double& dx, double& dy) const;
00126     
00127     /* Evaluates second derivatives in x- and y-direction in position (u,v).
00128     * (u,v) must be inside the domain, see getDomain.
00129     */
00130     void secondDerivatives(double u, double v, double& ddx, double& ddy, double& dxdy) const;
00131     
00132     /* Evaluates both profile- and planform curvature in position (u,v).
00133     * (u,v) must be inside the domain, see getDomain.
00134     */
00135     void curvatures(double u, double v, double& profC, double& planC) const;
00136     
00142     void eval(double u, double v, double& z, double& gx, double& gy, double& gz) const;
00143     
00147     void eval(int i, int j, double& z, double& gx, double& gy, double& gz) const;
00148     
00150     const boost::shared_ptr<GenMatrixType> getCoefficients() const {return PHI_;}
00151     
00158     void getIndexDomain(int& m, int& n) const {m = PHI_->noX()-3; n = PHI_->noY()-3;}
00159 
00166         void refineCoeffs();
00167         
00181     bool restrictCoeffs();
00182   };
00183   
00184 }; // end namespace
00185 
00186 #endif

Generated on Wed Nov 28 12:27:19 2007 for MBA by  doxygen 1.5.1