1 #ifndef bwm_io_config_parser_h_ 2 #define bwm_io_config_parser_h_ 3 4 #include <iostream> 5 #include <string> 6 #include <vector> 7 #include <utility> 8 #include "bwm_io_structs.h" 9 #include <bwm/io/bwm_site_sptr.h> 10 11 #ifdef WIN32 12 #define _LIB 13 #endif 14 #include <expatpp.h> 15 #ifdef _MSC_VER 16 # include <vcl_msvc_warnings.h> 17 #endif 18 19 #include <vsol/vsol_point_2d.h> 20 #include <vsol/vsol_point_3d.h> 21 22 class bwm_io_config_parser : public expatpp 23 { 24 public: 25 bwm_io_config_parser(void); 26 // parser should not delete the site, it is used afterwards ~bwm_io_config_parser(void)27 ~bwm_io_config_parser(void) {} 28 site()29 bwm_site_sptr site() { return site_; } 30 #if 0 31 std::vector<std::vector<std::pair<std::string, vsol_point_2d> > > correspondences() const { return corresp_; } 32 std::string corresp_mode() const {return corr_mode_; } 33 std::string corresp_type() const {return corr_type_; } 34 std::vector<vsol_point_3d> corresp_world_pts() const {return corresp_world_pts_; } 35 #endif 36 // accessors for fiducial information fiducial_locations()37 std::vector<std::pair<float, float> > fiducial_locations() const {return fid_locs_;} fid_mode()38 std::string fid_mode() const {return fid_mode_;} fid_type()39 std::string fid_type() const {return fid_type_;} fid_site_name()40 std::string fid_site_name() const {return fid_site_name_;} fid_image_path()41 std::string fid_image_path() const {return image_path_;} fiducial_path()42 std::string fiducial_path() const {return fiducial_path_;} 43 private: 44 virtual void startElement(const XML_Char* name, const XML_Char** atts); 45 virtual void endElement(const XML_Char* name); 46 virtual void charData(const XML_Char* s, int len); 47 48 void handleAtts(const XML_Char** atts); 49 void cdataHandler(std::string name, std::string data); 50 void init_params(); 51 52 //Data 53 int mDepth; 54 std::string cdata; 55 std::string last_tag; 56 57 bwm_site_sptr site_; 58 59 // intermediate variables to keep values during parsing 60 std::string name_; 61 bool status_; 62 std::string image_path_; 63 std::string camera_path_; 64 std::string camera_type_; 65 std::string proj2d_type_; 66 std::string coin3d_name_; 67 std::string object_path_; 68 std::string object_type_; 69 double lat_, lon_, elev_; 70 71 // correspondence related parameters 72 //std::string corr_mode_; 73 //std::string corr_type_; 74 std::string corr_cam_tab_; 75 double X_, Y_, Z_; 76 #if 0 77 std::vector<std::vector<std::pair<std::string, vsol_point_2d> > > corresp_; 78 std::vector<vsol_point_3d> corresp_world_pts_; 79 #endif 80 std::vector<std::pair<std::string, vsol_point_2d> > corresp_elm_; 81 void trim_string(std::string& s); 82 // members for reading the fiducial file 83 std::string fid_site_name_; 84 std::string fiducial_path_; 85 std::string fid_mode_; 86 std::string fid_type_; 87 std::vector<std::pair<float, float> > fid_locs_; 88 }; 89 90 #endif 91