Beispiel #1
0
        void write_offset_string()
        {
            CLabtype lab;
            CModType mod;
            CStgType stg;
            CPTStype pts;

            //CTXTtype txt;

            //fsetpos(fp1, &loc2);

            if (offind == 0)
            {
                lab      = new CLabtype();
                lab.attr = CLabtype.Type.Model;
                mod      = new CModType();
                mod.name = offmod;
                lab.Tag  = mod;
                listmodelfilNew.Add(lab);

                lab       = new CLabtype();
                lab.attr  = CLabtype.Type.String;
                stg       = new CStgType();
                stg.label = offstr;
                lab.Tag   = stg;
                listmodelfilNew.Add(lab);

                write_list();

                offind = 1;
            }

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.Point;
            pts      = new CPTStype();
            pts.mc   = ochn;
            pts.mx   = ox;
            pts.my   = oy;
            pts.mz   = oz;
            lab.Tag  = pts;
            listmodelfilNew.Add(lab);

            //fgetpos(fp1, &loc2);

            fp4.Write(string.Format(" {0,10:f5}  {1,15:f5}  {2,15:f5}  {3,10:f3} {4,8:f3} {5,8:f3}\n", ochn, ox, oy, oz, ho, vo));
            //fprintf(fp4," %10.5f  %15.5f  %15.5f  %10.3f %8.3f %8.3f\n", ochn, ox, oy, oz, ho, vo);

            try
            {
                StreamWriter tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true);
                tmpFile.WriteLine(string.Format("{0} {1} {2,10:f3} {3,10:f3} {4,10:f3} {5,10:f3}", offmod, offstr, ochn, ox, oy, oz));
                tmpFile.Close();
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Failed to write display file", HeadsUtils.Constants.ProductName);
                return;
            }
        }
Beispiel #2
0
        void ShowItemEntities(List <CLabtype> entities, string strModelName, string stgLabel)
        {
            int           NumPts   = 0;
            CPoint3D      ptStart  = new CPoint3D();
            CPoint3D      ptEnd    = new CPoint3D();
            CPoint3D      ptLast   = new CPoint3D();
            CTXTtype      txt      = new CTXTtype();
            CLinetype     uline    = new CLinetype();
            IHdPolyline3D polyline = null;
            string        str1     = "";

            IHdPoint aPoint = null;
            CPTStype pts    = new CPTStype();

            this.App.ActiveDocument.ConfigParam.XMetric = 1.0;
            this.App.ActiveDocument.ConfigParam.YMetric = 1.0;

            CCfgtype cfg = this.App.ActiveDocument.ConfigParam;

            eHEADS_COLOR entitycolor = (stgLabel.StartsWith("member")) ? FormLoadDeflection.MemberColor : FormLoadDeflection.LoadColor;

            double dTextHeight = (this.App.ActiveDocument.ActiveTextHeight > 0) ? this.App.ActiveDocument.ActiveTextHeight : 1.0;

            for (int iIndex = 0; iIndex < entities.Count; iIndex++)
            {
                CLabtype labtype = entities[iIndex];

                if (labtype.attr == CLabtype.Type.Point)
                {
                    pts = (CPTStype)labtype.Tag;

                    ptEnd = new CPoint3D(pts.mx * cfg.XMetric, pts.my * cfg.YMetric, pts.mz);
                    NumPts++;

                    ptStart = ptLast;
                    ptLast  = ptEnd;

                    uline.StartPoint = new CPoint3D(ptStart);
                    uline.EndPoint   = new CPoint3D(ptEnd);

                    str1 = stgLabel;

                    if (NumPts == 1)
                    {
                        aPoint = this.App.ActiveDocument.DrawPoint(ptEnd);

                        aPoint.color = entitycolor;
                    }
                    else if (NumPts == 2)
                    {
                        uline.Layer  = this.App.ActiveDocument.GetActiveLayer().Name;
                        uline.elatt  = 1;
                        uline.laatt  = 1;
                        uline.Label  = strModelName;
                        uline.Label += ":";
                        uline.Label += stgLabel;
                        uline.scatt  = 1;

                        polyline = DrawingUtil.DrawPolyline3DDx(this.App.ActiveDocument, true, uline);

                        polyline.color = entitycolor;

                        aPoint.Erase();
                    }
                    else if (NumPts > 2)
                    {
                        polyline.AppendVertex(ptEnd);
                    }
                }
                else if (labtype.attr == CLabtype.Type.Text)
                {
                    txt = (CTXTtype)labtype.Tag;

                    ptEnd = new CPoint3D(txt.tx * cfg.XMetric, txt.ty * cfg.YMetric, txt.tz);
                    str1  = txt.tg;
                    IHdText textobj = this.App.ActiveDocument.DrawText(ptEnd, str1, dTextHeight);
                    textobj.color = entitycolor;
                    aPoint        = this.App.ActiveDocument.DrawPoint(ptEnd);
                    aPoint.color  = entitycolor;
                }
                else if (labtype.attr == CLabtype.Type.EndCode)
                {
                    NumPts = 0;
                }
            }
            this.App.ActiveDocument.RefreshDocument(true);
        }
