コード例 #1
0
        public string StringName; //[20];

        public static FirstLine FromStream(System.IO.BinaryReader br)
        {
            FirstLine data = new FirstLine();

            data.Code       = br.ReadInt16();
            data.AcceptCode = br.ReadInt16();
            data.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
            data.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

            return(data);
        }
コード例 #2
0
        public bool ReadModelsFromFile()
        {
            string filePath = fPath;
            bool   success  = false;

            if (File.Exists(filePath))
            {
                filePath = Path.GetDirectoryName(filePath);
            }
            BinaryReader br;
            long         len = 1;

            filePath = Path.Combine(filePath, "model.lst");
            //LstModel.Clear();

            if (File.Exists(filePath) == false)
            {
                return(false);
            }

            br = new BinaryReader(new FileStream(filePath, FileMode.Open, FileAccess.Read), Encoding.Default);
            try
            {
                LstModel = new List <CModel>();
                len      = br.BaseStream.Length;
                CModel cm;
                while (br.BaseStream.Position < len)
                {
                    cm            = new CModel();
                    cm.ModelName  = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30));
                    cm.StringName = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20));

                    if (cm.ModelName != "")
                    {
                        LstModel.Add(cm);
                    }
                }
                success = true;
            }
            catch (Exception exx)
            {
                success = false;
            }
            finally
            {
                br.Close();
            }
            return(success);
        }
コード例 #3
0
        void read_input()
        {
            //IN_flag = 0;

            pathfile = Path.Combine(path, "chain1.tmp");

            if (File.Exists(pathfile) == false)
            {
                textstring = "File %s not found..." + pathfile;
                error_msg();
            }
            else
            {
                HeadsUtils.Chainage chain = new HeadsUtils.Chainage();

                fp1 = new BinaryReader(new FileStream(pathfile, FileMode.Open, FileAccess.Read), Encoding.Default);

                chain.ModelName        = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(30));
                chain.StringName       = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(20));
                chain.XMin             = fp1.ReadDouble();
                chain.YMin             = fp1.ReadDouble();
                chain.ChainageInterval = fp1.ReadDouble();
                chain.TextSize         = fp1.ReadDouble();
                chain.Rotation         = fp1.ReadDouble();

                model  = chain.ModelName;
                stglbl = chain.StringName;

                inc      = chain.ChainageInterval;
                textsize = chain.TextSize;
                rotn     = chain.Rotation;
                XMIN     = chain.XMin;
                YMIN     = chain.YMin;

                fp1.Close();
            }
        }
コード例 #4
0
        public bool ReadHIPFile(string strPath, out CHalFile filedata)
        {
            bool bSuccess = false;

            filedata = new CHalFile();
            BinaryReader br = new BinaryReader(new FileStream(strPath, FileMode.Open, FileAccess.Read), Encoding.Default);

            if (br != null)
            {
                filedata.Code        = br.ReadInt16();                                         //Line code
                filedata.AcceptCode  = br.ReadInt16();                                         //Accept code
                filedata.ModelName   = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(30)); //Model name
                filedata.StringLevel = ViewerUtils.ConvertCharArrayToString(br.ReadBytes(20)); //String level

                short sTotalHIP = br.ReadInt16();                                              //Total HIPs
                filedata.StartChainage    = br.ReadDouble();                                   //Start Chain
                filedata.ChainageInterval = br.ReadDouble();                                   //Chainage Interval

                for (short sCnt = 0; sCnt < sTotalHIP; sCnt++)
                {
                    CHHipData hhipObj = new CHHipData();
                    short     iHipNo  = br.ReadInt16();
                    hhipObj.xvalue     = br.ReadDouble();
                    hhipObj.yvalue     = br.ReadDouble();
                    hhipObj.radius     = br.ReadDouble();
                    hhipObj.leadtrans  = br.ReadDouble();
                    hhipObj.trailtrans = br.ReadDouble();

                    filedata.ListHip.Add(hhipObj);
                }

                br.Close();
                bSuccess = true;
            }
            return(bSuccess);
        }
