00001
00002
00005
00006
00007 #ifndef CAJUN_CELL_H
00008 #define CAJUN_CELL_H
00009
00010 #include <vector>
00011 #include <cmath>
00012
00013 #include "scan_gp_data.H"
00014 #include "survey_gp_data.H"
00015
00016 namespace cajun
00017 {
00018 struct point_3d_t
00019 {
00020 point_3d_t ()
00021 : x (0.0), y (0.0), z (0.0), r (0), g (0), b (0),
00022 m_depth (0.0), m_used (false), m_pt_id (0),
00023 m_colored (false) { }
00024
00025 point_3d_t (const scan_gp_data_t::coord_t &pt_)
00026 : x (pt_.x), y (pt_.y), z (pt_.z), r (0), g (0),
00027 b (0), m_depth (0), m_used (false), m_pt_id (0),
00028 m_colored (false) { }
00029 point_3d_t (const survey_gp_data_t::coord_t &pt_)
00030 : x (pt_.x), y (pt_.y), z (pt_.z), r (pt_.r),
00031 g (pt_.g), b (pt_.b), m_depth (0.0),
00032 m_used (false), m_pt_id (0), m_colored (false) { }
00033
00034 point_3d_t (const point_3d_t &pt_, float depth_, size_t id_)
00035 : x (pt_.x), y (pt_.y), z (pt_.z), r (pt_.r),
00036 g (pt_.g), b (pt_.b), m_depth (depth_),
00037 m_used (pt_.m_used), m_pt_id (id_),
00038 m_colored (pt_.m_colored) { }
00039
00040 void print_point () const
00041 {
00042 printf ("x:%f y%f z:%f d:%f\n", x, y, z,
00043 m_depth);
00044 }
00045 inline void set_used (bool used_) { m_used = used_; }
00046 inline size_t id () const { return m_pt_id; }
00047 inline bool is_used () const { return m_used; }
00048 inline bool is_colored () const { return m_colored; }
00049
00050 bool operator== (const point_3d_t &pt_) const
00051 {
00052 return this->x == pt_.x &&
00053 this->y == pt_.y &&
00054 this->z == pt_.z;
00055 }
00056 bool operator< (const point_3d_t &p_) const
00057 {
00058 return (this->m_depth < p_.m_depth);
00059 }
00060 float x, y, z;
00061 uint8_t r, g, b;
00062 float m_depth;
00063 bool m_used;
00064 size_t m_pt_id;
00065 bool m_colored;
00066 };
00067
00068 class cell_t
00069 {
00070 friend class stripe_t;
00071 public:
00072 cell_t ();
00073 ~cell_t ();
00074 void insert_point (const point_3d_t &point_, float depth_);
00075 const point_3d_t& get_point (unsigned id_) const;
00076 point_3d_t& get_point (unsigned id_);
00077 size_t num_points () const;
00078 size_t get_point_pos (const point_3d_t &pt_) const;
00079 void print_cell () const;
00080 void set_heading (double heading_);
00081 double get_heading () const;
00082 float get_cell_size () const;
00083 void set_cell_size (float cell_size_);
00084 bool empty () const;
00085 bool is_used () const;
00086 void set_used (bool used_);
00087 void add_marked_pt (point_3d_t &pt_);
00088 std::vector<point_3d_t> get_marked_pts () const;
00089 bool is_first_pt (unsigned id_) const;
00090
00091 size_t id () const;
00092 bool operator== (const cell_t &cell_) const
00093 {
00094 return this->m_id == cell_.m_id;
00095 }
00096 protected:
00097 private:
00098 std::vector<point_3d_t> m_points;
00099 std::vector<point_3d_t> m_marked_pts;
00100 void cleanup_cell ();
00101 void sort_cell ();
00102 bool m_used;
00103 size_t m_id;
00104 static size_t m_next_id;
00105 size_t m_pt_id_counter;
00106 double m_heading;
00107 float m_cell_size;
00108 };
00109 };
00110
00111 #endif