contrib/tbl/vipl/section/vipl_section_descriptor_2d.h
Go to the documentation of this file.
00001 // This is tbl/vipl/section/vipl_section_descriptor_2d.h
00002 #ifndef vipl_section_descriptor_2d_h_
00003 #define vipl_section_descriptor_2d_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 //  \file
00009 
00010 #include <vipl/section/vipl_section_descriptor.h>
00011 
00012 template < class DataType > class vipl_section_container_2d; //template forward reference
00013 template < class DataType > class vipl_section_iterator; //template forward reference
00014 
00015 template < class DataType >
00016 class vipl_section_descriptor_2d : public vipl_section_descriptor< DataType >
00017 {
00018   friend class vipl_section_container< DataType > ; //declare a friend class
00019   friend class vipl_section_iterator< DataType > ; //declare a friend class
00020 
00021   // since STL does things by values we play a few games so we can have subclasses
00022 
00023   vipl_section_descriptor< DataType >* hsreal_descriptor;
00024   vipl_section_container< DataType >* hsreal_container;
00025   // pointer to the real data
00026   DataType* hsi_data_ptr;
00027   // "pointer offsets" to move 1 unit in any dimen
00028   vcl_vector< int > hsi_data_offsets;
00029   // describe the start,end and size of the section
00030   vcl_vector< int > hsi_curr_sec_start;
00031   vcl_vector< int > hsi_curr_sec_end;
00032   vcl_vector< int > hsi_curr_sec_size;
00033  public:
00034   //: Ctor useful to define 2D section descriptors for ROA's. If you.
00035   //  Once constructed there is no way to change the data in the section descriptor.
00036   vipl_section_descriptor_2d( int startx , int endx , int starty , int endy);
00037  protected:
00038   // Assigns the pointers directly. Does not attempt to deep copy them.
00039   vipl_section_descriptor_2d(
00040                  vipl_section_descriptor< DataType >* desc ,
00041                  vipl_section_container< DataType >* container);
00042   //  Deep-copies the pointers
00043   vipl_section_descriptor_2d(
00044                 const vipl_section_descriptor< DataType >* desc ,
00045                 const vipl_section_container< DataType >* container ,
00046                 int t);
00047  public:
00048   virtual ~vipl_section_descriptor_2d(); //low_level destructor
00049   vipl_section_descriptor_2d(); //low_level c++ constructor
00050   //user accessed low_level c++ copy constructor
00051   vipl_section_descriptor_2d(const vipl_section_descriptor_2d< DataType > &);
00052 #if 0 // not implemented at this level
00053   //:
00054   // This method takes in an argument called axis (i.e. 0 means the ``x'' axis,
00055   // 1 means ``y'' axis) etc... and returns an integer which describes the start
00056   // coordinate value for ``x'' (or ``y'' etc..) with respect to the ``image''
00057   // coordinate system.
00058   virtual int curr_sec_start( int axis) const;
00059   //:
00060   // This method takes in an argument called axis (i.e. 0 means the ``x'' axis,
00061   // 1 means ``y'' axis) etc... and returns an integer which describes the end
00062   // coordinate value for ``x'' (or ``y'' etc..) with respect to the ``image''
00063   // coordinate system.
00064   virtual int curr_sec_end( int axis) const;
00065   //:
00066   // This method takes in an argument called axis (i.e. 0 means the ``x'' axis,
00067   // 1 means ``y'' axis) etc... and returns an integer which describes the size
00068   // of the axis (end minus start) for ``x'' (or ``y'' etc..) with respect to
00069   // the ``image'' coordinate system.
00070   virtual int curr_sec_size( int axis) const;
00071   //:
00072   // This method takes in an argument called axis (i.e. 0 means the ``x'' axis,
00073   // 1 means ``y'' axis) etc... and returns an integer which describes the
00074   // offset of the next (i.e. associated with the higher coordinate value) data
00075   // item along the axis.
00076   virtual int data_offsets( int axis) const;
00077   //: Returns a referable pointer to the first data item in the current section.
00078   // If the value returned is null, then the address is not available to the
00079   // filter.
00080   virtual DataType* data_ptr();
00081   //: Returns a const pointer to the first data item in the current section.
00082   // If the value returned is null, then the address is not available to the
00083   // filter.
00084   virtual const DataType* data_ptr() const;
00085   //: Returns a writable pointer to the ``real'' section descriptor.
00086   // If this method is called on a concrete instance, it should return 0.
00087   virtual vipl_section_descriptor< DataType >* inner_descriptor();
00088   //:
00089   // Returns a const pointer to the ``real'' section descriptor. If this method
00090   // is called on a concrete instance, it should return 0.
00091   virtual const vipl_section_descriptor< DataType >* inner_descriptor() const;
00092   //:
00093   // Makes a new correct copy. It's just a bit more tricky because descriptors
00094   // have pointers to its ``real instance.''
00095  protected:
00096   virtual vipl_section_descriptor< DataType >* virtual_copy() const;
00097 #endif
00098  public:
00099   vipl_section_descriptor< DataType >* real_descriptor() const { return hsreal_descriptor; }
00100   vipl_section_descriptor< DataType >* & ref_real_descriptor() { return hsreal_descriptor; }
00101   void put_real_descriptor( vipl_section_descriptor< DataType >* v) { hsreal_descriptor = v; }
00102  public: vipl_section_container< DataType >* real_container() const { return hsreal_container; }
00103  public: vipl_section_container< DataType >* & ref_real_container() { return hsreal_container; }
00104  public: void put_real_container( vipl_section_container< DataType >* v) { hsreal_container = v; }
00105  public: DataType* i_data_ptr() const { return hsi_data_ptr; }
00106  public: DataType* & ref_i_data_ptr() { return hsi_data_ptr; }
00107  public: void put_i_data_ptr( DataType* v) { hsi_data_ptr = v; }
00108  public: vcl_vector< int > const & i_data_offsets() const { return hsi_data_offsets; }
00109  public: vcl_vector< int > & ref_i_data_offsets() { return hsi_data_offsets; }
00110  public: void put_i_data_offsets( vcl_vector< int > const & v) { hsi_data_offsets = v; }
00111  public: vcl_vector< int > const & i_curr_sec_start() const { return hsi_curr_sec_start; }
00112  public: vcl_vector< int > & ref_i_curr_sec_start() { return hsi_curr_sec_start; }
00113  public: void put_i_curr_sec_start( vcl_vector< int > const & v) { hsi_curr_sec_start = v; }
00114  public: vcl_vector< int > const & i_curr_sec_end() const { return hsi_curr_sec_end; }
00115  public: vcl_vector< int > & ref_i_curr_sec_end() { return hsi_curr_sec_end; }
00116  public: void put_i_curr_sec_end( vcl_vector< int > const & v) { hsi_curr_sec_end = v; }
00117  public: vcl_vector< int > const & i_curr_sec_size() const { return hsi_curr_sec_size; }
00118  public: vcl_vector< int > & ref_i_curr_sec_size() { return hsi_curr_sec_size; }
00119  public: void put_i_curr_sec_size( vcl_vector< int > const & v) { hsi_curr_sec_size = v; }
00120 }; // end of class definition
00121 
00122 #ifdef INSTANTIATE_TEMPLATES
00123 #include "vipl_section_descriptor_2d.txx"
00124 #endif
00125 
00126 #endif // vipl_section_descriptor_2d_h_