contrib/gel/vtol/vtol_vertex.h
Go to the documentation of this file.
00001 // This is gel/vtol/vtol_vertex.h
00002 #ifndef vtol_vertex_h_
00003 #define vtol_vertex_h_
00004 //:
00005 // \file
00006 // \brief Topological container for a spatial point, without geometry info
00007 //
00008 //  The vtol_vertex class is used to represent either a 2D or 3D point on
00009 //  a topological structure.  A vtol_vertex does not actually maintain a pointer
00010 //  to the vsol_point which is the actual spatial point, since this could either
00011 //  be a vsol_point_2d or a vsol_point_3d.  See vtol_vertex_2d for this purpose.
00012 //
00013 // \verbatim
00014 //  Modifications:
00015 //   JLM December 1995, Added timeStamp(touch) to operations which affect bounds
00016 //   JLM October 1996,  Added the method EuclideanDistance(vtol_vertex &)
00017 //                      to permit Charlie Rothwell's Polyhedra code to be more
00018 //                      generic.  Note this is distance, NOT squared distance.
00019 //   LEG May 2000. ported to vxl
00020 //   Dec. 2002, Peter Vanroose -interface change: vtol objects -> smart pointers
00021 //   Sept.2004, Peter Vanroose -is_endpoint() now accepts smart pointer argument
00022 // \endverbatim
00023 
00024 #include <vtol/vtol_topology_object.h>
00025 #include <vcl_iosfwd.h>
00026 class vtol_vertex_2d;
00027 class vtol_edge;
00028 class vtol_zero_chain;
00029 class vtol_one_chain;
00030 class vtol_face;
00031 class vtol_two_chain;
00032 class vtol_block;
00033 
00034 class vtol_vertex : public vtol_topology_object
00035 {
00036  public:
00037   //***************************************************************************
00038   // Initialization
00039   //***************************************************************************
00040 
00041   //---------------------------------------------------------------------------
00042   //: Default constructor
00043   //---------------------------------------------------------------------------
00044   vtol_vertex() {}
00045 
00046   //---------------------------------------------------------------------------
00047   //: Destructor
00048   //---------------------------------------------------------------------------
00049   virtual ~vtol_vertex();
00050 
00051   // Accessors
00052 
00053  private: // has been superseded by is_a()
00054   //: Return the topology type
00055   virtual vtol_topology_object_type topology_type() const { return VERTEX; }
00056 
00057  public:
00058   //---------------------------------------------------------------------------
00059   //: create a list of all connected vertices
00060   //---------------------------------------------------------------------------
00061   virtual void explore_vertex(vertex_list &);
00062 
00063   //---------------------------------------------------------------------------
00064   //: Is `this' has the same coordinates for its point than `other' ?
00065   //---------------------------------------------------------------------------
00066   virtual bool operator==(const vtol_vertex &other) const;
00067   inline bool operator!=(const vtol_vertex &other)const{return !operator==(other);}
00068   bool operator==(const vsol_spatial_object_2d& obj) const; // virtual of vsol_spatial_object_2d
00069 
00070   //---------------------------------------------------------------------------
00071   //: Assignment of `this' with `other' (copy the point not the links)
00072   //---------------------------------------------------------------------------
00073   virtual vtol_vertex& operator=(const vtol_vertex &other);
00074 
00075   //***************************************************************************
00076   // Replaces dynamic_cast<T>
00077   //***************************************************************************
00078 
00079   //---------------------------------------------------------------------------
00080   //: Return `this' if `this' is a vertex, 0 otherwise
00081   //---------------------------------------------------------------------------
00082   virtual const vtol_vertex *cast_to_vertex() const { return this; }
00083 
00084   //---------------------------------------------------------------------------
00085   //: Return `this' if `this' is a vertex, 0 otherwise
00086   //---------------------------------------------------------------------------
00087   virtual vtol_vertex *cast_to_vertex() { return this; }
00088 
00089   //---------------------------------------------------------------------------
00090   //: Return `this' if `this' is a 2D vertex, 0 otherwise
00091   //---------------------------------------------------------------------------
00092   virtual const vtol_vertex_2d *cast_to_vertex_2d() const {return 0;}
00093 
00094   //---------------------------------------------------------------------------
00095   //: Return `this' if `this' is a 2D vertex, 0 otherwise
00096   //---------------------------------------------------------------------------
00097   virtual vtol_vertex_2d *cast_to_vertex_2d() {return 0;}
00098 
00099   //***************************************************************************
00100   // Status report
00101   //***************************************************************************
00102 
00103   //---------------------------------------------------------------------------
00104   //: Is `inferior' type valid for `this' ?
00105   //---------------------------------------------------------------------------
00106   virtual bool valid_inferior_type(vtol_topology_object const* /*inf*/) const
00107   { return false; } // a vertex can never have an inferior
00108   bool valid_superior_type(vtol_zero_chain_sptr const& ) const { return true; }
00109 
00110   //---------------------------------------------------------------------------
00111   //: Is `this' connected with `v2' ?
00112   //  ie has a superior of `this' `v2' as inferior ?
00113   //---------------------------------------------------------------------------
00114   virtual bool is_connected(vtol_vertex_sptr const& v2) const;
00115 
00116   // methods that will be defined by inherited classes
00117 
00118   //---------------------------------------------------------------------------
00119   //: Create a line edge from `this' and `other' only if this edge does not exist.
00120   //  Otherwise it just returns the existing edge
00121   //  REQUIRE: other!=*this
00122   //---------------------------------------------------------------------------
00123 
00124   virtual vtol_edge_sptr new_edge(vtol_vertex_sptr const& other)=0;
00125  private: // deprecated:
00126   vtol_edge_sptr new_edge(vtol_vertex const& other);
00127  public:
00128 
00129   //: check to see if the vertex is part of the edge
00130   bool is_endpoint(vtol_edge_sptr const&) const;
00131 
00132   void print(vcl_ostream &strm=vcl_cout) const;
00133   void describe(vcl_ostream &strm=vcl_cout, int blanking=0) const;
00134 
00135   //: Return a platform independent string identifying the class
00136   virtual vcl_string is_a() const { return vcl_string("vtol_vertex"); }
00137 
00138   //: Return true if the argument matches the string identifying the class or any parent class
00139   virtual bool is_class(const vcl_string& cls) const { return cls==is_a(); }
00140 
00141   //: have the inherited classes copy the geometry
00142   virtual void copy_geometry(const vtol_vertex &other)=0;
00143   virtual bool compare_geometry(const vtol_vertex &other) const =0;
00144 
00145  protected:
00146   // \warning these should not be used by clients
00147 
00148   virtual vcl_vector<vtol_vertex*> *compute_vertices();
00149   virtual vcl_vector<vtol_edge*> *compute_edges();
00150   virtual vcl_vector<vtol_zero_chain*> *compute_zero_chains();
00151   virtual vcl_vector<vtol_one_chain*> *compute_one_chains();
00152   virtual vcl_vector<vtol_face*> *compute_faces();
00153   virtual vcl_vector<vtol_two_chain*> *compute_two_chains();
00154   virtual vcl_vector<vtol_block*> *compute_blocks();
00155 };
00156 
00157 #endif // vtol_vertex_h_