public void getNext()
        {
            // Test the null case
            roadPiece roadPiece1 = new roadPiece();

            Assert.IsNull(roadPiece1.getNext());

            // Test if only one roadPice is connected to this one
            roadPiece roadPiece2       = new roadPiece();
            roadPiece roadPiece2Child1 = new roadPiece();

            roadPiece[] roadPiece2array = new roadPiece[1];
            roadPiece2array[0]   = roadPiece2Child1;
            roadPiece2.NextArray = roadPiece2array;
            Assert.AreSame(roadPiece2Child1, roadPiece2.getNext());

            // Test with 3 possibilities
            roadPiece roadPiece3       = new roadPiece();
            roadPiece roadPiece3Child1 = new roadPiece();
            roadPiece roadPiece3Child2 = new roadPiece();
            roadPiece roadPiece3Child3 = new roadPiece();

            roadPiece[] roadPiece3array = new roadPiece[3];
            roadPiece3array[0]   = roadPiece3Child1;
            roadPiece3array[1]   = roadPiece3Child2;
            roadPiece3array[2]   = roadPiece3Child3;
            roadPiece3.NextArray = roadPiece3array;
            roadPiece next = roadPiece3.getNext();

            if (next != roadPiece3Child1 && next != roadPiece3Child2 && next != roadPiece3Child3)
            {
                Assert.Fail();
            }
        }
Esempio n. 2
0
    public Crossing(CrossingType ct)
    {
        this.ReferencePath = new roadPiece[4];
        // Create all the end point needed by the crossing, those will be connected by the simulator to the other crossing
        // The direction is relative to the crossing,
        // Deg0
        endPoints = new roadPiece[4];
        endPoints[(int)Oriention.Degree0]             = new roadPiece((roadPiece)null);
        endPoints[(int)Oriention.Degree0].orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, this.Oriention);
        endPoints[(int)Oriention.Degree0].coordinate  = new System.Drawing.Point(10, 10);

        // Deg90
        endPoints[(int)Oriention.Degree90]             = new roadPiece((roadPiece)null);
        endPoints[(int)Oriention.Degree90].orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, this.Oriention);
        endPoints[(int)Oriention.Degree90].coordinate  = new System.Drawing.Point(10, 10);

        // Deg180
        endPoints[(int)Oriention.Degree180]             = new roadPiece((roadPiece)null);
        endPoints[(int)Oriention.Degree180].orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, this.Oriention);
        endPoints[(int)Oriention.Degree180].coordinate  = new System.Drawing.Point(10, 10);

        // Deg270
        endPoints[(int)Oriention.Degree270]             = new roadPiece((roadPiece)null);
        endPoints[(int)Oriention.Degree270].orientation = getGlobalOrientationFromLocal(global::Oriention.Degree270, this.Oriention);
        endPoints[(int)Oriention.Degree270].coordinate  = new System.Drawing.Point(10, 10);


        switch (ct)
        {
        case CrossingType.CrossingWithoutPedestrian:
            crossingWithoutPedestrian();
            break;
        }
    }
Esempio n. 3
0
 // Constructor
 public MovingObject(Boolean isPedest, roadPiece startPoint)
 {
     IsPedestrian          = isPedest;
     IsAlive               = true;
     CoordinateInRoadPiece = new Point(0, 0);
     MovingObjectPicture   = new Rectangle(coordinateInRoadPiece, new Size(10, 10));
     Path = startPoint;
 }
Esempio n. 4
0
 public MovingObject(Boolean isPedest, roadPiece startPoint)
 {
     isPedestrian          = isPedest;
     isAlive               = true;
     coordinateInRoadPiece = new System.Drawing.Point(0, 0);
     picture               = new System.Drawing.Rectangle(coordinateInRoadPiece, new System.Drawing.Size(10, 10));
     path = startPoint;
 }
Esempio n. 5
0
        private void addMovingObject(roadPiece rp, bool isPedestrian)
        {
            MovingObject mo = new MovingObject(isPedestrian, rp);

            if (MovingObjects == null)
            {
                MovingObjects = new List <MovingObject>();
            }
            MovingObjects.Add(mo);
        }
        public void Randomize()
        {
            roadPiece roadPiece = new roadPiece();

            for (int i = 0; i < 1000; i++)
            {
                int test = roadPiece.Randomize(10, 1000);
                Assert.IsTrue(test >= 10 && test <= 1000);
            }
        }
Esempio n. 7
0
 public roadPiece(roadPiece next)
 {
     Randomizer           = new Random();
     coordinate           = new System.Drawing.Point();
     trafficlightRefrence = null;
     orientation          = Oriention.Degree0;
     NextArray            = new roadPiece[1];
     NextArray[0]         = next;
     Sensor = null;
 }
