23 #ifndef COLA_CC_NONOVERLAPCONSTRAINTS_H 24 #define COLA_CC_NONOVERLAPCONSTRAINTS_H 28 #include "libcola/cola.h" 29 #include "libcola/compound_constraints.h" 30 #include "libcola/shapepair.h" 40 class OverlapShapeOffsets :
public SubConstraintInfo
43 OverlapShapeOffsets(
unsigned ind,
double xOffset,
double yOffset,
45 : SubConstraintInfo(ind),
53 OverlapShapeOffsets(
unsigned ind, Cluster *cluster,
unsigned int group)
54 : SubConstraintInfo(ind),
56 rectPadding(cluster->margin()),
63 : SubConstraintInfo(1000000),
68 bool usesClusterBounds(
void)
const 70 return (cluster && !cluster->clusterIsFromFixedRectangle());
72 void resize(
double xOffset,
double yOffset)
87 ShapePairInfo(
unsigned ind1,
unsigned ind2,
unsigned ord = 1)
92 COLA_ASSERT(ind1 != ind2);
94 varIndex1 = (ind1 < ind2) ? ind1 : ind2;
96 varIndex2 = (ind1 > ind2) ? ind1 : ind2;
98 bool operator<(
const ShapePairInfo& rhs)
const 101 int processedInt = processed ? 1 : 0;
102 int rhsProcessedInt = rhs.processed ? 1 : 0;
103 if (processedInt != rhsProcessedInt)
105 return processedInt < rhsProcessedInt;
108 if (order != rhs.order)
110 return order < rhs.order;
112 return overlapMax > rhs.overlapMax;
114 unsigned short order;
115 unsigned short varIndex1;
116 unsigned short varIndex2;
124 class NonOverlapConstraintExemptions {
126 NonOverlapConstraintExemptions();
128 bool shapePairIsExempt(ShapePair shapePair)
const;
129 std::set<ShapePair> getExemptPairs(
void) {
return m_exempt_pairs;}
132 std::set<ShapePair> m_exempt_pairs;
136 class NonOverlapConstraints :
public CompoundConstraint {
138 NonOverlapConstraints(NonOverlapConstraintExemptions *exemptions,
139 unsigned int priority = PRIORITY_NONOVERLAP);
155 void addShape(
unsigned id,
double halfW,
double halfH,
156 unsigned int group = 1, std::set<unsigned> exemptions = std::set<unsigned>());
157 void resizeShape(
unsigned id,
double halfW,
double halfH);
158 void removeShape(
unsigned id);
159 void addCluster(Cluster *cluster,
unsigned int group);
161 void markCurrSubConstraintAsActive(
const bool satisfiable);
162 void markAllSubConstraintsAsInactive(
void);
163 bool subConstraintsRemaining(
void)
const;
164 SubConstraintAlternatives getCurrSubConstraintAlternatives(
166 std::string toString(
void)
const;
167 void setClusterClusterExemptions(std::set<ShapePair> exemptions);
189 std::vector<vpsc::Rectangle*>& boundingBoxes);
192 void computeOverlapForShapePairInfo(ShapePairInfo& info,
195 std::list<ShapePairInfo> pairInfoList;
196 std::map<unsigned, OverlapShapeOffsets> shapeOffsets;
197 bool pairInfoListSorted;
198 bool initialSortCompleted;
201 size_t clusterVarStartIndex;
202 size_t currClusterIndex;
205 NonOverlapConstraintExemptions *m_exemptions;
206 std::set<ShapePair> m_cluster_cluster_exemptions;
210 #endif // COLA_CC_NONOVERLAPCONSTRAINTS std::vector< NodeIndexes > ListOfNodeIndexes
A vector of NodeIndexes.
Definition: cola.h:65
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
std::vector< Constraint * > Constraints
A vector of pointers to Constraint objects.
Definition: constraint.h:125
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 ...
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
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