Пример #1
0
        changeAlignStartPoint()
        {
            //BEGIN: UPDATE PROFILE, TABLE, AND POIs

            AlgnData  algnData = new AlgnData();
            ObjectId  idAlign  = ObjectId.Null;
            Alignment objAlign = null;

            if (selectAlignment(idAlign))
            {
                objAlign = fStake.ACTIVEALIGN;
            }
            else
            {
                return;
            }

            objAlign = fStake.ACTIVEALIGN;
            AlignmentEntityCollection objAlignEnts = objAlign.Entities;

            //BEGIN: UPDATE PROFILE, TABLE, AND POIs
            double       dblLenAlign = objAlign.Length;
            PromptStatus ps;
            Point3d      varPnt = UserInput.getPoint("Select Desired Start Point", out ps, osMode: 0);

            double dblStation = 0, dblOffset = 0;

            idAlign.getAlignStaOffset(varPnt, ref dblStation, ref dblOffset);
            double dblStationStart = objAlign.StartingStation;
            double dblStationDelta = dblStation - dblStationStart;
            // if varPnt is out of range then dblStation returns ZERO

            Profile profFLOWLINE      = Prof.getProfile(idAlign, "FLOwLINE");
            ProfilePVICollection pvis = profFLOWLINE.PVIs;

            List <POI> varPOI_Temp = new List <POI>();

            foreach (ProfilePVI pvi in pvis)
            {
                POI poi = new POI {
                    Station = Math.roundDown3(pvi.Station), Elevation = pvi.Elevation
                };
                varPOI_Temp.Add(poi);
            }

            Debug.Print("varPOI_Temp Before");
            for (int i = 0; i < varPOI_Temp.Count; i++)
            {
                Debug.Print(varPOI_Temp[i].Station + "  " + varPOI_Temp[i].Elevation);
            }

            //adjust POI_Temp stationing

            for (int i = 0; i < varPOI_Temp.Count; i++)
            {
                POI poi = varPOI_Temp[i];
                if (poi.Station < dblStationDelta + dblStationStart)
                {
                    poi.Station = Math.roundDown3(dblLenAlign + varPOI_Temp[i].Station);
                }
                else
                {
                    poi.Station = Math.roundDown3(varPOI_Temp[i].Station - dblStationDelta);
                }
                varPOI_Temp[i] = poi;
            }

            List <POI> poiTmp       = new List <POI>();
            var        sortPOI_Temp = from t in varPOI_Temp
                                      orderby t.Station ascending
                                      select t;

            foreach (var t in sortPOI_Temp)
            {
                poiTmp.Add(t);
            }
            varPOI_Temp = poiTmp;

            int k = varPOI_Temp.Count;

            POI poitemp = varPOI_Temp[k - 1];

            poitemp.Elevation = varPOI_Temp[0].Elevation;
            varPOI_Temp[k]    = poitemp;

            Debug.Print("varPOI_Temp After");
            for (int i = 0; i < k; i++)
            {
                Debug.Print(varPOI_Temp[i].Station + "  " + varPOI_Temp[i].Elevation);
            }

            //END: UPDATE PROFILE, TABLE, AND POIs

            ObjectId idPoly = objAlign.GetPolyline();
            Polyline poly   = (Polyline)idPoly.getEnt();

            string   strAlignName = objAlign.Name;
            AlgnData aData;

            for (int j = 1; j < fStake.algnData.Count; j++)
            {
                aData = fStake.algnData[j];
                if (aData.AlignHandle == objAlign.Handle)
                {
                    break;
                }
            }

            objAlign.ReferencePointStation = 100.0;

            foreach (AlignmentEntity ent in objAlignEnts)
            {
                objAlignEnts.Remove(ent);
            }

            List <Vertex2d> v2ds = Conv.poly_Vertex2dList(idPoly);

            int p = 0;

            foreach (Vertex2d v in v2ds)
            {
                if (v.Position.IsEqualTo(varPnt, new Tolerance(0, 0)))
                {
                    break;
                }
                p++;
            }

            List <Vertex2d> v2dsNew = new List <Vertex2d>();

            for (int i = p; i < v2ds.Count; i++)
            {
                v2dsNew.Add(v2ds[i]);
            }

            for (int i = 1; i < p; i++)
            {
                v2dsNew.Add(v2ds[i]);
            }
            v2dsNew.Add(v2ds[p]);

            int     lngID = 0;
            Point3d dblPntBeg = Pub.pnt3dO, dblPntEnd = Pub.pnt3dO, dblPntMid = Pub.pnt3dO;

            for (int i = 1; i < v2dsNew.Count; i++)
            {
                if (v2dsNew[i].Bulge == 0)
                {
                    dblPntBeg = v2dsNew[i - 1].Position;
                    dblPntEnd = v2dsNew[i = 0].Position;

                    AlignmentLine objAlignEntTan = objAlign.Entities.AddFixedLine(lngID, dblPntBeg, dblPntEnd);
                    lngID = objAlignEntTan.EntityId;
                }
                else
                {
                    dblPntBeg = v2dsNew[i - 1].Position;
                    dblPntEnd = v2dsNew[i = 0].Position;

                    int intDir = 0;

                    if (v2dsNew[i - 1].Bulge > 0)
                    {
                        intDir = 1;
                    }
                    else
                    {
                        intDir = -1;
                    }

                    Arc arc = (Arc)Arc.Create(IntPtr.Zero, true);
                    arc.StartPoint = dblPntBeg;
                    arc.EndPoint   = dblPntEnd;

                    Point3d pnt3dMidLC = dblPntBeg.getMidPoint3d(dblPntEnd);
                    double  lenLC      = dblPntBeg.getDistance(dblPntEnd);
                    double  dirLC      = dblPntBeg.getDirection(dblPntEnd);
                    double  lenM       = System.Math.Abs(lenLC / 2 * v2dsNew[i - 1].Bulge);
                    dblPntMid = pnt3dMidLC.traverse(dirLC + System.Math.PI / 2 * intDir, lenM);

                    AlignmentArc objAlignEntArc = objAlign.Entities.AddFixedCurve(lngID, dblPntBeg, dblPntMid, dblPntEnd);
                    lngID = objAlignEntArc.EntityId;
                }
            }

            objAlign.Update();
            objAlign.ReferencePoint        = varPnt.Convert2d(BaseObjs.xyPlane);
            objAlign.ReferencePointStation = System.Math.Round(100.0 + dblStationDelta, 3);

            //BEGIN: UPDATE PROFILE, TABLE, AND POIs
            List <POI> varpoi = fStake.POI_CALC;

            //POIs are updated when selectAlignment is executed

            //ADJUST POI STATIONING
            //need complete POIs for descriptions
            for (int i = 0; i < varpoi.Count; i++)
            {
                if (varpoi[i].Station < dblStationDelta + dblStationStart)
                {
                    varpoi[i].Station = Math.roundDown3(dblLenAlign + varpoi[i].Station);
                }
                else
                {
                    varpoi[i].Station = Math.roundDown3(varpoi[i].Station - dblStationDelta);
                }
            }

            varpoi = varpoi.sortPOIbyStation();

            int n = varpoi.Count;

            varpoi[0].DescX     = "BEG " + varpoi[0].Desc0;
            varpoi[n - 2].DescX = varpoi[n - 2].DescX.Replace("END", "").Trim();
            varpoi[n - 1].DescX = varpoi[n - 1].DescX.Replace("BEG", "END").Trim();

            if (fStake.ClassObj == "CURB")
            {
                Stake_AddProfile.makeProfile(idAlign, varPOI_Temp, "CURB", "ByLayout", true);
            }

            ObjectId idTable = Stake_Table.makeTable(idAlign, varpoi);

            Stake_Table.addTableData(idTable, varpoi);

            if (Stake_GetBC_EC.getBC_EC(idAlign, ref varpoi) == false)
            {
                return;
            }

            fStake.POI_CALC = varpoi;
            //END: UPDATE PROFILE, TABLE, AND POIs
        }
