contrib/mul/mfpf/mfpf_edge_finder_builder.cxx
Go to the documentation of this file.
00001 #include "mfpf_edge_finder_builder.h"
00002 //:
00003 // \file
00004 // \brief Builder for mfpf_edge_finder objects.
00005 // \author Tim Cootes
00006 
00007 #include <mfpf/mfpf_edge_finder.h>
00008 #include <vsl/vsl_binary_loader.h>
00009 #include <vcl_sstream.h>
00010 #include <vcl_cassert.h>
00011 
00012 #include <mbl/mbl_parse_block.h>
00013 #include <mbl/mbl_read_props.h>
00014 #include <vgl/vgl_point_2d.h>
00015 #include <vgl/vgl_vector_2d.h>
00016 
00017 //=======================================================================
00018 // Dflt ctor
00019 //=======================================================================
00020 
00021 mfpf_edge_finder_builder::mfpf_edge_finder_builder()
00022 {
00023 }
00024 
00025 //=======================================================================
00026 // Destructor
00027 //=======================================================================
00028 
00029 mfpf_edge_finder_builder::~mfpf_edge_finder_builder()
00030 {
00031 }
00032 
00033 //: Define region size in world co-ordinates
00034 //  Sets up ROI to cover given box (with samples at step_size()),
00035 //  with ref point at centre.
00036 void mfpf_edge_finder_builder::set_region_size(double, double)
00037 {
00038   // NYI
00039 }
00040 
00041 //: Create new mfpf_edge_finder on heap
00042 mfpf_point_finder* mfpf_edge_finder_builder::new_finder() const
00043 {
00044   return new mfpf_edge_finder();
00045 }
00046 
00047 //: Initialise building
00048 // Must be called before any calls to add_example(...)
00049 void mfpf_edge_finder_builder::clear(unsigned /*n_egs*/)
00050 {
00051   // NYI
00052 }
00053 
00054 //: Add one example to the model
00055 void mfpf_edge_finder_builder::add_example(const vimt_image_2d_of<float>& /*image*/,
00056                                            const vgl_point_2d<double>& /*p*/,
00057                                            const vgl_vector_2d<double>& /*u*/)
00058 {
00059   // NYI
00060 }
00061 
00062 //: Build this object from the data supplied in add_example()
00063 void mfpf_edge_finder_builder::build(mfpf_point_finder& pf)
00064 {
00065   assert(pf.is_a()=="mfpf_edge_finder");
00066   mfpf_edge_finder& ef = static_cast<mfpf_edge_finder&>(pf);
00067   set_base_parameters(ef);
00068 }
00069 
00070 //=======================================================================
00071 // Method: set_from_stream
00072 //=======================================================================
00073 //: Initialise from a string stream
00074 bool mfpf_edge_finder_builder::set_from_stream(vcl_istream &is)
00075 {
00076   // Cycle through string and produce a map of properties
00077   vcl_string s = mbl_parse_block(is);
00078   vcl_istringstream ss(s);
00079   mbl_read_props_type props = mbl_read_props_ws(ss);
00080 
00081   search_ni_=5;
00082   // Extract the properties
00083   parse_base_props(props);
00084 
00085   // Check for unused props
00086   mbl_read_props_look_for_unused_props(
00087       "mfpf_edge_finder_builder::set_from_stream", props, mbl_read_props_type());
00088   return true;
00089 }
00090 
00091 //=======================================================================
00092 // Method: is_a
00093 //=======================================================================
00094 
00095 vcl_string mfpf_edge_finder_builder::is_a() const
00096 {
00097   return vcl_string("mfpf_edge_finder_builder");
00098 }
00099 
00100 //: Create a copy on the heap and return base class pointer
00101 mfpf_point_finder_builder* mfpf_edge_finder_builder::clone() const
00102 {
00103   return new mfpf_edge_finder_builder(*this);
00104 }
00105 
00106 //=======================================================================
00107 // Method: print
00108 //=======================================================================
00109 
00110 void mfpf_edge_finder_builder::print_summary(vcl_ostream& os) const
00111 {
00112   os << "{ ";
00113   mfpf_point_finder_builder::print_summary(os);
00114   os << " }";
00115 }
00116 
00117 //: Version number for I/O
00118 short mfpf_edge_finder_builder::version_no() const
00119 {
00120   return 1;
00121 }
00122 
00123 void mfpf_edge_finder_builder::b_write(vsl_b_ostream& bfs) const
00124 {
00125   vsl_b_write(bfs,version_no());
00126   mfpf_point_finder_builder::b_write(bfs);  // Save base class
00127 }
00128 
00129 //=======================================================================
00130 // Method: load
00131 //=======================================================================
00132 
00133 void mfpf_edge_finder_builder::b_read(vsl_b_istream& bfs)
00134 {
00135   if (!bfs) return;
00136   short version;
00137   vsl_b_read(bfs,version);
00138   switch (version)
00139   {
00140     case (1):
00141       mfpf_point_finder_builder::b_read(bfs);  // Load base class
00142       break;
00143     default:
00144       vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&)\n"
00145                << "           Unknown version number "<< version << vcl_endl;
00146       bfs.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on stream
00147       return;
00148   }
00149 }
00150