Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxBSplineBasis.h

00001 /*
00002  *  Copyright (c) 1998, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Silvia D. Olabarriaga  (silvia@wins.uva.nl)
00008  *  Dennis Koelma (koelma@wins.uva.nl)
00009  */
00010 
00011 #ifndef HxBSplineBasis_h
00012 #define HxBSplineBasis_h
00013 
00014 #include <vector>
00015 using std::vector;
00016 
00017 #include "HxStd.h"
00018 #include "HxBSplineType.h"
00019 #include "HxBSplineInterval.h"
00020 #include "HxIoFwd.h"
00021 
00022 class HxBSplineCurve;
00023 
00024 
00028 enum HxBSplineKnotsAlg 
00029 { 
00030     uniformKnots,       // uniform spacing
00031     givenKnots          // any spacing
00032 };
00033 
00034 
00044 class HxBSplineBasis  {
00045 public:
00047                         HxBSplineBasis();
00048 
00053                         HxBSplineBasis(HxBSplineType typeCurve, 
00054                             int degree, int nIntervals,
00055                             HxBSplineKnotsAlg typeKnots =uniformKnots, 
00056                             double minT =0.0, double maxT =1.0);
00057 
00062                         HxBSplineBasis(HxBSplineType typeCurve, int degree,
00063                                        const std::vector<double>& knots);
00064 
00066                         ~HxBSplineBasis();
00067 
00068 
00070     HxBSplineType       curveType() const;
00071 
00073     int                 degree() const;
00074 
00076     int                 nIntervals() const;
00077 
00079     HxBSplineKnotsAlg   knotsType() const;
00080 
00082     double              minT() const;
00083 
00085     double              maxT() const;
00086 
00088     double              knot(int j) const;
00089 
00091     std::vector<double> allKnots() const;
00092 
00094     int                 numB() const;
00095 
00097     double              B(int index, double t) const;
00098 
00100     double              dB(int order, int index, double t) const;
00101 
00103     HxBSplineInterval   pathAffectedBy(int index) const;
00104 
00105 
00107     HxBSplineBasis      insertKnot(double t, int n=1) const;
00108 
00110     STD_OSTREAM&        dump(STD_OSTREAM&) const;
00111 
00112 // 
00113 // these methods support the implementation
00114 // of curve manipulation of higher level
00115 // described in the NURBS book, p.512
00116 // they should be protected in some way!
00117 // 
00118     double              node(int i) const;
00119     int                 maxBasis(double t) const;
00120     double              nearestKnot(double t) const;
00121 
00122 private:
00123     HxBSplineType       _curveType;
00124     int                 _degree;
00125 
00126     int                 _nIntervals;
00127     double              _minT;
00128     double              _maxT;
00129     HxBSplineKnotsAlg   _knotsType;
00130 
00131     // vector with knots
00132     vector <double>     _knotsVec;
00133 
00134     friend class HxBSplineCurve;
00135 
00136     void                makeDefault();
00137     void                message( charPtr msg=0 ) const;
00138     void                completeKnots( const vector<double>& knots);
00139     void                correctEnds( int i );
00140     vector<double>      makeUniformKnots();
00141     int                 internalBasisIndex( int i, double t) const;
00142     int                 whichInterval ( double t ) const;
00143     int                 isNullAt( int index, double t) const;
00144     double              nim(double t,int i,int M) const;
00145     double              dNim(int order, double t, int i,int M) const;
00146 };
00147 
00148 inline STD_OSTREAM&
00149 operator<<(STD_OSTREAM& os, const HxBSplineBasis& b)
00150 {
00151     return b.dump(os);
00152 }
00153 
00154 inline HxBSplineType 
00155 HxBSplineBasis::curveType() const
00156 {
00157     return _curveType; 
00158 }
00159 
00160 inline
00161 int HxBSplineBasis::degree() const
00162 {
00163     return _degree;
00164 }
00165 
00166 
00167 inline
00168 int HxBSplineBasis::nIntervals() const
00169 {
00170     return _nIntervals;
00171 }
00172 
00173 inline HxBSplineKnotsAlg 
00174 HxBSplineBasis::knotsType() const 
00175 { 
00176     return _knotsType; 
00177 }
00178 
00179 inline double 
00180 HxBSplineBasis::minT() const 
00181 { 
00182     return _minT; 
00183 }
00184 
00185 inline double
00186 HxBSplineBasis::maxT() const
00187 { 
00188     return _maxT;
00189 }
00190 
00191 inline int 
00192 HxBSplineBasis::numB() const
00193 { 
00194     switch ( curveType() ) {
00195       case closed:
00196             return _nIntervals; 
00197             break;
00198       case openRepeatEndPoints:
00199       case open:
00200       default:  // this case should never happen!
00201             return _nIntervals+degree(); 
00202             break;
00203     }
00204 }
00205 
00206 inline double 
00207 HxBSplineBasis::knot(int i) const
00208 { 
00209     return _knotsVec[i];
00210 }
00211 
00212 inline vector<double> 
00213 HxBSplineBasis::allKnots() const
00214 { 
00215     return _knotsVec;
00216 }
00217 
00218 inline int
00219 HxBSplineBasis::isNullAt(int i, double t) const
00220 {
00221     HxBSplineInterval interval = pathAffectedBy(i);
00222     return ! interval.contains(t);
00223 }
00224 
00225 #endif 

Generated on Mon Jan 27 15:48:41 2003 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001