示例#1
0
        //构造切线点
        private void button5_Click(object sender, EventArgs e)
        {
            delFeature("point");
            IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
            {
                points[i] = new PointClass();
            }

            points[0].PutCoords(15, 10);
            points[1].PutCoords(20, 60);
            points[2].PutCoords(40, 60);
            points[3].PutCoords(45, 10);
            addFeature("point", points[0]);
            addFeature("point", points[1]);
            addFeature("point", points[2]);
            addFeature("point", points[3]);

            IBezierCurveGEN bezierCurve = new BezierCurveClass();

            bezierCurve.PutCoords(ref points);
            IConstructMultipoint constructMultipoint = new MultipointClass();

            constructMultipoint.ConstructTangent(bezierCurve as ICurve, points[1]);
            IMultipoint      multipoint      = constructMultipoint as IMultipoint;
            IPointCollection pointCollection = multipoint as IPointCollection;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
            axMapControl1.Refresh();
        }
示例#2
0
        //构造交点
        private void button4_Click(object sender, EventArgs e)
        {
            delFeature("point");
            IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
            {
                points[i] = new PointClass();
            }

            points[0].PutCoords(15, 10);
            points[1].PutCoords(20, 60);
            points[2].PutCoords(40, 60);
            points[3].PutCoords(45, 10);
            addFeature("point", points[0]);
            addFeature("point", points[1]);
            addFeature("point", points[2]);
            addFeature("point", points[3]);
            //构造Bezier曲线
            IBezierCurveGEN bezierCurve = new BezierCurveClass();

            bezierCurve.PutCoords(ref points);
            IPoint centerPoint = new PointClass();

            centerPoint.PutCoords(30, 30);
            IPoint fromPoint = new PointClass();

            fromPoint.PutCoords(10, 10);
            IPoint toPoint = new PointClass();

            toPoint.PutCoords(50, 10);
            //构造圆弧
            IConstructCircularArc circularArcConstruction = new CircularArcClass();

            circularArcConstruction.ConstructThreePoints(fromPoint, centerPoint, toPoint, false);


            object param0;
            object param1;
            object isTangentPoint;
            IConstructMultipoint constructMultipoint = new MultipointClass();

            constructMultipoint.ConstructIntersection(circularArcConstruction as ISegment, esriSegmentExtension.esriNoExtension, bezierCurve as ISegment, esriSegmentExtension.esriNoExtension, out param0, out param1, out isTangentPoint);
            IMultipoint      multipoint      = constructMultipoint as IMultipoint;
            IPointCollection pointCollection = multipoint as IPointCollection;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }

            axMapControl1.Extent = multipoint.Envelope;
            axMapControl1.Refresh();
        }
示例#3
0
        /// <summary>
        /// 通过开始点和结束点创建贝塞尔曲线片段
        /// </summary>
        /// <param name="fromPoint">开始点</param>
        /// <param name="toPoint">结束点</param>
        /// <returns>贝塞尔曲线片段</returns>
        public static ISegment CreateBezierCurveByTwoPoints(IPoint fromPoint, IPoint toPoint)
        {
            IBezierCurveGEN CurveGEN = new BezierCurveClass();
            ILine           line     = CreateLineByTwoPoints(fromPoint, toPoint);
            ILine           normal   = new LineClass();

            line.QueryNormal(esriSegmentExtension.esriNoExtension, 0.5, true, (double)(line.Length / 2.0), normal);
            IPoint fromTangent = (IPoint)normal.ToPoint;

            line = CreateLineByTwoPoints(toPoint, fromPoint);
            line.QueryNormal(esriSegmentExtension.esriNoExtension, 0.5, true, (double)(line.Length / 2.0), normal);
            IPoint toTangent = (IPoint)normal.ToPoint;

            IPoint[] points = { fromPoint, fromTangent, toTangent, toPoint };
            CurveGEN.PutCoords(ref points);
            return((ISegment)CurveGEN);
        }
