mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-26 20:38:28 +00:00
+ 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:
parent
96693e062b
commit
62a0a034a1
@ -20,12 +20,10 @@ namespace OSCADSharp.UnitTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Text_BoundsBasedOnFontSize()
|
[ExpectedException(typeof(NotSupportedException))]
|
||||||
|
public void Text_BoundsNotSupported()
|
||||||
{
|
{
|
||||||
var obj = new Text3D("BBBB", 16);
|
var obj = new Text3D("BBBB", 16).Bounds();
|
||||||
|
|
||||||
Assert.AreEqual(new Vector3(32, 8, 0.5), obj.Bounds().TopRight);
|
|
||||||
Assert.AreEqual(new Vector3(-32, -8, -0.5), obj.Bounds().BottomLeft);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,18 +145,10 @@ namespace OSCADSharp.Solids
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the approximate boundaries of this OpenSCAD object
|
/// 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>
|
/// <returns></returns>
|
||||||
public override Bounds Bounds()
|
public override Bounds Bounds()
|
||||||
{
|
{
|
||||||
double fontSize = this.Size ?? 8;
|
throw new NotSupportedException("Bounds are not supported for objects using Text3D");
|
||||||
double xAmount = fontSize * this.Text.Length;
|
|
||||||
|
|
||||||
return new Bounds(new Vector3(-xAmount/2, -fontSize/2, -.5), new Vector3(xAmount / 2, fontSize / 2, .5));
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user