+ Added a NotSupportedException when Position is called on a mirrored object that's been mirrored on multiple axes + test

This commit is contained in:
Michael L Smith 2016-02-16 19:34:33 -08:00
parent 8e5aa0a2f3
commit 2bbe452da6
2 changed files with 20 additions and 0 deletions

View File

@ -31,5 +31,14 @@ namespace OSCADSharp.UnitTests
pos.Z = -pos.Z;
Assert.AreEqual(pos, zMirror.Position());
}
[TestMethod]
[ExpectedException(typeof(NotSupportedException))]
public void Mirror_MultiAxisPositionThrowsNotSupportedException()
{
var cube = new Cube(5, 10, 20);
var pos = cube.Mirror(1, 1, 0).Position();
}
}
}

View File

@ -55,6 +55,11 @@ namespace OSCADSharp.Transforms
// fix mirrored positions for multiple-axis mirroring
public override Vector3 Position()
{
if (this.isMoreThanOneAxis())
{
throw new NotSupportedException("Getting the position of an object that's been mirrored on more than one axis is not currently supported.");
}
var pos = obj.Position();
double x = this.Normal.X != 0 ? pos.X * -1 : pos.X;
@ -63,5 +68,11 @@ namespace OSCADSharp.Transforms
return new Vector3(x, y, z);
}
private bool isMoreThanOneAxis()
{
return (this.Normal.X != 0 && (this.Normal.Y != 0 || this.Normal.Z != 0)) ||
(this.Normal.Y != 0 && (this.Normal.X != 0 || this.Normal.Z != 0));
}
}
}