BsplineShape.hpp

00001 // This file is part of the imaging2 class library.
00002 //
00003 // University of Innsbruck, Infmath Imaging, 2009.
00004 // http://infmath.uibk.ac.at
00005 //
00006 // All rights reserved.
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

Generated on Tue Feb 10 10:01:30 2009 for imaging2 by  doxygen 1.5.5