Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

rsdl_point.h

Go to the documentation of this file.
00001 
00002 #ifndef rsdl_point_h_
00003 #define rsdl_point_h_
00004 
00005 //:
00006 // \file
00007 // \brief A point with mixed Cartesian and angular coordinates.
00008 // \author Chuck Stewart
00009 // \date June 2001
00010 //
00011 //  This is a class to represent points with mixed Cartesian and
00012 //  angular coordinates.  The size of each dimension must be provided
00013 //  to the constructor either explicitly or implicitly.  The code acts
00014 //  as though the cartesian and angular values are represented in two
00015 //  separate arrays.
00016 
00017 
00018 #include <vnl/vnl_vector.h>
00019 
00020 #include <vcl_iosfwd.h>
00021 #include <vcl_vector.h>
00022 
00023 class rsdl_point {
00024 public:
00025   //: Used until we support member templates.
00026   typedef vcl_vector<double>::const_iterator const_iterator;
00027 
00028 public:
00029   //: Provided only for STL.
00030   //  Creates a point without any data.
00031   rsdl_point( );
00032 
00033   //: Ctor to set the dimensions without setting the values.
00034   //  \a Nc and \a Na are the number of cartesian and angular
00035   //  coordinates, respectively.
00036   rsdl_point( unsigned int Nc, unsigned int Na=0 );
00037 
00038   //: Ctor from Cartesian and angular value vector iterators.
00039   rsdl_point( const_iterator c_begin, const_iterator c_end,
00040               const_iterator a_begin, const_iterator a_end );
00041 
00042   //: Ctor from Cartesian and angular value vnl_vectors.
00043   rsdl_point( const vnl_vector<double>& c, const vnl_vector<double>& a );
00044 
00045   //: Copy constructor.
00046   rsdl_point( const rsdl_point& old );
00047 
00048   //: Ctor from cartesian and the angular values, in order, in a single vnl_vector.
00049   //  The angular data is taken as the last \a Na values in the vector.
00050   rsdl_point( const vnl_vector<double>& all, unsigned int Na=0 );
00051 
00052   //: Destructor.
00053   ~rsdl_point();
00054 
00055   //: Number of cartesian dimensions
00056   unsigned int num_cartesian() const { return Nc_; }
00057 
00058   //: Number of angular dimensions
00059   unsigned int num_angular() const { return Na_; }
00060 
00061   //: Establish the cartesian values from a vnl_vector.
00062   void set_cartesian( const vnl_vector<double>& c );
00063 
00064   //: Establish the cartesian values from an iterator.
00065   //  No checking is done: \a Nc elements are expected.
00066   void set_cartesian( const_iterator c );
00067 
00068   //: Establish the angular values from a vnl_vector.
00069   void set_angular( const vnl_vector<double>& a );
00070 
00071   //: Establish the cartesian and angular values from a vnl_vector.
00072   void set_all( const vnl_vector<double>& all );
00073 
00074   //: Establish the angular values from an iterator.
00075   //  No checking is done: \a Nc elements are expected.
00076   void set_angular( const_iterator a );
00077 
00078   //: Constant access to the indexed cartesian coordinate.
00079   inline const double& cartesian( unsigned int i ) const { return data_[i]; }
00080 
00081   //: Mutable access to the indexed cartesian coordinate.
00082   inline double& cartesian( unsigned int i ) { return data_[i]; }
00083 
00084   //: Constant access to the indexed angular coordinate.
00085   inline const double& angular( unsigned int i ) const { return data_[Nc_+i]; }
00086 
00087   //: Mutable access to the indexed angular coordinate.
00088   inline double& angular ( unsigned int i ) { return data_[Nc_+i]; }
00089   
00090   //: Assignment operator.
00091   rsdl_point&  operator= ( const rsdl_point& old );
00092 
00093   //: Resize both the cartesian and angular dimensions.
00094   void resize( unsigned int Nc, unsigned int Na );
00095 
00096 private:
00097   unsigned int Nc_;
00098   unsigned int Na_;
00099   double *data_;
00100 };
00101   
00102 vcl_ostream& operator<< ( vcl_ostream& ostr, const rsdl_point& pt );
00103 
00104 #endif

Generated on Thu Jan 10 14:49:34 2008 for contrib/rpl/rsdl by  doxygen 1.4.4