Adaptagrams
Public Member Functions | Static Public Attributes | List of all members
dialect::Chain Class Reference

A Chain is a sequence of degree-2 Nodes, possibly forming a cycle. More...

#include <chains.h>

Collaboration diagram for dialect::Chain:
Collaboration graph

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Chain()

Chain::Chain ( Graph_SP  G,
std::deque< Node_SP >  nodes,
bool  isCycle = false 
)

Standard constructor.

Parameters
[in]GThe Graph to which the Chain belongs.
[in]nodesThe Nodes belonging to the Chain, in order
[in]isCycleSet true if these Nodes form a closed cycle. Default false.
Exceptions
Runtimeerror if nodes is empty.
Note
We accept a deque of Nodes (rather than a vector) not because it is needed, but because the Graph method that computes the lists of nodes forming chains uses deques.
See also
Graph::getChainsAndCycles

References dialect::shapeOfLink(), Avoid::Point::x, and Avoid::Point::y.

Here is the call graph for this function:

Member Function Documentation

◆ bendCost()

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.

Parameters
[in]bendTypeA bent LinkShape.
[in]i0A 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.

Here is the call graph for this function:

◆ computePossibleBendSequences()

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.

Returns
Vector of BendSequences indicating all the possibilites.

References dialect::bentLinkShapeCw, dialect::bentLinkShapeCwFromStartingPt(), dialect::lookupMinimalBendSeqs(), and dialect::possibleCardinalDirections().

Referenced by takeShapeBasedConfiguration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaluateBendSequence()

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.

Parameters
[in,out]bendSeqThe BendSequence to be considered. Sequence of best places to make the bends is recorded in here, along with the total cost.

Referenced by takeShapeBasedConfiguration().

Here is the caller graph for this function:

◆ getEdge()

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.

Parameters
[in]iAn odd integer from -1 to 2n-1, where n is the number of nodes in this chain.
Returns
Left anchor edge for i == -1, self.edges[(i-1)/2] for i from 1 to 2n-3, and right anchor edge for i == 2n-1.

Referenced by takeShapeBasedConfiguration().

Here is the caller graph for this function:

◆ getNode()

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.

Parameters
[in]iAn even integer from -2 to 2n, where n is the number of nodes in this chain.
Returns
Left anchor node for i == -2, self.nodes[i/2] for i from 0 to 2n-2, and right anchor node for i == 2n.

Referenced by bendCost(), and takeShapeBasedConfiguration().

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:

◆ writeConfigSeq()

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.

Parameters
[in]bendSeqThe 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.
Returns
A "chain configuration sequence," which looks like [ c0, c1, ..., cm-1 ] where m is the number of edges to be configured, which is n - 1 if this is not a cycle, and n if it is – n the number of nodes in the chain – and each ci is a pair of CardinalDirs.

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().

Here is the caller graph for this function:

Member Data Documentation

◆ npos

const size_t Chain::npos = -1
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().


The documentation for this class was generated from the following files: