feat(core): add CircleShape
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
20
OpenNest.Core/Shapes/CircleShape.cs
Normal file
20
OpenNest.Core/Shapes/CircleShape.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.Shapes
|
||||
{
|
||||
public class CircleShape : ShapeDefinition
|
||||
{
|
||||
public double Diameter { get; set; }
|
||||
|
||||
public override Drawing GetDrawing()
|
||||
{
|
||||
var entities = new List<Entity>
|
||||
{
|
||||
new Circle(0, 0, Diameter / 2.0)
|
||||
};
|
||||
|
||||
return CreateDrawing(entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
OpenNest.Tests/Shapes/CircleShapeTests.cs
Normal file
26
OpenNest.Tests/Shapes/CircleShapeTests.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using OpenNest.Shapes;
|
||||
|
||||
namespace OpenNest.Tests.Shapes;
|
||||
|
||||
public class CircleShapeTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetDrawing_ReturnsDrawingWithCorrectBoundingBox()
|
||||
{
|
||||
var shape = new CircleShape { Diameter = 10 };
|
||||
var drawing = shape.GetDrawing();
|
||||
|
||||
var bbox = drawing.Program.BoundingBox();
|
||||
Assert.Equal(10, bbox.Width, 0.01);
|
||||
Assert.Equal(10, bbox.Length, 0.01);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDrawing_DefaultName_IsCircle()
|
||||
{
|
||||
var shape = new CircleShape { Diameter = 10 };
|
||||
var drawing = shape.GetDrawing();
|
||||
|
||||
Assert.Equal("Circle", drawing.Name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user