Beispiel #3
0
        void ProcessData()
        {
            BinaryWriter fp2 = null;
            StreamWriter fp3 = null;

            string nam;
            string lbl;

            int ind = 0, len, ival;
            int slno, eltype, turn;

            double x, y, z;
            double stchn, RC, sc = 0, inc, seglen, segend;    //, seginc;
            double RCI, num, val;
            double T1, T2, R, D, lastRC = -999.999;

            /* Select a Polyline from screen */
            /* User Input data in dialog box */
            modnam = this.tbModelName_.Text;
            stglbl = this.tbStringlabel_.Text;

            stchn = this.tbStartChainage_.Value;

            inc = this.tbChainageInterval_.Value;

            string csTemp = Path.Combine(this.app.AppDataPath, "MODEL.FIL");

            fp2 = new BinaryWriter(new FileStream(csTemp, FileMode.Append), Encoding.Default);

            if (this.checkMasterString_.Checked == true)
            {
                csTemp = Path.Combine(this.app.AppDataPath, "HALIGN.FIL");
                fp3    = new StreamWriter(csTemp, true);
            }
            CLabtype lab = null;
            CPTStype pts = null;
            CModType mod = null;
            CStgType stg = null;
            ClSTtype lst = null;

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.Model;
            mod      = new CModType();
            mod.name = modnam;
            lab.Tag  = mod;
            lab.ToStream(fp2);

            lab       = new CLabtype();
            lab.attr  = CLabtype.Type.String;
            stg       = new CStgType();
            stg.label = stglbl;
            lab.Tag   = stg;
            lab.ToStream(fp2);


            RC = stchn;
            //seginc=0.0;
            sx     = sy = sz = -999.999;
            T1     = T2 = R = D = 0;
            turn   = 0;
            B1     = B2 = 0.0;
            slno   = 1;
            eltype = 1;
            turn   = 1;
            ind    = 0;
            //ind1=0;


            for (int vx = 0; vx < this.ptCords.Length; vx++)
            {
                /*JBLN*/
                ex = this.ptCords[vx].X;
                ey = this.ptCords[vx].Y;
                ez = this.ptCords[vx].Z;
                //		fscanf(fp1, "%lf %lf %lf", &ex, &ey, &ez);  /* close in vc++    */

                if (ind == 0)
                {
                    lab      = new CLabtype();
                    lab.attr = CLabtype.Type.Point;
                    pts      = new CPTStype();
                    pts.mc   = RC;
                    pts.mx   = ex;
                    pts.my   = ey;
                    pts.mz   = ez;
                    lab.Tag  = pts;
                    lab.ToStream(fp2);

                    sc = RC;
                    sx = ex;
                    sy = ey;
                    sz = ez;
                    B1 = B2;

                    ind = 1;
                    continue;
                }


                if (ex == sx && ey == sy)
                {
                    continue;
                }

                tt = string.Format("{0:f0}", inc);//sprintf(tt,"%.0f", inc);

                len = tt.Length;

                RCI  = RC;
                num  = Math.Pow(10, len);
                RCI  = RCI / num;
                ival = (int)RCI;
                RCI  = ival * num;
                while (RCI < RC)
                {
                    RCI += inc;
                }
                RC = RCI;

                if (RC == sc)
                {
                    RC += inc;  /* NEW */
                }
                determine_bearing();

                seglen = Math.Sqrt((ex - sx) * (ex - sx) + (ey - sy) * (ey - sy));      /* NEW */

                segend = sc + seglen;                                                   /* NEW */

                if (this.checkMasterString_.Checked == true)
                {
                    if (B1 == 0)
                    {
                        B1 = B2;
                    }
                    D = B1 - B2; if (D < 0)
                    {
                        D += 360;
                    }
                    if (D > 360)
                    {
                        D -= 360;
                    }

                    CHalignFilData fildata = new CHalignFilData();
                    fildata.sMod       = modnam;
                    fildata.sString    = stglbl;
                    fildata.iSlno      = slno;
                    fildata.iEltype    = (short)eltype;
                    fildata.dStartchn  = sc;
                    fildata.dEndchn    = segend;
                    fildata.dHipx      = ex;
                    fildata.dHipy      = ey;
                    fildata.dT1        = T1;
                    fildata.dT2        = T2;
                    fildata.dRadius    = R;
                    fildata.dEllength  = seglen;
                    fildata.dStartx    = sx;
                    fildata.dStarty    = sy;
                    fildata.dEndx      = ex;
                    fildata.dEndy      = ey;
                    fildata.dB1        = B2;
                    fildata.dB2        = B2;
                    fildata.dDeviation = D;
                    fildata.iTurn      = (short)turn;
                    fp3.WriteLine(fildata.ToString());

                    //fprintf(fp3, "%s %s %d %d %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f %.3f %.3f %.3f %d\n", modnam, stglbl, slno, eltype, sc, segend, ex, ey, T1, T2, R, seglen, sx, sy, ex, ey, B2, B2, D, turn);
                    slno++;     /* NEW */
                }


                val = Math.Abs(RC - segend);/* fabs will be abs in VC++*/
                if (val < 0.001)
                {
                    segend = RC;
                }


                while (true)
                {
                    if (segend < RC)
                    {
                        if (segend + inc != RC)
                        {
                            val = Math.Abs(segend - lastRC);
                            if (val > 0.001)
                            {
                                lab      = new CLabtype();
                                lab.attr = CLabtype.Type.Point;
                                pts      = new CPTStype();
                                pts.mc   = segend;
                                pts.mx   = ex;
                                pts.my   = ey;
                                pts.mz   = ez;
                                lab.Tag  = pts;
                                lab.ToStream(fp2);

                                lastRC = segend;
                            }
                        }
                        RC = segend;

                        ind = 0;
                        break;
                    }
                    else
                    {
                        if ((RC - sc) > 0.001)
                        {
                            x = sx + (RC - sc) * Math.Sin(B2 / r9);     /*  E  */
                            y = sy + (RC - sc) * Math.Cos(B2 / r9);     /*  N  */
                            z = sz + (RC - sc) * (ez - sz) / (segend - sc);

                            if (RC != lastRC)
                            {
                                lab      = new CLabtype();
                                lab.attr = CLabtype.Type.Point;
                                pts      = new CPTStype();
                                pts.mc   = RC;
                                pts.mx   = x;
                                pts.my   = y;
                                pts.mz   = z;
                                lab.Tag  = pts;
                                lab.ToStream(fp2);

                                lastRC = RC;
                            }
                        }
                        RC += inc;
                    }
                }

                sc = RC;
                sx = ex;
                sy = ey;
                sz = ez;
                B1 = B2;

                ind = 1;
            }// end for previously while

            fp2.Close();

            if (this.checkMasterString_.Checked == true)
            {
                fp3.Close();
            }

            csTemp      = Path.Combine(this.app.AppDataPath, "MODEL.LST");
            fp2         = new BinaryWriter(new FileStream(csTemp, FileMode.Append), Encoding.Default);
            lst         = new ClSTtype();
            lst.strMod1 = modnam;
            lst.strStg  = stglbl;
            lst.ToStream(fp2);
            fp2.Close();

            csTemp = Path.Combine(this.app.AppDataPath, "MODEL.FIL");
            fp2    = new BinaryWriter(new FileStream(csTemp, FileMode.Append), Encoding.Default);

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.Model;
            mod      = new CModType();
            nam      = modnam + "%%";
            mod.name = nam;
            lab.Tag  = mod;
            lab.ToStream(fp2);

            lab       = new CLabtype();
            lab.attr  = CLabtype.Type.String;
            stg       = new CStgType();
            lbl       = stglbl;
            stg.label = lbl;
            lab.Tag   = stg;
            lab.ToStream(fp2);


            for (int vx = 0; vx < this.ptCords.Length; vx++)
            {
                ex = this.ptCords[vx].X;
                ey = this.ptCords[vx].Y;
                ez = this.ptCords[vx].Z;

                lab      = new CLabtype();
                lab.attr = CLabtype.Type.Point;
                pts      = new CPTStype();
                pts.mc   = RC;
                pts.mx   = ex;
                pts.my   = ey;
                pts.mz   = ez;
                lab.Tag  = pts;
                lab.ToStream(fp2);
            }

            fp2.Close();

            csTemp      = Path.Combine(this.app.AppDataPath, "MODEL.LST");
            fp2         = new BinaryWriter(new FileStream(csTemp, FileMode.Append), Encoding.Default);
            lst         = new ClSTtype();
            lst.strMod1 = nam;
            lst.strStg  = lbl;
            lst.ToStream(fp2);
            fp2.Close();
        }
