variable.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. *
  3. * Authors:
  4. * Tim Dwyer <[email protected]>
  5. *
  6. * Copyright (C) 2005 Authors
  7. *
  8. * This version is released under the CPL (Common Public License) with
  9. * the Graphviz distribution.
  10. * A version is also available under the LGPL as part of the Adaptagrams
  11. * project: https://github.com/mjwybrow/adaptagrams.
  12. * If you make improvements or bug fixes to this code it would be much
  13. * appreciated if you could also contribute those changes back to the
  14. * Adaptagrams repository.
  15. */
  16. #pragma once
  17. #include <vector>
  18. #include <iostream>
  19. class Block;
  20. struct Constraint;
  21. #include <vpsc/block.h>
  22. typedef std::vector<Constraint*> Constraints;
  23. struct Variable
  24. {
  25. friend std::ostream& operator <<(std::ostream &os, const Variable &v);
  26. public:
  27. const int id; // useful in log files
  28. double desiredPosition;
  29. const double weight;
  30. double offset;
  31. Block *block = nullptr;
  32. bool visited;
  33. Constraints in;
  34. Constraints out;
  35. char *toString();
  36. Variable(const int id_, const double desiredPos_, const double weight_)
  37. : id(id_)
  38. , desiredPosition(desiredPos_)
  39. , weight(weight_)
  40. , offset(0)
  41. , visited(false)
  42. {
  43. }
  44. double position() const {
  45. return block->posn+offset;
  46. }
  47. };