diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs index a0748ee..7d1ff28 100644 --- a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs +++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs @@ -13,7 +13,10 @@ namespace OSCADSharp.ConsoleTests { static void Main(string[] args) { - var obj = new Cube(5, 10, 20).Mirror(0, 0, 1); + var obj = new Cube(5, 10, 20).Mirror(0, 0, 1).Mirror(0, 1, 0) + .Rotate(15, -45, 120).Translate(-20, 10, 15).Rotate(90, 15, 25) + .Translate(-10, -20, -20).Rotate(-90, -90, -45); + obj = obj.Minkowski(new Cube(1, 1, 5)); var pos = obj.Position(); var cyl1 = new Cylinder(1, 100, true).Translate(pos); diff --git a/OSCADSharp/OSCADSharp.UnitTests/DifferenceTests.cs b/OSCADSharp/OSCADSharp.UnitTests/DifferenceTests.cs new file mode 100644 index 0000000..16b5c31 --- /dev/null +++ b/OSCADSharp/OSCADSharp.UnitTests/DifferenceTests.cs @@ -0,0 +1,19 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OSCADSharp.Solids; + +namespace OSCADSharp.UnitTests +{ + [TestClass] + public class DifferenceTests + { + [TestMethod] + [ExpectedException(typeof(NotSupportedException))] + public void Difference_PositionThrowsNotSupportedException() + { + var diff = new Sphere().Difference(new Cube()); + + var pos = diff.Position(); + } + } +} diff --git a/OSCADSharp/OSCADSharp.UnitTests/IntersectionTests.cs b/OSCADSharp/OSCADSharp.UnitTests/IntersectionTests.cs new file mode 100644 index 0000000..fadd682 --- /dev/null +++ b/OSCADSharp/OSCADSharp.UnitTests/IntersectionTests.cs @@ -0,0 +1,19 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OSCADSharp.Solids; + +namespace OSCADSharp.UnitTests +{ + [TestClass] + public class IntersectionTests + { + [TestMethod] + [ExpectedException(typeof(NotSupportedException))] + public void Intersection_PositionThrowsNotSupportedException() + { + var obj = new Sphere().Intersection(new Text3D("Sup")); + + var pos = obj.Position(); + } + } +} diff --git a/OSCADSharp/OSCADSharp.UnitTests/MinkowskiTests.cs b/OSCADSharp/OSCADSharp.UnitTests/MinkowskiTests.cs new file mode 100644 index 0000000..abbc9c7 --- /dev/null +++ b/OSCADSharp/OSCADSharp.UnitTests/MinkowskiTests.cs @@ -0,0 +1,19 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OSCADSharp.Solids; + +namespace OSCADSharp.UnitTests +{ + [TestClass] + public class MinkowskiTests + { + [TestMethod] + [ExpectedException(typeof(NotSupportedException))] + public void Minkowski_PositionThrowsNotSupportedException() + { + var obj = new Cylinder().Intersection(new Sphere()).Translate(0, 5, 5); + + var pos = obj.Position(); + } + } +} diff --git a/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj b/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj index b2e1d2e..f66616f 100644 --- a/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj +++ b/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj @@ -62,6 +62,9 @@ + + + diff --git a/OSCADSharp/OSCADSharp/Booleans/Difference.cs b/OSCADSharp/OSCADSharp/Booleans/Difference.cs index 3877265..bd66924 100644 --- a/OSCADSharp/OSCADSharp/Booleans/Difference.cs +++ b/OSCADSharp/OSCADSharp/Booleans/Difference.cs @@ -18,6 +18,11 @@ namespace OSCADSharp.Booleans /// public Difference(IEnumerable children) : base("difference()", children) { - } + } + + public override Vector3 Position() + { + throw new NotSupportedException("Position is not supported on Differenced objects."); + } } } diff --git a/OSCADSharp/OSCADSharp/Booleans/Intersection.cs b/OSCADSharp/OSCADSharp/Booleans/Intersection.cs index a67f010..f5c0f72 100644 --- a/OSCADSharp/OSCADSharp/Booleans/Intersection.cs +++ b/OSCADSharp/OSCADSharp/Booleans/Intersection.cs @@ -19,5 +19,10 @@ namespace OSCADSharp.Booleans public Intersection(IEnumerable children) : base("intersection()", children) { } + + public override Vector3 Position() + { + throw new NotSupportedException("Position is not supported on Intersected objects."); + } } } diff --git a/OSCADSharp/OSCADSharp/Transforms/MinkowskiedObject.cs b/OSCADSharp/OSCADSharp/Transforms/MinkowskiedObject.cs index 1af5640..3b4693c 100644 --- a/OSCADSharp/OSCADSharp/Transforms/MinkowskiedObject.cs +++ b/OSCADSharp/OSCADSharp/Transforms/MinkowskiedObject.cs @@ -15,6 +15,11 @@ namespace OSCADSharp.Transforms public MinkowskiedObject(IEnumerable children) : base("minkowski()", children) { - } + } + + public override Vector3 Position() + { + throw new NotSupportedException("Position is not supported on Minkowskied objects."); + } } }