/// <summary>
        /// Builds polygons for the z-value ranges.
        /// </summary>
        /// <param name="triangles">An object that enumerates triangles defining surface. All triangle coordinates should be instances of the MapAround.Geometry.Coordinate3D.</param>
        /// <param name="zLevels">A descending array of z-values that define ranges</param>
        /// <returns>An array containing level range polygons</returns>
        public LevelRangePolygon[] BuildPolygonsForLevelRanges(IEnumerable <Triangle> triangles, double[] zLevels)
        {
            if (triangles == null)
            {
                throw new ArgumentNullException("triangles");
            }

            for (int i = 0; i < zLevels.Length - 1; i++)
            {
                if (zLevels[i] <= zLevels[i + 1])
                {
                    throw new ArgumentException("Z-levels aren't descending and/or distinct", "zLevels");
                }
            }

            Polyline[] isolines = buildIsolinesInternal(triangles, zLevels);

            IList <ICoordinate> coonvexHull;

            List <LinePath> paths = getPathsForPolygonBuilding(triangles, isolines, out coonvexHull);

            IList <Polygon> polygons;
            IList <Segment> dangles;
            IList <Segment> cuts;

            PolygonBuilder.BuildPolygons(paths, out polygons, out dangles, out cuts);

            List <Triangle> tempTriangles = triangles.ToList();

            LevelRangePolygon[] result =
                assignLevelsToPolygons(polygons, tempTriangles, zLevels, PlanimetryAlgorithms.GetPointsBoundingRectangle(coonvexHull));

            return(result);
        }