PolygonModel2d.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_POLYGONMODEL2D_H
00010 #define SHAPE_MREP_POLYGONMODEL2D_H
00011 
00012 #include <shape/mrep/MrepSkeleton2d.hpp>
00013 #include <spline/PeriodicBspline.hpp>
00014 #include <shape/DiscretizableShapeInterface.hpp>
00015 #include <polytope/Polygon.hpp>
00016 
00017 
00018 namespace imaging
00019 {
00023   class PolygonModel2d : public MrepSkeleton2d, public DiscretizableShapeInterface<2>
00024   {
00025   public:
00026     typedef PeriodicBspline< ublas::fixed_vector<float_t, 2> > curve_t;
00027 
00028   private:
00029     class Discretizer;
00030     
00031     void compute_limb_polygon(size_t atom_1, size_t atom_2, size_t n_sector_discretization_points, Polygon & polygon) const;
00032 
00033   public:
00034     PolygonModel2d() : MrepSkeleton2d() {}
00035     PolygonModel2d(const Position2d & position,
00036                 size_t n_atoms = 0, size_t n_connections = 0) :
00037       MrepSkeleton2d(position, n_atoms, n_connections) {}
00038       
00039     virtual std::auto_ptr< BoundaryDiscretizer<2> > boundary_discretizer(size_t n_points) const;
00040       
00042     void compute_boundary(size_t n_sector_discretization_points, Polygon & polygon) const;
00043   };
00044   
00046   class PolygonModel2d::Discretizer : public BoundaryDiscretizer<2>
00047   {
00048     float_t _step_size;
00049     std::vector< ublas::fixed_vector<float_t, 2> > _points;
00050     std::vector< ublas::fixed_vector<float_t, 2> > _normals;
00051     
00052     static const size_t N_SECTOR_DISCRETIZATION_POINTS = 5;
00053 
00054   public:
00055     
00056     Discretizer(const PolygonModel2d & model, size_t n_points);
00057 
00058     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;
00059   };  
00062 }
00063 
00064 #endif

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