Esempio n. 8
0
 public void drawMovingObject(List <MovingObject> mo)
 {
     foreach (MovingObject moving in mo)
     {
         RoadObject roadObject = moving.Path.RoadObject;
         roadPiece  rp         = moving.Path;
         int        x          = roadObject.Coordinate.X + rp.coordinate.X + moving.CoordinateInRoadPiece.X;
         int        y          = roadObject.Coordinate.Y + rp.coordinate.Y + moving.CoordinateInRoadPiece.Y;
         g.DrawEllipse(pen, x, y, 4, 4);
     }
 }
Esempio n. 9
0
    void crossingWithoutPedestrian()
    {
        this.Image = TrafficLightSimulator.Properties.Resources.crossingA;
        // List of all direction
        Orientation[] todo = { Orientation.Degree0, Orientation.Degree90, Orientation.Degree180, Orientation.Degree270 };
        // For all direction, we're making the graph
        foreach (Orientation localO in todo)
        {
            // First, we need the global direction of this direction
            Orientation o = getGlobalOrientationFromLocal(localO, this.Oriention);

            // First endpoint
            roadPiece rp3deg0EndPoint = new roadPiece(this, EndPoints[(int)getGlobalOrientationFromLocal(localO, Orientation.Degree180)]);
            // Orientation of the roadpiece ?
            rp3deg0EndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree180, o);
            // Now generating the good coordinate from 84, 125 which is the point on the picture of Abdullah
            rp3deg0EndPoint.coordinate = rotatePoint(o, new System.Drawing.Point(100, 90));
            rp3deg0EndPoint.size       = new System.Drawing.Point(30, 30);

            roadPiece rp1 = new roadPiece(this, rp3deg0EndPoint);
            rp1.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp1.size        = new System.Drawing.Point(23, 23);

            rp1.coordinate = rotatePoint(o, new System.Drawing.Point(100, 133));


            roadPiece rp5deg90EndPoint = new roadPiece(this, EndPoints[(int)getGlobalOrientationFromLocal(localO, Orientation.Degree90)]);
            rp5deg90EndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp5deg90EndPoint.coordinate  = rotatePoint(o, new System.Drawing.Point(84, 40));
            rp5deg90EndPoint.size        = new System.Drawing.Point(30, 30);

            roadPiece rp6deg180EndPoint = new roadPiece(this, EndPoints[(int)getGlobalOrientationFromLocal(localO, Orientation.Degree0)]);
            rp6deg180EndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp6deg180EndPoint.coordinate  = rotatePoint(o, new System.Drawing.Point(84, 40));
            rp6deg180EndPoint.size        = new System.Drawing.Point(84, 84);

            roadPiece rp4 = new roadPiece(this, new roadPiece[] { rp5deg90EndPoint, rp6deg180EndPoint });//rp6deg180EndPoint rp6deg180EndPoint
            rp4.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp4.coordinate  = rotatePoint(o, new System.Drawing.Point(84, 115));
            rp4.size        = new System.Drawing.Point(75, 75);

            roadPiece rp2 = new roadPiece(this, rp4);
            rp2.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp2.coordinate  = rotatePoint(o, new System.Drawing.Point(84, 140));
            rp2.size        = new System.Drawing.Point(25, 25);
            roadPiece rp0StartPoint = new roadPiece(this, new roadPiece[] { rp1, rp2 });  // manque rp1 rp2
            rp0StartPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp0StartPoint.coordinate  = rotatePoint(o, new System.Drawing.Point(90, 150));

            //  assign the start point
            this.ReferencePath[(int)localO]       = rp0StartPoint;
            this.ReferencePathLinked[(int)localO] = false; // not conencted first
        }
    }
Esempio n. 10
0
 public roadPiece(RoadObject ro, roadPiece next)
 {
     size                 = new System.Drawing.Point(10, 10);
     RoadObject           = ro;
     Randomizer           = new Random();
     coordinate           = new System.Drawing.Point();
     trafficlightRefrence = null;
     orientation          = Orientation.Degree0;
     NextArray            = new roadPiece[1];
     NextArray[0]         = next;
     Sensor               = null;
 }
        public void addNextRoadPieceTest()
        {
            roadPiece roadPiece = new roadPiece();
            roadPiece obtToAdd  = new roadPiece();
            roadPiece obtToAdd2 = new roadPiece();

            roadPiece.addNextRoadPiece(obtToAdd);
            Assert.AreSame(roadPiece.getNext(), obtToAdd);
            roadPiece.addNextRoadPiece(obtToAdd2);
            roadPiece ret = roadPiece.getNext();

            Assert.IsTrue(ret == obtToAdd || ret == obtToAdd2);
        }