Beispiel #4
0
        void Write_Boundary_Offset_in_Model_File()
        {
            BinaryWriter fp2 = null;
            StreamWriter fp3 = null;

            string nam;
            string lbl;

            int ind = 0, len, ival;
            int slno, eltype, turn;

            double x, y, z;
            double stchn, RC, sc = 0, inc, seglen, segend;//, seginc;
            double RCI, num, val;
            double T1, T2, R, D, lastRC = -999.999;

            /* Select a Polyline from screen */
            /* User Input data in dialog box */
            //if (this.checkMasterString_.Checked)
            //{
            //    modnam = this.txt_make_str_Model.Text;
            //    stglbl = this.txt_make_str_String.Text;
            //}
            //else
            //{
            modnam = this.txt_model.Text;
            stglbl = this.txt_string.Text;
            //}



            stchn = Start_Chainage;

            inc = Chainage_Interval;

            string csTemp = Path.Combine(AppDataPath, "MODEL.FIL");

            fp2 = new BinaryWriter(new FileStream(csTemp, FileMode.Append), Encoding.Default);

            CLabtype lab = null;
            CPTStype pts = null;
            CModType mod = null;
            CStgType stg = null;
            ClSTtype lst = null;

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.Model;
            mod      = new CModType();
            mod.name = modnam;
            lab.Tag  = mod;
            lab.ToStream(fp2);

            lab       = new CLabtype();
            lab.attr  = CLabtype.Type.String;
            stg       = new CStgType();
            stg.label = stglbl;
            lab.Tag   = stg;
            lab.ToStream(fp2);


            RC = stchn;
            //seginc=0.0;
            sx     = sy = sz = -999.999;
            T1     = T2 = R = D = 0;
            turn   = 0;
            B1     = B2 = 0.0;
            slno   = 1;
            eltype = 1;
            turn   = 1;
            ind    = 0;
            //ind1=0;


            for (int vx = 0; vx < this.ptCords.Count; vx++)
            {
                /*JBLN*/
                ex = this.ptCords[vx].x;
                ey = this.ptCords[vx].y;
                ez = this.ptCords[vx].z;

                if (ind == 0)
                {
                    lab      = new CLabtype();
                    lab.attr = CLabtype.Type.Point;
                    pts      = new CPTStype();
                    pts.mc   = RC;
                    pts.mx   = ex;
                    pts.my   = ey;
                    pts.mz   = ez;
                    lab.Tag  = pts;
                    lab.ToStream(fp2);
                    chainage_points.Add(pts); // Store Chainage Points

                    sc = RC;
                    sx = ex;
                    sy = ey;
                    sz = ez;
                    B1 = B2;

                    ind = 1;
                    continue;
                }


                if (ex == sx && ey == sy)
                {
                    continue;
                }

                tt = string.Format("{0:f0}", inc);//sprintf(tt,"%.0f", inc);

                len = tt.Length;

                RCI  = RC;
                num  = Math.Pow(10, len);
                RCI  = RCI / num;
                ival = (int)RCI;
                RCI  = ival * num;
                while (RCI < RC)
                {
                    RCI += inc;
                }
                RC = RCI;

                if (RC == sc)
                {
                    RC += inc;  /* NEW */
                }
                determine_bearing();

                seglen = Math.Sqrt((ex - sx) * (ex - sx) + (ey - sy) * (ey - sy));      /* NEW */

                segend = sc + seglen;                                                   /* NEW */


                val = Math.Abs(RC - segend);/* fabs will be abs in VC++*/
                if (val < 0.001)
                {
                    segend = RC;
                }

                sc = RC;
                sx = ex;
                sy = ey;
                sz = ez;
                B1 = B2;

                ind = 1;
            }// end for previously while

            fp2.Close();

            csTemp      = Path.Combine(this.AppDataPath, "MODEL.LST");
            fp2         = new BinaryWriter(new FileStream(csTemp, FileMode.Append), Encoding.Default);
            lst         = new ClSTtype();
            lst.strMod1 = modnam;
            lst.strStg  = stglbl;
            lst.ToStream(fp2);
            fp2.Close();
        }
