+ Decided not to support Bounds() on Text3D objects, since there's a lot of work needed before it will be viable.

This commit is contained in:
Michael L Smith 2016-02-22 18:32:17 -08:00
parent 96693e062b
commit 62a0a034a1
2 changed files with 4 additions and 14 deletions

View File

@ -20,12 +20,10 @@ namespace OSCADSharp.UnitTests
}
[TestMethod]
public void Text_BoundsBasedOnFontSize()
[ExpectedException(typeof(NotSupportedException))]
public void Text_BoundsNotSupported()
{
var obj = new Text3D("BBBB", 16);
Assert.AreEqual(new Vector3(32, 8, 0.5), obj.Bounds().TopRight);
Assert.AreEqual(new Vector3(-32, -8, -0.5), obj.Bounds().BottomLeft);
var obj = new Text3D("BBBB", 16).Bounds();
}
}
}

View File

@ -145,18 +145,10 @@ namespace OSCADSharp.Solids
/// <summary>
/// Returns the approximate boundaries of this OpenSCAD object
///
/// Disclaimer: The bounds for text are particularly inaccurate, since
/// OSCADSharp doesn't have all font data necessary to calculate the
/// boundaries for all the possible fonts that could be used
/// </summary>
/// <returns></returns>
public override Bounds Bounds()
{
double fontSize = this.Size ?? 8;
double xAmount = fontSize * this.Text.Length;
return new Bounds(new Vector3(-xAmount/2, -fontSize/2, -.5), new Vector3(xAmount / 2, fontSize / 2, .5));
throw new NotSupportedException("Bounds are not supported for objects using Text3D");
}
#endregion
}