core/vcsl/vcsl_graph.h
Go to the documentation of this file.
00001 // This is core/vcsl/vcsl_graph.h
00002 #ifndef vcsl_graph_h_
00003 #define vcsl_graph_h_
00004 //:
00005 // \file
00006 // \brief Spatial coordinate system transformation graph
00007 // \author François BERTEL
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   2000/08/01 François BERTEL Creation.
00012 //   2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
00013 //   2002/01/28 Peter Vanroose - vcl_vector member vertices_ changed to non-ptr
00014 //   2004/09/10 Peter Vanroose - Added explicit copy constructor (ref_count !)
00015 //   2004/09/17 Peter Vanroose - made count() non-virtual - it just returns a member and should not be overloaded
00016 // \endverbatim
00017 
00018 #include <vbl/vbl_ref_count.h>
00019 #include <vcsl/vcsl_graph_sptr.h>
00020 #include <vcsl/vcsl_spatial_sptr.h>
00021 #include <vcl_vector.h>
00022 
00023 //: Spatial coordinate system transformation graph
00024 // Graph where nodes are spatial coordinate systems and arrows are
00025 // transformations. Only the nodes are in the graph class. The transformations
00026 // are in the spatial coordinates systems
00027 class vcsl_graph
00028   :public vbl_ref_count
00029 {
00030  public:
00031   //***************************************************************************
00032   // Constructors/Destructor
00033   //***************************************************************************
00034 
00035   // Default constructor
00036   vcsl_graph() {}
00037 
00038   // Copy constructor
00039   vcsl_graph(vcsl_graph const& x) : vbl_ref_count(), vertices_(x.vertices_) {}
00040 
00041   // Destructor
00042   ~vcsl_graph() {}
00043 
00044   //***************************************************************************
00045   // Measurement
00046   //***************************************************************************
00047 
00048   //: Number of coordinate systems
00049   unsigned int count() const { return (unsigned int)(vertices_.size()); }
00050 
00051   //***************************************************************************
00052   // Status report
00053   //***************************************************************************
00054 
00055   //: Has `this' `cs' as node ?
00056   bool has(const vcsl_spatial_sptr &cs) const;
00057 
00058   //: Is `index' valid in the list of the spatial coordinate systems ?
00059   bool valid_index(unsigned int index) const { return index < count(); }
00060 
00061   //***************************************************************************
00062   // Access
00063   //***************************************************************************
00064 
00065   //: Spatial coordinate system number `index'
00066   //  REQUIRE: valid_index(index)
00067   vcsl_spatial_sptr item(unsigned int index) const;
00068 
00069   //: Add `cs' in `this'
00070   //  REQUIRE: !has(cs)
00071   void put(const vcsl_spatial_sptr &cs);
00072 
00073   //: Remove `cs' from `this'
00074   //  REQUIRE: has(cs)
00075   void remove(const vcsl_spatial_sptr &cs);
00076 
00077   //***************************************************************************
00078   // Basic operations
00079   //***************************************************************************
00080 
00081   //: Set the flag `reached' to false for each spatial coordinate system.
00082   //  Used by the search path algorithm
00083   void init_vertices() const;
00084 
00085  protected:
00086 
00087   //: Vertices of the graph: all the spatial coordinate systems
00088   vcl_vector<vcsl_spatial_sptr> vertices_;
00089 };
00090 
00091 #endif // vcsl_graph_h_