コード例 #1
0
        private Multipatch CreateCubeMultipatch()
        {
            double side = 5.0;

            // create the multipatch builder
            MultipatchBuilderEx cubeMultipatchBuilderEx = new MultipatchBuilderEx();

            // make the top face patch
            Patch topFacePatch = cubeMultipatchBuilderEx.MakePatch(PatchType.FirstRing);

            topFacePatch.Coords = new List <Coordinate3D>
            {
                new Coordinate3D(0, 0, side),
                new Coordinate3D(0, side, side),
                new Coordinate3D(side, side, side),
                new Coordinate3D(side, 0, side),
            };

            // make the bottom face patch
            Patch bottomFacePatch = cubeMultipatchBuilderEx.MakePatch(PatchType.FirstRing);

            bottomFacePatch.Coords = new List <Coordinate3D>
            {
                new Coordinate3D(0, 0, 0),
                new Coordinate3D(0, side, 0),
                new Coordinate3D(side, side, 0),
                new Coordinate3D(side, 0, 0),
            };

            // make the sides face patch
            Patch sidesFacePatch = cubeMultipatchBuilderEx.MakePatch(PatchType.TriangleStrip);

            sidesFacePatch.Coords = new List <Coordinate3D>
            {
                new Coordinate3D(0, 0, 0),
                new Coordinate3D(0, 0, side),
                new Coordinate3D(side, 0, 0),
                new Coordinate3D(side, 0, side),
                new Coordinate3D(side, side, 0),
                new Coordinate3D(side, side, side),
                new Coordinate3D(0, side, 0),
                new Coordinate3D(0, side, side),
                new Coordinate3D(0, 0, 0),
                new Coordinate3D(0, 0, side),
            };

            // add to the Patches collection on the builder
            cubeMultipatchBuilderEx.Patches.Add(topFacePatch);
            cubeMultipatchBuilderEx.Patches.Add(bottomFacePatch);
            cubeMultipatchBuilderEx.Patches.Add(sidesFacePatch);

            // create the geometry
            Multipatch cubeMultipatch = cubeMultipatchBuilderEx.ToGeometry() as Multipatch;

            return(cubeMultipatch);
        }
コード例 #2
0
        internal static async Task <Multipatch> MakeFishnetRingMultiPatchAsync(Polygon inputPoly)
        {
            Envelope envPoly  = inputPoly.Extent;
            var      interval = GetFishnetIntervalDistance(envPoly);

            var mColor      = System.Windows.Media.Colors.LightCyan;
            var materialRed = new BasicMaterial
            {
                Color     = mColor,
                EdgeColor = mColor,
                EdgeWidth = 0
            };
            // create the multipatchBuilderEx object
            var mpb = new MultipatchBuilderEx();
            // create a list of patch objects
            var patches = new List <Patch>();
            var first   = true;

            for (var dX = envPoly.XMin; dX < envPoly.XMax + interval; dX += interval)
            {
                for (var dY = envPoly.YMin; dY < envPoly.YMax + interval; dY += interval)
                {
                    var cutEnv = EnvelopeBuilder.CreateEnvelope(dX, dY, dX + interval, dY + interval,
                                                                envPoly.SpatialReference);
                    if (GeometryEngine.Instance.Intersects(cutEnv, inputPoly))
                    {
                        var addPolygonPart = GeometryEngine.Instance.Clip(inputPoly, cutEnv) as Polygon;
                        if (addPolygonPart.Area < 0)
                        {
                            System.Diagnostics.Debug.WriteLine($@"area: {addPolygonPart.Area}");
                        }
                        var result = await Module1.CurrentMapView.Map.GetZsFromSurfaceAsync(addPolygonPart);

                        if (result.Status == SurfaceZsResultStatus.Ok)
                        {
                            addPolygonPart = GeometryEngine.Instance.Move(result.Geometry, 0, 0, Module1.Elevation) as Polygon;
                        }
                        var patch = mpb.MakePatch(first ? esriPatchType.FirstRing : esriPatchType.Ring);
                        first = false;
                        patch.InsertPoints(0, addPolygonPart.Points);
                        patch.Material = materialRed;
                        patches.Add(patch);
                    }
                }
            }      // assign the patches to the multipatchBuilder
            mpb.Patches = patches;
            // call ToGeometry to get the multipatch
            return(mpb.ToGeometry() as Multipatch);
        }