Пример #1
0
        stakeGridPoints(ObjectId idAlign, List <POI> varPOI_STAKE, double staBeg = 0, double staEnd = 0, int side = 0, long begNum = 30000)
        {
            Alignment objAlign = (Alignment)idAlign.getEnt();
            double    dblStation = 0, dblOffset = 0;

            if ((side == 0))
            {
                if (double.Parse(fGrid.tbxOffsetH.Text) != 0)
                {
                    PromptStatus ps;
                    bool         escape = true;

                    Point3d varPntPick = UserInput.getPoint("Select side to place stake points: <ESC to Cancel>", Pub.pnt3dO, out escape, out ps, osMode: 8);
                    if (escape)
                    {
                        return;
                    }

                    objAlign.StationOffset(varPntPick.X, varPntPick.Y, ref dblStation, ref dblOffset);

                    if (System.Math.Abs(dblOffset) > 20.0)
                    {
                        DialogResult varResponse = MessageBox.Show(string.Format("\nPoint selected is more than 20' from Alignment: {0} \nContinue?", objAlign.Name, MessageBoxButtons.YesNo));

                        if (varResponse == DialogResult.No)
                        {
                            return;
                        }
                    }
                    if (dblOffset < 0)
                    {
                        side = -1;
                    }
                    else
                    {
                        side = 1;
                    }
                    fStake.Side = side;
                }
                else
                {
                    fStake.Side = 1;
                }
            }
            else
            {
                fStake.Side = side;
            }

            fStake.STAKE_LAYER = fGrid.tbxOffsetH.Text + "-OS-" + objAlign.Name;

            dblOffset = double.Parse(fGrid.tbxOffsetH.Text);
            string strName = fStake.NameStakeObject;

            double dblStaBeg = Math.roundDown3((objAlign.StartingStation));
            double dblStaEnd = Math.roundDown3((objAlign.EndingStation));

            uint lngPntNumBeg = Stake_Util.getBegPntNum();

            fStake.NextPntNum = lngPntNumBeg;

            CogoPointCollection cgPnts = CivilApplication.ActiveDocument.CogoPoints;

            fStake.POI_STAKED = new List <POI>();

            //**********PROCESS varPOI_STAKE*********************
            for (int i = 0; i <= varPOI_STAKE.Count; i++)
            {
                if (varPOI_STAKE[i].DescX == "")
                {
                    POI vPOI_STAKE = varPOI_STAKE[i];
                    vPOI_STAKE.DescX = vPOI_STAKE.Desc0;
                    varPOI_STAKE[i]  = vPOI_STAKE;
                }

                if (i == varPOI_STAKE.Count - 1)
                {
                    break;
                }

                double dblElev = varPOI_STAKE[i].Elevation;

                switch (varPOI_STAKE[i].Desc0)
                {
                case "AP":

                    switch (side)
                    {
                    case 1:
                        //right side

                        //counterclockwise
                        if (varPOI_STAKE[i].isRightHand)
                        {
                            if (fGrid.optPBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                            else if (fGrid.optRBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT_RBC(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                            //clockwise
                        }
                        else
                        {
                            Stake_Calc.doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                        }

                        break;

                    case -1:
                        //left side

                        //counterclockwise
                        if (varPOI_STAKE[i].isRightHand)
                        {
                            Stake_Calc.doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            //clockwise
                        }
                        else
                        {
                            if (fGrid.optPBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                            else if (fGrid.optRBC.Checked)
                            {
                                Stake_Calc.doAnglePointOUT_RBC(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, side, dblOffset);
                            }
                        }

                        break;
                    }

                    break;

                default:

                    string strDesc = varPOI_STAKE[i].DescX;
                    double dblEasting = 0, dblNorthing = 0;
                    try
                    {
                        objAlign.PointLocation(varPOI_STAKE[i].Station, dblOffset * side, ref dblEasting, ref dblNorthing);
                    }
                    catch (IndexOutOfRangeException)
                    {
                        try
                        {
                            objAlign.PointLocation(varPOI_STAKE[i].Station - 0.01, dblOffset * side, ref dblEasting, ref dblNorthing);
                        }
                        catch (IndexOutOfRangeException)
                        {
                            objAlign.PointLocation(varPOI_STAKE[i].Station + 0.01, dblOffset * side, ref dblEasting, ref dblNorthing);
                        }
                    }

                    Point3d dblPnt = new Point3d(dblEasting, dblNorthing, varPOI_STAKE[i].Elevation);

                    string strOffset = dblOffset.ToString();
                    Stake_Calc.setOffsetPoint(dblPnt, strOffset, strName, strDesc, idAlign, varPOI_STAKE[i].Station);

                    break;
                }
            }

            List <POI> varPOI_STAKED = fStake.POI_STAKED;
            int        k             = varPOI_STAKED.Count - 1;

            uint lngPntNumEnd = uint.Parse(varPOI_STAKED[k].PntNum);

            TypedValue[] tvs = new TypedValue[4] {
                new TypedValue(1001, "STAKE"),
                new TypedValue(1071, lngPntNumBeg),
                new TypedValue(1071, lngPntNumEnd),
                new TypedValue(1000, fStake.STAKE_LAYER)
            };

            idAlign.setXData(tvs, "STAKE");

            CgPnt_Group.updatePntGroup("SPNT");

            Stake_UpdateProfile.updateProfile(idAlign, (fStake.POI_STAKED), "STAKE", true, "STAKED");

            bool     exists = false;
            ObjectId idDict = Dict.getNamedDictionary("STAKE_PNTS", out exists);

            List <Point3d> dblPnts = new List <Point3d>();
            Point3d        pnt3d   = Pub.pnt3dO;

            for (int p = 0; p < varPOI_STAKED.Count; p++)
            {
                ObjectId idPnt = BaseObjs._civDoc.CogoPoints.GetPointByPointNumber(uint.Parse(varPOI_STAKED[p].PntNum));
                pnt3d = idPnt.getCogoPntCoordinates();
                dblPnts.Add(pnt3d);
                ResultBuffer rb = new ResultBuffer {
                    new TypedValue(1000, idPnt.getCogoPntNumber().ToString()),
                    new TypedValue(1005, idPnt.getHandle().ToString())
                };
                Dict.addXRec(idDict, idPnt.ToString(), rb);
            }

            dblPnts.Add(dblPnts[0]);
            Draw.addPoly(dblPnts, fStake.STAKE_LAYER, 9);

            Misc.logUsage("STAKE", (lngPntNumEnd - lngPntNumBeg + 1));
        }
Пример #2
0
        stakePoints(object varStaBeg = null, object varStaEnd = null, object varSide = null, object varBegNum = null)
        {
            string    strClass = fStake.ClassObj;
            Alignment objAlign = null;

            try
            {
                objAlign = fStake.ACTIVEALIGN;
            }
            catch (System.Exception)
            {
                if (Stake_Algn.selectAlignment(ObjectId.Null))
                {
                    objAlign = fStake.ACTIVEALIGN;
                }
                else
                {
                    return;
                }
            }

            ObjectId idAlign = objAlign.ObjectId;

            fStake.STAKE_LAYER = fStake.cboOffset.Text + "-OS-" + objAlign.Name;

            ObjectId idTable = Stake_Table.getTableId(idAlign);

            List <POI> varpoi = Stake_Table.resetPOI(idTable);

            fStake.POI_CALC = varpoi;

            fStake.objectID = objAlign.ObjectId;
            int intSide = 0;

            double dblStation = 0, dblOffset = 0;

            if ((varSide == null))
            {
                if (double.Parse(fStake.cboOffset.Text) != 0)
                {
                    PromptStatus ps;
                    Point3d      varPntPick = Pub.pnt3dO;
                    try
                    {
                        varPntPick = UserInput.getPoint("\nSelect side to place stake points: <ESC to Cancel>", out ps, osMode: 0);
                    }
                    catch (System.Exception)
                    {
                        return;

                        ;
                    }

                    idAlign.getAlignStaOffset(varPntPick, ref dblStation, ref dblOffset);
                    if (System.Math.Abs(dblOffset) > 10.0)
                    {
                        string       message     = string.Format("Point selected is more than 10' from Alignment: {0} Continue", objAlign.Name);
                        DialogResult varResponse = MessageBox.Show(message, "Confirm stakng target.", MessageBoxButtons.YesNo);

                        if (varResponse == DialogResult.No)
                        {
                            return;
                        }
                        else
                        {
                            if (dblOffset < 0)
                            {
                                intSide = -1;
                            }
                            else
                            {
                                intSide = 1;
                            }

                            fStake.Side = intSide;
                        }
                    }
                    else
                    {
                        if (dblOffset < 0)
                        {
                            intSide = -1;
                        }
                        else
                        {
                            intSide = 1;
                        }

                        fStake.Side = intSide;
                    }
                }
                else
                {
                    fStake.Side = 1;
                }
            }
            else
            {
                intSide = int.Parse(varSide.ToString());
            }

            dblOffset = double.Parse(fStake.cboOffset.Text);
            string strName = fStake.NameStakeObject;

            var sortSta = from p in varpoi                              //sort stations
                          orderby p.Station ascending
                          select p;

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

            foreach (var p in sortSta)
            {
                poiTmp.Add(p);
            }
            varpoi = poiTmp;

            double dblStaBeg = Math.roundDown3((objAlign.StartingStation));
            double dblStaEnd = Math.roundDown3((objAlign.EndingStation));

            List <POI> varPOI_TOF = null;
            List <POI> varPOI_TOW = null;

            Profile objProfile = null;

            switch (strClass)
            {
            case "WTR":

                objProfile = Prof.getProfile(idAlign, "CPNT");

                break;

            case "WALL":
                for (int i = 0; i < varpoi.Count; i++)
                {
                    if (varpoi[i].Desc0 == "TOF")
                    {
                        varPOI_TOF.Add(varpoi[i]);
                    }
                    else if (varpoi[i].Desc0 == "TOW")
                    {
                        varPOI_TOW.Add(varpoi[i]);
                    }
                }
                break;

            default:

                objProfile = Prof.getProfile(idAlign, "STAKE");

                break;
            }

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

            if (strClass == "WALL")
            {
                Stake_GetStationing.getStationing(ref varPOI_TOF, dblStaBeg, dblStaEnd);
                Stake_GetStationing.getStationing(ref varPOI_TOW, dblStaBeg, dblStaEnd);
                for (int i = 0; i < varPOI_TOF.Count; i++)
                {
                    varPOI_TMP.Add(varPOI_TOF[i]);
                }

                for (int j = 0; j < varPOI_TOW.Count; j++)
                {
                    varPOI_TMP.Add(varPOI_TOW[j]);
                }

                varpoi = varPOI_TMP;
            }
            else
            {
                Stake_GetCardinals.checkBegAndEndDesc(idAlign, ref varpoi);
                Stake_GetStationing.getStationing(ref varpoi, dblStaBeg, dblStaEnd);
            }

            poiTmp = new List <POI>();
            foreach (var p in sortSta)             //sort stations
            {
                poiTmp.Add(p);
            }
            varpoi = poiTmp;

            uint lngPntNumBeg = Stake_Util.getBegPntNum();

            fStake.POI_STAKED = new List <POI>();
            List <POI> varPOI_STAKE = new List <POI>();

            if (strClass == "BLDG")
            {
                varPOI_STAKE = fStake.POI_STAKE;
            }
            else
            {
                if ((varStaBeg == null))
                {
                    varPOI_STAKE = varpoi;
                }
                else
                {
                    for (int i = 0; i < varpoi.Count; i++)
                    {
                        if (varpoi[i].Station >= double.Parse(varStaBeg.ToString()) && varpoi[i].Station <= double.Parse(varStaEnd.ToString()))
                        {
                            varPOI_STAKE.Add(varpoi[i]);
                        }
                    }
                }
            }

            for (int i = 0; i < varPOI_STAKE.Count; i++)
            {
                Debug.Print(varPOI_STAKE[i].Station + " " + varPOI_STAKE[i].Desc0);
            }
            POI     poi = new POI();
            double  dblElev = 0, dblEasting = 0, dblNorthing = 0;
            string  strDesc = "", strOffset = "";
            Point3d dblPnt = Pub.pnt3dO;

            for (int i = 0; i < varPOI_STAKE.Count; i++)
            {             //**********PROCESS varPOI_STAKE*********************
                if (varPOI_STAKE[i].DescX == "")
                {
                    poi             = varPOI_STAKE[i];
                    poi.DescX       = varPOI_STAKE[i].Desc0;
                    varPOI_STAKE[i] = poi;
                }

                switch (varPOI_STAKE[i].ClassObj)
                {
                case "WALL":

                    if (varPOI_STAKE[i].Desc0 == "TOW")
                    {
                        dblElev = varPOI_STAKE[i].ElevTOW;
                    }
                    else if (varPOI_STAKE[i].Desc0 == "TOF")
                    {
                        dblElev = varPOI_STAKE[i].ElevTOF;
                    }

                    switch (varPOI_STAKE[i].Desc0)
                    {
                    case "AP":

                        if (varPOI_STAKE[i].DescX.Contains("END"))
                        {
                            switch (intSide)
                            {
                            case 1:                                                    //right side

                                if (varPOI_STAKE[i].isRightHand)
                                {                                                         //counterclockwise
                                    doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }
                                else
                                {                                                         //clockwise
                                    doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }

                                break;

                            case -1:                                                    //left side

                                if (varPOI_STAKE[i].isRightHand)
                                {                                                         //counterclockwise
                                    doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }
                                else
                                {                                                         //clockwise
                                    doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }

                                break;
                            }
                        }

                        break;

                    case "BC":
                    case "EC":

                        doCurve(ref i, idAlign, objProfile, varPOI_STAKE, intSide, dblOffset, strName);

                        break;

                    default:

                        strDesc = varPOI_STAKE[i].DescX;
                        if (string.IsNullOrEmpty(strDesc))
                        {
                            strDesc = varPOI_STAKE[i].Desc0;
                        }

                        try
                        {
                            idAlign.getAlignPointLoc(varPOI_STAKE[i].Station, dblOffset * intSide, ref dblEasting, ref dblNorthing);
                        }
                        catch (System.Exception)
                        {
                            idAlign.getAlignPointLoc(varPOI_STAKE[i].Station - 0.01, dblOffset * intSide, ref dblEasting, ref dblNorthing);
                        }

                        dblPnt = new Point3d(dblEasting, dblNorthing, dblElev);

                        strOffset = dblOffset.ToString();
                        setOffsetPoint(dblPnt, strOffset, strName, strDesc, idAlign, varPOI_STAKE[i].Station);

                        break;
                    }

                    break;

                case "WTR":

                    dblElev = System.Math.Round(objProfile.ElevationAt(Math.roundDown3(varPOI_STAKE[i].Station)), 2);

                    switch (varPOI_STAKE[i].Desc0.Substring(0, 2))
                    {
                    case "TE":

                        if (varPOI_STAKE[i].Side == intSide)
                        {
                            set5x5(idAlign, dblElev, varPOI_STAKE[i].Station, dblOffset, intSide, strName, varPOI_STAKE[i].DescX);
                        }
                        else
                        {
                            idAlign.getAlignPointLoc(varPOI_STAKE[i].Station, dblOffset * intSide, ref dblEasting, ref dblNorthing);

                            dblPnt = new Point3d(dblEasting, dblNorthing, dblElev);

                            strOffset = dblOffset.ToString();

                            setOffsetPoint(dblPnt, strOffset, strName, varPOI_STAKE[i].DescX, idAlign, varPOI_STAKE[i].Station);
                        }

                        break;

                    case "AP":

                        switch (intSide)
                        {
                        case 1:
                            //right side

                            //counterclockwise
                            if (varPOI_STAKE[i].isRightHand)
                            {
                                doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                //clockwise
                            }
                            else
                            {
                                doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                            }

                            break;

                        case -1:
                            //left side

                            //counterclockwise
                            if (varPOI_STAKE[i].isRightHand)
                            {
                                doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                //clockwise
                            }
                            else
                            {
                                doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                            }

                            break;
                        }

                        break;

                    default:

                        idAlign.getAlignPointLoc(varPOI_STAKE[i].Station, dblOffset * intSide, ref dblEasting, ref dblNorthing);
                        dblPnt = new Point3d(dblEasting, dblNorthing, dblElev);

                        strOffset = dblOffset.ToString();

                        double dblCrossingInv = 0;
                        string strCrossingInv = "";
                        if (varPOI_STAKE[i].CrossAlign != "")
                        {
                            if (varPOI_STAKE[i].CrossAlignInv != 0)
                            {
                                dblCrossingInv = System.Math.Round(varPOI_STAKE[i].CrossAlignInv, 2);
                                strCrossingInv = string.Format("{0} INV.", dblCrossingInv);
                            }
                            else
                            {
                                strCrossingInv = "";
                            }

                            ASCIIEncoding ascii = new ASCIIEncoding();

                            string strAlignDesc = string.Format("{0}{1}%%C PIPE {2}", varPOI_STAKE[i].CrossAlignSize, ascii.GetString(new Byte[] { (Byte)34 }), strCrossingInv);

                            setOffsetPoint(dblPnt, strOffset, strName, strAlignDesc, idAlign, varPOI_STAKE[i].Station);
                        }
                        else
                        {
                            setOffsetPoint(dblPnt, strOffset, strName, varPOI_STAKE[i].DescX, idAlign, varPOI_STAKE[i].Station);

                            if (varPOI_STAKE[i].Type != "")
                            {
                                setOffsetPoint(dblPnt, strOffset, strName, varPOI_STAKE[i].Type, idAlign, varPOI_STAKE[i].Station, " INV=");
                            }
                        }

                        break;
                    }

                    break;

                case "CURB":
                case "FL":

                    dblElev = System.Math.Round(objProfile.ElevationAt(Math.roundDown3(varPOI_STAKE[i].Station)), 2);

                    switch (varPOI_STAKE[i].Desc0)
                    {
                    case "AP":

                        if (varPOI_STAKE[i].DescX.Contains("END"))
                        {
                            switch (intSide)
                            {
                            case 1:                                                    //right side

                                if (varPOI_STAKE[i].isRightHand)
                                {                                                         //counterclockwise
                                    doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }
                                else
                                {                                                         //clockwise
                                    doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }

                                break;

                            case -1:                                                    //left side

                                if (varPOI_STAKE[i].isRightHand)
                                {                                                         //counterclockwise
                                    doAnglePointIN(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }
                                else
                                {                                                         //clockwise
                                    doAnglePointOUT(idAlign, dblElev, varPOI_STAKE[i].Station, varPOI_STAKE[i].AngDelta, varPOI_STAKE[i].AngDir, varPOI_STAKE[i].DescX, strName, intSide, dblOffset);
                                }

                                break;
                            }
                        }

                        break;

                    case "BC":
                    case "EC":

                        doCurve(ref i, idAlign, objProfile, varPOI_STAKE, intSide, dblOffset, strName);

                        break;

                    default:

                        strDesc = varPOI_STAKE[i].DescX;
                        //          If strDesc = "" Then
                        //            strDesc = varPOI_Stake[i].Desc0
                        //          End If

                        try
                        {
                            idAlign.getAlignPointLoc(varPOI_STAKE[i].Station, dblOffset * intSide, ref dblEasting, ref dblNorthing);
                        }
                        catch (System.Exception)
                        {
                            idAlign.getAlignPointLoc(varPOI_STAKE[i].Station - 0.01, dblOffset * intSide, ref dblEasting, ref dblNorthing);
                        }
                        dblPnt = new Point3d(dblEasting, dblNorthing, dblElev);

                        strOffset = dblOffset.ToString();
                        setOffsetPoint(dblPnt, strOffset, strName, strDesc, idAlign, varPOI_STAKE[i].Station);

                        break;
                    }

                    break;

                case "ALIGN":
                case "SEWER":

                    dblElev = System.Math.Round(objProfile.ElevationAt(Math.roundDown3(varPOI_STAKE[i].Station)), 2);

                    if (varPOI_STAKE[i].Desc0 == "BC")
                    {
                        setRadiusPoint(idAlign, varPOI_STAKE[i], varPOI_STAKE[i].Radius, strName);
                    }

                    try
                    {
                        idAlign.getAlignPointLoc(varPOI_STAKE[i].Station, dblOffset * intSide, ref dblEasting, ref dblNorthing);
                    }
                    catch (System.Exception)
                    {
                    }

                    dblPnt = new Point3d(dblEasting, dblNorthing, dblElev);

                    strOffset = dblOffset.ToString();
                    setOffsetPoint(dblPnt, strOffset, strName, varPOI_STAKE[i].Desc0, idAlign, varPOI_STAKE[i].Station);

                    break;
                }
            }

            List <POI> varPOI_STAKED = fStake.POI_STAKED;
            int        intUBnd       = varPOI_STAKED.Count - 1;

            uint lngPntNumEnd = uint.Parse(varPOI_STAKED[intUBnd].PntNum);

            TypedValue[] tvs = new TypedValue[4] {
                new TypedValue(1001, "STAKE"),
                new TypedValue(1071, lngPntNumBeg),
                new TypedValue(1071, lngPntNumEnd),
                new TypedValue(1000, fStake.STAKE_LAYER)
            };

            idAlign.setXData(tvs, "STAKE");

            CgPnt_Group.updatePntGroup("SPNT");

            Stake_UpdateProfile.updateProfile(idAlign, (fStake.POI_STAKED), "STAKE", true, "STAKED");

            bool     exists = false;
            ObjectId idDict = Dict.getNamedDictionary("STAKE_PNTS", out exists);

            List <Point3d> dblPnts   = new List <Point3d>();
            Point3d        pnt3d     = Pub.pnt3dO;
            uint           lngPntNum = 0;

            for (int p = 0; p < varPOI_STAKED.Count; p++)
            {
                string varPntNum = varPOI_STAKED[p].PntNum;

                int intPos = varPntNum.IndexOf(" ");

                if (intPos != 0)
                {
                    lngPntNum = uint.Parse(varPntNum.Substring(0, intPos - 1));
                }
                else
                {
                    lngPntNum = uint.Parse(varPntNum);
                }

                ObjectId idPnt = BaseObjs._civDoc.CogoPoints.GetPointByPointNumber(uint.Parse(varPOI_STAKED[p].PntNum));
                pnt3d = idPnt.getCogoPntCoordinates();
                dblPnts.Add(pnt3d);
                ResultBuffer rb = new ResultBuffer {
                    new TypedValue(1000, idPnt.getCogoPntNumber().ToString()),
                    new TypedValue(1005, idPnt.getHandle().ToString())
                };
                Dict.addXRec(idDict, idPnt.ToString(), rb);
            }

            dblPnts.Add(dblPnts[0]);

            Misc.logUsage("STAKE", (lngPntNumEnd - lngPntNumBeg + 1));
        }
Пример #3
0
        getNestedPoints(ObjectId idAlign, ref List <POI> varpoi, BlockTableRecord objXRefDbModelSpace, string strSource)
        {
            Alignment objAlign = (Alignment)idAlign.getEnt();

            string strNameStakeObject = fStake.NameStakeObject;
            double dblToleranceLength = 0.15;

            double dblToleranceAngle = PI;

            Point2d varPntRef = objAlign.ReferencePoint;
            string  strFilter = "";

            if (strSource.Contains("GCAL")
                )
            {
                strFilter = "*CPNT*";
            }
            else
            {
                strFilter = "*";
            }

            List <string> strPntNums = new List <string>();
            double        dblStation = 0, dblOffset = 0;
            ResultBuffer  rb = null;

            TypedValue[] tvs = null;

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

            foreach (ObjectId id in objXRefDbModelSpace)
            {
                bool boolAdd = false;

                Entity objXRefObj = id.getEnt();

                if (objXRefObj is CogoPoint)
                {
                    CogoPoint objPnt = (CogoPoint)objXRefObj;
                    Debug.Print(objPnt.PointNumber.ToString());

                    if (objPnt.Layer.Contains(strFilter))
                    {
                        strPntNums.Add(objPnt.PointNumber.ToString());

                        if (strSource == "GCAL")
                        {
                            rb  = id.getXData("STAKE");
                            tvs = rb.AsArray();
                        }

                        objAlign.StationOffset(objPnt.Easting, objPnt.Northing, ref dblStation, ref dblOffset);

                        Debug.Print(objPnt.Easting + "," + objPnt.Northing);

                        Point2d pnt2d = new Point2d(objPnt.Location.X, objPnt.Location.Y);

                        if (System.Math.Abs(dblOffset) < dblToleranceLength)
                        {
                            if (dblStation >= objAlign.StartingStation && dblStation <= objAlign.EndingStation)
                            {
                                boolAdd = true;
                            }
                        }
                        else if (pnt2d.isEqual(varPntRef, dblToleranceLength))
                        {
                            Point3d pnt3d = new Point3d(objPnt.Easting, objPnt.Northing, 0);

                            double dblAngle1 = Math.roundDown3(pnt2d.getDirection(varPntRef));

                            AlignmentEntity objAlignEnt = objAlign.Entities.EntityAtId(objAlign.Entities.FirstEntity);

                            switch (objAlignEnt.EntityType)
                            {
                            case AlignmentEntityType.Arc:

                                AlignmentArc objAlignEntArc = (AlignmentArc)objAlignEnt;
                                double       dblangle2      = 0;
                                if (objAlignEntArc.Clockwise)
                                {
                                    dblangle2 = objAlignEntArc.StartDirection - PI / 2 + objAlignEntArc.Delta / 2;
                                }
                                else
                                {
                                    dblangle2 = objAlignEntArc.StartDirection + PI / 2 - objAlignEntArc.Delta / 2;
                                }

                                if (System.Math.Abs(dblAngle1 - dblangle2) < dblToleranceAngle)
                                {
                                    boolAdd    = true;
                                    dblStation = objAlign.StartingStation;
                                }
                                else if (System.Math.Abs(Math.roundDown3(dblAngle1 - 2 * PI) - dblangle2) < dblToleranceAngle)
                                {
                                    boolAdd    = true;
                                    dblStation = objAlign.StartingStation;
                                }

                                break;

                            case AlignmentEntityType.Line:

                                AlignmentLine objAlignEntTan = (AlignmentLine)objAlignEnt;

                                dblangle2 = Math.roundDown3((objAlignEntTan.Direction));

                                if (System.Math.Abs(dblAngle1 - dblangle2) < dblToleranceAngle)
                                {
                                    boolAdd    = true;
                                    dblStation = objAlign.StartingStation;
                                }

                                break;
                            }
                        }
                        else
                        {
                            boolAdd = false;
                        }
                    }

                    if (boolAdd == true)
                    {
                        POI varPOI_PNT = new POI();

                        varPOI_PNT.Station   = Math.roundDown3(dblStation);
                        varPOI_PNT.PntNum    = objPnt.PointNumber.ToString();
                        varPOI_PNT.Elevation = System.Math.Round(objPnt.Elevation, 3);

                        if (strSource != "WALLDESIGN")
                        {
                            varPOI_PNT.ClassObj = fStake.ClassObj;
                        }

                        varPOI_PNT.OFFSET    = System.Math.Round(dblOffset, 2);
                        varPOI_PNT.PntSource = strSource;

                        if (strSource == "GCAL")
                        {
                            try
                            {
                                if (isTG(objXRefDbModelSpace, tvs[1].Value.ToString().stringToHandle()))
                                {
                                    varPOI_PNT.Desc0 = "TG";
                                }
                            }
                            catch (System.Exception)
                            {
                                varPOI_PNT.Desc0 = "PNT";
                            }
                        }
                        else if (strSource == "WALLDESIGN")
                        {
                            objAlign.StationOffset(objPnt.Easting, objPnt.Northing, ref dblStation, ref dblOffset);
                            varPOI_PNT.OFFSET    = System.Math.Round(dblOffset, 2);
                            varPOI_PNT.Desc0     = string.Format("{0} {0} {2}", objPnt.RawDescription, varPOI_PNT.OFFSET, varPOI_PNT.Elevation);
                            varPOI_PNT.PntSource = "TOPO";
                        }
                        else
                        {
                            varPOI_PNT.Desc0 = "PNT";
                        }
                        varPOI_PNTs.Add(varPOI_PNT);
                    }
                }
            }

            if (varPOI_PNTs.Count > 0)
            {
                var sortSta = from p in varPOI_PNTs
                              orderby p.Station ascending
                              select p;

                List <POI> poiTmp = new List <POI>();
                foreach (var p in sortSta)
                {
                    poiTmp.Add(p);
                }

                Stake_Util.removeDuplicatePoints(ref poiTmp);

                varPOI_PNTs = poiTmp;

                if (strSource != "WALLDESIGN")
                {
                    fStake.POI_PNTs = varPOI_PNTs;
                }

                if (varPOI_PNTs[0].Desc0 != "NOTHING")
                {
                    for (int i = 0; i < varPOI_PNTs.Count; i++)
                    {
                        varpoi.Add(varPOI_PNTs[i]);
                    }
                }

                poiTmp  = varpoi;
                sortSta = from p in poiTmp
                          orderby p.Station ascending
                          select p;
                varpoi = new List <POI>();
                foreach (var p in sortSta)
                {
                    varpoi.Add(p);
                }

                return(true);
            }
            return(false);
        }