示例#4
0
        /// <summary>
        /// 绘制曲线部分
        /// </summary>
        /// <params name="lyr">推断断层</params>
        /// <params name="newplines">延长点构造的线</params>
        /// <params name="originlines">原始点构造的线</params>
        private void AddCurveToMap(IFeatureLayer lyr, List<IPolyline> newplines, List<IPolyline> originlines)
        {
            IFeatureClass Featureclass = lyr.FeatureClass;
            IWorkspaceEdit workspace = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;
            workspace.StartEditing(true);
            workspace.StartEditOperation();
            object missing = Type.Missing;
            //揭露断层上的曲线对象
            IGeometry geom = new PolylineClass();
            geom.SpatialReference = Global.spatialref;
            IGeometryCollection outgeomcols = geom as IGeometryCollection;
            IFeature fea = Featureclass.CreateFeature();
            ISegmentCollection newpath = new PathClass();
            int kindpos = Featureclass.Fields.FindField(GIS.GIS_Const.FIELD_TYPE);
            int bidpos = Featureclass.Fields.FindField(GIS.GIS_Const.FIELD_BID);
            for (int i = 0; i < newplines.Count; i++)
            {
                ILine lin = new LineClass();
                lin.SpatialReference = Global.spatialref;
                //直线段
                IPath path = new PathClass();
                if (i == 0)
                {
                    lin.FromPoint = newplines[i].FromPoint;
                    lin.ToPoint = originlines[i].ToPoint;
                }
                else if (i == originlines.Count - 1)
                {
                    lin.FromPoint = originlines[i].FromPoint;
                    lin.ToPoint = newplines[i].ToPoint;
                }
                else
                {
                    lin.FromPoint = originlines[i].FromPoint;
                    lin.ToPoint = originlines[i].ToPoint;
                }
                newpath.AddSegment(lin as ISegment, ref missing, ref missing);
                //曲线段
                if (i < newplines.Count - 1)
                {
                    IBezierCurveGEN bezier = new BezierCurveClass();
                    IPoint[] pntcontrols = new IPoint[4];
                    pntcontrols[0] = originlines[i].ToPoint;
                    pntcontrols[1] = newplines[i].ToPoint;
                    pntcontrols[2] = newplines[i + 1].FromPoint;
                    pntcontrols[3] = originlines[i + 1].FromPoint;
                    bezier.PutCoords(ref pntcontrols);

                    newpath.AddSegment(bezier as ISegment, ref missing, ref missing);
                }
            }
            outgeomcols.AddGeometry(newpath as IGeometry, ref missing, ref missing);
            int index = fea.Fields.FindField(GIS_Const.FIELD_SHAPE);
            IGeometryDef geometryDef = fea.Fields.get_Field(index).GeometryDef as IGeometryDef;
            if (geometryDef.HasZ)
            {
                IZAware pZAware = (IZAware)outgeomcols;
                pZAware.ZAware = true;
            }
            fea.Shape = outgeomcols as IPolyline;
            fea.set_Value(kindpos, 1);
            fea.set_Value(bidpos, BID);
            fea.Store();
            //外围曲线绘制
            ITopologicalOperator2 top = outgeomcols as ITopologicalOperator2;
            if (!top.IsSimple)
                top.Simplify();
            IConstructCurve curve = new PolylineClass();
            curve.ConstructOffset(outgeomcols as IPolyline, -3, ref missing, ref missing);
            IPolyline plinnew = curve as IPolyline;
            plinnew.SpatialReference = Global.spatialref;
            plinnew.FromPoint = newplines[0].FromPoint;
            plinnew.ToPoint = newplines[newplines.Count - 1].ToPoint;

            IFeature outcurve = Featureclass.CreateFeature();
            outcurve.set_Value(kindpos, 2);
            outcurve.set_Value(bidpos, BID);
            outcurve.Shape = plinnew;
            outcurve.Store();
            //结束编辑
            workspace.StopEditOperation();
            workspace.StopEditing(true);
            //定位跳转
            Global.commonclss.JumpToGeometry(plinnew);
        }
