// Copyright (C) Stichting Deltares 2016. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser 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 Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser 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. namespace Core.Common.Base.Geometry { /// /// Class that captures the intersection calculation result between two /// instances. /// public class Segment2DIntersectSegment2DResult { private Segment2DIntersectSegment2DResult(Intersection2DType type, Point2D[] points) { IntersectionType = type; IntersectionPoints = points; } /// /// Gets the type of the intersection found. /// public Intersection2DType IntersectionType { get; private set; } /// /// Gets the intersection points, if any. /// /// /// If has a value of , /// the array holds the single intersection points found. /// If has a value of , /// the array holds the two points defining the overlapping area for both segments. /// public Point2D[] IntersectionPoints { get; private set; } /// /// Creates the calculation result for having found no intersections. /// public static Segment2DIntersectSegment2DResult CreateNoIntersectResult() { return new Segment2DIntersectSegment2DResult(Intersection2DType.NoIntersections, new Point2D[0]); } /// /// Creates the calculation result for having found a single intersection. /// /// The intersection point. public static Segment2DIntersectSegment2DResult CreateIntersectionResult(Point2D intersectionPoint) { return new Segment2DIntersectSegment2DResult(Intersection2DType.Intersects, new[] { intersectionPoint }); } /// /// Creates the calculation result for having found an overlap between the two segments. /// /// The start of the overlapping segment. /// The end of the overlapping segment. public static Segment2DIntersectSegment2DResult CreateOverlapResult(Point2D start, Point2D end) { return new Segment2DIntersectSegment2DResult(Intersection2DType.Overlapping, new[] { start, end }); } } }