Beispiel #5
0
        public bool Write_Model(Vertexes vertx, string model, string strlbl, string work_folder)
        {
            string last_str = "";

            CLabtype lab;
            CModType mod;
            CStgType stg;
            CPTStype pts;
            CTXTtype txt;
            ClSTtype lst;

            List <CLabtype> listlabs = new List <CLabtype>();
            List <ClSTtype> listLst  = new List <ClSTtype>();

            mod      = new CModType();
            mod.Name = model;

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.Model;
            lab.Tag  = mod;
            listlabs.Add(lab);

            stg       = new CStgType();
            stg.label = strlbl;

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.String;
            lab.Tag  = stg;
            listlabs.Add(lab);


            lst         = new ClSTtype();
            lst.strMod1 = model;
            lst.strStg  = strlbl;
            listLst.Add(lst);
            for (int i = 0; i < vertx.Count; i++)
            {
                lab      = new CLabtype();
                lab.attr = CLabtype.Type.Point;

                pts = new CPTStype();

                pts.mx  = vertx[i].x;
                pts.my  = vertx[i].y;
                pts.mz  = (vertx[i].z == 0.0) ? -999.0 : vertx[i].z;
                pts.mc  = (i + 1);
                lab.Tag = pts;
                listlabs.Add(lab);
            }
            lab      = new CLabtype();
            lab.attr = CLabtype.Type.EndCode;
            listlabs.Add(lab);

            string pth = Path.Combine(work_folder, "MODEL.LST");

            WriteModelLstFile(pth, listLst);
            pth = Path.Combine(work_folder, "MODEL.FIL");
            WriteModelFilFile(pth, listlabs);

            return(true);
        }
Beispiel #6
0
        public bool Write_Model(string model)
        {
            string last_str = "";

            CLabtype lab;
            CModType mod;
            CStgType stg;
            CPTStype pts;
            CTXTtype txt;
            ClSTtype lst;

            List <CLabtype> listlabs = new List <CLabtype>();
            List <ClSTtype> listLst  = new List <ClSTtype>();

            for (int i = 0; i < list.Count; i++)
            {
                if ((list[i].SerialNo == 0) ||
                    ((list[i].X <= -999 || list[i].X == 0.0) &&
                     (list[i].Y <= -999 || list[i].Y == 0.0)))
                {
                    lab      = new CLabtype();
                    lab.attr = CLabtype.Type.EndCode;
                    listlabs.Add(lab);
                }
                else
                {
                    if (list[i].FeatureCode != last_str)
                    {
                        last_str = list[i].FeatureCode;

                        mod      = new CModType();
                        mod.Name = Model;

                        lab      = new CLabtype();
                        lab.attr = CLabtype.Type.Model;
                        lab.Tag  = mod;
                        listlabs.Add(lab);

                        stg       = new CStgType();
                        stg.label = last_str;

                        lab      = new CLabtype();
                        lab.attr = CLabtype.Type.String;
                        lab.Tag  = stg;
                        listlabs.Add(lab);


                        lst         = new ClSTtype();
                        lst.strMod1 = Model;
                        lst.strStg  = last_str;
                        listLst.Add(lst);
                    }

                    lab      = new CLabtype();
                    lab.attr = CLabtype.Type.Point;

                    pts = new CPTStype();

                    pts.mx = list[i].X;
                    pts.my = list[i].Y;
                    pts.mz = (list[i].Z == 0.0) ? -999.0 : list[i].Z;
                    //pts.mc = 123.00;
                    pts.mc  = (i + 1);
                    lab.Tag = pts;
                    listlabs.Add(lab);
                }
            }
            lab      = new CLabtype();
            lab.attr = CLabtype.Type.EndCode;
            listlabs.Add(lab);

            string pth = Path.Combine(WorkingFolder, "MODEL.LST");

            WriteModelLstFile(pth, listLst);
            pth = Path.Combine(WorkingFolder, "MODEL.FIL");
            WriteModelFilFile(pth, listlabs);

            return(true);
        }