Esempio n. 12
0
    // Constrcutor
    public Crossing(Point pp, CrossingType ct, Image img) : base(pp)
    {
        this.Image      = img;
        this.Coordinate = pp;

        this.ReferencePath       = new roadPiece[4];
        this.ReferencePathLinked = new Boolean[4];
        // Create all the end point needed by the crossing, those will be connected by the simulator to the other crossing
        // The direction is relative to the crossing,
        // Deg0 Done
        EndPoints = new roadPiece[4];
        EndPoints[(int)Orientation.Degree0]             = new roadPiece(this, (roadPiece)null);
        EndPoints[(int)Orientation.Degree0].orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, this.Oriention);
        EndPoints[(int)Orientation.Degree0].coordinate  = new System.Drawing.Point(10, 55);

        // Deg90 Done
        EndPoints[(int)Orientation.Degree90]             = new roadPiece(this, (roadPiece)null);
        EndPoints[(int)Orientation.Degree90].orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, this.Oriention);
        EndPoints[(int)Orientation.Degree90].coordinate  = new System.Drawing.Point(84, 10);

        // Deg180 Done
        EndPoints[(int)Orientation.Degree180]             = new roadPiece(this, (roadPiece)null);
        EndPoints[(int)Orientation.Degree180].orientation = getGlobalOrientationFromLocal(global::Orientation.Degree180, this.Oriention);
        EndPoints[(int)Orientation.Degree180].coordinate  = new System.Drawing.Point(135, 85);

        // Deg270 Done
        EndPoints[(int)Orientation.Degree270]             = new roadPiece(this, (roadPiece)null);
        EndPoints[(int)Orientation.Degree270].orientation = getGlobalOrientationFromLocal(global::Orientation.Degree270, this.Oriention);
        EndPoints[(int)Orientation.Degree270].coordinate  = new System.Drawing.Point(56, 135);


        switch (ct)
        {
        case CrossingType.CrossingWithoutPedestrian:
            Image = TrafficLightSimulator.Properties.Resources.crossingA;
            crossingWithoutPedestrian();
            break;

        case CrossingType.CrossingWithPedestrian:
            Image = TrafficLightSimulator.Properties.Resources.crossingB;
            crossingWithPedestrian();
            break;

        default:
            System.Windows.Forms.MessageBox.Show("Error From the Crossing class");
            break;
        }
    }
Esempio n. 13
0
    public void addNextRoadPiece(roadPiece n)
    {
        if (NextArray == null)
        {
            NextArray    = new roadPiece[1];
            NextArray[0] = n;
            return;
        }

        roadPiece[] newArray = new roadPiece[NextArray.Length + 1];
        int         i;

        for (i = 0; i < NextArray.Length; i++)
        {// Copy the old array
            newArray[i] = NextArray[i];
        }
        newArray[i] = n;
        // Push the new element on the array
    }
Esempio n. 14
0
    void crossingWithoutPedestrian()
    {
        Oriention[] todo = { Oriention.Degree0, Oriention.Degree90, Oriention.Degree180, Oriention.Degree270 };
        foreach (Oriention localO in todo)
        {
            Oriention o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp3deg0EndPoint = new roadPiece(endPoints[(int)Oriention.Degree0]);
            rp3deg0EndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp3deg0EndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp1 = new roadPiece(rp3deg0EndPoint);
            rp1.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp1.coordinate  = new System.Drawing.Point(10, 10);


            roadPiece rp5deg90EndPoint = new roadPiece(endPoints[(int)Oriention.Degree90]);
            rp5deg90EndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp5deg90EndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp6deg180EndPoint = new roadPiece(endPoints[(int)Oriention.Degree180]);
            rp6deg180EndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, o);
            rp6deg180EndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp4 = new roadPiece(new roadPiece[] { rp6deg180EndPoint, rp5deg90EndPoint });
            rp4.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp4.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp2 = new roadPiece(rp4);
            rp2.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp2.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp0StartPoint = new roadPiece(new roadPiece[] { rp2, rp1 });
            rp0StartPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp0StartPoint.coordinate  = new System.Drawing.Point(10, 10);

            //  assign the start point
            this.ReferencePath[(int)localO] = rp0StartPoint;
        }
    }
