25 #ifndef DIALECT_CHAINS_H 26 #define DIALECT_CHAINS_H 34 #include "libdialect/commontypes.h" 35 #include "libdialect/ortho.h" 56 typedef std::vector<LinkShape> LinkShapes;
67 extern const std::map<LinkShape, std::map<CardinalDir, CardinalDir>>
applyBendToDir;
86 extern const std::map<CompassDir, std::map<CardinalDir, std::map<CardinalDir, std::vector<std::vector<LinkShape>>>>>
minimalBendSeqs;
97 std::vector<std::vector<LinkShape>>
lookupMinimalBendSeqs(Node_SP A, CardinalDir d0, Node_SP Z, CardinalDir d1);
125 BendSequence(LinkShapes &shapes, CardinalDir inDir, CardinalDir outDir)
126 :
bendTypes(shapes), incomingDirec(inDir), outgoingDirec(outDir) {}
141 CardinalDir incomingDirec;
142 CardinalDir outgoingDirec;
145 typedef std::shared_ptr<BendSequence> BendSequence_SP;
146 typedef std::vector<BendSequence_SP> BendSequences;
151 AestheticBend(Edge_SP edge, Node_SP bendNode, Node_SP nbrNode1, Node_SP nbrNode2)
152 : edge(edge), bendNode(bendNode), nbrNode1(nbrNode1), nbrNode2(nbrNode2) {}
164 typedef std::shared_ptr<AestheticBend> AestheticBend_SP;
165 typedef std::vector<AestheticBend_SP> AestheticBends;
167 typedef std::vector<std::pair<CardinalDir, CardinalDir>> ChainConfigSeq;
185 Chain(Graph_SP G, std::deque<Node_SP> nodes,
bool isCycle=
false);
219 size_t size(
void)
const {
return m_n; }
287 double nextLocalOptimalPoint(
size_t i0,
LinkShape bendType,
size_t remaining,
size_t &i1)
const;
299 double globalOptimalPoint(
LinkShape bendType,
size_t &i1,
size_t beginAt = 0)
const;
303 size_t getNumPotentialBendPlaces(
void)
const {
size_t M = 2*m_n - 1;
if (m_isCycle) ++M;
return M; }
309 LinkShapes m_linkShapes;
311 Node_SP m_anchorNodeLeft =
nullptr;
312 Edge_SP m_anchorEdgeLeft =
nullptr;
313 Node_SP m_anchorNodeRight =
nullptr;
314 Edge_SP m_anchorEdgeRight =
nullptr;
315 Edge_SP m_returnEdge =
nullptr;
316 AestheticBends m_aestheticBends;
320 typedef std::shared_ptr<Chain> Chain_SP;
321 typedef std::vector<Chain_SP> Chains;
330 #endif // DIALECT_CHAINS_H double bendCost(LinkShape bendType, size_t i0) const
Compute the cost of making a given bend shape at a given position in the chain, given the current geo...
Definition: chains.cpp:273
A bend point deliberately added to a connector route, for aesthetic reasons.
Definition: chains.h:149
const std::map< CompassDir, std::map< CardinalDir, std::map< CardinalDir, std::vector< std::vector< LinkShape > > > > > minimalBendSeqs
Definition: bendseqlookup.cpp:42
size_t size(void) const
Check how many nodes are in the chain.
Definition: chains.h:219
BendSequences computePossibleBendSequences(void) const
Compute the possible bend sequences that this chain could have.
Definition: chains.cpp:404
BendSequence(LinkShapes &shapes)
Basic constructor.
Definition: chains.h:119
Chain(Graph_SP G, std::deque< Node_SP > nodes, bool isCycle=false)
Standard constructor.
Definition: chains.cpp:135
LinkShape shapeOfLink(Node_SP link)
Determine the LinkShape for a given Node of degree 2.
Definition: chains.cpp:117
std::vector< std::vector< LinkShape > > lookupMinimalBendSeqs(Node_SP A, CardinalDir d0, Node_SP Z, CardinalDir d1)
Look up the minimal bend sequences for a Chain.
Definition: chains.cpp:90
libdialect: A library for computing human-like orthogonal network (DiAlEcT) layouts.
Definition: cola.h:44
A Chain is a sequence of degree-2 Nodes, possibly forming a cycle.
Definition: chains.h:173
void addAestheticBendsToEdges(void)
Add any aesthetic bends that were chosen during shape-based configuration, to the Edges to which they...
Definition: chains.cpp:616
void evaluateBendSequence(BendSequence_SP bendSeq) const
For a given BendSequence, determine the best places for those bends to occur in this Chain...
Definition: chains.cpp:459
LinkShape
Definition: chains.h:47
CardinalDirs possibleCardinalDirections(Node_SP node1, Node_SP node2)
List the possible cardinal directions from node1 to node2, if they were to be aligned non-aggressivel...
Definition: chains.cpp:104
Chains buildAllChainsInGraph(std::shared_ptr< dialect::Graph > graph)
Convenience method to build all the chains and cycles in a graph.
const std::map< LinkShape, CardinalDir > cwIncomingDirForBend
Definition: chains.cpp:83
ChainConfigSeq writeConfigSeq(BendSequence_SP bendSeq) const
Determine the direction in which each edge in this chain should be configured, in order to enforce a ...
Definition: chains.cpp:485
LinkShapes bentLinkShapeCwFromStartingPt(LinkShape start)
Get the bent LinkShapes, in clockwise order, starting from a given one.
Definition: chains.cpp:63
const std::map< LinkShape, std::map< CardinalDir, CardinalDir > > applyBendToDir
Definition: chains.cpp:76
void addBendToEdge(void)
Add the bend node to the edge.
Definition: chains.cpp:620
const LinkShapes bentLinkShapeCw
The bent LinkShapes, in clockwise order:
Definition: chains.cpp:59
static const size_t npos
Definition: chains.h:266
Edge_SP getEdge(int i) const
Get an Edge according to its "place" in the Chain.
Definition: chains.cpp:260
void takeShapeBasedConfiguration(void)
Give this chain an orthogonal configuration best fitting its present geometric shape.
Definition: chains.cpp:555
Node_SP getNode(int i) const
Get a Node according to its "place" in the Chain.
Definition: chains.cpp:247
BendSequence(LinkShapes &shapes, CardinalDir inDir, CardinalDir outDir)
Augmented constructor in which incoming and outgoing directions are also set.
Definition: chains.h:125
size_t size(void) const
Report the number of bends in the sequence.
Definition: chains.h:129
LinkShapes bendTypes
Under bendTypes we record what shape bend we want.
Definition: chains.h:132
std::vector< size_t > bendPoints
Definition: chains.h:138
A data structure for managing sequences of bend types, points at which these bends should occur (in a...
Definition: chains.h:115