Beispiel #7
0
        private void ExecDrawString(BinaryReader br)
        {
            bool bIsModel = false;
            bool bIsLabel = false;

            CPoint3D ptStart      = new CPoint3D();
            CPoint3D ptEnd        = new CPoint3D();
            CPoint3D ptLast       = new CPoint3D();
            CPoint3D ptFirst3dFac = new CPoint3D();
            string   strSeleModel = GetSelectedModelName();

            CTXTtype        txt          = new CTXTtype();
            CLinetype       uline        = new CLinetype();
            string          strModelName = "";
            int             NumPts       = 0;
            string          str1         = "";
            string          stgLabel     = "";
            IHdPoint        aPoint       = null;
            IHdPolyline3D   polyline     = null;
            CPTStype        pts          = new CPTStype();
            List <CPoint3D> pFArray      = new List <CPoint3D>();

            this.m_app.ActiveDocument.ConfigParam.XMetric = 1.0;
            this.m_app.ActiveDocument.ConfigParam.YMetric = 1.0;

            CCfgtype cfg = this.m_app.ActiveDocument.ConfigParam;

            int iSelectedLineType = this.GetSelectedLineType();

            double dTextHeight = (this.m_app.ActiveDocument.ActiveTextHeight > 0) ? this.m_app.ActiveDocument.ActiveTextHeight : 1.0;


            string strFilePath = m_strpathfilfile;
            //if (File.Exists(strFilePath))
            {
                //BinaryReader br = new BinaryReader(new FileStream(strFilePath, FileMode.Open, FileAccess.Read), Encoding.Default);

                //set the progress bar max value
                SetProgressBarMaxValue(100);

                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    CLabtype labtype = CLabtype.FromStream(br);

                    if (labtype.attr == CLabtype.Type.Model) // Model Name
                    {
                        NumPts       = 0;
                        strModelName = ((CModType)labtype.Tag).Name;
                        bIsModel     = (strModelName == strSeleModel) ? true : false;
                    }
                    else if (labtype.attr == CLabtype.Type.String)// String Label
                    {
                        stgLabel = ((CStgType)labtype.Tag).label;
                        if (bIsModel)
                        {
                            bIsLabel = this.lbStringLebels_.CheckedItems.Contains(stgLabel);
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.Point)
                    {
                        pts = (CPTStype)labtype.Tag;

                        ptEnd = new CPoint3D(pts.mx * cfg.XMetric, pts.my * cfg.YMetric, pts.mz);
                        NumPts++;

                        ptStart = ptLast;
                        ptLast  = ptEnd;

                        if (bIsModel && bIsLabel)
                        {
                            uline.StartPoint = new CPoint3D(ptStart);
                            uline.EndPoint   = new CPoint3D(ptEnd);

                            str1 = stgLabel;
                            if (str1.ToUpper().StartsWith("P") == true)
                            {
                                if (str1.ToUpper().StartsWith("P0") == true)
                                {
                                    txt.Point = ptEnd;
                                    //double[] res = ptEnd.GetCordArr();

                                    txt.tr = 0.0;

                                    str1 = ptEnd.Z.ToString("0.000");
                                    this.m_app.ActiveDocument.DrawText(new CPoint3D(ptEnd.X, ptEnd.Y, dTextHeight), str1, dTextHeight);

                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X - 0.5, ptEnd.Y, ptEnd.Z), new CPoint3D(ptEnd.X + 0.5, ptEnd.Y, ptEnd.Z));
                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X, ptEnd.Y - 0.5, ptEnd.Z), new CPoint3D(ptEnd.X, ptEnd.Y + 0.5, ptEnd.Z));
                                }
                                else
                                {
                                    txt.Point = ptEnd;
                                    txt.tr    = 0.0;
                                    double[] res = ptEnd.GetCordArr();

                                    this.m_app.ActiveDocument.DrawText(new CPoint3D(ptEnd.X, ptEnd.Y, dTextHeight), str1, dTextHeight);

                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X - 0.5, ptEnd.Y, ptEnd.Z), new CPoint3D(ptEnd.X + 0.5, ptEnd.Y, ptEnd.Z));
                                    this.m_app.ActiveDocument.DrawLine(new CPoint3D(ptEnd.X, ptEnd.Y - 0.5, ptEnd.Z), new CPoint3D(ptEnd.X, ptEnd.Y + 0.5, ptEnd.Z));
                                }
                            }
                            else
                            {
                                if (NumPts == 1)
                                {
                                    aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    if (iSelectedLineType == 4)
                                    {
                                        aPoint.Erase();
                                        ptFirst3dFac = new CPoint3D(ptEnd);
                                        pFArray.Add(ptEnd);
                                    }
                                }
                                else if (NumPts == 2)
                                {
                                    uline.Layer  = this.m_app.ActiveDocument.GetActiveLayer().Name;
                                    uline.elatt  = 1;
                                    uline.laatt  = 1;
                                    uline.Label  = strModelName;
                                    uline.Label += ":";
                                    uline.Label += stgLabel;
                                    uline.scatt  = 1;

                                    if (iSelectedLineType == 1)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 2)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 3)
                                    {
                                        aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    }
                                    else if (iSelectedLineType == 4)
                                    {
                                        pFArray.Add(ptEnd);
                                    }

                                    aPoint.Erase();
                                }
                                else if (NumPts > 2)
                                {
                                    if (iSelectedLineType == 1)
                                    {
                                        polyline.AppendVertex(ptEnd);
                                    }
                                    else if (iSelectedLineType == 2)
                                    {
                                        polyline = DrawingUtil.DrawPolyline3DDx(this.m_app.ActiveDocument, true, uline);
                                    }
                                    else if (iSelectedLineType == 3)
                                    {
                                        aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                                    }
                                    else if (iSelectedLineType == 4)
                                    {
                                        pFArray.Add(ptEnd);
                                    }
                                }
                            }
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.Text)
                    {
                        txt = (CTXTtype)labtype.Tag;

                        ptEnd = new CPoint3D(txt.tx * cfg.XMetric, txt.ty * cfg.YMetric, txt.tz);
                        if (bIsLabel && bIsModel)
                        {
                            str1 = txt.tg;
                            //Display an Elevation
                            //TO DO:
                            this.m_app.ActiveDocument.DrawText(ptEnd, str1, dTextHeight);
                            aPoint = this.m_app.ActiveDocument.DrawPoint(ptEnd);
                        }
                    }
                    else if (labtype.attr == CLabtype.Type.EndCode)
                    {
                        if ((iSelectedLineType == 4) && (bIsLabel && bIsModel))
                        {
                            if ((System.Math.Abs(ptEnd.X - ptFirst3dFac.X) > 0.00001) || (System.Math.Abs(ptEnd.Y - ptFirst3dFac.Y) > 0.00001))
                            {
                                if (NumPts < 4)
                                {
                                    pFArray.Add(ptFirst3dFac);   //close the face
                                }
                            }

                            if (pFArray.Count > 3)
                            {
                                IHd3DFace face3d = this.m_app.ActiveDocument.Draw3DFace(pFArray[0], pFArray[1], pFArray[2], pFArray[3]);
                                face3d.Update();
                            }
                            pFArray.Clear();
                        }
                        NumPts = 0;
                    }
                    int iCurProgressInPercent = (int)(((double)br.BaseStream.Position / (double)br.BaseStream.Length) * 100.00);

                    SetProgressBarValue(iCurProgressInPercent);
                    Thread.Sleep(0);
                }
                //br.Close();
            }
        }
