dynamicvoronoi.h
Go to the documentation of this file.
00001 #ifndef _DYNAMICVORONOI_H_
00002 #define _DYNAMICVORONOI_H_
00003 
00004 
00005 #include <stdlib.h>
00006 #include <stdio.h>
00007 #include <limits.h>
00008 #include <queue>
00009 
00010 #include "bucketedqueue.h"
00011 
00013 class DynamicVoronoi {
00014   
00015 public:
00016   
00017   DynamicVoronoi();
00018   ~DynamicVoronoi();
00019 
00021   void initializeEmpty(int _sizeX, int _sizeY, bool initGridMap=true);
00023   void initializeMap(int _sizeX, int _sizeY, bool** _gridMap);
00024 
00026   void occupyCell(int x, int y);
00028   void clearCell(int x, int y);
00030   void exchangeObstacles(std::vector<INTPOINT> newObstacles);
00031 
00033   void update(bool updateRealDist=true);
00035   void prune();
00036   
00038   float getDistance( int x, int y );
00040   bool isVoronoi( int x, int y );
00042   bool isOccupied(int x, int y);
00044   void visualize(const char* filename="result.ppm");
00045 
00047   unsigned int getSizeX() {return sizeX;}
00049   unsigned int getSizeY() {return sizeY;}
00050 
00051 private:  
00052   struct dataCell {
00053     float dist;
00054     char voronoi;
00055     char queueing;
00056     int obstX;
00057     int obstY;
00058     bool needsRaise;
00059     int sqdist;
00060   };
00061 
00062   typedef enum {voronoiKeep=-4, freeQueued = -3, voronoiRetry=-2, voronoiPrune=-1, free=0, occupied=1} State;
00063   typedef enum {fwNotQueued=1, fwQueued=2, fwProcessed=3, bwQueued=4, bwProcessed=1} QueueingState;
00064   typedef enum {invalidObstData = SHRT_MAX/2} ObstDataState;
00065   typedef enum {pruned, keep, retry} markerMatchResult;
00066 
00067 
00068   
00069   // methods
00070   void setObstacle(int x, int y);
00071   void removeObstacle(int x, int y);
00072   inline void checkVoro(int x, int y, int nx, int ny, dataCell& c, dataCell& nc);
00073   void recheckVoro();
00074   void commitAndColorize(bool updateRealDist=true);
00075   inline void reviveVoroNeighbors(int &x, int &y);
00076 
00077   inline bool isOccupied(int &x, int &y, dataCell &c);
00078   inline markerMatchResult markerMatch(int x, int y);
00079 
00080   // queues
00081 
00082   BucketPrioQueue open;
00083   std::queue<INTPOINT> pruneQueue;
00084 
00085   std::vector<INTPOINT> removeList;
00086   std::vector<INTPOINT> addList;
00087   std::vector<INTPOINT> lastObstacles;
00088 
00089   // maps
00090   int sizeY;
00091   int sizeX;
00092   dataCell** data;
00093   bool** gridMap;
00094 
00095   // parameters
00096   int padding;
00097   double doubleThreshold;
00098 
00099   double sqrt2;
00100 
00101   //  dataCell** getData(){ return data; }
00102 };
00103 
00104 
00105 #endif
00106 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


dynamicvoronoi
Author(s): Boris Lau, Christoph Sprunk, Wolfram Burgard
autogenerated on Wed Dec 26 2012 16:35:03