/// <summary> /// Find the Boundingbox with the given Algorythm /// </summary> /// <param name="boxfindingAlgorythm">Concrete implementation of the bounding finder Algorythm to use</param> /// <returns></returns> public Rectangle2 FindBoundingBox(IPolygonBoundingBoxAlgorythm boxfindingAlgorythm) { Rectangle2 rect = null; var hull = !IsConvex() ? ToConvexPolygon() : this; var vertices = boxfindingAlgorythm.FindBounds(hull); if (vertices.Count() == 4) { rect = new Rectangle2(vertices); } if (rect == null || rect.Size.IsEmpty) { // Smallest boundingboxfinder failed - use simple boundingbox instead rect = this.BoundingBox.ToRectangle(); } return(rect); }
/// <summary> /// Find the Boundingbox with the given Algorythm /// </summary> /// <param name="boxfindingAlgorythm">Concrete implementation of the bounding finder Algorythm to use</param> /// <returns></returns> public Rectangle2 FindBoundingBox(IPolygonBoundingBoxAlgorythm boxfindingAlgorythm) { Rectangle2 rect = null; var hull = !IsConvex() ? ToConvexPolygon() : this; var vertices = boxfindingAlgorythm.FindBounds(hull); if (vertices.Count() == 4) { rect = new Rectangle2(vertices); } if (rect == null || rect.Size.IsEmpty) { // Smallest boundingboxfinder failed - use simple boundingbox instead rect = this.BoundingBox.ToRectangle(); } return rect; }