Adaptagrams
|
Represents a single face of a 4-planar, orthogonal layout. More...
#include <faces.h>
Public Member Functions | |
Face (Graph_SP &G) | |
Standard constructor. More... | |
void | initWithEdgeSeq (const std::vector< IdPair > &edges) |
A method to build the Face, based on the clockwise sequence of "edges" of which it is made up; here an "edge" is a mere IdPair. | |
Nodes | getNodeSeq (void) |
Access the sequence (vector) of Nodes belonging to the Face, in clockwise order. | |
Sides | getSides (void) |
Get a copy of the vector of Sides. | |
NexesById | getNexusLookup (void) |
Get a copy of the Nexus lookup. | |
bool | containsNodeIdSeq (std::vector< id_type > idSeq) const |
Utility method, to test whether the Face contains a given sequence of Node IDs, in clockwise cyclic order. | |
Graph_SP | getGraph (void) |
Access the underlying Graph. | |
id_type | id (void) const |
Access the unique ID of a given instance. More... | |
bool | isExternal (void) const |
Check whether this is the external face or not. | |
std::string | toString (void) const |
Get a string representation. | |
std::map< id_type, std::vector< std::pair< Node_SP, Node_SP > > > | getNbrPairs (void) |
Access the neighbour pairs. | |
Sides | getRelevantSidesForPlacement (TreePlacement_SP tp) const |
Get a vector of all Sides that are relevant to a given TreePlacement. | |
void | listAllPossibleTreePlacements (TreePlacements &tps, Tree_SP tree, Node_SP root, HolaOpts opts) |
Compute all the possible ways of placing a given Tree into this Faces, at a given root Node belonging to this Face. More... | |
CompassDirs | inwardDirsAvailable (Node_SP node) |
List the compass directions in which an edge could point if it were anchored at the given Node, and pointed inward, into the Face. More... | |
void | insertTreeNode (TreePlacement_SP tp, double padding=0) |
To be used after the face has been expanded to make room for the tree. This method adds a large node to the graph, representing the bounding box of the tree, with padding. The treenode is constrained to lie beside its root node. More... | |
ProjSeq_SP | computeCollateralProjSeq (TreePlacement_SP tp, double padding=0) |
Compute a projection sequence to remove/prevent overlaps between the given TreePlacement's tree box, and any existing tree boxes or ordinary perimeter Nodes on relevant Sides of this Face. More... | |
bool | applyProjSeq (ProjSeq &ps) |
Convenience function for applying a ProjSeq with all the appropriate options. More... | |
ProjSeq_SP | doCollateralExpansion (TreePlacement_SP tp, double padding=-1) |
Perform collateral expansion for a given TreePlacement. This means pushing Nodes and tree boxes on relevant Sides out of the way, to make room for the new tree box. More... | |
void | buildBdrySegsFacingOneDir (CardinalDir facingDir, LineSegments &closedSegs, LineSegments &openSegs, TreePlacement_SP ignoreTP=nullptr) |
Build LineSegments to represent all those segments of the internal boundary of this Face that face in a given direction. These segments can represent aligned Edges, or parts of boundaries of Nodes or tree boxes. More... | |
ProjSeq_SP | buildBestProjSeq (TreePlacement_SP tp, double padding=0, bool doCostlierDimensionFirst=false, ExpansionEstimateMethod estimateMethod=ExpansionEstimateMethod::CONSTRAINTS) |
Build the best projection sequence for a given tree placement. More... | |
Sides | getAllSidesOppositeSegment (LineSegment &seg, bool openInterval=false) const |
Get all the Sides of this Face that lie opposite a given LineSegment. More... | |
TreePlacements | getAllTreePlacements (void) const |
Get all TreePlacements that have been added to this Face. More... | |
std::set< TreePlacement_SP > | getSetOfAllTreePlacements (void) const |
Get the set of all TreePlacements that have been added to this Face. More... | |
void | getAllTreePlacements (TreePlacements &tps) const |
Get all TreePlacements that have been added to this Face. More... | |
void | getNumTreesByGrowthDir (std::map< CardinalDir, size_t > &counts, bool scaleBySize=false) const |
After tree placements have been chosen and performed, get a count of trees by growth direction. More... | |
Represents a single face of a 4-planar, orthogonal layout.
|
inline |
bool Face::applyProjSeq | ( | ProjSeq & | ps | ) |
Convenience function for applying a ProjSeq with all the appropriate options.
[in] | ps | The ProjSeq to be applied. |
References dialect::ColaOptions::preventOverlaps, and dialect::ColaOptions::solidifyAlignedEdges.
Referenced by doCollateralExpansion().
void Face::buildBdrySegsFacingOneDir | ( | CardinalDir | facingDir, |
LineSegments & | closedSegs, | ||
LineSegments & | openSegs, | ||
TreePlacement_SP | ignoreTP = nullptr |
||
) |
Build LineSegments to represent all those segments of the internal boundary of this Face that face in a given direction. These segments can represent aligned Edges, or parts of boundaries of Nodes or tree boxes.
[in] | facingDir | CardinalDir telling which side the segments should face. |
[out] | closedSegs | Vector in which to store all constructed closed segments. |
[out] | openSegs | Vector in which to store all constructed open segments. |
[in] | ignoreTP | Optional TreePlacement whose collateral tree boxes should be ignored. |
For example, if facingDir is SOUTH, then closedSegs will get one LineSegment for every horizontal Edge in the Face, while openSegs will get a LineSegment representing the southern boundary of (a) each Node in the Face, and (b) each Tree box in the Face.
References dialect::BoundingBox::buildSideSegment(), getRelevantSidesForPlacement(), Avoid::Point::id, Avoid::Point::x, and Avoid::Point::y.
ProjSeq_SP Face::buildBestProjSeq | ( | TreePlacement_SP | tp, |
double | padding = 0 , |
||
bool | doCostlierDimensionFirst = false , |
||
ExpansionEstimateMethod | estimateMethod = ExpansionEstimateMethod::CONSTRAINTS |
||
) |
Build the best projection sequence for a given tree placement.
[in] | tp | The TreePlacement to be added to this Face. |
[in] | padding | Optional padding for the new tree box. |
[in] | doCostlierDimensionFirst | See TreePlacement::buildBestProjSeq. |
[in] | estimateMethod | See defn of ExpansionEstimateMethod enum class. |
References doCollateralExpansion(), and vpsc::XDIM.
ProjSeq_SP Face::computeCollateralProjSeq | ( | TreePlacement_SP | tp, |
double | padding = 0 |
||
) |
Compute a projection sequence to remove/prevent overlaps between the given TreePlacement's tree box, and any existing tree boxes or ordinary perimeter Nodes on relevant Sides of this Face.
[in] | tp | The TreePlacement to be added to this Face. |
[in] | padding | Optional padding for the new tree box. |
That is, if each side has an existing treenode that must be pushed away, the sepco for one tree will never achieve the push for the other, since these pushes /must/ be done in complementary dimensions.
Therefore there is no need to wait until after the first removal has been actually performed to compute the sepco for the second removal; it cannot be affected by the first one. This means we can safely compute them simultaneously.
References getRelevantSidesForPlacement().
Referenced by doCollateralExpansion().
ProjSeq_SP Face::doCollateralExpansion | ( | TreePlacement_SP | tp, |
double | padding = -1 |
||
) |
Perform collateral expansion for a given TreePlacement. This means pushing Nodes and tree boxes on relevant Sides out of the way, to make room for the new tree box.
[in] | tp | The TreePlacement requiring space. |
[in] | padding | Optional padding to be added to the new tree box. Leave negative if you want padding equal to iel/4 to be automatically applied, where iel is the underlying graph's current ideal edge length. |
Runtime | exception if any of the collateral expansion projections are infeasible. In theory this should never happen. |
References applyProjSeq(), and computeCollateralProjSeq().
Referenced by buildBestProjSeq().
Sides Face::getAllSidesOppositeSegment | ( | LineSegment & | seg, |
bool | openInterval = false |
||
) | const |
Get all the Sides of this Face that lie opposite a given LineSegment.
[in] | seg | The LineSegment in question. |
[in] | openInterval | Set true if you want to consider the overlap with the LineSegment's open interval instead of closed (the default). |
TreePlacements Face::getAllTreePlacements | ( | void | ) | const |
Get all TreePlacements that have been added to this Face.
Referenced by getNumTreesByGrowthDir().
void Face::getAllTreePlacements | ( | TreePlacements & | tps | ) | const |
void Face::getNumTreesByGrowthDir | ( | std::map< CardinalDir, size_t > & | counts, |
bool | scaleBySize = false |
||
) | const |
After tree placements have been chosen and performed, get a count of trees by growth direction.
[out] | counts | Map into which the counts should be added. |
[in] | scaleBySize | Set true if for each tree you actually want to count its number of nodes. In other words, the final counts you get actually indicate the number of nodes in trees that grow in the given directions. |
References getAllTreePlacements().
std::set< TreePlacement_SP > Face::getSetOfAllTreePlacements | ( | void | ) | const |
Get the set of all TreePlacements that have been added to this Face.
|
inline |
Access the unique ID of a given instance.
void Face::insertTreeNode | ( | TreePlacement_SP | tp, |
double | padding = 0 |
||
) |
To be used after the face has been expanded to make room for the tree. This method adds a large node to the graph, representing the bounding box of the tree, with padding. The treenode is constrained to lie beside its root node.
[in] | tp | A TreePlacement representing the Tree to be placed. |
[in] | padding | Optional padding to be added to the tree box. |
References getRelevantSidesForPlacement(), Avoid::Point::x, and Avoid::Point::y.
Referenced by dialect::TreePlacement::insertTreeNode().
CompassDirs Face::inwardDirsAvailable | ( | Node_SP | node | ) |
List the compass directions in which an edge could point if it were anchored at the given Node, and pointed inward, into the Face.
Because of the way the faces are traced out, swinging from the previous node to the next one sweeps out an area of the /inside/ of this face when you go /anticlockwise/.
Therefore if d0 is the compass direction from node to prev, and if d1 is that from node to next, then the available directions are all those strictly between d0 and d1 /in the anticlockwise direction/.
For example, if node –> prev points South while node –> next points West, then both East and North are available. But if node –> prev points East while node –> next points North, then only NE is available.
Referenced by listAllPossibleTreePlacements().
void Face::listAllPossibleTreePlacements | ( | TreePlacements & | tps, |
Tree_SP | tree, | ||
Node_SP | root, | ||
HolaOpts | opts | ||
) |
Compute all the possible ways of placing a given Tree into this Faces, at a given root Node belonging to this Face.
[out] | tps | A vector of TreePlacements to which all those allocated by this method are to be added. |
[in] | tree | The Tree to be placed. |
[in] | root | The Node, belonging to this Face, where the Tree is to attach. |
[in] | opts | Options to control which kinds of placements are defined. |
References inwardDirsAvailable().