// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; namespace Deltares.DamEngine.Data.Geometry { /// /// Class holding the boundaries of a geometry object /// public class GeometryBounds { /// /// Initializes a new instance of the class. /// public GeometryBounds() : this(0, 0, 0, 0) { } /// /// Initializes a new instance of the class. /// /// The left. /// The right. /// The bottom. /// The top. public GeometryBounds(double left, double right, double bottom, double top) { Left = left; Right = right; Bottom = bottom; Top = top; } /// /// Gets or sets the left. /// /// /// The left. /// public double Left { get; set; } /// /// Gets or sets the top. /// /// /// The top. /// public double Top { get; set; } /// /// Gets or sets the right. /// /// /// The right. /// public double Right { get; set; } /// /// Gets or sets the bottom. /// /// /// The bottom. /// public double Bottom { get; set; } /// /// Determines whether the boundary contains the specified point. /// /// The x. /// The y. /// public bool ContainsPoint(double x, double y) { return x >= Left && x <= Right && y >= Bottom && y <= Top; } /// /// Implements the operator +. /// /// The bounds1. /// The bounds2. /// /// The result of the operator. /// public static GeometryBounds operator +(GeometryBounds bounds1, GeometryBounds bounds2) { if (bounds2 == null) { return bounds1; } if (bounds1 == null) { return bounds2; } return new GeometryBounds(Math.Min(bounds1.Left, bounds2.Left), Math.Max(bounds1.Right, bounds2.Right), Math.Min(bounds1.Bottom, bounds2.Bottom), Math.Max(bounds1.Top, bounds2.Top)); } } }