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

The Node class represents nodes in a graph. More...

#include <graphs.h>

Inheritance diagram for dialect::Node:
Inheritance graph
Collaboration diagram for dialect::Node:
Collaboration graph

Public Member Functions

GhostNode_SP makeGhost (void) const
 Allocate a GhostNode of this Node.
 
dialect::Nodeoperator= (const dialect::Node &)=default
 Copy-assignment operator.
 
virtual ~Node (void)=default
 Destructor.
 
virtual id_type id (void) const
 Access the unique ID of a given instance. More...
 
unsigned getDegree (void) const
 Check the degree (number of incident Edges) of the Node. More...
 
void setGraph (Graph &graph)
 Tell the Node which Graph it belongs to. More...
 
GraphgetGraph (void)
 Access the Graph to which the Node belongs.
 
void addEdge (const Edge_SP &edge)
 Add an incident Edge.
 
void removeEdge (const dialect::Edge &edge)
 Remove an incident Edge.
 
const EdgesById & getEdgeLookup (void) const
 Read-only access to this Node's lookup map for Edges by their ID.
 
EdgesById getCopyOfEdgeLookup (void) const
 Get a copy of this Node's lookup map for Edges by their ID.
 
void copyGeometry (const dialect::Node &other)
 Give this Node the same coordinates and dimensions as another.
 
void copyOtherGhostProperties (const dialect::Node &other)
 Besides copying geometry, there may be other properties we wish to copy; in particular, properties that are suitable to be copied by a GhostNode.
 
dimensions getHalfDimensions (void) const
 Get an ordered pair (half-width, half-height) for this Node.
 
dimensions getDimensions (void) const
 Get an ordered pair (width, height) for this Node.
 
BoundingBox getBoundingBox (void) const
 Get the bounding box for this Node.
 
Avoid::Point getBoundaryCompassPt (CompassDir dir) const
 Get the point on the boundary of this Node in a given direction from its centre.
 
void setCentre (double cx, double cy)
 Set the position of the node, by setting its centre coordinates.
 
void translate (double dx, double dy)
 Update the position of the node, by adding to its centre coordinates.
 
void applyPlaneMap (PlaneMap map)
 Apply a mapping from libavoid Points to libavoid Points, to this Node's centre.
 
Avoid::Point getCentre (void) const
 Get the centre coordinates of the node.
 
void setExternalId (unsigned id)
 Set an externally-determined ID. (This is useful for TGLF and other interfacing operations.)
 
int getExternalId (void)
 Get the external ID.
 
dialect::Nodes getNeighbours (void) const
 Get the neighbours of this Node.
 
dialect::Nodes getNeighboursCwCyclic (void) const
 Get the neighbours of this Node, listed in clockwise cyclic order (assuming the usual graphics convention of x increasing to the right and y increasing downward).
 
virtual dialect::Nodes getChildren (void) const
 Get the neighbours of this Node that sit as the target end of the connecting Edge. More...
 
void setDims (double w, double h)
 Set the dimensions of the node.
 
void setBoundingBox (double x, double X, double y, double Y)
 Set the bounding box of the node. This sets both the dimensions and the centre point. More...
 
void addPadding (double dw, double dh)
 Add padding to the node's dimensions. More...
 
void updatePosnFromRect (vpsc::Rectangle *r)
 Update the position of this Node to equal that of the given Rectangle.
 
void updateXCoordFromRect (vpsc::Rectangle *r)
 Update the x-coordinate of this Node to equal that of the given Rectangle.
 
void updateYCoordFromRect (vpsc::Rectangle *r)
 Update the y-coordinate of this Node to equal that of the given Rectangle.
 
Avoid::Polygon makeLibavoidPolygon (void) const
 Build and return a Polygon to represent this Node in libavoid.
 
bool isRoot (void) const
 Check whether this Node has been marked as being a root. This is useful when working with trees, and can be safely ignored when working with other sorts of graphs.
 
void setIsRoot (bool isRoot)
 Say whether this Node is a root. This is useful when working with trees, and can be safely ignored when working with other sorts of graphs.
 
bool liesOppositeSegment (const LineSegment &seg, bool openInterval=false)
 Check whether this Node lies opposite a LineSegment, i.e. whether the sides of the Node lying parallel to the segment intersect its interval. More...
 
std::string writeSvg (bool useExternalId=false) const
 Write SVG to represent this Node. More...
 

Static Public Member Functions

static Node_SP allocate (void)
 Factory function, to get a shared pointer to a Node allocated on the heap. We make the constructors protected, in order to ensure that Nodes always come with a control block. More...
 
