21 #ifndef _COMPOUND_CONSTRAINTS_H 22 #define _COMPOUND_CONSTRAINTS_H 29 #include "libvpsc/rectangle.h" 30 #include "libvpsc/constraint.h" 31 #include "libcola/sparse_matrix.h" 32 #include "libcola/unused.h" 40 typedef std::vector<vpsc::Constraint *>
Constraints;
41 typedef std::vector<vpsc::Variable *>
Variables;
57 constraint(constraint),
61 bool operator<(
const SubConstraint& rhs)
const 63 return cost < rhs.cost;
73 typedef std::list<SubConstraint> SubConstraintAlternatives;
75 static const double freeWeight = 0.0001;
77 static const unsigned int DEFAULT_CONSTRAINT_PRIORITY = 30000;
78 static const unsigned int PRIORITY_NONOVERLAP =
79 DEFAULT_CONSTRAINT_PRIORITY - 2000;
107 unsigned mappingForVariable(
const unsigned var,
108 bool forward =
true)
const;
110 void printCreationCode(FILE *fp)
const;
113 std::list<std::pair<unsigned, unsigned> > m_mapping;
116 class SubConstraintInfo
119 SubConstraintInfo(
unsigned ind) :
124 virtual ~SubConstraintInfo()
127 virtual void updateVarIDsWithMapping(
const VariableIDMap& idMap,
134 typedef std::vector<SubConstraintInfo *> SubConstraintInfoList;
149 unsigned int priority = DEFAULT_CONSTRAINT_PRIORITY);
207 virtual std::string
toString(
void)
const = 0;
217 unsigned int priority(
void)
const;
218 virtual void updateVarIDsWithMapping(
const VariableIDMap& idMap,
219 bool forward =
true);
220 virtual void updateShapeOffsetsForDifferentCentres(
221 const std::vector<double>& offsets,
bool forward =
true)
223 COLA_UNUSED(offsets);
224 COLA_UNUSED(forward);
230 virtual void markAllSubConstraintsAsInactive(
void);
231 virtual bool subConstraintsRemaining(
void)
const;
232 virtual void markCurrSubConstraintAsActive(
const bool satisfiable);
233 virtual SubConstraintAlternatives getCurrSubConstraintAlternatives(
235 std::list<unsigned> subConstraintObjIndexes(
void)
const;
236 virtual void printCreationCode(FILE *fp)
const;
237 bool shouldCombineSubConstraints(
void)
const;
241 const unsigned index);
248 unsigned int _priority;
251 bool _combineSubConstraints;
254 SubConstraintInfoList _subConstraintInfo;
256 size_t _currSubConstraintIndex;
307 void addShape(
const unsigned int index,
const double offset);
316 SubConstraintAlternatives getCurrSubConstraintAlternatives(
323 void printCreationCode(FILE *fp)
const;
365 void addShape(
const unsigned int index,
const double offset);
396 SubConstraintAlternatives getCurrSubConstraintAlternatives(
403 double position(
void)
const;
404 void printCreationCode(FILE *fp)
const;
405 void updateShapeOffsetsForDifferentCentres(
406 const std::vector<double>& offsets,
bool forward =
true);
451 double g,
bool equality =
false);
478 SubConstraintAlternatives getCurrSubConstraintAlternatives(
484 void setSeparation(
double gap);
485 unsigned left(
void)
const;
486 unsigned right(
void)
const;
487 void printCreationCode(FILE *fp)
const;
502 OrthogonalEdgeConstraint(
const vpsc::Dim dim,
unsigned l,
unsigned r);
504 SubConstraintAlternatives getCurrSubConstraintAlternatives(
507 void generateSeparationConstraints(
const vpsc::Dim dim,
510 void generateTopologyConstraints(
const vpsc::Dim k,
512 std::vector<vpsc::Variable*>
const& vars,
513 std::vector<vpsc::Constraint*>& cs);
514 void printCreationCode(FILE *fp)
const;
515 std::string toString(
void)
const;
522 double& cmin,
double& cmax,
double& centre,
double& l)
const;
548 bool equality =
false);
582 SubConstraintAlternatives getCurrSubConstraintAlternatives(
588 void printCreationCode(FILE *fp)
const;
651 SubConstraintAlternatives getCurrSubConstraintAlternatives(
657 void printCreationCode(FILE *fp)
const;
694 std::vector<unsigned> shapeIds,
695 const bool fixedPosition =
false);
704 SubConstraintAlternatives getCurrSubConstraintAlternatives(
710 void printCreationCode(FILE *fp)
const;
712 bool forward =
true);
715 bool m_fixed_position;
716 std::vector<unsigned> m_shape_vars;
744 double yLow,
double yHigh,
double weight = 100.0);
753 void addShape(
unsigned index,
double halfW,
double halfH);
762 SubConstraintAlternatives getCurrSubConstraintAlternatives(
769 double getActualLeftMargin(
const vpsc::Dim dim);
770 double getActualRightMargin(
const vpsc::Dim dim);
771 void printCreationCode(FILE *fp)
const;
774 double leftMargin[2];
775 double rightMargin[2];
776 double actualLeftMargin[2];
777 double actualRightMargin[2];
778 double leftWeight[2];
779 double rightWeight[2];
803 std::string toString(
void)
const 805 std::stringstream stream;
806 stream <<
"Unsatisfiable constraint: var(" <<
leftVarIndex <<
") ";
815 stream <<
" " << ((
equality) ?
"== " :
"<= ");
829 #endif // _COMPOUND_CONSTRAINTS_H void * indicator
Definition: compound_constraints.h:410
A variable is comprised of an ideal position, final position and a weight.
Definition: variable.h:44
bool equality
Whether the separation is an exact distance or not.
Definition: compound_constraints.h:799
void generateVariablesAndConstraints(CompoundConstraints &ccs, const vpsc::Dim dim, vpsc::Variables &vars, vpsc::Constraints &cs, vpsc::Rectangles &bbs)
Generate all the variables and constraints for a collection of CompoundConstraints.
Definition: compound_constraints.cpp:1455
A fixed-relative constraint specifies that a group of nodes are constrained to be fixed in position r...
Definition: compound_constraints.h:679
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:1155
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:814
MultiSeparationConstraint(const vpsc::Dim dim, double minSep=0, bool equality=false)
Constructs a new empty MultiSeparationConstraint with a minimum or exact spacing. ...
Definition: compound_constraints.cpp:750
void fixPos(double pos)
Mark the alignment as ideally having a fixed position.
Definition: compound_constraints.cpp:237
Holds a mapping between two sets of Variable indices.
Definition: compound_constraints.h:93
double position
Holds the position of the boundary line, once layout is complete.
Definition: compound_constraints.h:326
PageBoundaryConstraints(double xLow, double xHigh, double yLow, double yHigh, double weight=100.0)
Constructs a new PageBoundaryConstraints object with given page boundary positions and weight...
Definition: compound_constraints.cpp:1241
void addAlignmentPair(AlignmentConstraint *ac1, AlignmentConstraint *ac2)
Mark a pair of alignment constraints as being part of this multi separation constraint.
Definition: compound_constraints.cpp:760
bool isFixed(void) const
Indicates if the alignment position is marked as fixed.
Definition: compound_constraints.cpp:255
void addAlignmentPair(AlignmentConstraint *ac1, AlignmentConstraint *ac2)
Mark a pair of alignment constraints as being part of this distribution constraint.
Definition: compound_constraints.cpp:895
Info about constraints that could not be satisfied in gradient projection process.
Definition: compound_constraints.h:788
An alignment constraint specifies a alignment line that a set of nodes must be constrained to by an e...
Definition: compound_constraints.h:345
BoundaryConstraint(const vpsc::Dim dim)
Constructs a new BoundaryConstraint in the specified dimension.
Definition: compound_constraints.cpp:63
void addShape(const unsigned int index, const double offset)
Mark a node as being part of this alignment constraint.
Definition: compound_constraints.cpp:221
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vars, vpsc::Constraints &gcs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:1380
void setSeparation(double sep)
Alter the exact spacing between each pair of alignment constraints.
Definition: compound_constraints.cpp:912
void updatePosition(const vpsc::Dim dim)
Implemented by the compound constraint to send position information back to the interface.
Definition: compound_constraints.cpp:228
void addShape(unsigned index, double halfW, double halfH)
Mark a node as being contained within this page boundary.
Definition: compound_constraints.cpp:1265
libvpsc: Variable Placement with Separation Constraints quadratic program solver library.
Definition: assertions.h:61
std::vector< Variable * > Variables
A vector of pointers to Variable objects.
Definition: constraint.h:38
void updatePosition(const vpsc::Dim dim)
Implemented by the compound constraint to send position information back to the interface.
Definition: compound_constraints.cpp:1334
SeparationConstraint(const vpsc::Dim dim, unsigned l, unsigned r, double g, bool equality=false)
Constructs a new SeparationConstraint between two nodes in the specified dimension.
Definition: compound_constraints.cpp:443
unsigned rightVarIndex
The index of the right variable.
Definition: compound_constraints.h:795
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:346
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:1360
std::vector< Constraint * > Constraints
A vector of pointers to Constraint objects.
Definition: constraint.h:125
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:902
void updatePosition(const vpsc::Dim dim)
Implemented by the compound constraint to send position information back to the interface.
Definition: compound_constraints.cpp:71
std::vector< Rectangle * > Rectangles
A vector of pointers to Rectangle objects.
Definition: rectangle.h:246
A constraint determines a minimum or exact spacing required between two Variable objects.
Definition: constraint.h:44
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vars, vpsc::Constraints &gcs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:988
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vs, vpsc::Constraints &cs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:548
unsigned leftVarIndex
The index of the left variable.
Definition: compound_constraints.h:793
void unfixPos(void)
Mark the alignment as not having a fixed position.
Definition: compound_constraints.cpp:244
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vars, vpsc::Constraints &cs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:140
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:519
bool addMappingForVariable(const unsigned from, const unsigned to)
Adds a mapping between a pair of variables.
Definition: compound_constraints.cpp:1597
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vars, vpsc::Constraints &cs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:277
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:104
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:940
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:1115
AlignmentConstraint(const vpsc::Dim dim, double position=0.0)
Constructs a new AlignmentConstraint in the specified dimension.
Definition: compound_constraints.cpp:211
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:260
A boundary constraint specifies a bounding line that a set of nodes must be either to the left or rig...
Definition: compound_constraints.h:288
A rectangle represents a fixed-size shape in the diagram that may be moved to prevent overlaps and sa...
Definition: rectangle.h:78
virtual std::string toString(void) const =0
Returns a textual description of the compound constraint.
void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)
Implemented by the compound constraint to generate any additional required variables in the given dim...
Definition: compound_constraints.cpp:127
virtual void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &var, vpsc::Constraints &cs, vpsc::Rectangles &bbs)=0
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
void * indicator
Definition: compound_constraints.h:594
cola::CompoundConstraint * cc
The index of the CompoundConstraint that created this.
Definition: compound_constraints.h:801
DistributionConstraint(const vpsc::Dim dim)
Constructs a new empty DistributionConstraint with a minimum or exact spacing.
Definition: compound_constraints.cpp:888
void setSeparation(double sep)
Alter the minimum or exact spacing between each pair of alignment constraints.
Definition: compound_constraints.cpp:849
libcola: Force-directed network layout subject to separation constraints library. ...
Definition: box.cpp:25
Dim
Indicates the x- or y-dimension.
Definition: rectangle.h:41
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:788
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:495
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vars, vpsc::Constraints &gcs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:1197
std::vector< UnsatisfiableConstraintInfo * > UnsatisfiableConstraintInfos
A vector of pointers to UnsatisfiableConstraintInfo objects.
Definition: compound_constraints.h:826
void * indicator
Definition: compound_constraints.h:663
std::string toString(void) const
Returns a textual description of the compound constraint.
Definition: compound_constraints.cpp:1292
virtual void generateVariables(const vpsc::Dim dim, vpsc::Variables &vars)=0
Implemented by the compound constraint to generate any additional required variables in the given dim...
A multi-separation constraint Specifies a set of horizontal or vertical equal spacing constraints bet...
Definition: compound_constraints.h:534
void generateSeparationConstraints(const vpsc::Dim dim, vpsc::Variables &vs, vpsc::Constraints &gcs, vpsc::Rectangles &bbs)
Implemented by the compound constraint to generate the low-level separation constraints in the given ...
Definition: compound_constraints.cpp:855
An abstract base class for all high-level compound constraints.
Definition: compound_constraints.h:146
std::vector< CompoundConstraint * > CompoundConstraints
A vector of pointers to CompoundConstraint objects.
Definition: compound_constraints.h:259
FixedRelativeConstraint(const vpsc::Rectangles &rs, std::vector< unsigned > shapeIds, const bool fixedPosition=false)
Constructs a new FixedRelativeConstraint between a set of nodes, optionally with a fixed position...
Definition: compound_constraints.cpp:1062
A separation constraint specifies a simple horizontal or vertical spacing constraint between 2 nodes ...
Definition: compound_constraints.h:432
virtual void updatePosition(const vpsc::Dim dim)
Implemented by the compound constraint to send position information back to the interface.
Definition: compound_constraints.h:197
double separation
The separation.
Definition: compound_constraints.h:797
void addShape(const unsigned int index, const double offset)
Mark a node as being part of this boundary constraint.
Definition: compound_constraints.cpp:80
A page boundary contraint specifies constraints that attempt to keep the given nodes within a defined...
Definition: compound_constraints.h:730
void generateVariables(CompoundConstraints &ccs, const vpsc::Dim dim, vpsc::Variables &vars)
Generate just all the variables for a collection of CompoundConstraints.
Definition: compound_constraints.cpp:1466
A distribution constraint specifies an ordered set of alignment constraints and a fixed separation re...
Definition: compound_constraints.h:611