Go to the documentation of this file.00001 #ifndef msm_points_h_
00002 #define msm_points_h_
00003
00004
00005
00006
00007
00008 #include <vcl_cassert.h>
00009 #include <vcl_iosfwd.h>
00010 #include <vcl_string.h>
00011 #include <vsl/vsl_fwd.h>
00012 #include <vnl/vnl_vector.h>
00013 #include <vgl/vgl_point_2d.h>
00014 #include <vgl/vgl_box_2d.h>
00015 #include <vimt/vimt_transform_2d.h>
00016
00017
00018
00019 class msm_points
00020 {
00021 private:
00022 vnl_vector<double> v_;
00023 public:
00024
00025
00026 msm_points();
00027
00028
00029 msm_points(unsigned n);
00030
00031
00032 ~msm_points();
00033
00034
00035 const vnl_vector<double>& vector() const { return v_; }
00036
00037
00038
00039 vnl_vector<double>& vector() { return v_; }
00040
00041
00042 unsigned size() const { return v_.size()/2; }
00043
00044
00045
00046 void set_size(unsigned n, double x=0, double y=0);
00047
00048
00049 void set_point(unsigned i, double x, double y)
00050 {
00051 assert(i<size()); v_[2*i]=x; v_[2*i+1]=y;
00052 }
00053
00054
00055 vgl_point_2d<double> operator[](unsigned i) const
00056 {
00057 assert(i<size());
00058 return vgl_point_2d<double>(v_[2*i],v_[2*i+1]);
00059 }
00060
00061
00062 void set_points(const vcl_vector<vgl_point_2d<double> >& pts);
00063
00064
00065 void get_points(vcl_vector<vgl_point_2d<double> >& pts) const;
00066
00067
00068 vgl_point_2d<double> cog() const;
00069
00070
00071 double scale() const;
00072
00073
00074 void get_cog_and_scale(vgl_point_2d<double>& cog, double& scale) const;
00075
00076
00077 void scale_by(double s);
00078
00079
00080 void translate_by(double tx, double ty);
00081
00082
00083
00084 void transform_by(double a, double b, double tx, double ty);
00085
00086
00087 void transform_by(const vimt_transform_2d& t);
00088
00089
00090 void get_bounds(vgl_point_2d<double>& b_lo,
00091 vgl_point_2d<double>& b_hi) const;
00092
00093
00094 vgl_box_2d<double> bounds() const;
00095
00096
00097
00098 bool write_text_file(const vcl_string& path) const;
00099
00100
00101
00102 bool read_text_file(const vcl_string& path);
00103
00104
00105 short version_no() const;
00106
00107
00108 vcl_string is_a() const;
00109
00110
00111 void print_summary(vcl_ostream& os) const;
00112
00113
00114 void b_write(vsl_b_ostream& bfs) const;
00115
00116
00117 void b_read(vsl_b_istream& bfs);
00118
00119
00120 bool operator==(const msm_points& points) const;
00121 };
00122
00123
00124
00125 void vsl_b_write(vsl_b_ostream& bfs, const msm_points& pts);
00126
00127
00128
00129 void vsl_b_read(vsl_b_istream& bfs, msm_points& pts);
00130
00131
00132 vcl_ostream& operator<<(vcl_ostream& os,const msm_points& pts);
00133
00134
00135 void vsl_print_summary(vcl_ostream& os,const msm_points& pts);
00136
00137 #endif // msm_points_h_