GCOP  1.0
dem.h
Go to the documentation of this file.
00001 #ifndef GCOP_DEM_H
00002 #define GCOP_DEM_H
00003 
00004 namespace gcop {
00005 
00011   class Dem {
00012   public:
00013     Dem();
00014 
00022     Dem(const char *fname, double cs = 1.0, double ds = 1.0, const double *o = 0);
00023 
00032     Dem(double w, double h, double cs = 1.0, double ds = 1.0, const double* o = 0);
00033     
00038     Dem(const Dem &dem);
00039     
00040     virtual ~Dem();
00041 
00048     virtual bool IsValid(double x, double y) const;
00049 
00056     virtual double Get(double x, double y) const;
00057 
00065     double GetNormal(double n[3], double x, double y) const;
00066 
00073     const double* GetNormal(double x, double y) const;
00074 
00081     virtual void Get(double *p, int i, int j) const;    
00082 
00089     void Set(int i, int j, double z);
00090 
00101     void Set(double x, double y, double z, double s = 0);    
00102 
00106     void Clear();
00107 
00108     void Scale(double s);
00109 
00117     bool Inside(double x, double y, double z) const;
00118 
00123     void Load(const char *fname);
00124 
00131     const double* GetNormal(int i, int j) const;
00132 
00136     void ComputeNormals();
00137 
00141     static double bilinterp(const double* z, int w, int h, double xi, double yi, double eps = 1e-10);
00142 
00148     void Dilate(double r, bool cube = true);
00149     
00154     void AddBoundary(double h);
00155 
00164     void Convolve(double sigma, bool cn = true, double thresh = 0);
00165     
00166     void Point2Index(int &i, int &j, double x, double y) const;
00167 
00168     void Index2Point(double &x, double &y, int i, int j) const;
00169 
00170 
00171     double w;          
00172     double h;          
00173     double cs;         
00174     double ds;         
00175     double o[3];       
00176     int ni;            
00177     int nj;            
00178     double *data;      
00179     double *odata;     
00180         
00181     double *normals;   
00182 
00183     double eps;        
00184   };
00185 
00186 
00187   inline bool Dem::IsValid(double x, double y) const
00188     {
00189       return 
00190         x - o[0] >= -eps && x - o[0] <= w + eps && 
00191         y - o[1] >= -eps && y - o[1] <= h + eps;
00192     }
00193   
00194 };
00195 
00196 
00197 
00198 #endif