MrepModel2d.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_MREP_MREPMODEL2D_H
00010 #define SHAPE_MREP_MREPMODEL2D_H
00011 
00012 #include <shape/mrep/MrepSkeleton2d.hpp>
00013 #include <spline/PeriodicBspline.hpp>
00014 #include <shape/DiscretizableShapeInterface.hpp>
00015 
00016 
00017 namespace imaging
00018 {
00022   class MrepModel2d : public MrepSkeleton2d, public DiscretizableShapeInterface<2>
00023   {
00024   public:
00025     typedef PeriodicBspline< ublas::fixed_vector<float_t, 2> > curve_t;
00026 
00027   private:
00028     class Discretizer;
00029     
00030     static const size_t SPLINE_ORDER = 4;
00031     
00032     static void init_boundary_coefficients(
00033       const std::vector< ublas::fixed_vector<float_t, 2> > & position_equations,
00034       const std::vector< ublas::fixed_vector<float_t, 2> > & tangent_equations,
00035       curve_t & spline_curve);
00036     static float_t tangent_factor(float_t angle);
00037     static bool intersect( const ublas::fixed_vector<float_t, 2> & a_1, const ublas::fixed_vector<float_t, 2> & a_2,
00038                     const ublas::fixed_vector<float_t, 2> & b_1, const ublas::fixed_vector<float_t, 2> & b_2,
00039                     ublas::fixed_vector<float_t, 2> & intersection_point );
00040 
00041 
00042 
00043   public:
00044     MrepModel2d() : MrepSkeleton2d() {}
00045     MrepModel2d(const Position2d & position,
00046                 size_t n_atoms = 0, size_t n_connections = 0) :
00047       MrepSkeleton2d(position, n_atoms, n_connections) {}
00048       
00049     virtual std::auto_ptr< BoundaryDiscretizer<2> > boundary_discretizer(size_t n_points) const;
00050 
00052     void compute_boundary(curve_t & spline_curve) const;
00053   };
00054     
00056   class MrepModel2d::Discretizer : public BoundaryDiscretizer<2>
00057   {
00058     PeriodicBspline< ublas::fixed_vector<float_t, 2> > _boundary;
00059     float_t _step_size;
00060 
00061   public:
00062     
00063     Discretizer(const MrepModel2d & model, size_t n_points);
00064 
00065     void evaluate(size_t i, ublas::fixed_vector<float_t, SHAPE_DIMENSION> & point, ublas::fixed_vector<float_t, SHAPE_DIMENSION> & normal, float_t & curvature) const;
00066   };
00069 }
00070 
00071 #endif

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