27#ifndef VPSC_RECTANGLE_H
28#define VPSC_RECTANGLE_H
55 return static_cast<Dim>(!d);
71 void nearest(
double x,
double y,
double & xi,
double & yi);
90 Rectangle(
double x,
double X,
double y,
double Y,
107 void reset(
const unsigned d,
double x,
double X);
116 COLA_ASSERT(d==0||d==1);
123 COLA_ASSERT(d==0||d==1);
126 void setMinD(
unsigned const d,
const double val)
127 {
if ( d == 0) {
minX = val; }
else {
minY = val; } }
128 void setMaxD(
unsigned const d,
const double val)
129 {
if ( d == 0) {
maxX = val; }
else {
maxY = val; } }
136 COLA_ASSERT(d==0||d==1);
146 COLA_ASSERT(d==0||d==1);
152 COLA_ASSERT(d==0||d==1);
170 COLA_ASSERT(fabs(
width()-
w)<1e-9);
176 COLA_ASSERT(fabs(
height()-h)<1e-9);
222 bool overlaps(
double x1,
double y1,
double x2,
double y2);
225 void routeAround(
double x1,
double y1,
double x2,
double y2,
226 std::vector<double> &xs, std::vector<double> &ys);
251typedef std::vector<Variable *>
Variables;
290 bool thirdPass =
true);
297 template <
typename T>
A constraint determines a minimum or exact spacing required between two Variable objects.
A rectangle represents a fixed-size shape in the diagram that may be moved to prevent overlaps and sa...
double overlapX(Rectangle *r) const
void moveCentreD(const unsigned d, double p)
bool overlaps(double x1, double y1, double x2, double y2)
void moveCentreY(double y)
double overlapD(const unsigned d, Rectangle *r)
void setMaxD(unsigned const d, const double val)
void lineIntersections(double x1, double y1, double x2, double y2, RectangleIntersections &ri) const
static void setXBorder(double x)
double getCentreY() const
void offset(double dx, double dy)
void reset(const unsigned d, double x, double X)
double getCentreX() const
Rectangle unionWith(const Rectangle &rhs) const
void moveCentreX(double x)
void moveCentre(double x, double y)
void setMinD(unsigned const d, const double val)
bool inside(double x, double y) const
double getCentreD(unsigned const d) const
void routeAround(double x1, double y1, double x2, double y2, std::vector< double > &xs, std::vector< double > &ys)
static void setYBorder(double y)
double overlapY(Rectangle *r) const
double length(unsigned const d) const
Rectangle(Rectangle const &Other)
double getMaxD(unsigned const d) const
void set_height(double h)
double getMinD(unsigned const d) const
A variable is comprised of an ideal position, final position and a weight.
vector< vpsc::Rectangle * > rs
libvpsc: Variable Placement with Separation Constraints quadratic program solver library.
Dim
Indicates the x- or y-dimension.
@ HORIZONTAL
The x-dimension (0).
@ XDIM
The x-dimension (0).
@ VERTICAL
The y-dimension (1).
@ YDIM
The y-dimension (1).
std::vector< vpsc::Variable * > Variables
A vector of pointers to Variable objects.
bool noRectangleOverlaps(const Rectangles &rs)
std::vector< vpsc::Constraint * > Constraints
A vector of pointers to Constraint objects.
void generateXConstraints(const Rectangles &rs, const Variables &vars, Constraints &cs, const bool useNeighbourLists)
void generateYConstraints(const Rectangles &rs, const Variables &vars, Constraints &cs)
std::vector< Rectangle * > Rectangles
A vector of pointers to Rectangle objects.
void removeoverlaps(Rectangles &rs)
Uses VPSC to remove overlaps between rectangles.
void printIntersections(void)
void nearest(double x, double y, double &xi, double &yi)