+ Added NotSupportedExceptions on all block statements except Hull and Union when Position() is called on them

This commit is contained in:
Michael L Smith 2016-02-16 19:54:34 -08:00
parent 2bbe452da6
commit b6a454e8b9
8 changed files with 81 additions and 3 deletions

View File

@ -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);

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -62,6 +62,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Text3DTests.cs" />
<Compile Include="UnionTests.cs" />
<Compile Include="DifferenceTests.cs" />
<Compile Include="IntersectionTests.cs" />
<Compile Include="MinkowskiTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OSCADSharp\OSCADSharp.csproj">

View File

@ -18,6 +18,11 @@ namespace OSCADSharp.Booleans
/// <param name="children"></param>
public Difference(IEnumerable<OSCADObject> children) : base("difference()", children)
{
}
}
public override Vector3 Position()
{
throw new NotSupportedException("Position is not supported on Differenced objects.");
}
}
}

View File

@ -19,5 +19,10 @@ namespace OSCADSharp.Booleans
public Intersection(IEnumerable<OSCADObject> children) : base("intersection()", children)
{
}
public override Vector3 Position()
{
throw new NotSupportedException("Position is not supported on Intersected objects.");
}
}
}

View File

@ -15,6 +15,11 @@ namespace OSCADSharp.Transforms
public MinkowskiedObject(IEnumerable<OSCADObject> children) : base("minkowski()", children)
{
}
}
public override Vector3 Position()
{
throw new NotSupportedException("Position is not supported on Minkowskied objects.");
}
}
}