Beispiel #8
0
        void master_sub_string()
        {
            CLabtype lab;
            CModType mod = null;
            CStgType stg;
            CPTStype pts;
            CTXTtype txt;

            // Redeveloped Sandipan 23/03/2007
            // Redeveloped  14/06/2004
            // Redeveloped by Sandipan 04 & 05/12/2003

            //rewind(fp1);

            double[] rchn = new double[10000];
            double[] rx = new double[10000];
            double[] ry = new double[10000];
            double[] rz = new double[10000];
            double[] schn = new double[10000];
            double[] sx = new double[10000];
            double[] sy = new double[10000];
            double[] sz = new double[10000];
            int      i, j;
            int      totref;
            int      totsub;
            //string substrFile;

            double valrc, valrx, valry, valrz;
            double valsc1, valsx1, valsy1, valsz1;
            double valsc2, valsx2, valsy2, valsz2;
            //double ic, valix, valiy, valiz;
            double m1, m2, c1, c2;
            double x4, y4, z4, d, id1, id2, id3;
            double xdiff1, ydiff1, xdiff2, ydiff2, B1 = 0, B2 = 0, theta, r9, ichn, checkd;
            int    direction;
            string curmod = string.Empty, curstr;

            StreamWriter ftmp;

            try
            {
                ftmp = new StreamWriter(Path.Combine(path, "SUBSTR.TMP"), true);
            }
            catch
            {
                msgstr = "Failed to write display file " + Path.Combine(path, "SCROLL.TMP");
                error_msg();
                return;
            }

            //FILE *ftmp;
            //strcpy(substrFile, path);
            //strcat(substrFile, "\\substr.tmp");

            //if((ftmp=fopen(substrFile, "w")) == NULL)
            //{
            //    fclose(fp1);
            //    sprintf(msgstr, "Failed to open file %s", substrFile);
            //    error_msg();
            //}

            i  = 0; j = 0;
            r9 = 57.29577951;

            for (int iPos = 0; iPos < listmodelfilOld.Count; iPos++)
            {
                lab = listmodelfilOld[iPos];
                // model file for offset string
                label = lab.attr;


                if (label == CLabtype.Type.Model)
                {
                    mod  = (CModType)lab.Tag;
                    str1 = mod.name;
                    ok1  = 0;
                    ok2  = 0;
                }
                else if (label == CLabtype.Type.String)
                {
                    stg  = (CStgType)lab.Tag;
                    str2 = stg.label;

                    if (refmod.ToLower() == str1.ToLower() && refstr.ToLower() == str2.ToLower())
                    {
                        ok1 = 1;
                    }
                    else if (submod.ToLower() == str1.ToLower() && substr.ToLower() == str2.ToLower())
                    {
                        ok2      = 1;
                        ss_found = 1;
                    }
                }
                else if (label == CLabtype.Type.Point)
                {
                    pts = (CPTStype)lab.Tag;
                    if (ok1 == 1)
                    {
                        rchn[i] = pts.mc;
                        rx[i]   = pts.mx;
                        ry[i]   = pts.my;
                        rz[i]   = pts.mz;
                        i++;
                    }
                    else if (ok2 == 1)
                    {
                        schn[j] = pts.mc;
                        sx[j]   = pts.mx;
                        sy[j]   = pts.my;
                        sz[j]   = pts.mz;
                        j++;
                    }
                }
                else if (label == CLabtype.Type.Text)
                {
                    txt = (CTXTtype)lab.Tag;
                    //fread(&txt, sizeof(char), sizeof(txt), fp1);
                }
                else if (label == CLabtype.Type.EndCode)
                {
                    continue;
                }
            }   // while ! feof

            totref = i;
            totsub = j;

            if (ss_found == 0)
            {
                return;
            }

            for (i = 0; i < totref; i++)
            {
                valrc = rchn[i];
                valrx = rx[i]; valry = ry[i]; valrz = rz[i];

                for (j = 1; j < totsub; j++)
                {
                    valsc1 = schn[j - 1];
                    valsx1 = sx[j - 1]; valsy1 = sy[j - 1]; valsz1 = sz[j - 1];
                    valsc2 = schn[j];
                    valsx2 = sx[j]; valsy2 = sy[j]; valsz2 = sz[j];

                    if (valsc1 == valsc2)
                    {
                        continue;
                    }

                    xdiff1 = Math.Abs(sx[j] - sx[j - 1]);
                    if (xdiff1 == 0.0)
                    {
                        xdiff1 = 0.001;
                    }

                    ydiff1 = Math.Abs(sy[j] - sy[j - 1]);
                    if (ydiff1 == 0.0)
                    {
                        ydiff1 = 0.001;
                    }


                    m1 = (sy[j] - sy[j - 1]) / (sx[j] - sx[j - 1]);
                    c1 = sy[j - 1] - ((sy[j] - sy[j - 1]) / (sx[j] - sx[j - 1])) * sx[j - 1];
                    m2 = 0.0 - (1 / m1);
                    c2 = ry[i] - m2 * rx[i];
                    x4 = (c2 - c1) / (m1 - m2);
                    y4 = m1 * x4 + c1;

                    id1    = Math.Sqrt((x4 - sx[j - 1]) * (x4 - sx[j - 1]) + (y4 - sy[j - 1]) * (y4 - sy[j - 1]));
                    id2    = Math.Sqrt((x4 - sx[j]) * (x4 - sx[j]) + (y4 - sy[j]) * (y4 - sy[j]));
                    id3    = Math.Sqrt((sx[j - 1] - sx[j]) * (sx[j - 1] - sx[j]) + (sy[j - 1] - sy[j]) * (sy[j - 1] - sy[j]));
                    checkd = Math.Abs(id1 + id2 - id3);

                    if (checkd > 0.001)
                    {
                        continue;
                    }

                    d = Math.Sqrt((rx[i] - x4) * (rx[i] - x4) + (ry[i] - y4) * (ry[i] - y4));


                    ////
                    theta = Math.Atan(ydiff1 / xdiff1);
                    theta = Math.Abs(theta * r9);

                    if (sx[j] >= sx[j - 1] && sy[j] >= sy[j - 1])
                    {
                        B1 = 90 - theta;
                    }
                    else if (sx[j] >= sx[j - 1] && sy[j] <= sy[j - 1])
                    {
                        B1 = 90 + theta;
                    }
                    else if (sx[j] <= sx[j - 1] && sy[j] <= sy[j - 1])
                    {
                        B1 = 270 - theta;
                    }
                    else if (sx[j] <= sx[j - 1] && sy[j] >= sy[j - 1])
                    {
                        B1 = 270 + theta;
                    }

                    if (B1 < 0.0)
                    {
                        B1 = B1 + 360;
                    }
                    if (B1 > 360)
                    {
                        B1 = B1 - 360;
                    }

                    xdiff2 = Math.Abs(rx[i] - x4);
                    if (xdiff2 == 0.0)
                    {
                        xdiff2 = 0.001;
                    }

                    ydiff2 = Math.Abs(ry[i] - y4);
                    if (ydiff2 == 0.0)
                    {
                        ydiff2 = 0.001;
                    }

                    theta = Math.Atan(ydiff2 / xdiff2);
                    theta = Math.Abs(theta * r9);

                    if (rx[i] >= x4 && ry[i] >= y4)
                    {
                        B2 = 90 - theta;
                    }
                    else if (rx[i] >= x4 && ry[i] <= y4)
                    {
                        B2 = 90 + theta;
                    }
                    else if (rx[i] <= x4 && ry[i] <= y4)
                    {
                        B2 = 270 - theta;
                    }
                    else if (rx[i] <= x4 && ry[i] >= y4)
                    {
                        B2 = 270 + theta;
                    }

                    if (B2 < 0.0)
                    {
                        B2 = B2 + 360;
                    }
                    if (B2 > 360)
                    {
                        B2 = B2 - 360;
                    }


                    // Ref Halignrep.cpp
                    // determine Actual direction of Turn
                    // 16/01/2003	Sandipan
                    // 30/05/2003	Sandipan
                    // 31/07/2003	Sandipan
                    // 17/08/2003	Sandipan
                    // Opened & modified on 10/02/2004  on Constell's Meghalaya work, Sandipan


                    if (B2 > B1)
                    {
                        if (0 <= B1 && B1 <= 90 && 270 <= B2 && B2 <= 360)
                        {
                            direction = 1;
                        }
                        else if (0 <= B1 && B1 <= 90 && 180 <= B2 && B2 <= 270)
                        {
                            if (B2 > B1 + 180)
                            {
                                direction = 1;
                            }
                            else
                            {
                                direction = 2;
                            }
                        }

                        else if (90 <= B1 && B1 <= 180 && 270 <= B2 && B2 <= 360)
                        {
                            if (B2 > B1 + 180)
                            {
                                direction = 1;
                            }
                            else
                            {
                                direction = 2;
                            }
                        }

                        else
                        {
                            direction = 2;
                        }
                    }
                    else
                    {
                        if (270 <= B1 && B1 <= 360 && 0 <= B2 && B2 <= 90)
                        {
                            direction = 2;
                        }
                        else if (180 <= B1 && B1 <= 270 && 0 <= B2 && B2 <= 90)
                        {
                            if (B1 > B2 + 180)
                            {
                                direction = 2;
                            }
                            else
                            {
                                direction = 1;
                            }
                        }
                        else if (270 <= B1 && B1 <= 360 && 90 <= B2 && B2 <= 180)
                        {
                            if (B1 > B2 + 180)
                            {
                                direction = 2;
                            }
                            else
                            {
                                direction = 1;
                            }
                        }
                        else
                        {
                            direction = 1;
                        }
                    }

                    // Done for halignrep.cpp on 10/02/2004  Sandipan

                    if (direction == 1)
                    {
                        sign_d = 1;
                    }
                    else if (direction == 2)
                    {
                        sign_d = -1;
                    }

                    ichn = schn[j - 1] + Math.Sqrt((sx[j - 1] - x4) * (sx[j - 1] - x4) + (sy[j - 1] - y4) * (sy[j - 1] - y4));
                    se   = se1 + (se2 - se1) * (ichn - ch1) / (ch2 - ch1);
                    ho   = d * sign_d;
                    vo   = Math.Abs(ho) * se / 100.0;
                    z4   = rz[i] + vo;
                    ////

                    ftmp.WriteLine(valrc.ToString() + '\t'
                                   + ichn.ToString() + '\t'
                                   + x4.ToString() + '\t'
                                   + y4.ToString() + '\t'
                                   + z4.ToString() + '\t'
                                   + ho.ToString() + '\t'
                                   + vo.ToString());
                    //ftmp.Write(string.Format("{0:f5} {1:f5} {2:f5} {3:f5} {4:f5} {5:f3} {6:f3}\n", valrc, ichn, x4, y4, z4, ho, vo));
                    //fprintf(ftmp, "%.5f %.5f %.5f %.5f %.5f %.3f %.3f\n", valrc, ichn, x4, y4, z4, ho, vo);
                    break;
                }
            }

            //fclose(fp1);
            ftmp.Close();


            for (int iPos = 0; iPos < listmodelfilOld.Count; iPos++)
            {
                lab = listmodelfilOld[iPos];
                if (label == CLabtype.Type.Model)
                {
                    mod    = (CModType)lab.Tag;
                    curmod = mod.name;
                }
                else if (label == CLabtype.Type.String)
                {
                    stg    = (CStgType)lab.Tag;
                    curstr = stg.label;

                    if (curmod.ToLower() == submod.ToLower() && curstr.ToLower() == substr.ToLower())
                    {
                        mod.name  = "";
                        stg.label = "";
                        listmodelfilOld[iPos - 1].Tag = mod;
                        listmodelfilOld[iPos].Tag     = stg;
                    }
                }
                else if (label == CLabtype.Type.Point)
                {
                    pts = (CPTStype)lab.Tag;
                }
                else if (label == CLabtype.Type.Text)
                {
                    txt = (CTXTtype)lab.Tag;
                }
            }

            StreamReader ftmpR = new StreamReader(Path.Combine(path, "SUBSTR.TMP"));

            fp5 = new StreamWriter(Path.Combine(path, "SHIFT.FIL"), false);

            StreamWriter tmpFile = null;
            int          scroll  = 1;

            try
            {
                tmpFile = new StreamWriter(Path.Combine(path, "SCROLL.TMP"), true);
            }
            catch
            {
                scroll = 0;
            }



            lab      = new CLabtype();
            lab.attr = CLabtype.Type.Model;
            mod      = new CModType();
            mod.name = submod;
            lab.Tag  = mod;
            listmodelfilNew.Add(lab);


            lab       = new CLabtype();
            lab.attr  = CLabtype.Type.String;
            stg       = new CStgType();
            stg.label = substr;
            lab.Tag   = stg;
            listmodelfilNew.Add(lab);

            while (ftmpR.EndOfStream == false)
            {
                string[] tok = ftmpR.ReadLine().Split(new char[] { '\t' });
                valrc = double.Parse(tok[0]);
                ichn  = double.Parse(tok[1]);
                x4    = double.Parse(tok[2]);
                y4    = double.Parse(tok[3]);
                z4    = double.Parse(tok[4]);
                ho    = double.Parse(tok[5]);
                vo    = double.Parse(tok[6]);
                //fscanf(ftmp, "%lf %lf %lf %lf %lf %lf %lf", &valrc, &ichn, &x4, &y4, &z4, &ho, &vo);

                lab      = new CLabtype();
                lab.attr = CLabtype.Type.Point;
                pts      = new CPTStype();
                pts.mc   = ichn;
                pts.mx   = x4;
                pts.my   = y4;
                pts.mz   = z4;
                lab.Tag  = pts;
                listmodelfilNew.Add(lab);


                //Write Report File
                fp4.Write(string.Format(" {0,10:f3}       {1,10:f5}  {2,15:f5}  {3,15:f5}  {4,10:f3} {5,8:f3} {6,8:f3}\n", valrc, ichn, x4, y4, z4, ho, vo));

                //Write Shift File
                fp5.Write(string.Format(" {0,10:f5}  {1,35:f3}\n", valrc, ho));

                //Write Display Scroll File
                if (scroll == 1)
                {
                    tmpFile.Write(string.Format("{0} {1} {2,10:f3} {3,10:f3} {4,10:f3} {5,10:f3} {6,8:f3} {7,5:f3} {8,5:f3}\n", submod, substr, valrc, ichn, x4, y4, z4, ho, vo));
                }
            }

            lab      = new CLabtype();
            lab.attr = CLabtype.Type.EndCode;
            listmodelfilNew.Add(lab);

            //fclose(fp1);
            ftmpR.Close();
            fp5.Close();
        }
