00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef SHAPE_BSPLINESHAPE_H
00010 #define SHAPE_BSPLINESHAPE_H
00011
00012 #include <shape/ShapeInterface.hpp>
00013 #include <shape/DiscretizableShapeInterface.hpp>
00014
00015 #include <spline/PeriodicBspline.hpp>
00016
00017 namespace imaging
00018 {
00024 class BsplineShape : public ShapeInterface, public DiscretizableShapeInterface<2>
00025 {
00026 PeriodicBspline< ublas::fixed_vector<float_t, 2> > _curve;
00027
00028 class Discretizer;
00029
00030 public:
00031 const static size_t SHAPE_DIMENSION = 2;
00032
00033 BsplineShape() : _curve() {}
00034
00036 BsplineShape(const BsplineShape & source) : _curve(source._curve) {}
00037
00039 BsplineShape(const PeriodicBspline< ublas::fixed_vector<float_t, 2> > & curve) : _curve(curve) {}
00040
00042 const BsplineShape & operator=(const BsplineShape & source)
00043 { _curve = source._curve; return *this; }
00044
00045 virtual std::auto_ptr< BoundaryDiscretizer<2> > boundary_discretizer(size_t n_points) const;
00046
00047 void exponential(const ublas::vector<float_t> & vector, ShapeInterface & shape) const;
00048
00049 void logarithm(const ShapeInterface & shape, ublas::vector<float_t> & vector) const;
00050
00051 size_t dimension() const { return 2 * _curve.n_coefficients(); }
00052
00054 const PeriodicBspline< ublas::fixed_vector<float_t, 2> > & curve() const { return _curve; }
00055 };
00056
00057
00059 class BsplineShape::Discretizer : public BoundaryDiscretizer<2>
00060 {
00061 float_t _step_size;
00062 const BsplineShape & _spline_curve;
00063
00064 public:
00065
00066 Discretizer(const BsplineShape & spline_curve, size_t n_points);
00067
00068 void evaluate(size_t i, ublas::fixed_vector<float_t, 2> & point, ublas::fixed_vector<float_t, 2> & normal, float_t & curvature) const;
00069 };
00072 }
00073
00074
00075 #endif