コード例 #5
0
        private bool hip_method()
        {
            bool bSuccess = true;

            fp1 = new BinaryReader(new FileStream(Path.Combine(this.m_strWorkingDirPath, "HAL1.tmp"), FileMode.Open, FileAccess.Read), Encoding.Default);

            CHalFile filedata = new CHalFile();

            filedata.Code        = fp1.ReadInt16();                                         //Line code
            filedata.AcceptCode  = fp1.ReadInt16();                                         //Accept code
            filedata.ModelName   = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(30)); //Model name
            filedata.StringLevel = ViewerUtils.ConvertCharArrayToString(fp1.ReadBytes(20)); //String level
            short sTotalHIP = fp1.ReadInt16();                                              //Total HIPs

            filedata.StartChainage    = fp1.ReadDouble();                                   //Start Chain
            filedata.ChainageInterval = fp1.ReadDouble();                                   //Chainage Interval



            modnam = filedata.ModelName;
            stglbl = filedata.StringLevel;
            hips   = sTotalHIP;
            chn1   = filedata.StartChainage;
            inc    = filedata.ChainageInterval;
            ptsc   = 0;
            pts    = 0;

            fpm = new StreamWriter(Path.Combine(this.m_strWorkingDirPath, "ERRORMESSAGES.TXT"), true);
            fpm.WriteLine();
            fpm.WriteLine("    *************************************************");
            fpm.WriteLine("    Program [HEADS:Design:HALIGNMENT] was run on : " + DateTime.Now.ToString());

            for (ip = 0; ip < hips - 2; ip++)
            {
                hip_input();

                bearings();

                deflection();

                tangent_points();

                if (error_flag != 0)
                {
                    break;
                }

                if (lt1 > 0)
                {
                    elno++;
                    eltype = 1;
                    //chn1 = chn1;
                    hipx = x2;
                    hipy = y2;
                    l    = lt1;

                    if (ip == 0)
                    {
                        xs = x1;
                        ys = y1;
                    }
                    else
                    {
                        xs = xe;
                        ys = ye;
                    }
                    b1 = B1;

                    element();
                }

                if (ls1 > 0)
                {
                    elno++;
                    eltype = 2;
                    chn1   = chn2;
                    hipx   = x2;
                    hipy   = y2;
                    l      = ls1;
                    xs     = xe; ys = ye;
                    b1     = b2;

                    element();
                }


                if (lc > 0)
                {
                    elno++;
                    eltype = 3;
                    chn1   = chn2;
                    hipx   = x2;
                    hipy   = y2;
                    l      = lc;
                    xs     = xe; ys = ye;
                    b1     = b2;

                    element();
                }

                if (ls2 > 0)
                {
                    elno++;
                    eltype = 4;
                    chn1   = chn2;
                    hipx   = x2;
                    hipy   = y2;
                    l      = ls2;
                    xs     = xe; ys = ye;
                    b1     = b2;

                    element();
                }

                x1 = xe; y1 = ye;
                xm = x2; ym = y2;
                x2 = x3; y2 = y3;

                rad  = last_rad;
                ls1  = last_ls1;
                ls2  = last_ls2;
                turn = last_turn;

                chn1 = chn2;
                B1   = b2;
            }

            if (error_flag == 0)
            {
                if (lt2 > 0)
                {
                    elno++;
                    eltype = 1;
                    chn1   = chn2;
                    hipx   = xm;
                    hipy   = ym;
                    l      = lt2;
                    xs     = xe; ys = ye;
                    b1     = B2;

                    element();
                }
            }


            fpm.WriteLine("    *************************************************");
            fpm.Close();
            fp1.Close();

            if (error_flag == 1)
            {
                System.Windows.Forms.MessageBox.Show("Check the file ERRORMESSAGES.TXT for all the details", HeadsUtils.Constants.ProductName);
                bSuccess = false;
            }
            else
            {
                bSuccess = true;
            }

            return(bSuccess);
        }