Adaptagrams
Public Member Functions | List of all members
cola::SeparationConstraint Class Reference

A separation constraint specifies a simple horizontal or vertical spacing constraint between 2 nodes or alignment constraints. More...

#include <compound_constraints.h>

Inheritance diagram for cola::SeparationConstraint:
Inheritance graph
Collaboration diagram for cola::SeparationConstraint:
Collaboration graph

Public Member Functions

 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. More...
 
 SeparationConstraint (const vpsc::Dim dim, AlignmentConstraint *l, AlignmentConstraint *r, double g, bool equality=false)
 Constructs a new SeparationConstraint between two alignment constraints in the specified dimension. More...
 
std::string toString (void) const
 Returns a textual description of the compound constraint. More...
 
void generateVariables (const vpsc::Dim dim, vpsc::Variables &vars)
 Implemented by the compound constraint to generate any additional required variables in the given dimension. More...
 
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 dimension. More...
 
- Public Member Functions inherited from cola::CompoundConstraint
virtual void updatePosition (const vpsc::Dim dim)
 Implemented by the compound constraint to send position information back to the interface. More...
 

Detailed Description

A separation constraint specifies a simple horizontal or vertical spacing constraint between 2 nodes or alignment constraints.

The non-equality constraint is lPos + g <= rPos and the equality constraint is lPos + g = rPos

Note
With an equality, you can effectively reverse the ordering of the two variables by making the gap a negative number. This is not so for the non-equality case, there you need to keep the same gap value but reverse the order of the variables passed to the constructor.

Constructor & Destructor Documentation

◆ SeparationConstraint() [1/2]

cola::SeparationConstraint::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.

The constraint will keep the centre of the left node to the left of the right node by exactly or more than the specified gap.

Parameters
[in]dimThe dimension the constraint will operate in.
[in]lThe index of the left node.
[in]rThe index of the right node.
[in]gThe minimum or exact distance to separate the two nodes.
[in]equalityWhether or not the constraint is an exact distance.

◆ SeparationConstraint() [2/2]

cola::SeparationConstraint::SeparationConstraint ( const vpsc::Dim  dim,
AlignmentConstraint l,
AlignmentConstraint r,
double  g,
bool  equality = false 
)

Constructs a new SeparationConstraint between two alignment constraints in the specified dimension.

The constraint will keep the centre of the left alignment line to the left of the right alignment line by exactly or more than the specified gap.

Parameters
[in]dimThe dimension the constraint will operate in.
[in]lA pointer to the left AlignmentConstraint.
[in]rA pointer to the right AlignmentConstraint.
[in]gThe minimum or exact distance to separate the two alignment constraints.
[in]equalityWhether or not the constraint is an exact distance.

Member Function Documentation

◆ generateSeparationConstraints()

void cola::SeparationConstraint::generateSeparationConstraints ( const vpsc::Dim  dim,
vpsc::Variables var,
vpsc::Constraints cs,
vpsc::Rectangles bbs 
)
virtual

Implemented by the compound constraint to generate the low-level separation constraints in the given dimension.

These constraints will be added to the list of constraints cs.

Parameters
[in]dimThe current active dimension.
[in]varsThe list of variables for the overall problem instance.
[in,out]csThe list of constraints to which the generated constraints will be added.
[in]bbsThe list of bounding boxes for all rectangles in the current problem. It has the same order as vars.

Implements cola::CompoundConstraint.

◆ generateVariables()

void cola::SeparationConstraint::generateVariables ( const vpsc::Dim  dim,
vpsc::Variables vars 
)
virtual

Implemented by the compound constraint to generate any additional required variables in the given dimension.

Generate any additional variables required by this compound constraint when operating in the given dimension dim and add them to vars. These variables should be cleaned up by the caller after the VPSC problem is solved.

The variables' ideal position and weight should be set by the compound constraint and they should be added to the end of vars.

Parameters
[in]dimThe current active dimension.
[in,out]varsThe list of variables for the overall problem instance to which any variables generated should be appended.

Implements cola::CompoundConstraint.

◆ toString()

std::string cola::SeparationConstraint::toString ( void  ) const
virtual

Returns a textual description of the compound constraint.

Returns
A string describing the compound constraint.

Implements cola::CompoundConstraint.


The documentation for this class was generated from the following files: