Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Decomp.hpp
Go to the documentation of this file.
00001 
00013 #ifndef LGL_DECOMPOSITION_HPP
00014 #define LGL_DECOMPOSITION_HPP
00015 
00016 #include <vector>
00017 
00018 #include <lgl/FlexGrid.hpp>
00019 #include <lgl/Location.hpp>
00020 #include <lgl/GeoData.hpp>
00021 #include <lgl/Attributes.hpp>
00022 
00023 namespace jafar { //namespace jafar
00024   namespace lgl { //namespace lgl
00025 
00026 
00027     //typedef struct DecompCluster {
00028     class DecompCluster { //{{{
00029       private:
00030         GeoData* raster;
00031         Attributes* att;
00032       public:
00034         int xsize;
00036         int ysize;
00037         
00042         DecompCluster(GeoData* _rast=NULL);
00043 
00053         DecompCluster(int _xsize,int _ysize, GeoData* _rast=NULL, int tlx=-1, int tly=-1);
00054           
00056         ~DecompCluster();
00057           
00058         void set(int _xsize, int _ysize) {
00059           xsize=_xsize;
00060           ysize=_ysize;
00061         }
00062         
00063         bool valid() { return ((xsize != 0) && (ysize != 0)); }
00064         
00065         bool isNegative() { return ((xsize < 0) && (ysize < 0)); }
00066 
00067         bool operator==(const  DecompCluster &rhs) const;
00068 
00069         DecompCluster& operator=(const DecompCluster& rdc);
00070 
00071         //==================== Attributes
00072         Attributes* getAttributes()
00073         {//{{{
00074           return att;
00075         }//}}}
00076 
00078                 bool hasBeenSet(attributeKey at_)
00079                 { //{{{
00080           if (att == NULL) { return false; }
00081                     return att->hasbeenset[at_];
00082                 } //}}}
00083 
00088                 bool setCertainty(attributeKey at_, double value_, bool reset_=true)
00089                 { //{{{
00090           if (att == NULL) { return false; }
00091                     att->set(at_, value_, reset_);
00092           return true;
00093                 } //}}}
00094 
00095                 double getEntropy(attributeClass _ac) const
00096                 { //{{{
00097           if (att == NULL) { return -1.0; }
00098                     return att->infotropy[_ac];
00099                 } //}}}
00100 
00101                 double getCertainty(attributeKey _at) const
00102                 { //{{{
00103           if (att == NULL) { return -1.0; }
00104                     return att->certainty[_at];
00105                 } //}}}
00106 
00107 
00108     //} DecompCluster;
00109     }; //}}}
00110 
00114     class Decomp {
00115 
00116       public:
00117           
00118         typedef FlexGrid<DecompCluster*> DecompT;
00119 
00120         enum SIDE { CLUSTER_TOP_SIDE, CLUSTER_RIGHT_SIDE, CLUSTER_BOTTOM_SIDE, CLUSTER_LEFT_SIDE };
00121           
00122         Decomp(GeoData* _raster);
00123 
00124         ~Decomp();
00125 
00126         int xbegin() const;
00127         int ybegin() const;
00128         int xend() const;
00129         int yend() const;
00130         int xsize() const;
00131         int ysize() const;
00132 
00133         int getNbClusters() const;
00134 
00136         DecompCluster* at(int i, int j);
00137 
00139         bool setCluster(const RasterRect& rect);
00140         bool setLeafCluster(const RasterRect& rect);
00141           
00142         // set the uniform cluster for the raster
00143         // rect.xsize must be divisible by raster.xsize rect.ysize must be divisible by raster.ysize
00144         bool setUniformClusters(const RasterRect& rect);
00145           
00155         bool getInOutPoints(const RasterCellIndex& root_cell, std::vector<NavLocation>& inout) const;
00156 
00157         bool consistancyCheck() const;
00158           
00159       private :
00160           
00161         // the raster ..
00162         GeoData* raster;
00163           
00164         DecompT decomp;
00165 
00171         bool clearCluster(const RasterRect& rect);
00172 
00174         bool clear();
00175             
00176         friend class Decomp_iterator;
00177         friend class NavGraph;
00178           
00179     };
00180 
00181     std::ostream& operator<<(std::ostream& out, const Decomp& decomp);
00182 
00187     class Decomp_iterator 
00188     {
00189       private:
00190         Decomp* data;
00191         int i,j;
00192           
00193 
00194         void increment();
00195         void incrementNextCluster();
00196 
00197       public:
00198         Decomp_iterator(const Decomp* _data);
00199 
00200         Decomp_iterator(const Decomp_iterator& _it);
00201 
00202         void begin();
00203           
00204         bool at_end() const;
00205         bool at_begin() const;
00206 
00207         // return the value for the iterator
00208         DecompCluster* operator*() const;
00209           
00210         // prefix increment the iterator pointer to the next cluster
00211         Decomp_iterator& operator++();
00212 
00213         // postfix increment the iterator pointer to the next cluster
00214         Decomp_iterator operator++(int);
00215 
00216         void getIndex(int& _i, int& _j) const;
00217 
00218     };
00219 
00220 
00221   }
00222 }
00223 
00224 #endif /* LGL_DECOMPOSITION_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:24 for Jafar by doxygen 1.7.6.1
LAAS-CNRS