library of assembled shared sources

http://lass.cocamware.com

spline_bezier_path.h

Go to the documentation of this file.
00001 /** @file
00002  *  @author Bram de Greve (bramz@users.sourceforge.net)
00003  *  @author Tom De Muer (tomdemuer@users.sourceforge.net)
00004  *
00005  *  Distributed under the terms of the GPL (GNU Public License)
00006  *
00007  *  The LASS License:
00008  *
00009  *  Copyright 2004-2006 Bram de Greve and Tom De Muer
00010  *
00011  *  LASS is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program 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
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License
00022  *  along with this program; if not, write to the Free Software
00023  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 
00027 
00028 /** @class lass::num::SplineBezierPath
00029  *  @brief connects the data nodes with cubic bezier splines.
00030  *  @author Bram de Greve [BdG]
00031  */
00032 
00033 #ifndef LASS_GUARDIAN_OF_INCLUSION_NUM_SPLINE_BEZIER_PATH_H
00034 #define LASS_GUARDIAN_OF_INCLUSION_NUM_SPLINE_BEZIER_PATH_H
00035 
00036 #include "num_common.h"
00037 #include "spline.h"
00038 
00039 namespace lass
00040 {
00041 namespace num
00042 {
00043 
00044 template 
00045 <
00046     typename ScalarType,
00047     typename DataType,
00048     typename DataTraits
00049 >
00050 class SplineBezierPath: public Spline<ScalarType, DataType>
00051 {
00052 public:
00053 
00054     typedef DataTraits TDataTraits;
00055     typedef Spline<ScalarType, DataType> TSplineBase;
00056     typedef typename TSplineBase::TScalar TScalar;
00057     typedef typename TSplineBase::TData TData;
00058     typedef typename TSplineBase::ControlRange TControlRange;
00059 
00060     class DataTriplet
00061     {
00062     public:
00063         DataTriplet(const TData& left, const TData& knot, const TData& right): 
00064             left_(left), knot_(knot), right_(right) {}
00065         const TData& left() const { return left_; }
00066         const TData& knot() const { return knot_; }
00067         const TData& right() const { return right_; }
00068     private:
00069         friend class SplineBezierPath;
00070         TData left_;
00071         TData knot_;
00072         TData right_;
00073     };
00074 
00075     SplineBezierPath();
00076     template <typename PairInputIterator>
00077     SplineBezierPath(PairInputIterator iFirst, PairInputIterator iLast);
00078     template <typename ScalarInputIterator, typename DataInputIterator>
00079     SplineBezierPath(ScalarInputIterator iFirstControl, ScalarInputIterator iLastControl,
00080         DataInputIterator iFirstData);
00081 
00082     const TData operator()(TScalar iX) const;
00083     const TData derivative(TScalar iX) const;
00084     const TData derivative2(TScalar iX) const;
00085     const TData integral(TScalar iA, TScalar iB) const;
00086 
00087     const bool isEmpty() const;
00088     const TControlRange controlRange() const;
00089 
00090 private:
00091 
00092     struct Node
00093     {
00094         DataTriplet triplet;
00095         TScalar x;
00096 
00097         Node(const DataTriplet& triplet, TScalar x): triplet(triplet), x(x) {}
00098         const TData& left() const { return triplet.left(); }
00099         const TData& knot() const { return triplet.knot(); }
00100         const TData& right() const { return triplet.right(); }
00101 
00102         static bool less(const Node& iA, const Node& iB) { return iA.x < iB.x; }
00103     };
00104     typedef std::vector<Node> TNodes;
00105     typedef typename TNodes::const_iterator TNodeConstIterator;
00106 
00107     typedef std::pair<TScalar, TData> TSimpleNode;
00108     typedef std::vector<TSimpleNode> TSimpleNodes;
00109 
00110     template <typename PairInputIterator>
00111     void init(PairInputIterator first, PairInputIterator last, const DataTriplet& dummy);
00112     template <typename PairInputIterator>
00113     void init(PairInputIterator first, PairInputIterator last, const TData& dummy);
00114     template <typename ScalarInputIterator, typename DataInputIterator>
00115     void init(ScalarInputIterator firstControl, ScalarInputIterator lastControl,
00116         DataInputIterator firstData, const DataTriplet& dummy);
00117     template <typename ScalarInputIterator, typename DataInputIterator>
00118     void init(ScalarInputIterator firstControl, ScalarInputIterator lastControl,
00119         DataInputIterator firstData, const TData& dummy);
00120     void makeFullNodes(const TSimpleNodes& simpleNodes);
00121     void finalInit();
00122 
00123     const TNodeConstIterator findNode(TScalar iX) const;
00124 
00125     TNodes nodes_;
00126     size_t dataDimension_;
00127 };
00128 
00129 
00130 
00131 }
00132 
00133 }
00134 
00135 #include "spline_bezier_path.inl"
00136 
00137 #endif
00138 
00139 // EOF

Generated on Mon Nov 10 14:21:39 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo