From aecff7f62699914c91728331d370318b66deaf07 Mon Sep 17 00:00:00 2001 From: DomCR Date: Fri, 1 Dec 2023 10:30:54 +0100 Subject: [PATCH] circle --- ACadSharp/Entities/Circle.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/ACadSharp/Entities/Circle.cs b/ACadSharp/Entities/Circle.cs index b55a9811..311349ea 100644 --- a/ACadSharp/Entities/Circle.cs +++ b/ACadSharp/Entities/Circle.cs @@ -1,5 +1,6 @@ using ACadSharp.Attributes; using CSMath; +using System; namespace ACadSharp.Entities { @@ -22,7 +23,7 @@ public class Circle : Entity /// public override string SubclassMarker => DxfSubclassMarker.Circle; - + /// /// Specifies the three-dimensional normal unit vector for the object. /// @@ -45,7 +46,20 @@ public class Circle : Entity /// Specifies the radius of an arc, circle, or position marker. /// [DxfCodeValue(40)] - public double Radius { get; set; } = 1.0; + public double Radius + { + get { return this._radius; } + set + { + if (value <= 0) + { + throw new ArgumentOutOfRangeException(nameof(value), value, "The radius must be greater than 0."); + } + this._radius = value; + } + } + + private double _radius = 1.0; /// /// Default constructor @@ -55,7 +69,15 @@ public Circle() : base() { } /// public override BoundingBox GetBoundingBox() { - throw new System.NotImplementedException(); + if (this.Normal != XYZ.AxisZ) + { + throw new NotImplementedException("Bounding box for not aligned Normal is not implemented"); + } + + XYZ min = new XYZ(Math.Min(this.Center.X - this.Radius, this.Center.X + this.Radius), Math.Min(this.Center.Y - this.Radius, this.Center.Y + this.Radius), Math.Min(this.Center.Z - this.Radius, this.Center.Z + this.Radius)); + XYZ max = new XYZ(Math.Max(this.Center.X - this.Radius, this.Center.X + this.Radius), Math.Max(this.Center.Y - this.Radius, this.Center.Y + this.Radius), Math.Max(this.Center.Z - this.Radius, this.Center.Z + this.Radius)); + + return new BoundingBox(min, max); } } }