Exemplo n.º 1
0
        void designed_curve_input()
        {
            findflag = 0;

            while (fp1SR.EndOfStream == false)
            {
                CHalignFilData fildata = CHalignFilData.Parse(fp1SR.ReadLine());
                if (fildata == null)
                {
                    continue;
                }

                modnam = fildata.sMod;
                strnam = fildata.sString;
                elno   = (short)fildata.iSlno;
                eltype = fildata.iEltype;
                stchn  = fildata.dStartchn;
                endchn = fildata.dEndchn;
                IPX    = fildata.dHipx;
                IPY    = fildata.dHipy;
                T1     = fildata.dT1;
                T2     = fildata.dT2;
                R      = fildata.dRadius;
                L      = fildata.dEllength;
                xst    = fildata.dStartx;
                yst    = fildata.dStarty;
                xed    = fildata.dEndx;
                yed    = fildata.dEndy;
                B1     = fildata.dB1;
                B2     = fildata.dB2;
                DEL    = fildata.dDeviation;
                turn   = fildata.iTurn;

                if (stchn == last_stchn && endchn == last_endchn)
                {
                    findflag = 0;
                    break;
                }

                if ((modnam == model) && (strnam == stglbl))
                {
                    findflag = 1;
                    break;
                }
            }

            if (findflag != 0)
            {
                initiate_param();

                start_param();

                if (eltype == 1)
                {
                    SL = L; L = 0; LC = 0; M = 0;
                }
                else if (eltype == 2) /*L = L;*/ SL {
Exemplo n.º 2
0
        public static CHIPInfo[] ReadHaligns(string strHalignFilePath)
        {
            List <CHIPInfo> listhips = new List <CHIPInfo>();

            if (File.Exists(strHalignFilePath))
            {
                StreamReader readerSrc = new StreamReader(strHalignFilePath);

                string   strLastModelName   = "";
                string   strLastStringLabel = "";
                CHIPInfo hipinfo            = null;
                while (readerSrc.EndOfStream == false)
                {
                    string         strline = readerSrc.ReadLine();
                    CHalignFilData fildata = CHalignFilData.Parse(strline);

                    if (fildata != null)
                    {
                        if (strLastModelName != fildata.sMod || strLastStringLabel != fildata.sString)
                        {
                            hipinfo             = new CHIPInfo();
                            hipinfo.ModelName   = fildata.sMod;
                            hipinfo.StringLabel = fildata.sString;
                            listhips.Add(hipinfo);

                            strLastModelName   = fildata.sMod;
                            strLastStringLabel = fildata.sString;
                        }
                        hipinfo.DataList.Add(fildata);
                    }

                    //string[] arrStr = strline.Split(new char[] { '\t' });
                    //if (arrStr.Length == 20)
                    //{
                    //    if (strLastModelName != arrStr[0] || strLastStringLabel != arrStr[1])
                    //    {
                    //        hipinfo = new CHIPInfo();
                    //        hipinfo.ModelName = arrStr[0];
                    //        hipinfo.StringLabel = arrStr[1];
                    //        listhips.Add(hipinfo);

                    //        strLastModelName = arrStr[0];
                    //        strLastStringLabel = arrStr[1];
                    //    }
                    //    hipinfo.DataList.Add(CHalignFilData.Parse(strline));
                    //}
                }

                readerSrc.Close();
            }
            return(listhips.ToArray());
        }
Exemplo n.º 3
0
        /// <summary>
        /// This function copied from CHalignDxCode::save_halign()
        /// </summary>
        /// <param name="strWorkingDirPath"></param>
        public static void SaveHalign(string strWorkingDirPath)
        {
            StreamReader          readerSrc      = new StreamReader(Path.Combine(strWorkingDirPath, "halign.tmp"));
            List <CHalignFilData> listTempHalign = new List <CHalignFilData>();

            while (readerSrc.EndOfStream == false)
            {
                string         strlineSrc  = readerSrc.ReadLine();
                CHalignFilData filDataTemp = CHalignFilData.Parse(strlineSrc);
                if (filDataTemp != null)
                {
                    listTempHalign.Add(filDataTemp);
                }
            }
            readerSrc.Close();

            //If any data present in temp file
            if (listTempHalign.Count > 0)
            {
                string       strHalignFilFilePath = Path.Combine(strWorkingDirPath, "HALIGN.FIL");
                CHIPInfo[]   infoarr     = CHalignHipUtil.ReadHaligns(strHalignFilFilePath);
                StreamWriter writerDesti = new StreamWriter(strHalignFilFilePath, false);
                foreach (CHIPInfo info in infoarr)
                {
                    foreach (CHalignFilData filData in info.DataList)
                    {
                        if (filData.sMod != listTempHalign[0].sMod || filData.sString != listTempHalign[0].sString)
                        {
                            writerDesti.WriteLine(filData.ToString());
                        }
                    }
                }

                //Now write the data from temp file
                foreach (CHalignFilData filData in listTempHalign)
                {
                    writerDesti.WriteLine(filData.ToString());
                }

                writerDesti.Close();
            }
        }
Exemplo n.º 4
0
        public void Funcmain(string argv1)
        {
            path = argv1;
            //err_code = 9; /* no error */
            V = 130.0;

            read_input();

            pathfile = Path.Combine(path, "DETAILS2.TMP");

            fp2 = new BinaryWriter(new FileStream(pathfile, FileMode.Create), Encoding.Default);

            if (rotn != 0.0)
            {
                textstring = "DRG not by 'Draw String', use 'Minor option(s) 1103 / 1104'...";
                error_msg();
                return;
            }

            pathfile = Path.Combine(path, "HALIGN.TMP");

            if (File.Exists(pathfile) == false)
            {
                pathfile = Path.Combine(path, "HALIGN.FIL");
            }

            if (File.Exists(pathfile) == false)
            {
                textstring = "File %s not found..." + pathfile;
                error_msg();
                return;
            }
            fp1SR = new StreamReader(pathfile);

            //index = false;
            elcount = 0;
            int telemno = 0;

            HIPchainage = 0.0;
            string mdlnam, strnam;      // Sandipan 25082008 Kolkata

            while (fp1SR.EndOfStream == false)
            {
                Ls1 = 0.0; Ls2 = 0.0;

                CHalignFilData fildata = CHalignFilData.Parse(fp1SR.ReadLine());

                mdlnam  = fildata.sMod;
                strnam  = fildata.sString;
                telemno = fildata.iSlno;
                eltype  = fildata.iEltype;
                stchn   = fildata.dStartchn;
                endchn  = fildata.dEndchn;
                IPX     = fildata.dHipx;
                IPY     = fildata.dHipy;
                T1      = fildata.dT1;
                T2      = fildata.dT2;
                R       = fildata.dRadius;
                L       = fildata.dEllength;
                xst     = fildata.dStartx;
                yst     = fildata.dStarty;
                xed     = fildata.dEndx;
                yed     = fildata.dEndy;
                B1      = fildata.dB1;
                B2      = fildata.dB2;
                DEL     = fildata.dDeviation;
                turn1   = fildata.iTurn;

                if ((telemno > 0) && (mdlnam == modstr) && (strnam == stgstr))
                {
                    finchn = endchn;
                }
            }

            fp1SR.Close();

            fp1SR = new StreamReader(pathfile);

            while (fp1SR.EndOfStream == false)
            {
                init_param();
                des_curve_input();

                if (flag == 0)
                {
                    continue;
                }

                if ((stchn == last_stchn) && (endchn == last_endchn))
                {
                    break;
                }

                //if(start_index == 0)
                //{
                //    XST = xst;
                //    YST = yst;
                //    start_index = 1;
                //}


                draw_hips();

                //index = true;

                if (endchn == finchn)
                {
                    break;
                }
            }   // end while(fp1SR.EndOfStream)

            end_HIP();

            fp1.Close();
            fp1SR.Close();
            fp2.Close();
        }
Exemplo n.º 5
0
        void des_curve_input()
        {
            string mdlnam;
            string strnam;
            int    telemno = 0, teltype = 0;
            double tstchn = 0.0, tendchn = 0.0, tIPX = 0.0, tIPY = 0.0;
            double tT1 = 0.0, tT2 = 0.0, tR = 0.0, tL = 0.0;
            double txst = 0.0, tyst = 0.0, txed = 0.0, tyed = 0.0;
            double tB1 = 0.0, tB2 = 0.0, tDEL = 0.0;
            int    tturn1 = 0;

            Ls1 = 0.0; Ls2 = 0.0;


            while (true)
            {
                string strLine = fp1SR.ReadLine();
                if (strLine == null)
                {
                    break;
                }
                CHalignFilData fildata = CHalignFilData.Parse(strLine);

                mdlnam  = fildata.sMod;
                strnam  = fildata.sString;
                telemno = fildata.iSlno;
                teltype = fildata.iEltype;
                tstchn  = fildata.dStartchn;
                tendchn = fildata.dEndchn;
                tIPX    = fildata.dHipx;
                tIPY    = fildata.dHipy;
                tT1     = fildata.dT1;
                tT2     = fildata.dT2;
                tR      = fildata.dRadius;
                tL      = fildata.dEllength;
                txst    = fildata.dStartx;
                tyst    = fildata.dStarty;
                txed    = fildata.dEndx;
                tyed    = fildata.dEndy;
                tB1     = fildata.dB1;
                tB2     = fildata.dB2;
                tDEL    = fildata.dDeviation;
                tturn1  = fildata.iTurn;

                if (lasteltype == teltype && last_endchn == tendchn)
                {
                    break;
                }

                if ((telemno > 0) && (mdlnam == modstr) && (strnam == stgstr))
                {
                    flag   = 1; // final 13/09/01 DD
                    elemno = (short)telemno;
                    eltype = (short)teltype;
                    stchn  = tstchn;
                    endchn = tendchn;

                    //if(telemno==1)
                    if (eltype == 1)
                    {
                        xst         = txst;
                        yst         = tyst;
                        Xc          = txst;
                        Yc          = tyst;
                        startchn    = tstchn;
                        HIPchainage = tstchn;
                        B1          = tB1;
                        B2          = tB2;
                    }
                    if (eltype == 2)
                    {
                        Ls1  = tL;
                        Brg1 = tB1;
                    }
                    else if (eltype == 3)
                    {
                        Lc = tL;
                        elcount++;
                        IPX          = tIPX;
                        IPY          = tIPY;
                        T1           = tT1;
                        T2           = tT2;
                        R            = tR;
                        L            = tL;
                        xed          = txed;
                        yed          = tyed;
                        B1           = tB1;
                        B2           = tB2;
                        DEL          = tDEL;
                        turn1        = (short)tturn1;
                        HIPchainage += Math.Sqrt((Xc - IPX) * (Xc - IPX) + (Yc - IPY) * (Yc - IPY));
                        Xc           = IPX;
                        Yc           = IPY;
                    }
                    if (eltype == 4)
                    {
                        Ls2  = tL;
                        Brg2 = tB2;
                    }

                    if (start_index == 0)
                    {
                        XST         = xst;
                        YST         = yst;
                        start_index = 1;
                    }

                    if (tIPX == 0.0 && tIPY == 0.0)
                    {
                        xed = txed;
                        yed = tyed;
                        break;
                    }
                    else
                    {
                        if (eltype == 1 && (lasteltype == 3 || lasteltype == 4))
                        {
                            xed = txed;
                            yed = tyed;
                            break;
                        }
                    }
                }
                else
                {
                    flag = 0;
                }

                lasteltype  = teltype;
                last_stchn  = stchn;
                last_endchn = endchn;
                last_eltype = eltype;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Unreachable code segment
        /// </summary>
        private void save_halign()
        {
            double last_chn1 = 0.0;
            double last_chn2 = 0.0;
            string last_mod  = "NULL";
            string last_stg  = "NULL";

            string strhalignPath = Path.Combine(this.m_strWorkingDirPath, "halign.tmp");

            if (File.Exists(strhalignPath) == false)
            {
                throw new Exception("Failed to open file : " + strhalignPath);
            }

            StreamReader readerfp2 = new StreamReader(strhalignPath);
            StreamWriter writerfp3 = new StreamWriter(Path.Combine(this.m_strWorkingDirPath, "HALIGN.FIL"), true);

            while (readerfp2.EndOfStream == false)
            {
                //int iIndex = 0;
                string         strValTSV  = readerfp2.ReadLine();
                CHalignFilData FilDataObj = CHalignFilData.Parse(strValTSV);
                //string[] Values = strValTSV.Split(new char[] { '\t' });
                modnam = FilDataObj.sMod;
                stglbl = FilDataObj.sString;


                if (last_mod.CompareTo(modnam) == 0 && last_stg.CompareTo(stglbl) == 0)
                {
                    break;
                }

                elno   = (short)FilDataObj.iSlno;
                eltype = FilDataObj.iEltype;
                chn1   = FilDataObj.dStartchn;
                chn2   = FilDataObj.dEndchn;
                hipx   = FilDataObj.dHipx;
                hipy   = FilDataObj.dHipy;
                t1     = FilDataObj.dT1;
                t2     = FilDataObj.dT2;
                rad    = FilDataObj.dRadius;
                l      = FilDataObj.dEllength;
                xs     = FilDataObj.dStartx;
                ys     = FilDataObj.dStarty;
                xe     = FilDataObj.dEndx;
                ye     = FilDataObj.dEndy;
                b1     = FilDataObj.dB1;
                b2     = FilDataObj.dB2;
                del    = FilDataObj.dDeviation;
                turn   = FilDataObj.iTurn;

                del = b2 - b1;
                if (del < 0)
                {
                    del = del + 360;
                }
                if (del > 360)
                {
                    del = del - 360;
                }

                FilDataObj.sMod       = modnam;
                FilDataObj.sString    = stglbl;
                FilDataObj.iSlno      = elno;
                FilDataObj.iEltype    = eltype;
                FilDataObj.dStartchn  = chn1;
                FilDataObj.dEndchn    = chn2;
                FilDataObj.dHipx      = hipx;
                FilDataObj.dHipy      = hipy;
                FilDataObj.dT1        = t1;
                FilDataObj.dT2        = t2;
                FilDataObj.dRadius    = rad;
                FilDataObj.dEllength  = l;
                FilDataObj.dStartx    = xs;
                FilDataObj.dStarty    = ys;
                FilDataObj.dEndx      = xe;
                FilDataObj.dEndy      = ye;
                FilDataObj.dB1        = b1;
                FilDataObj.dB2        = b2;
                FilDataObj.dDeviation = del;
                FilDataObj.iTurn      = turn;

                writerfp3.WriteLine(FilDataObj.ToString());

                last_chn1 = chn1;
                last_chn2 = chn2;

                last_mod = modnam;
                last_stg = stglbl;
            }

            readerfp2.Close();
            writerfp3.Close();
        }