Beispiel #9
0
        void offset_alignment()
        {
            CLabtype.Type label = CLabtype.Type.Unknown;
            short         ok;
            double        temp;

            CLabtype lab;
            CPTStype pts = new CPTStype();
            //CTXTtype txt;
            CModType mod = null;
            CStgType stg;

            ok       = 0;
            cont_ind = 0;

            if (chn1 > chn2)
            {
                temp = chn2;
                chn2 = chn1;
                chn1 = temp;
            }

            pathfile = Path.Combine(path, "MODEL.FIL");

            if (File.Exists(pathfile) == false)
            {
                return;
            }
            List <CLabtype> listmodelfil = new List <CLabtype>();

            ViewerUtils.ReadModelFilFile(pathfile, ref listmodelfil);
            for (int iIndex = 0; iIndex < listmodelfil.Count; iIndex++)
            {
                lab   = listmodelfil[iIndex];
                label = lab.attr;

                if (label == CLabtype.Type.EndCode)
                {
                    ok = 0;
                }

                else if (label == CLabtype.Type.Model)
                {
                    mod = (CModType)lab.Tag;
                }

                else if (label == CLabtype.Type.String)
                {
                    stg = (CStgType)lab.Tag;

                    if (refmod.ToLower() == mod.name.ToLower() && refstg.ToLower() == stg.label.ToLower())
                    {
                        ok = 1;
                    }
                }
                else if (label == CLabtype.Type.Point)
                {
                    pts = (CPTStype)lab.Tag;
                    chn = pts.mc;
                    mx  = pts.mx;
                    my  = pts.my;
                    mz  = pts.mz;

                    if (ok == 1)
                    {
                        if (cont_ind == 0)
                        {
                            store_last();

                            lab = listmodelfil[iIndex + 1];
                            pts = (CPTStype)lab.Tag;


                            chn = pts.mc;
                            mx  = pts.mx;
                            my  = pts.my;
                            mz  = pts.mz;

                            //fsetpos(fp1, &loc1);
                        }

                        if (last_chn2 == chn)
                        {
                            continue;
                        }

                        if (last_x == mx)
                        {
                            mx += 0.001;
                        }

                        if (last_y == my)
                        {
                            my += 0.001;
                        }

                        if ((chn > chn1 && chn < chn2) && chn != last_chn2)
                        {
                            calc_offset();

                            write_drg();
                        }

                        if (chn >= chn2)
                        {
                            break;
                        }

                        if (cont_ind == 1)
                        {
                            store_last();
                        }

                        cont_ind = 1;
                    }   // OK=1
                }       //103
            }
            if (ok == 1)
            {
                store_last();
                chn = pts.mc + 0.001;
                mx  = pts.mx + 0.001;
                my  = pts.my + 0.001;
                mz  = pts.mz;
                calc_offset();
                write_drg();
            }
        }