00001 // This is gel/vtol/vtol_zero_chain.h 00002 #ifndef vtol_zero_chain_h_ 00003 #define vtol_zero_chain_h_ 00004 //----------------------------------------------------------------------------- 00005 //: 00006 // \file 00007 // \brief Represents a set of vertices 00008 // 00009 // The vtol_zero_chain class is used to represent a set of vertices on 00010 // a topological structure. A vtol_zero_chain maintains only the inferiors and 00011 // superiors, not the geometry. It is the topological inferior of an edge. 00012 // 00013 // \author 00014 // Patricia A. Vrobel 00015 // 00016 // \verbatim 00017 // Modifications: 00018 // JLM Dec 1995, Added timeStamp (Touch) to operations which affect bounds. 00019 // Peter Vanroose - 02-26-97 Added implementation for virtual Transform() 00020 // PTU may 2000 - ported to vxl 00021 // Dec. 2002, Peter Vanroose -interface change: vtol objects -> smart pointers 00022 // \endverbatim 00023 //----------------------------------------------------------------------------- 00024 00025 #include <vcl_iosfwd.h> 00026 #include <vcl_vector.h> 00027 #include <vtol/vtol_topology_object.h> 00028 #include <vtol/vtol_vertex.h> 00029 #include <vtol/vtol_vertex_sptr.h> 00030 #include <vtol/vtol_vertex_2d_sptr.h> 00031 #include <vtol/vtol_edge_2d_sptr.h> 00032 class vtol_vertex; 00033 class vtol_edge; 00034 class vtol_one_chain; 00035 class vtol_face; 00036 class vtol_two_chain; 00037 class vtol_block; 00038 00039 class vtol_zero_chain : public vtol_topology_object 00040 { 00041 public: 00042 //*************************************************************************** 00043 // Initialization 00044 //*************************************************************************** 00045 00046 //--------------------------------------------------------------------------- 00047 //: Default constructor. Empty zero-chain 00048 //--------------------------------------------------------------------------- 00049 vtol_zero_chain() {} 00050 00051 //--------------------------------------------------------------------------- 00052 //: Constructor from two vertices (to make edge creation easier) 00053 // REQUIRE: v1!=v2 00054 //--------------------------------------------------------------------------- 00055 vtol_zero_chain(vtol_vertex_sptr const& v1, 00056 vtol_vertex_sptr const& v2); 00057 00058 vtol_zero_chain(vtol_vertex_2d_sptr const& v1, 00059 vtol_vertex_2d_sptr const& v2); 00060 private: 00061 // Deprecated 00062 vtol_zero_chain(vtol_vertex &v1, vtol_vertex &v2); 00063 00064 public: 00065 //--------------------------------------------------------------------------- 00066 //: Constructor from an array of vertices 00067 // REQUIRE: new_vertices.size()>0 00068 //--------------------------------------------------------------------------- 00069 explicit vtol_zero_chain(const vertex_list &new_vertices); 00070 00071 //--------------------------------------------------------------------------- 00072 //: Pseudo copy constructor. Deep copy. 00073 //--------------------------------------------------------------------------- 00074 vtol_zero_chain(vtol_zero_chain_sptr const& other); 00075 private: 00076 //--------------------------------------------------------------------------- 00077 //: Copy constructor. Copy the vertices and the links. Deprecated. 00078 //--------------------------------------------------------------------------- 00079 vtol_zero_chain(const vtol_zero_chain &other); 00080 public: 00081 //--------------------------------------------------------------------------- 00082 //: Destructor 00083 //--------------------------------------------------------------------------- 00084 virtual ~vtol_zero_chain(); 00085 00086 //--------------------------------------------------------------------------- 00087 //: Clone `this': creation of a new object and initialization 00088 // See Prototype pattern 00089 //--------------------------------------------------------------------------- 00090 virtual vsol_spatial_object_2d* clone() const; 00091 00092 //: Return a platform independent string identifying the class 00093 virtual vcl_string is_a() const { return vcl_string("vtol_zero_chain"); } 00094 00095 //: Return true if the argument matches the string identifying the class or any parent class 00096 virtual bool is_class(vcl_string const& cls) const { return cls==is_a(); } 00097 00098 private: // has been superseded by is_a() 00099 //: Return the topology type 00100 virtual vtol_topology_object_type topology_type() const{return ZEROCHAIN;} 00101 00102 public: 00103 //--------------------------------------------------------------------------- 00104 //: Return the first vertex of `this'. If it does not exist, return 0 00105 //--------------------------------------------------------------------------- 00106 virtual vtol_vertex_sptr v0() const; 00107 00108 //*************************************************************************** 00109 // Replaces dynamic_cast<T> 00110 //*************************************************************************** 00111 00112 //--------------------------------------------------------------------------- 00113 //: Return `this' if `this' is a zero_chain, 0 otherwise 00114 //--------------------------------------------------------------------------- 00115 virtual const vtol_zero_chain *cast_to_zero_chain() const { return this; } 00116 00117 //--------------------------------------------------------------------------- 00118 //: Return `this' if `this' is a zero_chain, 0 otherwise 00119 //--------------------------------------------------------------------------- 00120 virtual vtol_zero_chain *cast_to_zero_chain() { return this; } 00121 00122 //*************************************************************************** 00123 // Status report 00124 //*************************************************************************** 00125 00126 void link_inferior(vtol_vertex_sptr inf); 00127 void unlink_inferior(vtol_vertex_sptr inf); 00128 void link_inferior(vtol_vertex_2d_sptr inf); 00129 void unlink_inferior(vtol_vertex_2d_sptr inf); 00130 00131 //--------------------------------------------------------------------------- 00132 //: Is `inferior' type valid for `this' ? 00133 //--------------------------------------------------------------------------- 00134 virtual bool valid_inferior_type(vtol_topology_object const* inferior) const 00135 { return inferior->cast_to_vertex()!=0; } 00136 bool valid_inferior_type(vtol_vertex_sptr const& ) const { return true; } 00137 bool valid_superior_type(vtol_edge_sptr const& ) const { return true; } 00138 bool valid_superior_type(vtol_edge_2d_sptr const& ) const { return true; } 00139 00140 //--------------------------------------------------------------------------- 00141 //: Return the length of the zero-chain 00142 //--------------------------------------------------------------------------- 00143 int length() const { return numinf(); } 00144 00145 //--------------------------------------------------------------------------- 00146 //: Is `this' equal to `other' ? 00147 //--------------------------------------------------------------------------- 00148 virtual bool operator==(const vtol_zero_chain &other) const; 00149 inline bool operator!=(const vtol_zero_chain &other)const{return !operator==(other);} 00150 bool operator==(const vsol_spatial_object_2d& obj) const; // virtual of vsol_spatial_object_2d 00151 00152 virtual void print(vcl_ostream &strm=vcl_cout) const; 00153 virtual void describe(vcl_ostream &strm=vcl_cout, 00154 int blanking=0) const; 00155 00156 //: \warning these should not be used by clients 00157 protected: 00158 virtual vcl_vector<vtol_vertex*> *compute_vertices(); 00159 virtual vcl_vector<vtol_edge*> *compute_edges(); 00160 virtual vcl_vector<vtol_zero_chain*> *compute_zero_chains(); 00161 virtual vcl_vector<vtol_one_chain*> *compute_one_chains(); 00162 virtual vcl_vector<vtol_face*> *compute_faces(); 00163 virtual vcl_vector<vtol_two_chain*> *compute_two_chains(); 00164 virtual vcl_vector<vtol_block*> *compute_blocks(); 00165 }; 00166 00167 #endif // vtol_zero_chain_h_