Model Railroad System
2.2.2
|
File to parse an XTrkCad layout file and create a track graph. More...
#include <ParseFile.h>
Public Member Functions | |
LayoutFile (const char *filename, MRRXtrkCad *p) | |
Constructor. More... | |
virtual | ~LayoutFile () |
Destructor. More... | |
void | Emit (ostream &outstream) |
Function to Emit a track graph to an output stream. 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... | |
TrackGraph::NodeType | TypeOfNode (int nid) const |
Returns the type of the node. More... | |
const TurnoutGraphic * | NodeTurnoutGraphic (int nid) const |
Returns the TurnoutGraphic of the node. More... | |
const TurnoutRoutelist * | NodeTurnoutRoutelist (int nid) const |
Returns the TurnoutRoutelist of the node. More... | |
float | LengthOfNode (int nid) const |
Return the track length of a node. More... | |
const IntegerList * | TrackList (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... | |
int | CompressedEdgeCount (int cnid) const |
Number of compressed graph edges. 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... | |
IntegerList * | CompressedNodeSegments (int cnid) const |
Raw nodes in a compressed graph node. More... | |
bool | IsCompressed () const |
const IntegerList * | Heads () |
bool | IsCompressedNode (int cnid) const |
Is cid a node in the compressed graph? More... | |
const IntegerList * | Roots () |
Compressed graph roots. 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... | |
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... | |
TrackGraph::CompressedEdgePairVector | CompressedGraphKruskalMinimumSpanningTree () |
Run the kruskal_minimum_spanning_tree algorithm and return a vector of edge pairs. More... | |
TrackGraph::CompressedEdgePairVector | CompressedGraphPrimMinimumSpanningTree () |
Run the prim_minimum_spanning_tree algorithm and return a vector of edge pairs. More... | |
![]() | |
const char * | SourceFile () const |
Return the name of the source file. More... | |
ParseFile (const char *filename) | |
Constructor. More... | |
virtual | ~ParseFile () |
Destructor. More... | |
int | ProcessFile (ostream &err) |
open file and parse it. More... | |
Protected Member Functions | |
virtual int | Parse () |
Parseer function. More... | |
virtual void | ParseError (const char *m) |
Parse error handler. More... | |
Protected Attributes | |
MRRXtrkCad * | parser |
Parser. More... | |
TrackGraph * | trackGraph |
Track graph, a graph of all of the trackwork in the layput file. More... | |
![]() | |
char * | lp |
Input line buffer pointer. More... | |
FILE * | fp |
Input file pointer. More... | |
int | source_line |
Source line number. More... | |
char | line_buffer [buffersize] |
Input line buffer. More... | |
ostream * | errorstream |
Stream for error reporting. More... | |
char * | source_file |
Name of the source file. More... | |
Additional Inherited Members | |
![]() | |
static const int | buffersize = 1024 |
Size of line buffer. More... | |
File to parse an XTrkCad layout file and create a track graph.
Parsers::LayoutFile::LayoutFile | ( | const char * | filename, |
MRRXtrkCad * | p | ||
) |
Constructor.
See MRRXtrkCad. User code normally creates a MRRXtrkCad object and the MRRXtrkCad constructor calls this constructor. User code then accesses the inherited methods of LayoutFile and ParseFile from the MRRXtrkCad object.
|
virtual |
Destructor.
|
inline |
Return the angle of the signal.
nid | The node to look at. |
References Parsers::TrackGraph::Angle(), and trackGraph.
|
inline |
Number of compressed graph edges.
References Parsers::TrackGraph::CompressedEdgeCount(), and trackGraph.
|
inline |
Length of a compressed graph edge.
References Parsers::TrackGraph::CompressedEdgeLength(), and trackGraph.
|
inline |
Next Edge node.
References Parsers::TrackGraph::CompressedEdgeNode(), and trackGraph.
|
inline |
Run the BGL circle_graph_layout for a given radius.
References Parsers::TrackGraph::CompressedGraphCircleLayout(), and trackGraph.
|
inline |
Run the BGL kamada_kawai_spring_layout for a given side length.
References Parsers::TrackGraph::CompressedGraphKamadaKawaiSpring(), and trackGraph.
|
inline |
Run the kruskal_minimum_spanning_tree algorithm and return a vector of edge pairs.
References Parsers::TrackGraph::CompressedGraphKruskalMinimumSpanningTree(), and trackGraph.
|
inline |
Run the prim_minimum_spanning_tree algorithm and return a vector of edge pairs.
References Parsers::TrackGraph::CompressedGraphPrimMinimumSpanningTree(), and trackGraph.
|
inline |
X Coordinate of a Compressed Node position.
References Parsers::TrackGraph::CompressedNodePositionX(), and trackGraph.
|
inline |
X Coordinate of a Compressed Node position.
References Parsers::TrackGraph::CompressedNodePositionY(), and trackGraph.
|
inline |
Raw nodes in a compressed graph node.
References Parsers::TrackGraph::CompressedNodeSegments(), and trackGraph.
|
inline |
Create a compressed graph.
References Parsers::TrackGraph::CompressGraph(), and trackGraph.
|
inline |
Returns the angle of the specificed edge of the node.
References Parsers::TrackGraph::EdgeA(), and trackGraph.
|
inline |
Returns the node id of the specificed edge of the node.
References Parsers::TrackGraph::EdgeIndex(), and trackGraph.
|
inline |
Returns the length of an edge.
References Parsers::TrackGraph::EdgeLength(), and trackGraph.
|
inline |
Returns the $X$ coordinate of the specificed edge of the node.
References Parsers::TrackGraph::EdgeX(), and trackGraph.
|
inline |
Returns the $Y$ coordinate of the specificed edge of the node.
References Parsers::TrackGraph::EdgeY(), and trackGraph.
void Parsers::LayoutFile::Emit | ( | ostream & | outstream | ) |
Function to Emit a track graph to an output stream.
outstream | The output stream to write the graph to. |
|
inline |
References Parsers::TrackGraph::Heads(), and trackGraph.
|
inline |
Returns the highest numbered node id.
References Parsers::TrackGraph::HighestNode(), and trackGraph.
|
inline |
References Parsers::TrackGraph::IsCompressed(), and trackGraph.
|
inline |
Is cid a node in the compressed graph?
References Parsers::TrackGraph::IsCompressedNode(), and trackGraph.
|
inline |
Tests if a node id exists in the graph.
References Parsers::TrackGraph::IsNodeP(), and trackGraph.
|
inline |
Return the track length of a node.
References Parsers::TrackGraph::LengthOfNode(), and trackGraph.
|
inline |
Returns the lowest numbered node id.
References Parsers::TrackGraph::LowestNode(), and trackGraph.
|
inline |
Return a block's or switchmotor's name.
References Parsers::TrackGraph::NameOfNode(), and trackGraph.
|
inline |
Returns the TurnoutGraphic of the node.
References Parsers::TrackGraph::NodeTurnoutGraphic(), and trackGraph.
|
inline |
Returns the TurnoutRoutelist of the node.
References Parsers::TrackGraph::NodeTurnoutRoutelist(), and trackGraph.
|
inline |
Return a switchmotor's normal action script.
References Parsers::TrackGraph::NormalActionScript(), and trackGraph.
|
inline |
Return a Signal's number of heads.
References Parsers::TrackGraph::NumberOfHeads(), and trackGraph.
|
inline |
Returns the number of edges for the specificed node id.
References Parsers::TrackGraph::NumEdges(), and trackGraph.
|
inline |
Return the off action script.
nid | The node to look at. |
References Parsers::TrackGraph::OffScript(), and trackGraph.
|
inline |
Return the on action script.
nid | The node to look at. |
References Parsers::TrackGraph::OnScript(), and trackGraph.
|
inline |
Return the $x$ coordinate of the signal base.
nid | The node to look at. |
References Parsers::TrackGraph::OrigX(), and trackGraph.
|
inline |
Return the $y$ coordinate of the signal base.
nid | The node to look at. |
References Parsers::TrackGraph::OrigY(), and trackGraph.
|
protectedvirtual |
Parseer function.
Implements Parsers::ParseFile.
|
protectedvirtual |
Parse error handler.
Implements Parsers::ParseFile.
|
inline |
Return a block's or switchmotor's reverse action script.
References Parsers::TrackGraph::ReverseActionScript(), and trackGraph.
|
inline |
Compressed graph roots.
References Parsers::TrackGraph::Roots(), and trackGraph.
|
inline |
Return a block's or switchmotor's sense script.
References Parsers::TrackGraph::SenseScript(), and trackGraph.
|
inline |
Return a Signal's aspect list.
References Parsers::TrackGraph::SignalAspects(), and trackGraph.
|
inline |
Return a block's tracklist.
References trackGraph, and Parsers::TrackGraph::TrackList().
|
inline |
Return a switchmotor's turnout number.
References trackGraph, and Parsers::TrackGraph::TurnoutNumber().
|
inline |
Returns the type of the node.
References trackGraph, and Parsers::TrackGraph::TypeOfNode().
|
protected |
Parser.
|
protected |
Track graph, a graph of all of the trackwork in the layput file.
Referenced by Angle(), CompressedEdgeCount(), CompressedEdgeLength(), CompressedEdgeNode(), CompressedGraphCircleLayout(), CompressedGraphKamadaKawaiSpring(), CompressedGraphKruskalMinimumSpanningTree(), CompressedGraphPrimMinimumSpanningTree(), CompressedNodePositionX(), CompressedNodePositionY(), CompressedNodeSegments(), CompressGraph(), EdgeA(), EdgeIndex(), EdgeLength(), EdgeX(), EdgeY(), Heads(), HighestNode(), IsCompressed(), IsCompressedNode(), IsNodeP(), LengthOfNode(), LowestNode(), NameOfNode(), NodeTurnoutGraphic(), NodeTurnoutRoutelist(), NormalActionScript(), NumberOfHeads(), NumEdges(), OffScript(), OnScript(), OrigX(), OrigY(), ReverseActionScript(), Roots(), SenseScript(), SignalAspects(), TrackList(), TurnoutNumber(), and TypeOfNode().