core/vcsl/vcsl_coordinate_system.h
Go to the documentation of this file.
00001 // This is core/vcsl/vcsl_coordinate_system.h
00002 #ifndef vcsl_coordinate_system_h_
00003 #define vcsl_coordinate_system_h_
00004 //:
00005 // \file
00006 // \brief Abstract coordinate system
00007 // \author François BERTEL
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   2000/06/28 François BERTEL Creation. Adapted from IUE
00012 //   2002/01/22 Peter Vanroose - return type of from_cs_to_standard_units() and from_standard_units_to_cs() changed non-ptr
00013 //   2004/09/10 Peter Vanroose - Added explicit copy constructor (ref_count !)
00014 //   2004/09/17 Peter Vanroose - made dimensionality() non-virtual - it just returns a member and should not be overloaded
00015 // \endverbatim
00016 
00017 #include <vbl/vbl_ref_count.h>
00018 #include <vcsl/vcsl_coordinate_system_sptr.h>
00019 #include <vcsl/vcsl_axis_sptr.h>
00020 #include <vcl_vector.h>
00021 #include <vnl/vnl_vector.h>
00022 class vcsl_spatial;
00023 
00024 //: Abstract coordinate system
00025 class vcsl_coordinate_system
00026   : public vbl_ref_count
00027 {
00028   //***************************************************************************
00029   // Constructors/Destructor
00030   //***************************************************************************
00031 
00032  protected:
00033   // Default constructor
00034   vcsl_coordinate_system() {}
00035 
00036  public:
00037   // Copy constructor
00038   vcsl_coordinate_system(vcsl_coordinate_system const& c)
00039     : vbl_ref_count(), axes_(c.axes_) {}
00040 
00041   // Destructor
00042   virtual ~vcsl_coordinate_system() {}
00043 
00044   //***************************************************************************
00045   // Status report
00046   //***************************************************************************
00047 
00048   //: Number of axes
00049   int dimensionality() const { return int(axes_.size()); }
00050 
00051   //: Is `i' an index on an axis ?
00052   bool valid_axis(unsigned int i) const { return i < axes_.size(); }
00053 
00054   //: Return the axis `i'
00055   //  REQUIRE: valid_axis(i)
00056   vcsl_axis_sptr axis(int i) const;
00057 
00058   //***************************************************************************
00059   // Because VXL does not necessarily use dynamic_cast<>
00060   //***************************************************************************
00061   virtual const vcsl_spatial *cast_to_spatial() const { return 0; }
00062 
00063   //***************************************************************************
00064   // Conversion
00065   //***************************************************************************
00066 
00067   //: Convert `v', expressed with cs units, to standard units
00068   //  REQUIRE: v.size()==dimensionality()
00069   vnl_vector<double>
00070   from_cs_to_standard_units(const vnl_vector<double> &v) const;
00071 
00072   //: Convert `v', expressed with standard units, to cs units
00073   //  REQUIRE: v.size()==dimensionality()
00074   vnl_vector<double>
00075   from_standard_units_to_cs(const vnl_vector<double> &v) const;
00076 
00077  protected:
00078   //***************************************************************************
00079   // Implementation
00080   //***************************************************************************
00081 
00082   //: List of axes
00083   vcl_vector<vcsl_axis_sptr> axes_;
00084 };
00085 
00086 #endif // vcsl_coordinate_system_h_