Esempio n. 15
0
        // Methods
        public void Update()
        {
            Boolean animationDone = false;

            switch (Path.orientation)
            {
            case Orientation.Degree270:
                if (coordinateInRoadPiece.Y < Path.size.Y)
                {
                    coordinateInRoadPiece = new System.Drawing.Point(coordinateInRoadPiece.X, coordinateInRoadPiece.Y + 2);
                }
                else
                {
                    animationDone = true;
                }
                break;

            case Orientation.Degree0:
                if (coordinateInRoadPiece.X > -Path.size.X)
                {
                    coordinateInRoadPiece = new System.Drawing.Point(coordinateInRoadPiece.X - 2, coordinateInRoadPiece.Y);
                }
                else
                {
                    animationDone = true;
                }
                break;

            case Orientation.Degree90:
                if (coordinateInRoadPiece.Y > -Path.size.Y)
                {
                    coordinateInRoadPiece = new System.Drawing.Point(coordinateInRoadPiece.X, coordinateInRoadPiece.Y - 2);
                }
                else
                {
                    animationDone = true;
                }
                break;

            default:
                if (coordinateInRoadPiece.X < Path.size.X)
                {
                    coordinateInRoadPiece = new System.Drawing.Point(coordinateInRoadPiece.X + 2, coordinateInRoadPiece.Y);
                }
                else
                {
                    animationDone = true;
                }
                break;
            }
            if (animationDone)
            {
                // We move the car to the next roadPiece (if exist)
                if (Path.getNext() == null)
                {
                    // Car out of the road : should be destroy
                    throw new Exception();
                }
                else
                {
                    if (Path.trafficlightRefrence == null || Path.trafficlightRefrence.GetColor() == TrafficColor.Green)
                    {
                        // We check if there is a traffic light and if i we can continue
                        Path = Path.getNext();
                        coordinateInRoadPiece = new System.Drawing.Point(0, 0);
                    }
                }
            }
        }
Esempio n. 16
0
    // Method : Instead of two diffrent classes

    void crossingWithPedestrian()
    {
        this.Image = TrafficLightSimulator.Properties.Resources.crossingB;

        PedestrianStartPoint = new roadPiece[4];
        Orientation[] todo = { Orientation.Degree0, Orientation.Degree180 };
        foreach (Orientation localO in todo)
        {
            // Pedestrian road
            PedestrianStartPoint[(int)localO] = new roadPiece(this, (roadPiece)null);
            // car road

            Orientation o = getGlobalOrientationFromLocal(localO, this.orientation);


            roadPiece rp2RightEndPoint = new roadPiece(this, EndPoints[(int)Orientation.Degree0]);
            rp2RightEndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp2RightEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp4TopEndPoint = new roadPiece(this, EndPoints[(int)Orientation.Degree90]);
            rp4TopEndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp4TopEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp5LeftEndPoint = new roadPiece(this, EndPoints[(int)Orientation.Degree180]);
            rp5LeftEndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree180, o);
            rp5LeftEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp3 = new roadPiece(this, new roadPiece[] { rp4TopEndPoint, rp5LeftEndPoint });
            rp3.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp3.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp1 = new roadPiece(this, new roadPiece[] { rp3, rp2RightEndPoint });
            rp1.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp1.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp0StartPoint = new roadPiece(this, rp1);
            rp0StartPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp0StartPoint.coordinate  = new System.Drawing.Point(10, 10);
            //  assign the start point
            this.ReferencePath[(int)localO]       = rp0StartPoint;
            this.ReferencePathLinked[(int)localO] = false; // not conencted first
        }

        // A5,A6, ...
        Orientation[] todo2 = { Orientation.Degree90, Orientation.Degree270 };
        foreach (Orientation localO in todo2)
        {
            Orientation o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp12BottomEndPoint = new roadPiece(this, EndPoints[(int)Orientation.Degree270]);
            rp12BottomEndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree270, o);
            rp12BottomEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp11 = new roadPiece(this, rp12BottomEndPoint);
            rp11.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree180, o);
            rp11.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp16RightEndPoint = new roadPiece(this, EndPoints[(int)Orientation.Degree0]);
            rp16RightEndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp16RightEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp17TopEndPoint = new roadPiece(this, EndPoints[(int)Orientation.Degree90]);
            rp17TopEndPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree90, o);
            rp17TopEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp15 = new roadPiece(this, rp16RightEndPoint);
            rp15.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp15.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp14 = new roadPiece(this, new roadPiece[] { rp17TopEndPoint, rp15 });
            rp14.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp14.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp13 = new roadPiece(this, rp14);
            rp13.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp13.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp10StartPoint = new roadPiece(this, rp13);
            rp10StartPoint.orientation = getGlobalOrientationFromLocal(global::Orientation.Degree0, o);
            rp10StartPoint.coordinate  = new System.Drawing.Point(10, 10);

            this.ReferencePath[(int)localO]       = rp10StartPoint;
            this.ReferencePathLinked[(int)localO] = false; // not conencted first
        }
    }
        public void Update()
        {
            roadPiece piece = new roadPiece();

            // First we create a road
            TrafficLight tl1 = new TrafficLight();

            tl1.SetColor(TrafficColor.Red); // you shall not pass !
            roadPiece piece1 = new roadPiece(this, piece);

            piece1.trafficlightRefrence = tl1;
            piece1.orientation          = Orientation.Degree270;

            roadPiece piece2 = new roadPiece(this, piece1);

            piece2.orientation = Orientation.Degree90; // because I don't like when it is too easy :p
            roadPiece    piece3 = new roadPiece(this, piece2);
            MovingObject car    = new MovingObject(false, piece3);

            Assert.AreEqual(car.path, piece3);
            // piece3 -> piece2 -> piece1v
            // The moving object is on piece3

            // First I want to test the animation
            Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, 0));
            for (int i = 0; i < 10; i++)
            {
                car.Update();
                Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(i + 1, 0));
            }
            // Now we should move to the new roadpiece
            car.Update();
            Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, 0));
            Assert.AreEqual(car.path, piece2);
            for (int i = 0; i < 10; i++)
            {
                car.Update();
                Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, i + 1));
            }
            car.Update();
            Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, 0));
            Assert.AreEqual(car.path, piece1);

            // Now i want to do the same but with a traffic light
            for (int i = 0; i < 10; i++)
            {
                car.Update();
                Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, i - 1));
            }
            // We check several times
            for (int i = 0; i < 10; i++)
            {
                car.Update();
                Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, -10));
                Assert.AreEqual(car.path, piece1);
            }
            // Now we change the color of the light
            tl1.SetColor(TrafficColor.Green);
            car.Update();
            Assert.AreEqual(car.coordinateInRoadPiece, new System.Drawing.Point(0, 0));
            Assert.AreEqual(car.path, piece);
        }
