28 #ifndef TOPOLOGY_CONSTRAINTS_H 29 #define TOPOLOGY_CONSTRAINTS_H 30 #include "libcola/commondefs.h" 31 #include "libtopology/topology_graph.h" 51 class StraightConstraint;
63 const Node *u, *v, *w;
72 TriConstraint(
vpsc::Dim dim,
const Node *u,
const Node *v,
const Node *w,
73 double p,
double g,
bool left);
78 double maxSafeAlpha()
const;
82 double slackAtInitial()
const;
86 double slackAtFinal()
const;
90 bool assertFeasible()
const;
92 double slack(
const double,
const double,
const double)
const;
94 class TopologyConstraint {
104 virtual void satisfy() = 0;
106 virtual std::string toString()
const = 0;
107 virtual unsigned getEdgeID()
const = 0;
108 virtual ~TopologyConstraint() {
116 bool assertFeasible()
const;
118 TopologyConstraint(
vpsc::Dim dim) : c(nullptr), scanDim(dim) { }
124 class BendConstraint :
public TopologyConstraint {
126 EdgePoint* bendPoint;
133 BendConstraint(EdgePoint* bendPoint,
vpsc::Dim dim);
135 std::string toString()
const;
136 unsigned getEdgeID()
const;
142 class StraightConstraint :
public TopologyConstraint {
146 EdgePoint::RectIntersect ri;
159 StraightConstraint(Segment* s,
vpsc::Dim dim,
160 Node* node,
const EdgePoint::RectIntersect ri,
161 const double scanPos,
const double segmentPos,
162 const bool nodeLeft);
164 std::string toString()
const;
165 unsigned getEdgeID()
const {
166 return segment->edge->id;
173 class TopologyConstraints {
194 ~TopologyConstraints();
196 void constraints(std::vector<TopologyConstraint*> & ts)
const;
197 void computeForces(std::valarray<double>& g, cola::SparseMap& h);
198 bool assertFeasible()
const;
199 void printInstance(std::valarray<double>& g)
const;
200 bool noOverlaps()
const;
227 rhsNode(nullptr) { };
228 Node *lhsNode, *rhsNode;
230 typedef std::map<unsigned, ResizeInfo> ResizeMap;
241 double computeStress(
const Edges& es);
243 #endif // TOPOLOGY_CONSTRAINTS_H libtopology: Extensions for topology preservation for libcola and libavoid libraries.
Definition: shape.h:41
ProjectionResult solve(vpsc::Variables &vs, vpsc::Constraints &cs, vpsc::Rectangles &rs, unsigned debugLevel=0)
Constructs a solver and attempts to solve the passed constraints on the passed vars.
std::pair< unsigned, unsigned > Edge
Edges are simply a pair of indices to entries in the Node vector.
Definition: cola.h:68
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
Holds the cluster hierarchy specification for a diagram.
Definition: cluster.h:172
std::vector< Node * > Nodes
A vector of pointers to Node objects.
Definition: topology_graph.h:82
A rectangle represents a fixed-size shape in the diagram that may be moved to prevent overlaps and sa...
Definition: rectangle.h:78
std::vector< Edge * > Edges
A vector of pointers to Edge objects.
Definition: topology_graph.h:533
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