25 #ifndef DIALECT_CONSTRAINTS_H 26 #define DIALECT_CONSTRAINTS_H 35 #include "libvpsc/rectangle.h" 36 #include "libcola/compound_constraints.h" 38 #include "libdialect/commontypes.h" 39 #include "libdialect/ortho.h" 57 EAST, SOUTH, WEST, NORTH,
73 bool sepDirIsCardinal(
SepDir sd);
75 CardinalDir sepDirToCardinalDir(
SepDir sd);
77 SepDir cardinalDirToSepDir(CardinalDir dir);
117 unsigned tglfPrecision = 3;
139 bool flippedRetrieval =
false;
147 bool isVerticalCardinal(
void)
const;
149 bool isHorizontalCardinal(
void)
const;
151 bool isVAlign(
void)
const;
153 bool isHAlign(
void)
const;
155 bool isCardinal(
void)
const;
159 CardinalDir getCardinalDir(
void)
const;
163 void roundGapsUpAbs(
void);
167 std::string writeTglf(std::map<id_type, unsigned> id2ext,
const SepMatrix &m)
const;
169 bool hasConstraintInDim(
vpsc::Dim dim)
const;
178 SepPair_SP sp =
nullptr;
183 static const unsigned int PRIORITY_SEPMATRIX = cola::DEFAULT_CONSTRAINT_PRIORITY;
191 SepMatrix(
Graph *G) :
cola::CompoundConstraint(
vpsc::UNSET, PRIORITY_SEPMATRIX), m_graph(G) {
192 _combineSubConstraints =
true;
195 SepMatrix(
void) =
delete;
197 SepMatrix(
const SepMatrix &m) =
default;
199 ~SepMatrix(
void) =
default;
224 void setCardinalOP(id_type id1, id_type id2, dialect::CardinalDir dir) {
234 void addFixedRelativeSep(id_type id1, id_type id2,
double dx,
double dy);
240 void addFixedRelativeSep(id_type id1, id_type id2);
254 void alignByEquatedCoord(id_type id1, id_type id2,
vpsc::Dim eqCoord);
258 void free(id_type id1, id_type id2);
263 void clear(
void) { m_sparseLookup.clear(); }
271 void setCorrespondingConstraints(SepMatrix &matrix)
const;
278 void setSepPair(id_type id1, id_type id2, SepPair_SP sp);
288 void transformClosedSubset(
SepTransform tf,
const std::set<id_type> &ids);
295 void transformOpenSubset(
SepTransform tf,
const std::set<id_type> &ids);
297 void removeNode(id_type
id);
299 void removeNodes(
const NodesById &nodes);
305 CardinalDir getCardinalDir(id_type id1, id_type id2)
const;
310 void getAlignedSets(std::map<id_type, std::set<id_type>> &hSets,
311 std::map<id_type, std::set<id_type>> &vSets)
const;
313 bool areHAligned(id_type id1, id_type id2)
const;
315 bool areVAligned(id_type id1, id_type id2)
const;
319 std::string writeTglf(std::map<id_type, unsigned> id2ext)
const;
321 void setGraph(Graph *G) { m_graph = G; }
323 Graph *getGraph(
void) {
return m_graph; }
326 void roundGapsUpward(
void);
328 void setExtraBdryGap(
double extraBdryGap) { m_extraBdryGap = extraBdryGap; }
329 double getExtraBdryGap(
void)
const {
return m_extraBdryGap; }
334 void generateSeparationConstraints(
const vpsc::Dim dim,
337 std::string toString(
void)
const;
338 void markAllSubConstraintsAsInactive(
void);
339 cola::SubConstraintAlternatives getCurrSubConstraintAlternatives(
vpsc::Variables vs[]);
345 double m_extraBdryGap = 0.0;
361 SepPair_SP &getSepPair(id_type id1, id_type id2);
369 SepPair_SP checkSepPair(id_type id1, id_type id2)
const;
395 SparseIdMatrix2d<SepPair_SP>::type m_sparseLookup;
431 : dim(dim), left(left), right(right), gap(gap), exact(exact) {}
460 typedef std::shared_ptr<SepCo> SepCo_SP;
461 typedef std::set<SepCo_SP> SepCoSet;
462 typedef std::vector<SepCoSet> SepCoSets;
474 size_t size(
void) {
return sepCoSet.size(); }
487 typedef std::shared_ptr<Projection> Projection_SP;
488 typedef std::vector<Projection_SP> Projections;
536 Projections m_projections;
538 std::vector<double> m_dSes;
542 std::map<vpsc::Dim, SepCoSet> m_finalSets;
550 #endif // DIALECT_CONSTRAINTS_H void reset(void)
Reset to start of sequence.
Definition: constraints.h:527
Flip over horizontal axis.
The Graph class represents graphs consisting of nodes and edges.
Definition: graphs.h:180
SepDir
Definition: constraints.h:55
size_t size(void)
Check how many SepCos are in the projection.
Definition: constraints.h:474
The x-dimension (0).
Definition: rectangle.h:45
ProjSeq(void)
Default constructor.
Definition: constraints.h:496
Gap between the opposite boundaries of two nodes:
Projection_SP nextProjection(void)
Get the next Projection, if any.
Definition: constraints.cpp:1037
std::string toString(void) const
Write a string representation.
Definition: constraints.cpp:1072
libdialect: A library for computing human-like orthogonal network (DiAlEcT) layouts.
Definition: cola.h:44
std::string toString(void) const
Write a string representation.
Definition: constraints.cpp:1085
Definition: constraints.h:176
SepCo(vpsc::Dim dim, Node_SP left, Node_SP right, double gap, bool exact=false)
Standard constructor.
Definition: constraints.h:430
libvpsc: Variable Placement with Separation Constraints quadratic program solver library.
Definition: assertions.h:61
Definition: constraints.h:492
ProjSeq & operator+=(const ProjSeq &rhs)
When another ProjSeq is added to this one, we simply add each Projection from the other one to this o...
Definition: constraints.cpp:1045
Cardinal constraints imply both a separation and an alignment:
double violation(void) const
Determine the extent to which this separation constraint is currently violated.
Definition: constraints.cpp:1012
SepTransform
Definition: constraints.h:83
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
std::string toString(void) const
Write a string representation.
Definition: constraints.cpp:1095
Gap between the centres of two nodes:
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
Rotate 90 degrees anticlockwise.
GapType
Definition: constraints.h:48
void noteStresschange(double dS)
Note a stress change.
Definition: constraints.h:513
Definition: constraints.h:466
cola::CompoundConstraints generateColaConstraints(const ColaGraphRep &cgr)
Build a vector of cola CompoundConstraints representing the constraints in this Projection.
Definition: constraints.cpp:1020
CardinalDir getDirecRelativeToNode(Node_SP baseNode) const
Determine the constrained direction from one Node to the other.
Definition: constraints.cpp:998
Definition: constraints.h:422
Lateral constraints imply only a separation:
SepType
Definition: constraints.h:62
double violation(void) const
Sum the violations of all SepCos in the final sets.
Definition: constraints.cpp:1065
void addProjection(SepCoSet sepCos, vpsc::Dim dim)
Add a new set of SepCos, ensuring monotonicity by uniting with the previous set of constraints in the...
Definition: constraints.cpp:1028
Rotate 90 degrees clockwise.
void addToMatrix(SepMatrix &matrix) const
Add this constraint to a SepMatrix.
Definition: constraints.cpp:1006
Flip over the "off diagonal".
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
Projection(SepCoSet s, vpsc::Dim d)
Standard constructor.
Definition: constraints.h:471
The y-dimension (1).
Definition: rectangle.h:49
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
SepCoSet getAllConstraints(void) const
Get the set of all constraints, in both dimensions.
Definition: constraints.cpp:1058
Bundles those data structures required in order to represent a Graph in libcola, and to map infomrati...
Definition: graphs.h:157
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
void generateColaConstraints(const ColaGraphRep &cgr, cola::CompoundConstraints &ccs)
Allocate cola::CompoundConstraints to represent this SepCo.
Definition: constraints.cpp:979