contrib/mul/msm/utils/msm_draw_shape_to_eps.cxx
Go to the documentation of this file.
00001 #include "msm_draw_shape_to_eps.h"
00002 //:
00003 // \file
00004 // \brief Draws current shape instance to an eps file
00005 // \author Tim Cootes
00006 
00007 #include <vcl_iosfwd.h>
00008 #include <vcl_cassert.h>
00009 
00010 //: Draws current shape instance to an eps file
00011 //  Uses writer.draw_polygon() function to write
00012 //  given curves to file in current colour, linewidth etc.
00013 void msm_draw_shape_to_eps(mbl_eps_writer& writer,
00014                            const msm_points& points,
00015                            const msm_curves& curves)
00016 {
00017   vcl_vector<vgl_point_2d<double> > pts;
00018   points.get_points(pts);
00019 
00020   for (unsigned c=0;c<curves.size();++c)
00021   {
00022     const vcl_vector<unsigned>& index = curves[c].index();
00023     vcl_vector<vgl_point_2d<double> > p(index.size());
00024     for (unsigned i=0;i<index.size();++i)
00025     {
00026       if (index[i]>=pts.size())
00027         vcl_cerr<<"Illegal index: "<<index[i]<<vcl_endl;
00028       assert(index[i]<pts.size());
00029       p[i]=pts[index[i]];
00030     }
00031     writer.draw_polygon(p,!curves[c].open(),false);
00032   }
00033 }
00034 
00035 //: Draws points to an eps file with given radius
00036 //  Uses writer.draw_disk() function to write points
00037 //  in current colour.
00038 void msm_draw_points_to_eps(mbl_eps_writer& writer,
00039                             const msm_points& points,
00040                             double radius, bool filled)
00041 {
00042   for (unsigned i=0;i<points.size();++i)
00043   {
00044     if (filled)
00045       writer.draw_disk(points[i],radius);
00046     else
00047       writer.draw_circle(points[i],radius);
00048   }
00049 }
00050