Esempio n. 18
0
    void crossingWithPedestrian()
    {
        pedestrianStartPoint = new roadPiece[2];
        Oriention[] todo = { Oriention.Degree0, Oriention.Degree180 };
        foreach (Oriention localO in todo)
        {
            // Pedestrian road
            pedestrianStartPoint[(int)localO] = new roadPiece((roadPiece)null);
            // car road

            Oriention o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp2RightEndPoint = new roadPiece(endPoints[(int)Oriention.Degree0]);
            rp2RightEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp2RightEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp4TopEndPoint = new roadPiece(endPoints[(int)Oriention.Degree90]);
            rp4TopEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp4TopEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp5LeftEndPoint = new roadPiece(endPoints[(int)Oriention.Degree180]);
            rp5LeftEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, o);
            rp5LeftEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp3 = new roadPiece(new roadPiece[] { rp4TopEndPoint, rp5LeftEndPoint });
            rp3.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp3.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp1 = new roadPiece(new roadPiece[] { rp3, rp2RightEndPoint });
            rp1.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp1.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp0StartPoint = new roadPiece(rp1);
            rp0StartPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp0StartPoint.coordinate  = new System.Drawing.Point(10, 10);
            //  assign the start point
            this.ReferencePath[(int)localO] = rp0StartPoint;
        }

        // A5,A6, ...
        Oriention[] todo2 = { Oriention.Degree90, Oriention.Degree270 };
        foreach (Oriention localO in todo2)
        {
            Oriention o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp12BottomEndPoint = new roadPiece(endPoints[(int)Oriention.Degree270]);
            rp12BottomEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree270, o);
            rp12BottomEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp11 = new roadPiece(rp12BottomEndPoint);
            rp11.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, o);
            rp11.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp16RightEndPoint = new roadPiece(endPoints[(int)Oriention.Degree0]);
            rp16RightEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp16RightEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp17TopEndPoint = new roadPiece(endPoints[(int)Oriention.Degree90]);
            rp17TopEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp17TopEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp15 = new roadPiece(rp16RightEndPoint);
            rp15.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp15.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp14 = new roadPiece(new roadPiece[] { rp17TopEndPoint, rp15 });
            rp14.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp14.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp13 = new roadPiece(rp14);
            rp13.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp13.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp10StartPoint = new roadPiece(rp13);
            rp10StartPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp10StartPoint.coordinate  = new System.Drawing.Point(10, 10);

            this.ReferencePath[(int)localO] = rp10StartPoint;
        }
    }