blocks.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * \brief A block structure defined over the variables
  3. *
  4. * A block structure defined over the variables such that each block contains
  5. * 1 or more variables, with the invariant that all constraints inside a block
  6. * are satisfied by keeping the variables fixed relative to one another
  7. *
  8. * Authors:
  9. * Tim Dwyer <[email protected]>
  10. *
  11. * Copyright (C) 2005 Authors
  12. *
  13. * This version is released under the CPL (Common Public License) with
  14. * the Graphviz distribution.
  15. * A version is also available under the LGPL as part of the Adaptagrams
  16. * project: https://github.com/mjwybrow/adaptagrams.
  17. * If you make improvements or bug fixes to this code it would be much
  18. * appreciated if you could also contribute those changes back to the
  19. * Adaptagrams repository.
  20. */
  21. #pragma once
  22. #define LOGFILE "cRectangleOverlap.log"
  23. #include <set>
  24. #include <list>
  25. class Block;
  26. struct Variable;
  27. struct Constraint;
  28. /**
  29. * A block structure defined over the variables such that each block contains
  30. * 1 or more variables, with the invariant that all constraints inside a block
  31. * are satisfied by keeping the variables fixed relative to one another
  32. */
  33. class Blocks : public std::set<Block*>
  34. {
  35. public:
  36. Blocks(const int n, Variable *vs[]);
  37. ~Blocks();
  38. void mergeLeft(Block *r);
  39. void mergeRight(Block *l);
  40. void split(Block *b, Block *&l, Block *&r, Constraint *c);
  41. std::list<Variable*> totalOrder();
  42. void cleanup();
  43. double cost();
  44. private:
  45. void dfsVisit(Variable *v, std::list<Variable*> &order);
  46. void removeBlock(Block *doomed);
  47. Variable **vs;
  48. int nvs;
  49. };
  50. extern long blockTimeCtr;