00001 // This is gel/vtol/algo/vtol_extract_topology.cxx 00002 #include "vtol_extract_topology.h" 00003 //: 00004 // \file 00005 // \author Amitha Perera 00006 // \date July 2003 00007 00008 #include <vtol/vtol_vertex_2d.h> 00009 #include <vtol/vtol_edge_2d.h> 00010 #include <vtol/vtol_edge_sptr.h> 00011 #include <vtol/vtol_one_chain.h> 00012 00013 #include <vdgl/vdgl_edgel.h> 00014 #include <vdgl/vdgl_edgel_chain.h> 00015 00016 00017 // ============================================================================= 00018 // VERTEX NODE 00019 // ============================================================================= 00020 00021 00022 // --------------------------------------------------------------------------- 00023 // constructor 00024 00025 // If we include vbl_smart_ptr.txx in this file, Borland 55 will try 00026 // to instantiate vbl_smart_ptr<vsol_point_2d> and fail because 00027 // vsol_point_2d is incomplete. It seems to make the attempt because 00028 // of the vtol_vertex_2d constructor call. Any call to a function in 00029 // vtol_vertex_2d seems to cause the instantiation. I'm not sure if we 00030 // are running into a compiler bug or missing some subtle detail in 00031 // templates with incomplete types. -- Amitha Perera 00032 // 00033 // Uncommenting the following line will trigger the bug(?) with Borland. 00034 //#include <vbl/vbl_smart_ptr.txx> 00035 00036 vtol_extract_topology_vertex_node:: 00037 vtol_extract_topology_vertex_node( unsigned in_i, unsigned in_j ) 00038 : i( in_i ), 00039 j( in_j ), 00040 vertex( new vtol_vertex_2d( i-0.5, j-0.5 ) ) 00041 { 00042 // The edge[4] will already be default constructed to null. We need 00043 // to explicitly initialize the link[4] array since it is a built-in 00044 // type and thus will not be zero-initialized. 00045 for ( unsigned i = 0; i < 4; ++i ) { 00046 link[i] = null_index; 00047 back_dir[i] = 100; 00048 } 00049 } 00050 00051 00052 // ============================================================================= 00053 // REGION TYPE 00054 // ============================================================================= 00055 00056 00057 // --------------------------------------------------------------------------- 00058 // push back 00059 00060 void 00061 vtol_extract_topology_region_type:: 00062 push_back( edgel_chain_sptr chain ) 00063 { 00064 list_.push_back( chain ); 00065 } 00066 00067 00068 // --------------------------------------------------------------------------- 00069 // size 00070 00071 unsigned 00072 vtol_extract_topology_region_type:: 00073 size() const 00074 { 00075 return list_.size(); 00076 } 00077 00078 00079 // --------------------------------------------------------------------------- 00080 // operator [] 00081 00082 vdgl_edgel_chain_sptr const& 00083 vtol_extract_topology_region_type:: 00084 operator[]( unsigned i ) const 00085 { 00086 return list_[i]->chain; 00087 } 00088 00089 00090 // --------------------------------------------------------------------------- 00091 // make one chain 00092 00093 vtol_one_chain_sptr 00094 vtol_extract_topology_region_type:: 00095 make_one_chain( ) const 00096 { 00097 vcl_vector< vtol_edge_sptr > edges; 00098 00099 for ( unsigned i = 0; i < list_.size(); ++i ) { 00100 edges.push_back( &*list_[i]->edge ); 00101 } 00102 00103 return new vtol_one_chain( edges, /*is_cycle=*/ true ); 00104 } 00105 00106 00107 // ============================================================================= 00108 // NON-MEMBER FUNCTIONS 00109 // ============================================================================= 00110