Graphviz 13.0.0~dev.20241222.1117
Loading...
Searching...
No Matches
generate-constraints.h
Go to the documentation of this file.
1
18#pragma once
19#include <iostream>
20#include <vector>
21
22class Rectangle {
23 friend std::ostream& operator <<(std::ostream &os, const Rectangle &r);
24public:
25 Rectangle(double x, double X, double y, double Y);
26 double getMaxX() const { return maxX; }
27 double getMaxY() const { return maxY; }
28 double getMinX() const { return minX; }
29 double getMinY() const { return minY; }
30 double getCentreX() const { return minX+width()/2.0; }
31 double getCentreY() const { return minY+height()/2.0; }
32 double width() const { return getMaxX()-minX; }
33 double height() const { return getMaxY()-minY; }
34 double overlapX(const Rectangle &r) const {
35 if (getCentreX() <= r.getCentreX() && r.minX < getMaxX())
36 return getMaxX() - r.minX;
37 if (r.getCentreX() <= getCentreX() && minX < r.getMaxX())
38 return r.getMaxX() - minX;
39 return 0;
40 }
41 double overlapY(const Rectangle &r) const {
42 if (getCentreY() <= r.getCentreY() && r.minY < getMaxY())
43 return getMaxY() - r.minY;
44 if (r.getCentreY() <= getCentreY() && minY < r.getMaxY())
45 return r.getMaxY() - minY;
46 return 0;
47 }
48private:
49 double minX,maxX,minY,maxY;
50};
51
52
53struct Variable;
54struct Constraint;
55
56// returns number of constraints generated
57int generateXConstraints(const std::vector<Rectangle> &rs, Variable** vars,
58 Constraint** &cs, const bool useNeighbourLists);
59int generateYConstraints(const std::vector<Rectangle> &rs, Variable** vars,
60 Constraint** &cs);
Functions to automatically generate constraints for the rectangular node overlap removal problem.
double getMaxX() const
double width() const
double getCentreY() const
double getCentreX() const
double overlapX(const Rectangle &r) const
double getMinY() const
double getMaxY() const
double overlapY(const Rectangle &r) const
friend std::ostream & operator<<(std::ostream &os, const Rectangle &r)
double height() const
double getMinX() const
#define Y(i)
Definition gdefs.h:3
#define X(prefix, name, str, type, subtype,...)
Definition gdefs.h:14
int generateYConstraints(const std::vector< Rectangle > &rs, Variable **vars, Constraint **&cs)
int generateXConstraints(const std::vector< Rectangle > &rs, Variable **vars, Constraint **&cs, const bool useNeighbourLists)
A constraint determines a minimum or exact spacing required between two variables.
Definition constraint.h:25