findopenrect.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _FINDOPENRECT_H
  2. #define _FINDOPENRECT_H
  3. #include <bfc/wasabi_std.h>
  4. #include <bfc/ptrlist.h>
  5. class FindOpenRect
  6. {
  7. public:
  8. FindOpenRect();
  9. typedef double (*compareRectsFn)(const RECT &rect, const RECT &dest, unsigned long userdata, unsigned long userdata2, int index, double bsf);
  10. static double compare_overlapArea(const RECT &rect, const RECT &dest, unsigned long userdata = 0, unsigned long userdata2 = 0, int index = 0, double bsf = 0);
  11. void setCompareRectsFn(compareRectsFn fn);
  12. // this one does it all in one call
  13. RECT find(const RECT &viewport, const PtrList<RECT> &list,
  14. const RECT &prev, unsigned long userdata = 0, unsigned long userdata2 = 0);
  15. // these let you do it over time
  16. void beginFind(const RECT &viewport, const PtrList<RECT> &list,
  17. const RECT &prev, unsigned long userdata = 0, unsigned long userdata2 = 0);
  18. RECT findMore();
  19. double trySingleRect(const RECT &r, int early_out = FALSE);
  20. void setTimeLimit(int ms);
  21. int getNumIters();
  22. void resetNumIters();
  23. double getBestValSoFar();
  24. RECT getBestRectSoFar();
  25. // this only sets it if it's a better value
  26. void setBestSoFar(double bsf, const RECT &bestrect);
  27. RECT getOriginalRect();
  28. void setCoordDivisor(int xdiv, int ydiv);
  29. private:
  30. RECT vr, prev;
  31. PtrList<RECT> list;
  32. compareRectsFn fn;
  33. unsigned long userdata, userdata2;
  34. int timelimit;
  35. int iters;
  36. int xdiv, ydiv;
  37. RECT bsfrect;
  38. double bsfval;
  39. double bsfdist;
  40. //CUT RECT bsf_nooverlap;
  41. //CUT int found_nooverlap;
  42. //CUT RECT bsf_overlap;
  43. //CUT double bsfval_nooverlap;
  44. //CUT double bsfval_overlap;
  45. };
  46. #endif