Model Railroad System  2.2.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
Parsers::TrackGraph Class Reference

Track Graph class, which encapsulates the track graphs. More...

#include <TrackGraph.h>

Classes

struct  CompressedEdgeValues
 Compressed graph edge values. More...
 
struct  CompressedNodeValues
 Compressed graph node values. More...
 
struct  EdgeValues
 Uncompressed graph edge values. More...
 
struct  NodeValues
 Uncompressed graph node values. More...
 
struct  Point
 Position structure. More...
 
class  Transform2D
 Two dimensional transform class. More...
 

Public Types

enum  NodeType {
  Undefined = -1 , Track = 0 , Turnout , Turntable ,
  Block , SwitchMotor , Signal , Sensor ,
  Control
}
 Node types. More...
 
typedef std::pair< int, int > CompressedEdgePair
 
typedef std::vector< CompressedEdgePairCompressedEdgePairVector
 

Public Member Functions

 TrackGraph ()
 Constructor. More...
 
 ~TrackGraph ()
 Destructor. More...
 
void InsertCurveTrack (int number, TrackBody *tb, float orgX, float orgY, float radius)
 Insert a (circular) curved piece of track. More...
 
void InsertBezierTrack (int number, BezierBody *trb, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 Insert a bezier curved piece of track. More...
 
void InsertCornuTrack (int number, CornuBody *trb, float pos1x, float pos1y, float angle1, float radius1, float center1x, float center1y, float pos2x, float pos2y, float angle2, float radius2, float center2x, float center2y)
 Insert a cornu curved piece of track. More...
 
void InsertStraightTrack (int number, TrackBody *tb)
 Insert a straight piece of track. More...
 
void InsertJointTrack (int number, TrackBody *tb, float l0, float l1, float angle, float R, float L)
 Insert a (spiral) curved piece of track. More...
 
void InsertTurnOut (int number, float orgX, float orgY, float orient, const char *name, TurnoutBody *trb)
 Insert a turnout or crossing. More...
 
void InsertTurnTable (int number, float orgX, float orgY, float radius, TrackBody *tb)
 Insert a turntable. More...
 
void InsertBlock (int number, char *_name, char *_script, IntegerList *_tracklist)
 Insert a Block. More...
 
void InsertSwitchMotor (int number, int turnout, char *_name, char *_normal, char *_reverse, char *_pointsense)
 Insert a switch motor. More...
 
void InsertSignal (int number, char *_name, float _origx, float _origy, float _angle, int _numheads, StringPairList *_aspects)
 Insert a signal. More...
 
void InsertSensor (int number, char *_name, float _origx, float _origy, char *_sensescript)
 Insert a sensor. More...
 
void InsertControl (int number, char *_name, float _origx, float _origy, char *_onscript, char *_offscript)
 Insert a control. More...
 
bool IsNodeP (int nid) const
 Tests if a node id exists in the graph. More...
 
int NumEdges (int nid) const
 Returns the number of edges for the specificed node id. More...
 
int EdgeIndex (int nid, int edgenum) const
 Returns the node id of the specificed edge of the node. More...
 
float EdgeX (int nid, int edgenum) const
 Returns the $X$ coordinate of the specificed edge of the node. More...
 
float EdgeY (int nid, int edgenum) const
 Returns the $Y$ coordinate of the specificed edge of the node. More...
 
float EdgeA (int nid, int edgenum) const
 Returns the angle of the specificed edge of the node. More...
 
float EdgeLength (int nid, int edgenum) const
 Returns the length of an edge. More...
 
NodeType TypeOfNode (int nid) const
 Returns the type of the node. More...
 
const TurnoutGraphicNodeTurnoutGraphic (int nid) const
 Returns the TurnoutGraphic of the node. More...
 
const TurnoutRoutelistNodeTurnoutRoutelist (int nid) const
 Returns the TurnoutRoutelist of the node. More...
 
float LengthOfNode (int nid) const
 Return the track length of a node. More...
 
const IntegerListTrackList (int nid) const
 Return a block's tracklist. More...
 
int TurnoutNumber (int nid) const
 Return a switchmotor's turnout number. More...
 
const char * NameOfNode (int nid) const
 Return a block's or switchmotor's name. More...
 
const char * SenseScript (int nid) const
 Return a block's or switchmotor's sense script. More...
 
const char * NormalActionScript (int nid) const
 Return a switchmotor's normal action script. More...
 
const char * ReverseActionScript (int nid) const
 Return a block's or switchmotor's reverse action script. More...
 
int NumberOfHeads (int nid) const
 Return a Signal's number of heads. More...
 
const StringPairList * SignalAspects (int nid) const
 Return a Signal's aspect list. More...
 
float OrigX (int nid) const
 Return the $x$ coordinate of the signal base. More...
 
float OrigY (int nid) const
 Return the $y$ coordinate of the signal base. More...
 
float Angle (int nid) const
 Return the angle of the signal. More...
 
const char * OnScript (int nid) const
 Return the on action script. More...
 
const char * OffScript (int nid) const
 Return the off action script. More...
 
int LowestNode () const
 Returns the lowest numbered node id. More...
 
int HighestNode () const
 Returns the highest numbered node id. More...
 
void CompressGraph ()
 Create a compressed graph. More...
 
bool IsCompressedNode (int cnid) const
 Is cid a node in the compressed graph? More...
 
int CompressedEdgeCount (int cnid) const
 Number of compressed graph edges for node cnid. More...
 
float CompressedEdgeLength (int cnid, int edgenum) const
 Length of a compressed graph edge. More...
 
int CompressedEdgeNode (int cnid, int edgenum) const
 Next Edge node. More...
 
IntegerListCompressedNodeSegments (int cnid) const
 Raw nodes in a compressed graph node. More...
 
double CompressedNodePositionX (int cnid) const
 X Coordinate of a Compressed Node position. More...
 
double CompressedNodePositionY (int cnid) const
 X Coordinate of a Compressed Node position. More...
 
bool IsCompressed () const
 Is the graph compressed? More...
 
const IntegerListHeads ()
 Uncompressed graph heads. More...
 
const IntegerListRoots ()
 Compressed graph roots. More...
 
void CompressedGraphCircleLayout (double radius)
 Run the BGL circle_graph_layout for a given radius. More...
 
bool CompressedGraphKamadaKawaiSpring (double sidelength)
 Run the BGL kamada_kawai_spring_layout for a given side length. More...
 
CompressedEdgePairVector CompressedGraphKruskalMinimumSpanningTree ()
 Run the kruskal_minimum_spanning_tree algorithm and return a vector of edge pairs. More...
 
CompressedEdgePairVector CompressedGraphPrimMinimumSpanningTree ()
 Run the prim_minimum_spanning_tree algorithm and return a Parent Vector. More...
 

Static Public Member Functions

static float LengthOfStraight (float x1, float y1, float x2, float y2)
 Compute the length of a piece of straight track. More...
 
static float LengthOfCurve (float radius, float a1, float a2)
 Compute the length of a (circular) curved piece of track. More...
 
static float LengthOfJoint (float l0, float l1, float angle, float R, float L)
 Compute the length of a (spiral) curved piece of track. More...
 

Private Types

enum  RotationUnit { Degrees , Radians }
 Rotational units. More...
 
typedef adjacency_list< vecS, vecS, directedS, NodeValues, EdgeValuesGraph
 Boost Graph type (adjacency_list). More...
 
typedef graph_traits< Graph >::vertex_descriptor Node
 Vertex type. More...
 
typedef std::map< int, NodeIdNodeMap
 Type of Node Id map. More...
 
typedef adjacency_list< vecS, vecS, undirectedS, CompressedNodeValues, CompressedEdgeValuesCompressedGraph
 Boost Compressed Graph type (adjacency_list). More...
 
typedef graph_traits< CompressedGraph >::vertex_descriptor CompressedNode
 Compressed Graph Vertex type. More...
 
typedef std::map< int, CompressedNodeCompressedIdNodeMap
 Type of Node Id map. More...
 
typedef std::vector< graph_traits< CompressedGraph >::vertex_descriptor > CompressedNodeVector
 

Private Member Functions

Node AddNewNode (int id, NodeType _type=Undefined, TurnoutGraphic *_tgr=NULL, TurnoutRoutelist *_tpo=NULL, float _length=0.0)
 Helper function to create a new node. More...
 
void computeHeads ()
 Compute uncompressed graph heads (calls strong_components). More...
 
CompressedNode insertCompressedNode (Node rawnode)
 Insert a compressed graph node. More...
 
bool IsNone (Node node)
 Check if node is the none node;. More...
 
void traversePrimMST (CompressedEdgePairVector &result, CompressedNodeVector &parents, CompressedNode r) const
 Traverse a PrimMST, starting at root r, inserting EdgePairs into result. More...
 
Node FindNode (int index) const
 Find a node in the hash table. More...
 
TurnoutGraphicMakeTurnoutGraphic (float orgX, float orgY, float orient, TurnoutBody *trb)
 Generate a turnout node's graphic. More...
 
TurnoutRoutelistMakeTurnoutRouteList (TurnoutBody *trb, const TurnoutGraphic *tgr, float &length)
 Generate a turnout node's route list. More...
 
bool compressed_edge_exists (CompressedNode cnode1, CompressedNode cnode2) const
 Test if an edge already exists. More...
 
Node FindBlock (Node node) const
 Find the block this (raw) nodeid is in. More...
 
Transform2Dtr_translate (float x, float y)
 Construct a translation transform. More...
 
Transform2Dtr_scale (float mag_factor)
 Construct a uniform scale transform. More...
 
Transform2Dtr_scale (float xscale, float yscale)
 Construct a non-uniform scale transform. More...
 
Transform2Dtr_rotate (float amount, RotationUnit measure)
 Construct a rotational transform. More...
 

Static Private Member Functions

static void DeleteTurnoutGraphic (TurnoutGraphic *tgr)
 Free up the memory used by a turnout node's graphic. More...
 
static void DeleteTurnoutRouteList (TurnoutRoutelist *tpo)
 Free up the memory used by a turnout node's route list. More...
 
static float ComputeRouteLength (const TurnoutGraphic *tgr, const IntegerList *il)
 Compute the length of a route. More...
 

Private Attributes

Graph nodes
 Graph adjacency_list. More...
 
IdNodeMap idMap
 Node Id map. More...
 
IntegerListheads
 Uncompressed graph heads (strong components). More...
 
bool valid_heads
 Flag to indicate if heads is valid. More...
 
Node none
 Special node that is nowhere (where all unconnected trackage goes). More...
 
CompressedGraph c_nodes
 Compressed Graph adjacency_list. More...
 
CompressedIdNodeMap c_idMap
 Node Id map. More...
 
IntegerListc_roots
 Compressed Graph Roots. More...
 
bool compressedP
 Is graph compressed? More...
 
bool circleLayoutP
 Has CompressedGraphCircleLayout been run? More...
 
bool KamadaKawaiSpringLayoutP
 Has CompressedGraphKamadaKawaiSpring been run? More...
 
std::map< Node, CompressedNodebackpointers
 Backpointer map. More...
 

Friends

std::ostream & operator<< (ostream &stream, TrackGraph &graph)
 Output operator. More...
 

Detailed Description

Track Graph class, which encapsulates the track graphs.

Holds the two track graphs, an uncompressed, directed graph built from the layout file and a compressed, undirected graph where successive segments of plain trackage are collasped into a single node. Both graphs use the Boost Graph Library adjacency_list template class as the basic graph implementation class. All nodes in both graphs have a unique node id, which is the XTrkCad layout object number.

Several of the Boost Graph Library graph algorithms are implemented, including circle_graph_layout(), kamada_kawai_spring_layout(), kruskal_minimum_spanning_tree() and prim_minimum_spanning_tree(). In addition, the strong_components() algorithm is used to gather nodes into one or more connected groups, since sometimes model train layouts have disjoint sections of track. An example would be a regular main line and an isolated mining or logging railroad. Another example would be a regular main line and one (or more) mass transit (eg trolley) line(s). The head nodes of the collected groups are accessed with the member function Heads(), which returns a list of nodes that are the heads of each of the connected groups. The CompressGraph() function will compress each connected group into a separately compressed graph, with its own root node. The root nodes of each of the compressed sub-graphs are returned with the Roots() member function.

The compuation of connected groups and graph compression are implemented using a lazy eval methodolgy. The connected group collection process is not run until the member function Heads() is called to actually access the list of group heads. And the graph compression is not called until the member function Roots() is called. Calling the CompressGraph() member function (or the Roots() member function), will also call the connected group collection process if it is needed.

To help discover possible mainlines, two minimum spanning tree (MST) algorithms are provided, Kruskal's and Prim's, via the member functions CompressedGraphKruskalMinimumSpanningTree() and CompressedGraphPrimMinimumSpanningTree(), respectively. Both of these function return a list of edge pairs: a STL vector of STL pairs of compressed nodes.

Two graphical layout algorithms are also provided, circle graph layout and kamada kawai spring layout, via the two member functions, CompressedGraphCircleLayout() and CompressedGraphKamadaKawaiSpring(), respectively. Both set or update a pair of double values $(x,y)$ associated with every compressed node and which are accessed with the CompressedNodePositionX() and CompressedNodePositionY() member functions. CompressedGraphCircleLayout() sets these files and CompressedGraphKamadaKawaiSpring() updates them. CompressedGraphCircleLayout() should be called before CompressedGraphKamadaKawaiSpring(). CompressedGraphKamadaKawaiSpring() returns a boolean flag indicating if it was able to create a layout. Returning a false value indicates that the graph was disjoint – CompressedGraphKamadaKawaiSpring() cannot be used with a disjoint graph.

Author
Robert Heller <heller@deepsoft.com>

Member Typedef Documentation

◆ CompressedEdgePair

typedef std::pair< int, int > Parsers::TrackGraph::CompressedEdgePair

◆ CompressedEdgePairVector

◆ CompressedGraph

typedef adjacency_list< vecS, vecS, undirectedS, CompressedNodeValues , CompressedEdgeValues > Parsers::TrackGraph::CompressedGraph
private

Boost Compressed Graph type (adjacency_list).

◆ CompressedIdNodeMap

typedef std::map< int, CompressedNode > Parsers::TrackGraph::CompressedIdNodeMap
private

Type of Node Id map.

◆ CompressedNode

typedef graph_traits< CompressedGraph >::vertex_descriptor Parsers::TrackGraph::CompressedNode
private

Compressed Graph Vertex type.

◆ CompressedNodeVector

typedef std::vector< graph_traits < CompressedGraph >::vertex_descriptor > Parsers::TrackGraph::CompressedNodeVector
private

◆ Graph

typedef adjacency_list< vecS, vecS, directedS, NodeValues , EdgeValues > Parsers::TrackGraph::Graph
private

Boost Graph type (adjacency_list).

◆ IdNodeMap

typedef std::map< int, Node > Parsers::TrackGraph::IdNodeMap
private

Type of Node Id map.

◆ Node

typedef graph_traits< Graph >::vertex_descriptor Parsers::TrackGraph::Node
private

Vertex type.

Member Enumeration Documentation

◆ NodeType

Node types.

Enumerator
Undefined 

Undefined type.

Track 

Plain trackage: straight, curved, or easement.

Turnout 

Turnout or crossing.

Turntable 

Turntable.

Block 

Block.

SwitchMotor 

Switch Motor.

Signal 

Signal.

Sensor 

Sensor.

Control 

Control.

◆ RotationUnit

Rotational units.

Enumerator
Degrees 

Units are in degrees.

Radians 

Units are in radians.

Constructor & Destructor Documentation

◆ TrackGraph()

Parsers::TrackGraph::TrackGraph ( )

Constructor.

◆ ~TrackGraph()

Parsers::TrackGraph::~TrackGraph ( )

Destructor.

Member Function Documentation

◆ AddNewNode()

Node Parsers::TrackGraph::AddNewNode ( int  id,
NodeType  _type = Undefined,
TurnoutGraphic _tgr = NULL,
TurnoutRoutelist _tpo = NULL,
float  _length = 0.0 
)
private

Helper function to create a new node.

◆ Angle()

float Parsers::TrackGraph::Angle ( int  nid) const

Return the angle of the signal.

Parameters
nidThe node to look at.

Referenced by Parsers::LayoutFile::Angle().

◆ compressed_edge_exists()

bool Parsers::TrackGraph::compressed_edge_exists ( CompressedNode  cnode1,
CompressedNode  cnode2 
) const
private

Test if an edge already exists.

◆ CompressedEdgeCount()

int Parsers::TrackGraph::CompressedEdgeCount ( int  cnid) const

Number of compressed graph edges for node cnid.

Referenced by Parsers::LayoutFile::CompressedEdgeCount().

◆ CompressedEdgeLength()

float Parsers::TrackGraph::CompressedEdgeLength ( int  cnid,
int  edgenum 
) const

Length of a compressed graph edge.

Referenced by Parsers::LayoutFile::CompressedEdgeLength().

◆ CompressedEdgeNode()

int Parsers::TrackGraph::CompressedEdgeNode ( int  cnid,
int  edgenum 
) const

Next Edge node.

Referenced by Parsers::LayoutFile::CompressedEdgeNode().

◆ CompressedGraphCircleLayout()

void Parsers::TrackGraph::CompressedGraphCircleLayout ( double  radius)

Run the BGL circle_graph_layout for a given radius.

Referenced by Parsers::LayoutFile::CompressedGraphCircleLayout().

◆ CompressedGraphKamadaKawaiSpring()

bool Parsers::TrackGraph::CompressedGraphKamadaKawaiSpring ( double  sidelength)

Run the BGL kamada_kawai_spring_layout for a given side length.

Referenced by Parsers::LayoutFile::CompressedGraphKamadaKawaiSpring().

◆ CompressedGraphKruskalMinimumSpanningTree()

CompressedEdgePairVector Parsers::TrackGraph::CompressedGraphKruskalMinimumSpanningTree ( )

Run the kruskal_minimum_spanning_tree algorithm and return a vector of edge pairs.

Referenced by Parsers::LayoutFile::CompressedGraphKruskalMinimumSpanningTree().

◆ CompressedGraphPrimMinimumSpanningTree()

CompressedEdgePairVector Parsers::TrackGraph::CompressedGraphPrimMinimumSpanningTree ( )

Run the prim_minimum_spanning_tree algorithm and return a Parent Vector.

Referenced by Parsers::LayoutFile::CompressedGraphPrimMinimumSpanningTree().

◆ CompressedNodePositionX()

double Parsers::TrackGraph::CompressedNodePositionX ( int  cnid) const

X Coordinate of a Compressed Node position.

Referenced by Parsers::LayoutFile::CompressedNodePositionX().

◆ CompressedNodePositionY()

double Parsers::TrackGraph::CompressedNodePositionY ( int  cnid) const

X Coordinate of a Compressed Node position.

Referenced by Parsers::LayoutFile::CompressedNodePositionY().

◆ CompressedNodeSegments()

IntegerList* Parsers::TrackGraph::CompressedNodeSegments ( int  cnid) const

Raw nodes in a compressed graph node.

Referenced by Parsers::LayoutFile::CompressedNodeSegments().

◆ CompressGraph()

void Parsers::TrackGraph::CompressGraph ( )

Create a compressed graph.

Referenced by Parsers::LayoutFile::CompressGraph().

◆ computeHeads()

void Parsers::TrackGraph::computeHeads ( )
private

Compute uncompressed graph heads (calls strong_components).

◆ ComputeRouteLength()

static float Parsers::TrackGraph::ComputeRouteLength ( const TurnoutGraphic tgr,
const IntegerList il 
)
staticprivate

Compute the length of a route.

◆ DeleteTurnoutGraphic()

static void Parsers::TrackGraph::DeleteTurnoutGraphic ( TurnoutGraphic tgr)
staticprivate

Free up the memory used by a turnout node's graphic.

◆ DeleteTurnoutRouteList()

static void Parsers::TrackGraph::DeleteTurnoutRouteList ( TurnoutRoutelist tpo)
staticprivate

Free up the memory used by a turnout node's route list.

◆ EdgeA()

float Parsers::TrackGraph::EdgeA ( int  nid,
int  edgenum 
) const

Returns the angle of the specificed edge of the node.

Referenced by Parsers::LayoutFile::EdgeA().

◆ EdgeIndex()

int Parsers::TrackGraph::EdgeIndex ( int  nid,
int  edgenum 
) const

Returns the node id of the specificed edge of the node.

Referenced by Parsers::LayoutFile::EdgeIndex().

◆ EdgeLength()

float Parsers::TrackGraph::EdgeLength ( int  nid,
int  edgenum 
) const

Returns the length of an edge.

Referenced by Parsers::LayoutFile::EdgeLength().

◆ EdgeX()

float Parsers::TrackGraph::EdgeX ( int  nid,
int  edgenum 
) const

Returns the $X$ coordinate of the specificed edge of the node.

Referenced by Parsers::LayoutFile::EdgeX().

◆ EdgeY()

float Parsers::TrackGraph::EdgeY ( int  nid,
int  edgenum 
) const

Returns the $Y$ coordinate of the specificed edge of the node.

Referenced by Parsers::LayoutFile::EdgeY().

◆ FindBlock()

Node Parsers::TrackGraph::FindBlock ( Node  node) const
private

Find the block this (raw) nodeid is in.

Parameters
nodeThe (raw) Node.
Returns
the raw Node of the block node or none, if there is no block.

◆ FindNode()

Node Parsers::TrackGraph::FindNode ( int  index) const
private

Find a node in the hash table.

◆ Heads()

const IntegerList* Parsers::TrackGraph::Heads ( )
inline

Uncompressed graph heads.

Referenced by Parsers::LayoutFile::Heads().

◆ HighestNode()

int Parsers::TrackGraph::HighestNode ( ) const

Returns the highest numbered node id.

Referenced by Parsers::LayoutFile::HighestNode().

◆ InsertBezierTrack()

void Parsers::TrackGraph::InsertBezierTrack ( int  number,
BezierBody trb,
float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
float  x4,
float  y4 
)

Insert a bezier curved piece of track.

◆ InsertBlock()

void Parsers::TrackGraph::InsertBlock ( int  number,
char *  _name,
char *  _script,
IntegerList _tracklist 
)

Insert a Block.

◆ insertCompressedNode()

CompressedNode Parsers::TrackGraph::insertCompressedNode ( Node  rawnode)
private

Insert a compressed graph node.

◆ InsertControl()

void Parsers::TrackGraph::InsertControl ( int  number,
char *  _name,
float  _origx,
float  _origy,
char *  _onscript,
char *  _offscript 
)

Insert a control.

◆ InsertCornuTrack()

void Parsers::TrackGraph::InsertCornuTrack ( int  number,
CornuBody trb,
float  pos1x,
float  pos1y,
float  angle1,
float  radius1,
float  center1x,
float  center1y,
float  pos2x,
float  pos2y,
float  angle2,
float  radius2,
float  center2x,
float  center2y 
)

Insert a cornu curved piece of track.

◆ InsertCurveTrack()

void Parsers::TrackGraph::InsertCurveTrack ( int  number,
TrackBody tb,
float  orgX,
float  orgY,
float  radius 
)

Insert a (circular) curved piece of track.

◆ InsertJointTrack()

void Parsers::TrackGraph::InsertJointTrack ( int  number,
TrackBody tb,
float  l0,
float  l1,
float  angle,
float  R,
float  L 
)

Insert a (spiral) curved piece of track.

◆ InsertSensor()

void Parsers::TrackGraph::InsertSensor ( int  number,
char *  _name,
float  _origx,
float  _origy,
char *  _sensescript 
)

Insert a sensor.

◆ InsertSignal()

void Parsers::TrackGraph::InsertSignal ( int  number,
char *  _name,
float  _origx,
float  _origy,
float  _angle,
int  _numheads,
StringPairList *  _aspects 
)

Insert a signal.

◆ InsertStraightTrack()

void Parsers::TrackGraph::InsertStraightTrack ( int  number,
TrackBody tb 
)

Insert a straight piece of track.

◆ InsertSwitchMotor()

void Parsers::TrackGraph::InsertSwitchMotor ( int  number,
int  turnout,
char *  _name,
char *  _normal,
char *  _reverse,
char *  _pointsense 
)

Insert a switch motor.

◆ InsertTurnOut()

void Parsers::TrackGraph::InsertTurnOut ( int  number,
float  orgX,
float  orgY,
float  orient,
const char *  name,
TurnoutBody trb 
)

Insert a turnout or crossing.

◆ InsertTurnTable()

void Parsers::TrackGraph::InsertTurnTable ( int  number,
float  orgX,
float  orgY,
float  radius,
TrackBody tb 
)

Insert a turntable.

◆ IsCompressed()

bool Parsers::TrackGraph::IsCompressed ( ) const
inline

Is the graph compressed?

Returns
True if the graph is compressed, False otherwised.

Referenced by Parsers::LayoutFile::IsCompressed().

◆ IsCompressedNode()

bool Parsers::TrackGraph::IsCompressedNode ( int  cnid) const

Is cid a node in the compressed graph?

Referenced by Parsers::LayoutFile::IsCompressedNode().

◆ IsNodeP()

bool Parsers::TrackGraph::IsNodeP ( int  nid) const

Tests if a node id exists in the graph.

Referenced by Parsers::LayoutFile::IsNodeP().

◆ IsNone()

bool Parsers::TrackGraph::IsNone ( Node  node)
inlineprivate

Check if node is the none node;.

◆ LengthOfCurve()

static float Parsers::TrackGraph::LengthOfCurve ( float  radius,
float  a1,
float  a2 
)
static

Compute the length of a (circular) curved piece of track.

◆ LengthOfJoint()

static float Parsers::TrackGraph::LengthOfJoint ( float  l0,
float  l1,
float  angle,
float  R,
float  L 
)
static

Compute the length of a (spiral) curved piece of track.

◆ LengthOfNode()

float Parsers::TrackGraph::LengthOfNode ( int  nid) const

Return the track length of a node.

Referenced by Parsers::LayoutFile::LengthOfNode().

◆ LengthOfStraight()

static float Parsers::TrackGraph::LengthOfStraight ( float  x1,
float  y1,
float  x2,
float  y2 
)
static

Compute the length of a piece of straight track.

◆ LowestNode()

int Parsers::TrackGraph::LowestNode ( ) const

Returns the lowest numbered node id.

Referenced by Parsers::LayoutFile::LowestNode().

◆ MakeTurnoutGraphic()

TurnoutGraphic* Parsers::TrackGraph::MakeTurnoutGraphic ( float  orgX,
float  orgY,
float  orient,
TurnoutBody trb 
)
private

Generate a turnout node's graphic.

◆ MakeTurnoutRouteList()

TurnoutRoutelist* Parsers::TrackGraph::MakeTurnoutRouteList ( TurnoutBody trb,
const TurnoutGraphic tgr,
float &  length 
)
private

Generate a turnout node's route list.

◆ NameOfNode()

const char* Parsers::TrackGraph::NameOfNode ( int  nid) const

Return a block's or switchmotor's name.

Referenced by Parsers::LayoutFile::NameOfNode().

◆ NodeTurnoutGraphic()

const TurnoutGraphic* Parsers::TrackGraph::NodeTurnoutGraphic ( int  nid) const

Returns the TurnoutGraphic of the node.

Referenced by Parsers::LayoutFile::NodeTurnoutGraphic().

◆ NodeTurnoutRoutelist()

const TurnoutRoutelist* Parsers::TrackGraph::NodeTurnoutRoutelist ( int  nid) const

Returns the TurnoutRoutelist of the node.

Referenced by Parsers::LayoutFile::NodeTurnoutRoutelist().

◆ NormalActionScript()

const char* Parsers::TrackGraph::NormalActionScript ( int  nid) const

Return a switchmotor's normal action script.

Referenced by Parsers::LayoutFile::NormalActionScript().

◆ NumberOfHeads()

int Parsers::TrackGraph::NumberOfHeads ( int  nid) const

Return a Signal's number of heads.

Referenced by Parsers::LayoutFile::NumberOfHeads().

◆ NumEdges()

int Parsers::TrackGraph::NumEdges ( int  nid) const

Returns the number of edges for the specificed node id.

Referenced by Parsers::LayoutFile::NumEdges().

◆ OffScript()

const char* Parsers::TrackGraph::OffScript ( int  nid) const

Return the off action script.

Parameters
nidThe node to look at.

Referenced by Parsers::LayoutFile::OffScript().

◆ OnScript()

const char* Parsers::TrackGraph::OnScript ( int  nid) const

Return the on action script.

Parameters
nidThe node to look at.

Referenced by Parsers::LayoutFile::OnScript().

◆ OrigX()

float Parsers::TrackGraph::OrigX ( int  nid) const

Return the $x$ coordinate of the signal base.

Parameters
nidThe node to look at.

Referenced by Parsers::LayoutFile::OrigX().

◆ OrigY()

float Parsers::TrackGraph::OrigY ( int  nid) const

Return the $y$ coordinate of the signal base.

Parameters
nidThe node to look at.

Referenced by Parsers::LayoutFile::OrigY().

◆ ReverseActionScript()

const char* Parsers::TrackGraph::ReverseActionScript ( int  nid) const

Return a block's or switchmotor's reverse action script.

Referenced by Parsers::LayoutFile::ReverseActionScript().

◆ Roots()

const IntegerList* Parsers::TrackGraph::Roots ( )
inline

Compressed graph roots.

Referenced by Parsers::LayoutFile::Roots().

◆ SenseScript()

const char* Parsers::TrackGraph::SenseScript ( int  nid) const

Return a block's or switchmotor's sense script.

Referenced by Parsers::LayoutFile::SenseScript().

◆ SignalAspects()

const StringPairList* Parsers::TrackGraph::SignalAspects ( int  nid) const

Return a Signal's aspect list.

Referenced by Parsers::LayoutFile::SignalAspects().

◆ tr_rotate()

Transform2D* Parsers::TrackGraph::tr_rotate ( float  amount,
RotationUnit  measure 
)
private

Construct a rotational transform.

◆ tr_scale() [1/2]

Transform2D* Parsers::TrackGraph::tr_scale ( float  mag_factor)
private

Construct a uniform scale transform.

◆ tr_scale() [2/2]

Transform2D* Parsers::TrackGraph::tr_scale ( float  xscale,
float  yscale 
)
private

Construct a non-uniform scale transform.

◆ tr_translate()

Transform2D* Parsers::TrackGraph::tr_translate ( float  x,
float  y 
)
private

Construct a translation transform.

◆ TrackList()

const IntegerList* Parsers::TrackGraph::TrackList ( int  nid) const

Return a block's tracklist.

Referenced by Parsers::LayoutFile::TrackList().

◆ traversePrimMST()

void Parsers::TrackGraph::traversePrimMST ( CompressedEdgePairVector result,
CompressedNodeVector parents,
CompressedNode  r 
) const
private

Traverse a PrimMST, starting at root r, inserting EdgePairs into result.

◆ TurnoutNumber()

int Parsers::TrackGraph::TurnoutNumber ( int  nid) const

Return a switchmotor's turnout number.

Referenced by Parsers::LayoutFile::TurnoutNumber().

◆ TypeOfNode()

NodeType Parsers::TrackGraph::TypeOfNode ( int  nid) const

Returns the type of the node.

Referenced by Parsers::LayoutFile::TypeOfNode().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( ostream &  stream,
TrackGraph graph 
)
friend

Output operator.

Member Data Documentation

◆ backpointers

std::map<Node, CompressedNode> Parsers::TrackGraph::backpointers
private

Backpointer map.

◆ c_idMap

CompressedIdNodeMap Parsers::TrackGraph::c_idMap
private

Node Id map.

◆ c_nodes

CompressedGraph Parsers::TrackGraph::c_nodes
private

Compressed Graph adjacency_list.

◆ c_roots

IntegerList* Parsers::TrackGraph::c_roots
private

Compressed Graph Roots.

◆ circleLayoutP

bool Parsers::TrackGraph::circleLayoutP
private

Has CompressedGraphCircleLayout been run?

◆ compressedP

bool Parsers::TrackGraph::compressedP
private

Is graph compressed?

◆ heads

IntegerList* Parsers::TrackGraph::heads
private

Uncompressed graph heads (strong components).

◆ idMap

IdNodeMap Parsers::TrackGraph::idMap
private

Node Id map.

◆ KamadaKawaiSpringLayoutP

bool Parsers::TrackGraph::KamadaKawaiSpringLayoutP
private

Has CompressedGraphKamadaKawaiSpring been run?

◆ nodes

Graph Parsers::TrackGraph::nodes
private

Graph adjacency_list.

◆ none

Node Parsers::TrackGraph::none
private

Special node that is nowhere (where all unconnected trackage goes).

◆ valid_heads

bool Parsers::TrackGraph::valid_heads
private

Flag to indicate if heads is valid.