00001
00002
00003
00004
00005
00006
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