Adaptagrams
|
A Chain is a sequence of degree-2 Nodes, possibly forming a cycle. More...
#include <chains.h>
Public Member Functions | |
Chain (Graph_SP G, std::deque< Node_SP > nodes, bool isCycle=false) | |
Standard constructor. More... | |
Node_SP | getNode (int i) const |
Get a Node according to its "place" in the Chain. More... | |
Edge_SP | getEdge (int i) const |
Get an Edge according to its "place" in the Chain. More... | |
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 geometry. More... | |
size_t | size (void) const |
Check how many nodes are in the chain. | |
BendSequences | computePossibleBendSequences (void) const |
Compute the possible bend sequences that this chain could have. More... | |
void | evaluateBendSequence (BendSequence_SP bendSeq) const |
For a given BendSequence, determine the best places for those bends to occur in this Chain, and the costs of applying those constraints. More... | |
ChainConfigSeq | writeConfigSeq (BendSequence_SP bendSeq) const |
Determine the direction in which each edge in this chain should be configured, in order to enforce a given bend sequence. More... | |
void | takeShapeBasedConfiguration (void) |
Give this chain an orthogonal configuration best fitting its present geometric shape. More... | |
void | addAestheticBendsToEdges (void) |
Add any aesthetic bends that were chosen during shape-based configuration, to the Edges to which they belong. | |
Static Public Attributes | |
static const size_t | npos = -1 |
A Chain is a sequence of degree-2 Nodes, possibly forming a cycle.
This class, like everything defined in this header, is intended for use only with 4-planar orthogonal layouts.
Chain::Chain | ( | Graph_SP | G, |
std::deque< Node_SP > | nodes, | ||
bool | isCycle = false |
||
) |
Standard constructor.
[in] | G | The Graph to which the Chain belongs. |
[in] | nodes | The Nodes belonging to the Chain, in order |
[in] | isCycle | Set true if these Nodes form a closed cycle. Default false. |
Runtime | error if nodes is empty. |
References dialect::shapeOfLink(), Avoid::Point::x, and Avoid::Point::y.
double Chain::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 geometry.
If this chain is a cycle, the cost takes into account that the nodes are in clockwise order.
[in] | bendType | A bent LinkShape. |
[in] | i0 | A position in the chain from 0 to 2n-2 – evens for nodes, odds for edges – where n is the number of nodes in this chain. |
References getNode(), Avoid::Point::x, and Avoid::Point::y.
BendSequences Chain::computePossibleBendSequences | ( | void | ) | const |
Compute the possible bend sequences that this chain could have.
If "no bends" is a possibility, then we return a single BendSequence with empty list of bend types.
References dialect::bentLinkShapeCw, dialect::bentLinkShapeCwFromStartingPt(), dialect::lookupMinimalBendSeqs(), and dialect::possibleCardinalDirections().
Referenced by takeShapeBasedConfiguration().
void Chain::evaluateBendSequence | ( | BendSequence_SP | bendSeq | ) | const |
For a given BendSequence, determine the best places for those bends to occur in this Chain, and the costs of applying those constraints.
[in,out] | bendSeq | The BendSequence to be considered. Sequence of best places to make the bends is recorded in here, along with the total cost. |
Referenced by takeShapeBasedConfiguration().
Edge_SP Chain::getEdge | ( | int | i | ) | const |
Get an Edge according to its "place" in the Chain.
Together with the getNode function, this function allows us to have the indices 0, 1, 2, 3, ... refer to the first node in the chain, then the first edge, next node, next edge, and so on. Negative integers refer to left anchors.
[in] | i | An odd integer from -1 to 2n-1, where n is the number of nodes in this chain. |
Referenced by takeShapeBasedConfiguration().
Node_SP Chain::getNode | ( | int | i | ) | const |
Get a Node according to its "place" in the Chain.
Together with the getEdge function, this function allows us to have the indices 0, 1, 2, 3, ... refer to the first node in the chain, then the first edge, next node, next edge, and so on. Negative integers refer to left anchors.
[in] | i | An even integer from -2 to 2n, where n is the number of nodes in this chain. |
Referenced by bendCost(), and takeShapeBasedConfiguration().
void Chain::takeShapeBasedConfiguration | ( | void | ) |
Give this chain an orthogonal configuration best fitting its present geometric shape.
This means we put the bend points in the most natural places, including the possibility that they go where edges are (meaning a new bend point is constructed).
Thus, constraints at least are added to the underlying Graph's SepMatrix. New Nodes (bend points) may also be added.
References dialect::Node::allocate(), dialect::Edge::allocate(), computePossibleBendSequences(), evaluateBendSequence(), getEdge(), getNode(), writeConfigSeq(), Avoid::Point::x, and Avoid::Point::y.
ChainConfigSeq Chain::writeConfigSeq | ( | BendSequence_SP | bendSeq | ) | const |
Determine the direction in which each edge in this chain should be configured, in order to enforce a given bend sequence.
[in] | bendSeq | The desired bend sequence. Its bendpoints are indices into this Chain's sequence of nodes AND edges – thus even indices for nodes and odd indices for edges. Its corresponding bendtypes are the types of bends that should occur at those indices. |
When ci == [ d, d ], then edge i is simply to be configured in direction d. When ci == [d1, d2] with d1 != d2, then edge i is to be replaced by a bend point, which we go into in direction d1, and come out of in direction d2.
References dialect::applyBendToDir, and dialect::cwIncomingDirForBend.
Referenced by takeShapeBasedConfiguration().
|
static |
For our search procedures we need a size_t that effectively means "no position". For this we follow the practice of std::string::find, using npos = -1, the largest possible size_t. We can certainly not work on networks with that many nodes!
Referenced by dialect::bentLinkShapeCwFromStartingPt().