コード例 #1
0
        calcBasePntAndTargetPntElev(Point3d pnt3dTAR, double grade, Polyline3d poly3d, int vertexNo, out double elevTAR, out double station)
        {
            station   = 0.0;
            elevTAR   = 0.0;
            gp.pnt3dX = Pub.pnt3dO;

            Point3dCollection pnts3d   = poly3d.getCoordinates3d();
            Point3d           pnt3dBEG = pnts3d[vertexNo + 0];
            Point3d           pnt3dEND = pnts3d[vertexNo + 1];

            double length = pnt3dBEG.getDistance(pnt3dEND);                                     //result is 2d distance
            double slope  = (pnt3dEND.Z - pnt3dBEG.Z) / length;

            station = Math.roundDown4(pnt3dTAR.getOrthoDist(pnt3dBEG, pnt3dEND));               //result is 2d distance

            if (gp.shift)
            {
                double angle = Measure.getAzRadians(pnt3dBEG, pnt3dEND);
                gp.pnt3dX = pnt3dBEG.traverse(angle, station, slope);
                double offset = gp.pnt3dX.getDistance(pnt3dTAR);                                    //result is 2d distance
                elevTAR = gp.pnt3dX.Z + offset * grade;
            }
            else
            {
                if (station > 0 && station < length)
                {
                    double angle = Measure.getAzRadians(pnt3dBEG, pnt3dEND);
                    gp.pnt3dX = pnt3dBEG.traverse(angle, station, slope);
                    double offset = gp.pnt3dX.getDistance(pnt3dTAR);                                    //result is 2d distance
                    elevTAR = gp.pnt3dX.Z + offset * grade;
                }
            }
            return(gp.pnt3dX);
        }
コード例 #2
0
        calcBasePnt3d(Point3d pnt3dTAR, Polyline3d poly3d, int vertexNo)
        {
            Point3d pnt3dBASE = Pub.pnt3dO;

            Point3dCollection pnts3d   = poly3d.getCoordinates3d();
            Point3d           pnt3dBEG = pnts3d[vertexNo + 0];
            Point3d           pnt3dEND = pnts3d[vertexNo + 1];

            double length   = pnt3dBEG.getDistance(pnt3dEND);
            double slope    = (pnt3dEND.Z - pnt3dBEG.Z) / length;
            double distance = pnt3dTAR.getOrthoDist(pnt3dBEG, pnt3dEND);

            if (distance > 0 && distance < length)
            {
                double angle = Measure.getAzRadians(pnt3dBEG, pnt3dEND);
                pnt3dBASE = pnt3dBEG.traverse(angle, distance, slope);
            }
            return(pnt3dBASE);
        }
