Microscopic Traffic Simulator
CellularTopologyBuilder.cs
Go to the documentation of this file.
6 using System.Windows;
7 
8 namespace Microscopic_Traffic_Simulator___Model.CellularTopologyObjects
9 {
14  {
18  private GeometricTopology geometricTopology;
19 
23  private CellularTopologyParameters cellularTopologyParameters;
24 
31  internal CellularTopologyBuilder(GeometricTopology geometricTopology,
32  CellularTopologyParameters cellularTopologyParameters)
33  {
34  this.geometricTopology = geometricTopology;
35  this.cellularTopologyParameters = cellularTopologyParameters;
36  }
37 
41  internal void Build()
42  {
43  foreach (Lane lane in geometricTopology.Lanes)
44  {
45  Cell previousCell = null;
46  int cellCounter = 0;
47  foreach (Point lanePoint in lane.LanePoints(cellularTopologyParameters.P1_CellLength))
48  {
49  Cell cell = new Cell(lanePoint);
50  if (previousCell == null)
51  {
53  {
54  Generator generator = lane.StartNode.Generator;
55  generator.ConnectedCell = cell;
56  }
57  }
58  else
59  {
60  if (cellCounter == 100)
61  {
62  Sensor sensor = (lane.InnerNodes[0] as SensorNode).Sensor;
63  sensor.ConnectedCell = cell;
64  cell.Sensor = sensor;
65  }
66  previousCell.FollowingCell = cell;
67  cell.PreviousCell = previousCell;
68  previousCell.NormalizedDirectionVector = cell.Location - previousCell.Location;
69  }
70  previousCell = cell;
71  cellCounter++;
72  }
73  }
74  }
75  }
76 }
Vector NormalizedDirectionVector
Normalized direction vector.
Definition: Cell.cs:28
Class representing geometric topology of road network.
StartNode StartNode
Node on the input end of lane.
Definition: Lane.cs:23
ReadOnlyCollection< Lane > Lanes
Lanes in geometric topology. </summary
ReadOnlyCollection< InnerNode > InnerNodes
Inner nodes on the lane.
Definition: Lane.cs:41
bool ContainsGenerator
Determines whether the node contains generator.
Definition: StartNode.cs:21