Go to the documentation of this file.00001
00002 #include "vtol_vertex.h"
00003
00004
00005
00006 #include <vtol/vtol_zero_chain.h>
00007 #include <vtol/vtol_edge.h>
00008 #include <vtol/vtol_face.h>
00009 #include <vtol/vtol_macros.h>
00010 #include <vtol/vtol_list_functions.h>
00011 #include <vcl_algorithm.h>
00012 #include <vcl_cassert.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021 vtol_vertex::~vtol_vertex()
00022 {
00023 unlink_all_inferiors();
00024 }
00025
00026
00027
00028
00029
00030
00031
00032 vcl_vector<vtol_vertex*> *vtol_vertex::compute_vertices()
00033 {
00034 LIST_SELF(vtol_vertex);
00035 }
00036
00037
00038 vcl_vector<vtol_zero_chain*>* vtol_vertex::compute_zero_chains()
00039 {
00040 SEL_SUP(vtol_zero_chain,compute_zero_chains);
00041 }
00042
00043
00044
00045 vcl_vector<vtol_edge*>* vtol_vertex::compute_edges()
00046 {
00047 SEL_SUP(vtol_edge,compute_edges);
00048 }
00049
00050
00051 vcl_vector<vtol_one_chain*>* vtol_vertex::compute_one_chains()
00052 {
00053 SEL_SUP(vtol_one_chain,compute_one_chains);
00054 }
00055
00056
00057 vcl_vector<vtol_face*>* vtol_vertex::compute_faces()
00058 {
00059 SEL_SUP(vtol_face,compute_faces);
00060 }
00061
00062
00063 vcl_vector<vtol_two_chain*>* vtol_vertex::compute_two_chains()
00064 {
00065 SEL_SUP(vtol_two_chain,compute_two_chains);
00066 }
00067
00068
00069 vcl_vector<vtol_block*>* vtol_vertex::compute_blocks()
00070 {
00071 SEL_SUP(vtol_block,compute_blocks);
00072 }
00073
00074
00075
00076
00077
00078
00079
00080 void vtol_vertex::print(vcl_ostream &strm) const
00081 {
00082 strm<< "<vtol_vertex " << (void const *)this<<"> with id "
00083 << get_id() << vcl_endl;
00084 }
00085
00086
00087
00088 void vtol_vertex::describe(vcl_ostream &strm,
00089 int blanking) const
00090 {
00091 for (int i=0; i<blanking; ++i) strm << ' ';
00092 print(strm);
00093 describe_inferiors(strm, blanking);
00094 describe_superiors(strm, blanking);
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 bool vtol_vertex::is_connected(vtol_vertex_sptr const& v2) const
00107 {
00108 edge_list vertedges; edges(vertedges);
00109 for (edge_list::const_iterator i=vertedges.begin(); i!=vertedges.end(); ++i)
00110 if ((*i)->is_endpoint(v2))
00111 return true;
00112 return false;
00113 }
00114
00115
00116
00117 bool vtol_vertex::is_endpoint(vtol_edge_sptr const& e) const
00118 {
00119 edge_list e_list; this->edges(e_list);
00120 return vcl_find(e_list.begin(),e_list.end(),e)!=e_list.end();
00121 }
00122
00123
00124
00125
00126 vtol_vertex &vtol_vertex::operator=(const vtol_vertex &other)
00127 {
00128 if (this!=&other)
00129 {
00130 this->copy_geometry(other);
00131
00132
00133
00134 touch();
00135 }
00136 return *this;
00137 }
00138
00139
00140
00141 bool vtol_vertex::operator==(const vsol_spatial_object_2d& obj) const
00142 {
00143 return
00144 obj.cast_to_topology_object() &&
00145 obj.cast_to_topology_object()->cast_to_vertex() &&
00146 *this == *obj.cast_to_topology_object()->cast_to_vertex();
00147 }
00148
00149
00150
00151
00152
00153 bool vtol_vertex::operator== (const vtol_vertex &other) const
00154 {
00155 return this==&other || compare_geometry(other);
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 void vtol_vertex::explore_vertex(vertex_list &verts)
00172 {
00173
00174
00175
00176 edge_list e_list; this->edges(e_list);
00177 for (edge_list::iterator i=e_list.begin();i!=e_list.end();++i)
00178 {
00179 vtol_edge_sptr e=*i;
00180 vtol_vertex_sptr vv;
00181 if (e->v1()==this)
00182 vv=e->v2();
00183 else if (e->v2()==this)
00184 vv=e->v1();
00185 else
00186 {
00187 vcl_cerr << "Explore vtol_vertex: shouldn't get this\n";
00188 assert(false);
00189 continue;
00190 }
00191
00192 if (vcl_find(verts.begin(),verts.end(),vv)==verts.end())
00193 {
00194 verts.push_back(vv);
00195 vv->explore_vertex(verts);
00196 }
00197 }
00198 }