예제 #1
0
 private byte[] Copy(MyPGM Pixmap)
 {
     byte[] NewPixMap = new byte[Pixmap.XSize * Pixmap.YSize];
     for (int i = 0; i < NewPixMap.Length; i++)
     {
         NewPixMap[i] = Pixmap.GetValue(i);
     }
     return(NewPixMap);
 }
예제 #2
0
 public void CopyAtPos(MyPGM pgm, int x, int y)
 {
     for (int i = 0; i < pgm.YSize; i++)
     {
         for (int j = 0; j < pgm.XSize; j++)
         {
             this.SetValue(x + j, y + i, pgm.GetValue(j, i));
         }
     }
 }
예제 #3
0
        public void Rotate90()
        {
            MyPGM temp = new MyPGM(m_XSize, m_YSize, m_PixelMap, false);

            m_XSize    = temp.YSize;
            m_YSize    = temp.XSize;
            m_PixelMap = new byte[m_XSize * m_YSize];

            for (int i = 0; i < temp.YSize; i++)
            {
                for (int j = 0; j < temp.XSize; j++)
                {
                    SetValue(m_XSize - i - 1, j, temp.GetValue(j, i));
                }
            }
        }
예제 #4
0
        private void SetSubroutine(int States)
        {
            RailParts rp   = new RailParts();
            MyPGM     Lazy = rp.GetLazy(false);

            Lazy.MirrorX();
            Lazy.Rotate90();
            MyPGM Sprung1 = rp.GetSprung(false);

            Sprung1.MirrorY();
            MyPGM Sprung2 = rp.GetSprung(false);

            Sprung2.Rotate180();
            int[] SubConn = null;

            MyPGM Begins = GetSubroutineConn(States, ref SubConn);

            bool OneCurveSet = false;

            // Paint Subroutine
            for (int i = SubConn.Length; i > 0; i--)
            {
                if (SubConn[i - 1] > 1)
                {
                    if (OneCurveSet)
                    {
                        SetField(Lazy, 1 + ReadWriteHead.XRailsCnt + i - 1, 0);
                    }
                    else
                    {
                        SetField(rp.GetCurve(2), 1 + ReadWriteHead.XRailsCnt + i - 1, 0);
                    }
                    OneCurveSet = true;
                }
                else
                {
                    if (OneCurveSet)
                    {
                        SetField(rp.GetStraight(1), 1 + ReadWriteHead.XRailsCnt + i - 1, 0);
                    }
                }
            }
            // Paint Connections
            int XStartPos = ReadWriteHead.XRailsCnt + 1;
            int YStartPos = 1;

            for (int i = 0; i < Begins.YSize; i++)
            {
                for (int j = 0; j < Begins.XSize; j++)
                {
                    int Val = Begins.GetValue(j, i);
                    if (Val == 1)
                    {
                        SetField(rp.GetStraight(0), XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 2)
                    {
                        SetField(Sprung1, XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 3)
                    {
                        SetField(rp.GetCurve(2), XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 4)
                    {
                        SetField(rp.GetCrossing(), XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 5)
                    {
                        SetField(Sprung2, XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 6)
                    {
                        SetField(rp.GetStraight(1), XStartPos + j, YStartPos + i);
                    }
                }
            }
            int LastPos = Begins.YSize - 1;

            for (int i = 0; i < Begins.XSize; i++)
            {
                if (Begins.GetValue(i, LastPos) > 0)
                {
                    m_Connected[i] = 1;
                }
                else
                {
                    m_Connected[i] = 0;
                }
            }
        }
예제 #5
0
        private void FillConnMatrix(MyPGM ConnMat, int[] SubConn, int[] ConnY)
        {
            int XStartPos = ReadWriteHead.XRailsCnt + 1;

            for (int j = 0; j < ConnMat.XSize; j++)
            {
                if (SubConn[j] == 2)
                {
                    ConnMat.SetValue(j, 0, 1);
                }
            }
            for (int i = 1; i < ConnMat.YSize; i++)
            {
                for (int j = 0; j < ConnMat.XSize; j++)
                {
                    int ValBefore = ConnMat.GetValue(j, i - 1);
                    int ValActual = ConnMat.GetValue(j, i);
                    int Conn      = ConnY[i];
                    int Sub       = SubConn[j];

                    if (ValActual == 2)
                    {
                        ConnMat.SetValue(j, i, 2);
                    }
                    else if (ValActual == 1)
                    {
                        if (ValBefore == 0)
                        {
                            ConnMat.SetValue(j, i, 3);
                        }
                        else
                        {
                            ConnMat.SetValue(j, i, 5);
                        }
                    }
                    else
                    {
                        if (Conn == 0)
                        {
                            if (ValBefore == 0)
                            {
                            }
                            else if (ValBefore == 6)
                            {
                            }
                            else
                            {
                                ConnMat.SetValue(j, i, 1);
                            }
                        }
                        else
                        {
                            if (ValBefore == 0)
                            {
                                if (Conn > j + 1)
                                {
                                    ConnMat.SetValue(j, i, 6);
                                }
                            }
                            else
                            {
                                if (Conn > j + 1)
                                {
                                    ConnMat.SetValue(j, i, 4);
                                }
                                else
                                {
                                    ConnMat.SetValue(j, i, 1);
                                }
                            }
                        }
                    }
                }
            }
        }