Example #1
0
        /// <summary>
        /// Creates the structure (multipatch) from a given footprint and the number of floors
        /// building a multipatch geometry using the new 2.5 MultipatchBuilderEx class
        /// Must be called from MCT !!!
        /// </summary>
        /// <param name="floorFootPrint">footprint line features of wall</param>
        /// <param name="floorLevels">Number of floors (4 meters/floor)</param>
        /// <returns></returns>
        public static MultipatchBuilderEx CreateTriangleMultipatchBuilder(Polygon floorFootPrint,
                                                                          int floorLevels)
        {
            var heightInMeters = floorLevels * 7;
            // create the multipatchBuilderEx object
            var mpb = new ArcGIS.Core.Geometry.MultipatchBuilderEx();
            // create a list of patch objects
            var patches = new List <Patch>();
            var coords  = new List <Coordinate3D>();

            // each line in the polygon makes up one 'face' (patch) for the multipatch
            // the floor footprint is the baseline
            // heightInMeters is the elevation
            coords.AddRange(CoordsWithHeight(floorFootPrint, heightInMeters));
            // to drape the faces with textures we have to using triangle patches
            // with one patch for each wall and each wall with the following coordinates
            // making two triangles per wall:
            // upper right, upper left, lower left
            // upper right, lower left, lower right
            // the coords list contains for each wall:
            // lower left, upper left, lower right, upper right
            // process each wall:
            for (var idx = 0; idx < coords.Count - 3; idx += 2)
            {
                var patch      = mpb.MakePatch(esriPatchType.Triangles);
                var wallCoords = GetWallCoordinates(coords, idx);
                patch.Coords = wallCoords;
                // if (idx == 0) ShowPatchLabels(patch);
                patches.Add(patch);
            }
            // add the roof
            var roofPatch  = mpb.MakePatch(esriPatchType.TriangleFan);
            var roofCoords = GetRoofCoordinates(coords);

            roofPatch.Coords = roofCoords;
            patches.Add(roofPatch);

            // assign the patches to the multipatchBuilder
            mpb.Patches = patches;

            // call ToGeometry to get the multipatch
            return(mpb);
        }
        // static method to hold the coordinates and code for building a multipatch geometry using the new 2.5 MultipatchBuilderEx class
        public static Multipatch CreateTriangleMultipatchGeometry()
        {
            #region Coordinates

            var coords_face1 = new List <Coordinate3D>()
            {
                new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
            };

            var coords_face2 = new List <Coordinate3D>()
            {
                new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
            };

            var coords_face3 = new List <Coordinate3D>()
            {
                new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
            };

            var coords_face4 = new List <Coordinate3D>()
            {
                new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
            };

            var coords_face5 = new List <Coordinate3D>()
            {
                new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
            };

            var coords_face6 = new List <Coordinate3D>()
            {
                new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
                new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
                new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
            };
            #endregion

            // create a list of patch objects
            var patches = new List <Patch>();

            // create the multipatchBuilderEx object
            var mpb = new ArcGIS.Core.Geometry.MultipatchBuilderEx();

            // make each patch using the appropriate coordinates and add to the patch list
            var patch = mpb.MakePatch(esriPatchType.Triangles);
            patch.Coords = coords_face1;
            patches.Add(patch);

            patch        = mpb.MakePatch(esriPatchType.Triangles);
            patch.Coords = coords_face2;
            patches.Add(patch);

            patch        = mpb.MakePatch(esriPatchType.Triangles);
            patch.Coords = coords_face3;
            patches.Add(patch);

            patch        = mpb.MakePatch(esriPatchType.Triangles);
            patch.Coords = coords_face4;
            patches.Add(patch);

            patch        = mpb.MakePatch(esriPatchType.Triangles);
            patch.Coords = coords_face5;
            patches.Add(patch);

            patch        = mpb.MakePatch(esriPatchType.Triangles);
            patch.Coords = coords_face6;
            patches.Add(patch);

            // assign the patches to the multipatchBuilder
            mpb.Patches = patches;

            // call ToGeometry to get the multipatch
            var multipatch = mpb.ToGeometry() as Multipatch;

            return(multipatch);
        }