예제 #1
0
 private void SetZToZero(IPointCollection4 pCol)
 {
     for (int i = 0; i < pCol.PointCount; i++)
     {
         IPoint copyipt = pCol.get_Point(i);
         copyipt.Z = 0;
         pCol.UpdatePoint(i, copyipt);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="pCol"></param>
 /// <remarks>note that if we set z coordinates, then we may lose many information related to IPolygon
 /// (ConnectedComponentBag, InteriorRingBag, ExteriorRingBag, etc.) </remarks>
 public static void SetZCoordinates(IPointCollection4 pCol)
 {
     for (int i = 0; i < pCol.PointCount; i++)
     {
         IPoint copyipt = pCol.get_Point(i);
         copyipt.Z = 0;
         pCol.UpdatePoint(i, copyipt);
     }
 }
        public IPointCollection4 modify1VertexOfAPolyline(IGeometryCollection geo, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            Double   hitDistance = 0; Int32 hitPartIndex = 0;
            Int32    hitSegmentIndex = 0;
            Boolean  rightSide       = false;
            IHitTest hitTest         = (IHitTest)geo;
            Boolean  foundGeometry   = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry         geometry        = geo.get_Geometry(hitPartIndex);
                IPointCollection4 pointCollection = (IPointCollection4)geometry;
                IPoint            transformPoint  = pointCollection.get_Point(hitSegmentIndex);
                ITransform2D      transform2D     = (ITransform2D)transformPoint;
                transform2D.Move(offsetX, offsetY);
                pointCollection.UpdatePoint(hitSegmentIndex, transformPoint);
                return(pointCollection);
            }
            return(null);
        }
        private void DWIntersect(CPolyline pBSCpl, ref List <CPoint> cptlt, double dblIgnorableDis)
        {
            IPointCollection4 pCol = new PolylineClass();

            for (int i = 0; i < cptlt.Count; i++)
            {
                cptlt[i].SetPoint();
                pCol.AddPoint(cptlt[i].pPoint);
            }
            IPolyline5 ipl = pCol as IPolyline5;

            pBSCpl.SetPolyline();
            IRelationalOperator pRel = pBSCpl.pPolyline as IRelationalOperator;
            bool isCrosses           = pRel.Crosses(ipl);

            if (isCrosses == true)
            {
                ITopologicalOperator pTop          = pBSCpl.pPolyline as ITopologicalOperator;
                IGeometry            pGeoIntersect = pTop.Intersect(ipl, esriGeometryDimension.esriGeometry0Dimension);
                IPointCollection4    pColIntersect = pGeoIntersect as IPointCollection4;

                double dblMaxDis = 0;
                for (int j = 0; j < pColIntersect.PointCount; j++)
                {
                    double dblDis = CGeoFunc.CalDistanceFromStartPoint(ipl, pColIntersect.get_Point(j), false);
                    if (dblDis > dblMaxDis)
                    {
                        dblMaxDis = dblDis;
                    }
                }

                ICurve pSubCurve;
                ipl.GetSubcurve(dblMaxDis, ipl.Length, false, out pSubCurve);
                //IPolyline5 Cutipl = pSubCurve as IPolyline5;
                IPointCollection4 iplCutCol = pSubCurve as IPointCollection4;

                //the new first segment
                IPointCollection4 pSegCol = new PolylineClass();
                pSegCol.AddPoint(ipl.FromPoint, _Missing, _Missing);
                pSegCol.AddPoint(iplCutCol.get_Point(1), _Missing, _Missing);
                IPolyline5 seg = pSegCol as IPolyline5;
                bool       isCrossesSeg;

                int intIndex = 0;
                while (intIndex < iplCutCol.PointCount - 1)
                {
                    intIndex++;
                    pSegCol.UpdatePoint(1, iplCutCol.get_Point(intIndex));
                    isCrossesSeg = pRel.Crosses(seg);
                    if (isCrossesSeg == false)
                    {
                        iplCutCol.RemovePoints(1, intIndex - 1);
                        iplCutCol.UpdatePoint(0, ipl.FromPoint);
                        break;
                    }
                    if (seg.Length >= dblIgnorableDis)
                    {
                        double dblOriginalIntersectionDis  = CGeoFunc.CalDistanceFromStartPoint(pBSCpl.pPolyline, pCol.get_Point(0), false);
                        double dblRealisticIntersectionDis = CGeoFunc.CalDistanceFromStartPoint(pBSCpl.pPolyline, iplCutCol.get_Point(0), false);

                        IPointCollection4 pColBSCpl = pBSCpl.pPolyline as IPointCollection4;
                        double            dblSumDis = 0;
                        for (int i = 0; i < pColBSCpl.PointCount - 1; i++)
                        {
                            double dblDis = CGeoFunc.CalDis(pColBSCpl.get_Point(i), pColBSCpl.get_Point(i + 1));
                            dblSumDis += dblDis;
                            if (dblSumDis >= dblRealisticIntersectionDis)
                            {
                                double dblDisPre   = Math.Abs(dblSumDis - dblDis - dblOriginalIntersectionDis);
                                double dblDisNext  = Math.Abs(dblSumDis - dblOriginalIntersectionDis);
                                IPoint intersectpt = new PointClass();
                                if (dblDisPre <= dblDisNext)
                                {
                                    intersectpt = pColBSCpl.get_Point(i);
                                }
                                else
                                {
                                    intersectpt = pColBSCpl.get_Point(i + 1);
                                }
                                iplCutCol.UpdatePoint(0, intersectpt);
                                break;
                            }
                        }
                        break;
                    }
                }
                cptlt = CHelpFunc.GetCptEbByICol(iplCutCol).ToList();
            }
        }