Example #1
0
        /// <summary>
        /// Creates Levels within the supplied Envelope, starting at Envelope.Elevation and proceeding upward at equal intervals until placing the last Level at Envelope.Elevation + Envelope.Height.
        /// </summary>
        /// <param name="envelope">Envelope that will encompass the new Levels.</param>
        /// <param name="interval">Desired vertical distance between Levels.</param>
        /// <returns>A List of Levels ordered from lowest Elevation to highest.</returns>
        public void MakeLevels(Envelope envelope, double interval, bool first = true, bool last = true)
        {
            var perimeter = envelope.Profile.Perimeter;

            if (perimeter.IsClockWise())
            {
                perimeter = perimeter.Reversed();
            }
            if (first)
            {
                Levels.Add(new Level(envelope.Elevation, Guid.NewGuid(), ""));
                LevelPerimeters.Add(new LevelPerimeter(perimeter.Area(), envelope.Elevation, perimeter, Guid.NewGuid(), ""));
            }
            ;
            var openHeight = envelope.Height;
            var stdHeight  = Math.Abs(openHeight / Math.Floor(openHeight / interval));
            var atHeight   = envelope.Elevation + stdHeight;

            while (openHeight >= stdHeight * 2)
            {
                Levels.Add(new Level(atHeight, Guid.NewGuid(), ""));
                LevelPerimeters.Add(new LevelPerimeter(perimeter.Area(), atHeight, perimeter, Guid.NewGuid(), ""));
                openHeight -= stdHeight;
                atHeight   += stdHeight;
            }
            if (last)
            {
                Levels.Add(new Level(envelope.Elevation + envelope.Height, Guid.NewGuid(), ""));
                LevelPerimeters.Add(new LevelPerimeter(perimeter.Area(), envelope.Elevation + envelope.Height, perimeter, Guid.NewGuid(), ""));
            }
        }
Example #2
0
        /// <summary>
        /// Creates a Level at the specified height if it falls within the vertical volume of the supplied Envelope.
        /// </summary>
        /// <param name="envelope">Envelope from which to derive the Level perimeter.</param>
        /// <param name="elevation">Elevation of the proposed Level.</param>
        /// <returns>A Level or null if no eligible envelope is found.</returns>
        public bool MakeLevel(Envelope envelope, double elevation)
        {
            var perimeter = envelope.Profile.Perimeter;

            if (perimeter.IsClockWise())
            {
                perimeter = perimeter.Reversed();
            }
            if (elevation < envelope.Elevation || elevation > envelope.Elevation + envelope.Height)
            {
                return(false);
            }
            Levels.Add(new Level(elevation, Guid.NewGuid(), ""));
            LevelPerimeters.Add(new LevelPerimeter(perimeter.Area(), elevation, perimeter, Guid.NewGuid(), ""));
            Levels          = Levels.OrderBy(l => l.Elevation).ToList();
            LevelPerimeters = LevelPerimeters.OrderBy(l => l.Elevation).ToList();
            return(true);
        }