SplineInterpolator.h

00001 //===========================================================================
00002 // GoTools - SINTEF Geometry Tools version 1.1
00003 //
00004 // GoTools module: CORE
00005 //
00006 // Copyright (C) 2000-2007 SINTEF ICT, Applied Mathematics, Norway.
00007 //
00008 // This program is free software; you can redistribute it and/or          
00009 // modify it under the terms of the GNU General Public License            
00010 // as published by the Free Software Foundation version 2 of the License. 
00011 //
00012 // This program is distributed in the hope that it will be useful,        
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00015 // GNU General Public License for more details.                           
00016 //
00017 // You should have received a copy of the GNU General Public License      
00018 // along with this program; if not, write to the Free Software            
00019 // Foundation, Inc.,                                                      
00020 // 59 Temple Place - Suite 330,                                           
00021 // Boston, MA  02111-1307, USA.                                           
00022 //
00023 // Contact information: E-mail: tor.dokken@sintef.no                      
00024 // SINTEF ICT, Department of Applied Mathematics,                         
00025 // P.O. Box 124 Blindern,                                                 
00026 // 0314 Oslo, Norway.                                                     
00027 //
00028 // Other licenses are also available for this software, notably licenses
00029 // for:
00030 // - Building commercial software.                                        
00031 // - Building software whose source code you wish to keep private.        
00032 //===========================================================================
00033 #ifndef _GOSPLINEINTERPOLATOR_H
00034 #define _GOSPLINEINTERPOLATOR_H
00035 
00036 
00037 #include "Interpolator.h"
00038 #include "BsplineBasis.h"
00039 #include "Point.h"
00040 #include <boost/smart_ptr.hpp>
00041 
00042 
00043 namespace Go
00044 {
00047 
00048 
00052 class SplineInterpolator : public Interpolator
00053 {
00054 public:
00056     SplineInterpolator()
00057         : ctype_(None), basis_set_(false)
00058         {
00059         }
00060 
00062     virtual ~SplineInterpolator();
00063 
00064     // inherited from Interpolator
00065     virtual const BsplineBasis& basis();
00066 
00089     void interpolate(const std::vector<double>& params,
00090                      const std::vector<double>& points,
00091                      const std::vector<int>& tangent_index,
00092                      const std::vector<double>& tangent_points,
00093                      int order,
00094                      std::vector<double>& coefs);
00095 
00103     void interpolate(const std::vector<double>& params,
00104                      const std::vector<double>& points,
00105                      const std::vector<int>& tangent_index,
00106                      const std::vector<double>& tangent_points,
00107                      std::vector<double>& coefs);
00108 
00116     virtual void interpolate(int num_points, int dimension,
00117                              const double* param_start,
00118                              const double* data_start,
00119                              std::vector<double>& coefs);
00120 
00137     enum CondType { None, Hermite, Natural, Free, NaturalAtStart, NaturalAtEnd };
00138 
00144     void setHermiteConditions(const Point& start_tangent,
00145                               const Point& end_tangent) {
00146         ctype_ = Hermite;
00147         start_tangent_ = boost::shared_ptr<Point>(new Point(start_tangent));
00148         end_tangent_ =  boost::shared_ptr<Point>(new Point(end_tangent));
00149     }
00150 
00154     void setNaturalConditions() { ctype_ = Natural; }
00155 
00161     void setNaturalStartCondition() { ctype_ = NaturalAtStart;}
00162 
00168     void setNaturalEndCondition() { ctype_ = NaturalAtEnd; }
00169 
00173     void setFreeConditions() { ctype_ = Free; }
00174 
00180     void setEndTangents(boost::shared_ptr<Point>& start_tangent,
00181                         boost::shared_ptr<Point>& end_tangent)
00182     {
00183         start_tangent_ = start_tangent;
00184         end_tangent_ = end_tangent;
00185         if (start_tangent.get() != 0 && end_tangent.get() != 0)
00186             ctype_ = Hermite;
00187         else if (start_tangent.get() != 0)
00188             ctype_ = NaturalAtEnd;
00189         else if (end_tangent.get() != 0)
00190             ctype_ = NaturalAtStart;
00191         else
00192             ctype_ = Natural;
00193     }
00194 
00197     CondType getCondType() {return ctype_; }
00198 
00206     void makeBasis(const std::vector<double>& params,
00207                    const std::vector<int>& tangent_index,
00208                    int order);
00209 
00212 
00217     void setBasis(BsplineBasis& basis) {
00218         basis_ = basis;
00219         basis_set_ = true;
00220     }
00221 
00222 private:
00223     CondType ctype_;
00224     boost::shared_ptr<Point> start_tangent_;
00225     boost::shared_ptr<Point> end_tangent_;
00226     BsplineBasis basis_;
00227     bool basis_set_;
00228 };
00229 
00230 
00231 
00233 } // namespace Go
00234 
00235 
00236 #endif // _GOSPLINEINTERPOLATOR_H
00237 
00238 

Generated on Mon Jun 11 14:48:18 2007 for GoTools Core Library by  doxygen 1.5.1