示例#5
0
        /// <summary>
        /// 绘制曲线部分
        /// </summary>
        /// <params name="lyr">推断断层</params>
        /// <params name="newplines">延长点构造的线</params>
        /// <params name="originlines">原始点构造的线</params>
        private void AddCurveToMap(IFeatureLayer lyr, List <IPolyline> newplines, List <IPolyline> originlines)
        {
            IFeatureClass  Featureclass = lyr.FeatureClass;
            IWorkspaceEdit workspace    = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;

            workspace.StartEditing(true);
            workspace.StartEditOperation();
            object missing = Type.Missing;
            //揭露断层上的曲线对象
            IGeometry geom = new PolylineClass();

            geom.SpatialReference = Global.spatialref;
            IGeometryCollection outgeomcols = geom as IGeometryCollection;
            IFeature            fea         = Featureclass.CreateFeature();
            ISegmentCollection  newpath     = new PathClass();
            int kindpos = Featureclass.Fields.FindField(GIS.GIS_Const.FIELD_TYPE);
            int bidpos  = Featureclass.Fields.FindField(GIS.GIS_Const.FIELD_BID);

            for (int i = 0; i < newplines.Count; i++)
            {
                ILine lin = new LineClass();
                lin.SpatialReference = Global.spatialref;
                //直线段
                IPath path = new PathClass();
                if (i == 0)
                {
                    lin.FromPoint = newplines[i].FromPoint;
                    lin.ToPoint   = originlines[i].ToPoint;
                }
                else if (i == originlines.Count - 1)
                {
                    lin.FromPoint = originlines[i].FromPoint;
                    lin.ToPoint   = newplines[i].ToPoint;
                }
                else
                {
                    lin.FromPoint = originlines[i].FromPoint;
                    lin.ToPoint   = originlines[i].ToPoint;
                }
                newpath.AddSegment(lin as ISegment, ref missing, ref missing);
                //曲线段
                if (i < newplines.Count - 1)
                {
                    IBezierCurveGEN bezier      = new BezierCurveClass();
                    IPoint[]        pntcontrols = new IPoint[4];
                    pntcontrols[0] = originlines[i].ToPoint;
                    pntcontrols[1] = newplines[i].ToPoint;
                    pntcontrols[2] = newplines[i + 1].FromPoint;
                    pntcontrols[3] = originlines[i + 1].FromPoint;
                    bezier.PutCoords(ref pntcontrols);

                    newpath.AddSegment(bezier as ISegment, ref missing, ref missing);
                }
            }
            outgeomcols.AddGeometry(newpath as IGeometry, ref missing, ref missing);
            int          index       = fea.Fields.FindField(GIS_Const.FIELD_SHAPE);
            IGeometryDef geometryDef = fea.Fields.get_Field(index).GeometryDef as IGeometryDef;

            if (geometryDef.HasZ)
            {
                IZAware pZAware = (IZAware)outgeomcols;
                pZAware.ZAware = true;
            }
            fea.Shape = outgeomcols as IPolyline;
            fea.set_Value(kindpos, 1);
            fea.set_Value(bidpos, BID);
            fea.Store();
            //外围曲线绘制
            ITopologicalOperator2 top = outgeomcols as ITopologicalOperator2;

            if (!top.IsSimple)
            {
                top.Simplify();
            }
            IConstructCurve curve = new PolylineClass();

            curve.ConstructOffset(outgeomcols as IPolyline, -3, ref missing, ref missing);
            IPolyline plinnew = curve as IPolyline;

            plinnew.SpatialReference = Global.spatialref;
            plinnew.FromPoint        = newplines[0].FromPoint;
            plinnew.ToPoint          = newplines[newplines.Count - 1].ToPoint;

            IFeature outcurve = Featureclass.CreateFeature();

            outcurve.set_Value(kindpos, 2);
            outcurve.set_Value(bidpos, BID);
            outcurve.Shape = plinnew;
            outcurve.Store();
            //结束编辑
            workspace.StopEditOperation();
            workspace.StopEditing(true);
            //定位跳转
            Global.commonclss.JumpToGeometry(plinnew);
        }