static Node_SP allocate (double w, double h)
 Convenience factory function to set dimensions.
 
static Node_SP allocate (double cx, double dy, double w, double h)
 Convenience factory function to set position and dimensions.
 

Protected Member Functions

 Node (void)
 Default constructor. More...
 
 Node (double w, double h)
 Construct with dimensions.
 
 Node (double cx, double cy, double w, double h)
 Construct with position and dimensions.
 
 Node (const dialect::Node &)=default
 Copy constructor.
 

Protected Attributes

const id_type m_ID
 An instance's own unique ID:
 
int m_externalID = -1
 
EdgesById m_edges
 Lookup table for incident Edges by Edge's ID:
 

Detailed Description

The Node class represents nodes in a graph.

Constructor & Destructor Documentation

◆ Node()

dialect::Node::Node ( void  )
inlineprotected

Default constructor.

Each Node has an ID number, unique among Nodes (but not necessarily distinct from ID numbers of objects of other classes).

Referenced by allocate().

Here is the caller graph for this function:

Member Function Documentation

◆ addPadding()

void Node::addPadding ( double  dw,
double  dh 
)

Add padding to the node's dimensions.

Note
Amounts can be positive or negative, thus adding or subtracting padding.

◆ allocate()

Node_SP Node::allocate ( void  )
static

Factory function, to get a shared pointer to a Node allocated on the heap. We make the constructors protected, in order to ensure that Nodes always come with a control block.

Returns
A shared_ptr to Node (Node_SP).

References Node().

Referenced by dialect::Graph::addNode(), dialect::TreePlacement::buildTreeBox(), dialect::Graph::buildUniqueBendPoints(), dialect::Graph::cloneNode(), makeGhost(), dialect::Graph::solidifyAlignedEdges(), and dialect::Chain::takeShapeBasedConfiguration().

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

◆ getChildren()

Nodes Node::getChildren ( void  ) const
virtual

Get the neighbours of this Node that sit as the target end of the connecting Edge.

Returns
vector of the children of this Node

Reimplemented in dialect::GhostNode.

References m_edges, and m_ID.

◆ getDegree()

unsigned dialect::Node::getDegree ( void  ) const
inline

Check the degree (number of incident Edges) of the Node.

Returns
The degree of the Node

◆ id()

virtual id_type dialect::Node::id ( void  ) const
inlinevirtual

Access the unique ID of a given instance.

Returns
The ID.

Reimplemented in dialect::GhostNode.

References m_ID.

Referenced by dialect::Edge::getOtherEnd(), dialect::Graph::removeNode(), and setExternalId().

Here is the caller graph for this function:

◆ liesOppositeSegment()

bool Node::liesOppositeSegment ( const LineSegment &  seg,
bool  openInterval = false 
)

Check whether this Node lies opposite a LineSegment, i.e. whether the sides of the Node lying parallel to the segment intersect its interval.

Parameters
segThe LineSegment in question.
openIntervalBoolean saying whether we should treat the interval in question as an open one (i.e. not including its endpoints). Defaults to false, so that the closed interval is considered by default.

References getBoundingBox(), and vpsc::XDIM.

Here is the call graph for this function:

◆ setBoundingBox()

void Node::setBoundingBox ( double  x,
double  X,
double  y,
double  Y 
)

Set the bounding box of the node. This sets both the dimensions and the centre point.

Parameters
[in]xThe minimum x-coord of the box.
[in]XThe maximum x-coord of the box.
[in]yThe minimum y-coord of the box.
[in]YThe maximum y-coord of the box.

◆ setGraph()

void dialect::Node::setGraph ( Graph graph)
inline

Tell the Node which Graph it belongs to.

Parameters
[in]graphThe Graph to which the Node is to belong.

◆ writeSvg()

string Node::writeSvg ( bool  useExternalId = false) const

Write SVG to represent this Node.

Parameters
[in]useExternalIdIf true, write external ID as label; otherwise write internal unique ID.
Returns
A string containing the SVG.

References getBoundingBox(), dialect::BoundingBox::h(), m_externalID, m_ID, dialect::string_format(), and dialect::BoundingBox::w().

Here is the call graph for this function:

Member Data Documentation

◆ m_externalID

int dialect::Node::m_externalID = -1
protected

A Node can store an ID specified externally, as by TGLF. Although external IDs are restricted to non-negative integers, we store the ID as an integer, so that we can use a negative value to indicate that none has been set.

Referenced by getExternalId(), setExternalId(), and writeSvg().


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