示例#1
0
        private unsafe void DrawContour(IDrawArgs drawArgs, ContourLine cntLine, ContourClass cntClass, ICanvas canvas)
        {
            if (!cntClass.IsDisplay)
            {
                return;
            }
            ICoordinateTransform tran = canvas.CoordTransform;
            int nCount = cntLine.Count;

            PointF[] pts       = new PointF[nCount];
            GCHandle dstHandle = GCHandle.Alloc(pts, GCHandleType.Pinned);
            GCHandle srcHandle = GCHandle.Alloc(cntLine.Points, GCHandleType.Pinned);

            try
            {
                MemoryCopy(dstHandle.AddrOfPinnedObject(), srcHandle.AddrOfPinnedObject(), nCount << _pointfSize); // nCount * sizeof(PointF)
                QuickTransform quickTran = drawArgs.QuickTransformArgs;
                fixed(PointF *ptr0 = pts)
                {
                    PointF *ptr = ptr0;

                    for (int i = 0; i < nCount; i++, ptr++)
                    {
                        quickTran.Transform(ptr);
                    }
                }
                Graphics g = drawArgs.Graphics as Graphics;
                //
                if (_isUseCurveRender)
                {
                    g.DrawCurve(cntClass.Pen, pts, _tension);
                }
                else
                {
                    _grahpicPath.Reset();
                    _grahpicPath.AddLines(pts);
                    g.DrawPath(cntClass.Pen, _grahpicPath);
                }
                //
                if (_isLabel)
                {
                    if (_isCheckConflicting)
                    {
                        if (_conflictor.IsConflicted(pts[0], cntClass.LabelBuffer.Size))
                        {
                            return;
                        }
                        _conflictor.HoldPosition(pts[0], cntClass.LabelBuffer.Size);
                    }
                    g.DrawImageUnscaled(cntClass.LabelBuffer, (int)pts[0].X, (int)pts[0].Y);
                }
            }
            finally
            {
                dstHandle.Free();
                srcHandle.Free();
            }
        }
 private void ParseLine()
 {
     if (_lastPoint != null)
     {
         var lineObj = new ContourLine {
             Begin = _lastPoint, End = _point
         };
         _contour.Objects.Add(lineObj);
     }
 }
示例#3
0
    // Use this for initialization
    void Start()
    {
        vertices = new List <Vector3>();
        objs     = new List <GameObject>();

        triangles = new List <Triangle>();

        contourLine = new ContourLine[4];
        for (int i = 0; i < 4; i++)
        {
            contourLine[i] = new ContourLine();
        }

        GetVertices();
    }
示例#4
0
        private void DoGenerateContourLines(ICanvas canvas, double resX, double resY, frmPointContour.ContourItem[] contourItems, bool isNeedDisplay, bool isNeedLabel, IDW_Interpolation interpolate, string shpFileName)
        {
            IProgressMonitor progress = _smartSession.ProgressMonitorManager.DefaultProgressMonitor;

            try
            {
                progress.Reset("正在生成等值线...", 100);
                progress.Start(false);
                ContourGenerateTool tool = new ContourGenerateTool();
                double[]            cvs  = ToContourValues(contourItems);

                ContourLine[] cntLines = tool.Generate(resX, resY, enumDataType.Float, cvs, interpolate, (idx, tip) => { progress.Boost(idx, tip); });
                if (cntLines == null || cntLines.Length == 0)
                {
                    MsgBox.ShowInfo("不存在符合指定条件的等值线!");
                    return;
                }

                double dMinX = interpolate.CoordPointXArr.Min();
                double dMaxY = interpolate.CoordPointYArr.Max();
                for (int i = 0; i < cntLines.Count(); i++)
                {
                    ContourLine cntLine    = cntLines[i];
                    ContourLine newCntLine = new ContourLine(cntLine.ContourValue);
                    PointF[]    pts        = cntLine.Points;
                    for (int j = 0; j < pts.Count(); j++)
                    {
                        pts[j].X = Convert.ToSingle(dMinX + resX * pts[j].X);
                        pts[j].Y = Convert.ToSingle(dMaxY - resY * pts[j].Y);
                    }
                    newCntLine.AddPoints(pts);
                    newCntLine.UpdateEnvelope();
                    cntLines[i] = newCntLine;
                }
                if (shpFileName != null)
                {
                    TryExport2ShapeFile(canvas, cntLines, shpFileName, progress, isNeedDisplay);
                }
                if (isNeedDisplay)
                {
                    TryDisplay(cntLines, contourItems, isNeedLabel);
                }
            }
            finally
            {
                progress.Finish();
            }
        }
示例#5
0
        private unsafe void Project(ContourLine cntLine, ICanvas canvas)
        {
            ICoordinateTransform tran = canvas.CoordTransform;

            if (tran == null)
            {
                return;
            }
            int nCount = cntLine.Count;

            fixed(PointF *ptr0 = cntLine.Points)
            {
                PointF *ptr = ptr0;

                for (int i = 0; i < nCount; i++, ptr++)
                {
                    tran.Raster2Prj(ptr);
                }
            }

            cntLine.UpdateEnvelope();
        }
示例#6
0
        private unsafe Feature GetFeature(ContourLine cntLine, ICanvas canvas, int OID)
        {
            int ptCount = cntLine.Count;

            ShapePoint[] pts = new ShapePoint[ptCount];
            fixed(PointF *ptr0 = cntLine.Points)
            {
                PointF *ptr = ptr0;

                for (int i = 0; i < ptCount; i++, ptr++)
                {
                    double geoX, geoY;
                    canvas.CoordTransform.Prj2Geo(ptr->X, ptr->Y, out geoX, out geoY);
                    pts[i] = new ShapePoint(geoX, geoY);
                }
            }

            ShapeLineString ring = new ShapeLineString(pts);
            ShapePolyline   ply  = new ShapePolyline(new ShapeLineString[] { ring });
            Feature         fet  = new Feature(OID, ply, new string[] { "Contour" }, new string[] { cntLine.ContourValue.ToString() }, null);

            return(fet);
        }
示例#7
0
        private unsafe Feature GetFeature(ContourLine cntLine, double resX, double resY,
                                          double minX, double maxY, int OID)
        {
            int ptCount = cntLine.Count;

            ShapePoint[] pts = new ShapePoint[ptCount];
            fixed(PointF *ptr0 = cntLine.Points)
            {
                PointF *ptr = ptr0;

                for (int i = 0; i < ptCount; i++, ptr++)
                {
                    ptr->X = (float)(ptr->X * resX + minX);
                    ptr->Y = (float)(maxY - ptr->Y * resY);
                    pts[i] = new ShapePoint(ptr->X, ptr->Y);
                }
            }

            ShapeLineString ring = new ShapeLineString(pts);
            ShapePolyline   ply  = new ShapePolyline(new ShapeLineString[] { ring });
            Feature         fet  = new Feature(OID, ply, new string[] { "Contour" }, new string[] { cntLine.ContourValue.ToString() }, null);

            return(fet);
        }