Skip to content

Commit

Permalink
circle
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Dec 1, 2023
1 parent 0357413 commit aecff7f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions ACadSharp/Entities/Circle.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ACadSharp.Attributes;
using CSMath;
using System;

namespace ACadSharp.Entities
{
Expand All @@ -22,7 +23,7 @@ public class Circle : Entity

/// <inheritdoc/>
public override string SubclassMarker => DxfSubclassMarker.Circle;

/// <summary>
/// Specifies the three-dimensional normal unit vector for the object.
/// </summary>
Expand All @@ -45,7 +46,20 @@ public class Circle : Entity
/// Specifies the radius of an arc, circle, or position marker.
/// </summary>
[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;

/// <summary>
/// Default constructor
Expand All @@ -55,7 +69,15 @@ public Circle() : base() { }
/// <inheritdoc/>
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);
}
}
}

0 comments on commit aecff7f

Please sign in to comment.