Пример #2
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            Control            cntrl;
            ControlCollection  cntrls   = (ControlCollection)this.Controls;
            List <AlgnEntData> algnData = new List <AlgnEntData>();
            int k = cntrls.Count;

            k = (k - 9) / 1 - 1;

            Object[,] varData = new object[k, 6];
            for (int i = 0; i < cntrls.Count; i++)
            {
                cntrl = cntrls[i];
                if (cntrl.Name.Contains("lbl"))
                {
                    int id  = int.Parse(cntrl.Name.Substring(4, 1));
                    int idx = id + 2;
                    varData[id, idx] = cntrl.Text;
                }
            }
            AlgnEntData aData;

            for (int i = 0; i < k; i++)
            {
                aData        = new AlgnEntData();
                aData.ID     = int.Parse(varData[i, 1].ToString());
                aData.Type   = varData[i, 2].ToString();
                aData.StaBeg = double.Parse(varData[i, 3].ToString());
                aData.StaEnd = double.Parse(varData[i, 4].ToString());
                aData.Length = double.Parse(varData[i, 5].ToString());
                aData.Radius = double.Parse(varData[i, 6].ToString());
                algnData.Add(aData);
            }

            Alignment align = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection ents = align.Entities;
            bool changed = false;

            for (int i = 0; i < ents.Count; i++)
            {
                AlignmentEntity ent = ents[i];
                if (ent.EntityType == AlignmentEntityType.Arc)
                {
                    if (algnData[1].Radius == 0)
                    {
                        ents.Remove(ent);
                        changed = true;
                    }
                }
                else
                {
                    AlignmentArc arc = (AlignmentArc)ent;
                    if (!arc.Radius.Equals(algnData[i].Radius))
                    {
                        arc.Radius = algnData[i].Radius;
                        changed    = true;
                    }
                }
                if (changed)
                {
                    this.Close();
                    MNP_Align.editAlign(align.ObjectId);
                }
            }
        }