00001 // This is brl/bseg/sdet/sdet_fit_lines_params.cxx 00002 #include "sdet_fit_lines_params.h" 00003 //: 00004 // \file 00005 // See sdet_fit_lines_params.h 00006 // 00007 //----------------------------------------------------------------------------- 00008 #include <vcl_sstream.h> 00009 #include <vcl_iostream.h> 00010 00011 //------------------------------------------------------------------------ 00012 // Constructors 00013 // 00014 00015 sdet_fit_lines_params:: 00016 sdet_fit_lines_params(const sdet_fit_lines_params& flp) 00017 : gevd_param_mixin(), vbl_ref_count() 00018 { 00019 InitParams(flp.min_fit_length_, 00020 flp.rms_distance_); 00021 } 00022 00023 sdet_fit_lines_params:: 00024 sdet_fit_lines_params(int min_fit_length, 00025 double rms_distance) 00026 { 00027 InitParams(min_fit_length, rms_distance); 00028 } 00029 00030 void sdet_fit_lines_params::InitParams(int min_fit_length, 00031 double rms_distance) 00032 { 00033 min_fit_length_ = min_fit_length; 00034 rms_distance_ = rms_distance; 00035 } 00036 00037 //----------------------------------------------------------------------------- 00038 // 00039 //: Checks that parameters are within acceptable bounds 00040 bool sdet_fit_lines_params::SanityCheck() 00041 { 00042 // Note that msg << ends seems to restart the string and erase the 00043 // previous string. We should only use it as the last call, use 00044 // vcl_endl otherwise. 00045 vcl_stringstream msg; 00046 bool valid = true; 00047 00048 if (min_fit_length_<3) 00049 { 00050 msg << "ERROR: need at least 3 points for a fit\n"; 00051 valid = false; 00052 } 00053 if (rms_distance_>1) 00054 { 00055 msg << "ERROR: a line fit should be better than one pixel rms\n"; 00056 valid = false; 00057 } 00058 msg << vcl_ends; 00059 00060 SetErrorMsg(msg.str().c_str()); 00061 return valid; 00062 } 00063 00064 vcl_ostream& operator << (vcl_ostream& os, const sdet_fit_lines_params& flp) 00065 { 00066 return 00067 os << "sdet_fit_lines_params:\n[---\n" 00068 << "min fit length " << flp.min_fit_length_ << vcl_endl 00069 << "rms distance tolerance" << flp.rms_distance_ << vcl_endl 00070 << "---]\n"; 00071 }