MBAdata.h

00001 //===========================================================================
00002 // SINTEF LSMG 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 _MBADATA_H_
00032 #define _MBADATA_H_
00033 
00034 #include <MBAtypedef.h>
00035 #include <vector>
00036 #include <boost/shared_ptr.hpp>
00037 
00038 //===========================================================================
00051 //===========================================================================
00052 class MBAdata {
00053   friend class MBA;
00054   friend class MBAadaptive;
00055 
00056   double umin_, vmin_, umax_, vmax_; // possibly user defined (expanded)
00057     
00058     double urange_inv_;
00059     double vrange_inv_;
00060 
00061   MBAbaseType  baseType_;  
00062   double offset_;
00063   boost::shared_ptr<dVec> U_;
00064   boost::shared_ptr<dVec> V_;
00065   boost::shared_ptr<dVec> Zorig_;
00066     std::vector<double> Z_;
00067 
00069     void readScatteredData(char filename[]);
00070 
00071   void buildOffset();
00072   void buildBaseSurface();
00073 
00074   /*  Expand the rectangular domain beyond the domain of the given 
00075    *  scattered data; see doc in MBA.
00076    *  This must be done after data initialization.
00077    *  Note that this can only be used to expand the domain 
00078    *  (and not shrink it in any direction). 
00079    */
00080   //void expandDomain(double Dumin, double Dvmin, double Dumax, double Dvmax) {
00081     //umin_ -= Dumin; vmin_ -= Dvmin; umax_ += Dumax; vmax_ += Dvmax;}
00082 
00083   //  Set the rectangular domain. See also above.
00084   void setDomain(double umin, double vmin, double umax, double vmax)
00085   {
00086       umin_ = umin; 
00087       vmin_ = vmin; 
00088       umax_ = umax; 
00089       vmax_ = vmax;
00090       urange_inv_ = double(1) / (umax_ - umin_);
00091       vrange_inv_ = double(1) / (vmax_ - vmin_);
00092   }
00093 
00094   // Clear all allocated memory
00095   void clear() {U_->clear(); V_->clear(); Z_.clear(); Zorig_->clear();}
00096 
00097   // Non-const for class MBA
00098   std::vector<double>& Z() {return Z_;};
00099 
00100   // From data limits
00101   void initDefaultDomain();
00102 
00103 public:
00104         MBAdata();
00105         ~MBAdata() {}
00106 
00108   void init(boost::shared_ptr<dVec> U, boost::shared_ptr<dVec> V, boost::shared_ptr<dVec> Z);
00109   
00111   const double& umin() const {return umin_;}
00113   const double& vmin() const {return vmin_;}
00115   const double& umax() const {return umax_;}
00117   const double& vmax() const {return vmax_;}
00118 
00119   const double& rangeUInv() const {return urange_inv_;}
00120   const double& rangeVInv() const {return vrange_inv_;}
00121 
00122   // Access to scattered data
00123   const boost::shared_ptr<dVec>& U() const {return U_;};
00124   const boost::shared_ptr<dVec>& V() const {return V_;};
00125   const boost::shared_ptr<dVec>& Zorig() const {return Zorig_;};
00126   const std::vector<double>& Z() const {return Z_;}; // also non-const private members
00127   double U(int i) const {return (*U_)[i];};
00128   double V(int i) const {return (*V_)[i];};
00129 
00131     int size() const {return U_->size();}
00132 
00133 
00134   // Evaluator.
00135   // Assumes that the base surface is a constant
00136   inline double f() const {return offset_;}
00137 };
00138 
00139 #endif //_MBADATA_H_

Generated on Wed Nov 28 12:27:29 2007 for LSMG by  doxygen 1.5.1