1 //This is brl/bbas/volm/volm_spherical_region.h 2 #ifndef volm_spherical_region_h_ 3 #define volm_spherical_region_h_ 4 //: 5 // \file 6 // \brief A class to store a spherical region in the form of a polygon and its bounding box. 7 // Units are in meters 8 // 9 // \author Vishal Jain 10 // \date Feb 27, 2013 11 // \verbatim 12 // Modifications 13 // None 14 // \endverbatim 15 16 #include <vector> 17 #include <iostream> 18 #include <string> 19 #include <algorithm> 20 #include <vsph/vsph_sph_box_2d.h> 21 #ifdef _MSC_VER 22 # include <vcl_msvc_warnings.h> 23 #endif 24 25 //const char* spherical_attributes_names[] = {"MIN_DEPTH","MAX_DEPTH","DEPTH_ORDER","DEPTH_INTERVAL","ORIENTATION","NLCD","SKY"}; 26 enum spherical_region_attributes 27 { 28 MIN_DEPTH = 0, 29 MAX_DEPTH, 30 DEPTH_ORDER, 31 DEPTH_INTERVAL, 32 ORIENTATION, 33 NLCD, 34 SKY, 35 GROUND 36 }; 37 38 // Currently the spherical region has a bounding box for a region but will be appended to have a polygon as well. 39 class volm_spherical_region 40 { 41 public: volm_spherical_region(vsph_sph_box_2d box)42 volm_spherical_region(vsph_sph_box_2d box):box_(box){} 43 //:accessors bbox_ref()44 const vsph_sph_box_2d& bbox_ref() {return box_;} 45 46 //: function to check if an attribute exists for this region 47 bool is_attribute(spherical_region_attributes att); 48 49 //: set the value of the attribute set_attribute(spherical_region_attributes att,unsigned char value)50 void set_attribute(spherical_region_attributes att, unsigned char value){attributes_[att]=value;} 51 52 //: returns false if the attribute does not exist. 53 bool attribute_value(spherical_region_attributes att, unsigned char & value); 54 55 56 //: returns the existing attribute types for this region 57 std::vector<spherical_region_attributes> attribute_types(); 58 void print(std::ostream& os) ; 59 60 private: 61 //: box in spherical coordinates 62 vsph_sph_box_2d box_; 63 64 //: asusming all the ttrinuites require values 0-255. 65 std::map<spherical_region_attributes,unsigned char > attributes_; 66 }; 67 68 69 // container to store a group of regions and a dictionary for the attributes. 70 class volm_spherical_regions_layer 71 { 72 public: 73 volm_spherical_regions_layer()= default; 74 void add_region(const volm_spherical_region& region); regions()75 std::vector<volm_spherical_region> & regions(){return regions_;} size()76 int size(){return regions_.size();} 77 //std::vector<unsigned int> attributed_regions(spherical_region_attributes att, unsigned char value); 78 //: returns the existing attribute types for this region 79 std::map<unsigned char,std::vector<unsigned int > > attributed_regions_by_type(spherical_region_attributes att); 80 std::vector<unsigned int > attributed_regions_by_type_only(spherical_region_attributes att); 81 //: returns the existing attribute vlaues for this region 82 std::vector<unsigned int> attributed_regions_by_value(spherical_region_attributes att,unsigned char & val); 83 84 private: 85 std::vector<volm_spherical_region> regions_; 86 void update_attribute_map(int id); 87 //: map of attribute types and values ( need to make a map of attrobute values ) 88 std::map<spherical_region_attributes,std::map<unsigned char, std::vector<unsigned int> > > attributed_regions_; 89 }; 90 91 #endif // volm_spherical_region_h_ 92