contrib/brl/bbas/bugl/bugl_curve_3d.h
Go to the documentation of this file.
00001 #ifndef bugl_curve_3d_h_
00002 #define bugl_curve_3d_h_
00003 //--------------------------------------------------------------------------
00004 //:
00005 // \file
00006 // \brief bugl_curve_3d - a 3-d pointset with curve (1-d) neighborhood
00007 //
00008 //    The data structure is a matrix of 3-d points with uncertainty
00009 // \verbatim
00010 //     ->|              |<--- 2*num_neighbors_ + 1
00011 //       x x x  p0  x x x
00012 //       x x x  p1  x x x
00013 //             ...  |---|  <--- num_neighbors_
00014 //             ...
00015 //       x x x pN-1 x x x
00016 //                    ^---neighboring points
00017 // \endverbatim
00018 //    N = data_.size()
00019 //
00020 //   There is also the notion of "fragments". A vector, index_, marks
00021 //   intervals between sets of 3-d points inserted by each invocation of
00022 //   ::add_curve(..)
00023 //
00024 // \author Kongbin Kang
00025 // \verbatim
00026 //  Modifications
00027 //   Initial version November 22, 2003
00028 // \endverbatim
00029 //---------------------------------------------------------------------------
00030 
00031 #include <bugl/bugl_normal_point_3d_sptr.h>
00032 #include <vcl_vector.h>
00033 
00034 class bugl_curve_3d
00035 {
00036   //: number of neighbors
00037   unsigned int num_neighbors_;
00038 
00039   //: data
00040   vcl_vector<vcl_vector<bugl_normal_point_3d_sptr > > data_;
00041 
00042   //: starting position index for each fragment
00043   vcl_vector<int> index_;
00044 
00045  public:
00046 
00047   //: total number of points in the curve
00048   int get_num_points() const { return data_.size(); }
00049 
00050   //: how many fragments in the curve
00051   int get_num_fragments() const { return index_.size(); }
00052 
00053   //: add a vector of point as a curve
00054   void add_curve(vcl_vector<bugl_normal_point_3d_sptr > &pts);
00055 
00056   bugl_curve_3d(unsigned int neighbors = 2) : num_neighbors_(neighbors) {}
00057 
00058   ~bugl_curve_3d() {}
00059 
00060   //: get the point
00061   bugl_normal_point_3d_sptr get_point(unsigned int index) const;
00062 
00063   //: get a point with neighbors
00064   vcl_vector<bugl_normal_point_3d_sptr> get_neighbors(unsigned int index) const;
00065 
00066   //: get a neighbor point
00067   bugl_normal_point_3d_sptr get_neighbor(unsigned int self, int offset) const;
00068 
00069   //: get the global position of a point in a fragment. 0-based indices are used.
00070   //  Returns -1 if the arguments are invalid.
00071   inline int get_global_pos(unsigned int frag_index, unsigned int loc_pos)
00072   { return frag_index<index_.size() && loc_pos<get_fragment_size(frag_index) ?
00073            int(index_[frag_index]+loc_pos) : -1; }
00074 
00075   //: get the i-th fragment size
00076   unsigned int get_fragment_size(unsigned int i) const;
00077 };
00078 
00079 #endif