コード例 #3
0
 removeDuplicateVertex(ObjectId id)
 {
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             DBObject dbObj = tr.GetObject(id, OpenMode.ForWrite);
             if (dbObj is Polyline)
             {
                 Polyline          poly   = (Polyline)tr.GetObject(id, OpenMode.ForRead);
                 Point3dCollection pnts3d = poly.getCoordinates3d();
                 Point3dCollection pnts3dRev;
                 if (hasDuplicateVertex(pnts3d, out pnts3dRev))
                 {
                     string layer = poly.Layer;
                     Misc.deleteObj(id);
                     Draw.addPoly(pnts3d, layer);
                 }
             }
             if (dbObj is Polyline3d)
             {
                 Polyline3d        poly3d = (Polyline3d)tr.GetObject(id, OpenMode.ForRead);
                 Point3dCollection pnts3d = poly3d.getCoordinates3d();
                 Point3dCollection pnts3dRev;
                 if (hasDuplicateVertex(pnts3d, out pnts3dRev))
                 {
                     string layer = poly3d.Layer;
                     Misc.deleteObj(id);
                     Draw.addPoly3d(pnts3d, layer);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 649");
     }
 }
コード例 #4
0
ファイル: Grading_xData.cs プロジェクト: 15831944/EM
        checkPointXData2Nodes(ObjectId idCogoPnt, ResultBuffer RBpnt, string nameApp)
        {
            try {
                List <Handle> handlesP3d = RBpnt.rb_handles();

                int i = 0;
                foreach (Handle hP3d in handlesP3d)
                {
                    Polyline3d poly3d = (Polyline3d)Db.handleToObject(hP3d.ToString());

                    if ((poly3d != null))
                    {
                        if (poly3d.Length != 0)
                        {
                            ResultBuffer      RBp3d        = poly3d.ObjectId.getXData(nameApp);
                            List <Handle>     handlesPnts  = RBp3d.rb_handles();
                            Handle            hPnt         = idCogoPnt.getHandle();
                            Point3dCollection pnts3d       = poly3d.getCoordinates3d();
                            Point3d           pnt3dCogoPnt = hPnt.getCogoPntCoordinates();

                            if (System.Math.Round(pnts3d[0].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                System.Math.Round(pnts3d[0].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[0].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setBegPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else if (System.Math.Round(pnts3d[1].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                     System.Math.Round(pnts3d[1].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[1].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setEndPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else
                            {
                                poly3d.ObjectId.delete();
                                handlesP3d.RemoveAt(i);
                                RBpnt = handlesP3d.handles_RB(nameApp);
                                idCogoPnt.setXData(RBpnt.AsArray(), nameApp);
                            }
                        }
                        else
                        {
                            poly3d.ObjectId.delete();
                            handlesP3d.RemoveAt(i);
                            RBpnt = handlesP3d.handles_RB(nameApp);
                            idCogoPnt.setXData(RBpnt.AsArray(), nameApp);
                        }
                    }
                    else
                    {
                        handlesP3d.RemoveAt(i);
                        RBpnt = handlesP3d.handles_RB(nameApp);
                        idCogoPnt.setXData(RBpnt.AsArray(), nameApp);
                    }
                    i++;
                }
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " Grading_xData.cs: line: 70");
            }
            return(RBpnt);
        }
コード例 #5
0
ファイル: xData.cs プロジェクト: 15831944/EM
        checkPointXData2Nodes(ObjectId idCogoPnt, ResultBuffer RBpnt, string nameApp)
        {
            try
            {
                List <Handle> handlesP3d = RBpnt.rb_handles();

                int i = 0;
                //Working with a list of unique non-zero handles
                foreach (Handle hP3d in handlesP3d)
                {
                    //GET BREAKLINE PER STORED HANDLES
                    Polyline3d poly3d = (Polyline3d)Db.handleToObject(hP3d.ToString());

                    if ((poly3d != null))
                    {
                        if (poly3d.Length != 0)
                        {
                            ResultBuffer  RBp3d       = poly3d.ObjectId.getXData(nameApp);
                            List <Handle> handlesPnts = RBp3d.rb_handles();
                            Handle        hPnt        = idCogoPnt.getHandle();
                            // if pnt handle is in poly3d handle list then check coordinates otherwise
                            Point3dCollection pnts3d       = poly3d.getCoordinates3d();
                            Point3d           pnt3dCogoPnt = hPnt.getCogoPntCoordinates();

                            if (System.Math.Round(pnts3d[0].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                System.Math.Round(pnts3d[0].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[0].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setBegPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else if (System.Math.Round(pnts3d[1].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) &&
                                     System.Math.Round(pnts3d[1].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3))
                            {
                                if (pnts3d[1].Z != pnt3dCogoPnt.Z)
                                {
                                    poly3d.setEndPnt(pnt3dCogoPnt);
                                }
                                if (!handlesPnts.Contains(hPnt))
                                {
                                    handlesPnts.Add(hPnt);
                                    poly3d.ObjectId.setXData(handlesPnts, nameApp);
                                }
                            }
                            else
                            {
                                poly3d.ObjectId.delete();
                                handlesP3d.RemoveAt(i);
                                RBpnt = handlesP3d.handles_RB(nameApp);
                                idCogoPnt.setXData(handlesP3d, nameApp);
                            }
                        }
                        else
                        {
                            poly3d.ObjectId.delete();
                            handlesP3d.RemoveAt(i);
                            RBpnt = handlesP3d.handles_RB(nameApp);
                            idCogoPnt.setXData(handlesP3d, nameApp);
                        }
                    }
                    else
                    {
                        //remove bad handle from list
                        handlesP3d.RemoveAt(i);
                        RBpnt = handlesP3d.handles_RB(nameApp);
                        idCogoPnt.setXData(handlesP3d, nameApp);
                    }
                    i++;
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " xData.cs: line: 145");
            }
            return(RBpnt);
        }