00001 #include "segv_vtol_soview2D.h" 00002 //: 00003 // \file 00004 #include <vcl_iostream.h> 00005 #include <vgui/vgui_gl.h> 00006 #include <vdgl/vdgl_digital_curve.h> 00007 #include <vdgl/vdgl_interpolator.h> 00008 #include <vdgl/vdgl_edgel_chain.h> 00009 #include <vtol/vtol_face_2d.h> 00010 00011 //-------------------------------------------------------------------------- 00012 //: vtol_vertex_2d view 00013 //-------------------------------------------------------------------------- 00014 vcl_ostream& segv_vtol_soview2D_vertex::print(vcl_ostream& s) const 00015 { 00016 s << "[segv_vtol_soview2D_vertex " << x << ',' << y << ' '; 00017 return vgui_soview2D::print(s) << ']'; 00018 } 00019 00020 //-------------------------------------------------------------------------- 00021 //: vtol_edge_2d view 00022 //-------------------------------------------------------------------------- 00023 vcl_ostream& segv_vtol_soview2D_edge::print(vcl_ostream& s) const 00024 { 00025 return vgui_soview2D_linestrip::print(s); 00026 } 00027 00028 segv_vtol_soview2D_edge::segv_vtol_soview2D_edge(vtol_edge_2d_sptr const& e) 00029 { 00030 if (!e) 00031 { 00032 vcl_cout << "In segv_vtol_soview2D_edge(..) - null input edge\n"; 00033 return; 00034 } 00035 00036 //find out what kind of curve the edge has 00037 vsol_curve_2d_sptr c = e->curve(); 00038 if (!c) 00039 { 00040 vcl_cout << "In segv_vtol_soview2D_edge(..) - null curve\n"; 00041 return; 00042 } 00043 if (c->cast_to_vdgl_digital_curve()) 00044 { 00045 vdgl_digital_curve_sptr dc = c->cast_to_vdgl_digital_curve(); 00046 //get the edgel chain 00047 vdgl_interpolator_sptr itrp = dc->get_interpolator(); 00048 vdgl_edgel_chain_sptr ech = itrp->get_edgel_chain(); 00049 00050 //n, x, and y are in the parent class vgui_soview2D_linestrip 00051 n = ech->size(); 00052 //offset the coordinates for display (may not be needed) 00053 x = new float[n], y = new float[n]; 00054 for (unsigned int i=0; i<n;i++) 00055 { 00056 vdgl_edgel ed = (*ech)[i]; 00057 x[i] = (float)ed.get_x(); 00058 y[i] = (float)ed.get_y(); 00059 } 00060 return; 00061 } 00062 vcl_cout << "In segv_vtol_soview2D_edge(vtol_edge_2d_sptr& e) -" 00063 << " attempt to draw an edge with unknown curve geometry\n"; 00064 } 00065 00066 //-------------------------------------------------------------------------- 00067 //: vtol_edge_2d group view 00068 //-------------------------------------------------------------------------- 00069 00070 vcl_ostream& segv_vtol_soview2D_edge_group::print(vcl_ostream& s) const 00071 { 00072 return vgui_soview2D_group::print(s); 00073 } 00074 00075 segv_vtol_soview2D_edge_group:: 00076 segv_vtol_soview2D_edge_group(vcl_vector<vtol_edge_2d_sptr>& edges) 00077 { 00078 for (vcl_vector<vtol_edge_2d_sptr>::iterator eit = edges.begin(); 00079 eit != edges.end(); eit++) 00080 { 00081 vgui_soview2D* sov = new segv_vtol_soview2D_edge(*eit); 00082 ls.push_back(sov); 00083 } 00084 } 00085 //-------------------------------------------------------------------------- 00086 //: vtol_face_2d view 00087 //-------------------------------------------------------------------------- 00088 00089 vcl_ostream& segv_vtol_soview2D_face::print(vcl_ostream& s) const 00090 { 00091 return vgui_soview2D_group::print(s); 00092 } 00093 00094 segv_vtol_soview2D_face::segv_vtol_soview2D_face(vtol_face_2d_sptr& f) 00095 { 00096 if (!f) 00097 { 00098 vcl_cout << "In segv_vtol_soview2D_face(..) - null input face\n"; 00099 return; 00100 } 00101 edge_list edges; f->edges(edges); 00102 for (edge_list::iterator eit = edges.begin(); eit != edges.end(); ++eit) 00103 ls.push_back(new segv_vtol_soview2D_edge((*eit)->cast_to_edge_2d())); 00104 }