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