mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-13 06:28:35 +00:00
+ Updated Difference's Position() behavior to return the position of the first child (object being differenced)
This commit is contained in:
parent
69a739c12f
commit
1bd6ad3543
@ -13,19 +13,15 @@ namespace OSCADSharp.ConsoleTests
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//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);
|
||||
|
||||
var obj = new Cube() + new Sphere() + new Sphere().Translate(2, 2, 2) - new Cylinder(2, 5) + new Text3D("Hey hey!");
|
||||
|
||||
//var pos = obj.Position();
|
||||
//var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
||||
//var cyl2 = new Cylinder(1, 100, true).Rotate(0, 90, 0).Translate(pos);
|
||||
//var cyl3 = new Cylinder(1, 100, true).Rotate(90, 0, 0).Translate(pos);
|
||||
//var axisHelper = cyl1.Union(cyl2, cyl3).Color("Red");
|
||||
var pos = obj.Position();
|
||||
var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
||||
var cyl2 = new Cylinder(1, 100, true).Rotate(0, 90, 0).Translate(pos);
|
||||
var cyl3 = new Cylinder(1, 100, true).Rotate(90, 0, 0).Translate(pos);
|
||||
var axisHelper = cyl1.Union(cyl2, cyl3).Color("Red");
|
||||
|
||||
string script = obj.ToString(); //obj.Union(axisHelper).ToString();
|
||||
string script = obj.Union(axisHelper).ToString();
|
||||
|
||||
File.WriteAllLines("test.scad", new string[] { script.ToString() });
|
||||
//Console.ReadKey();
|
||||
|
||||
@ -8,13 +8,21 @@ namespace OSCADSharp.UnitTests
|
||||
[TestClass]
|
||||
public class DifferenceTests
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(NotSupportedException))]
|
||||
public void Difference_PositionThrowsNotSupportedException()
|
||||
/// <summary>
|
||||
/// Note: The decision that Difference should yield the position of the
|
||||
/// first child stems from the common use case of using Difference to bore out
|
||||
/// holes for pegs, screws, supports, etc. It's often used in such a way that
|
||||
/// the overall structure of the object being differenced is not greatly affected,
|
||||
/// thus the position should not change.
|
||||
/// -MLS 2/17/2016
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void Difference_PositionYieldsPositionOfFirstChild()
|
||||
{
|
||||
var diff = new Sphere().Difference(new Cube());
|
||||
var sphere = new Sphere().Translate(.25, .25, 1);
|
||||
var diff = sphere.Difference(new Cube());
|
||||
|
||||
var pos = diff.Position();
|
||||
Assert.AreEqual(sphere.Position(), diff.Position());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@ -22,7 +22,7 @@ namespace OSCADSharp.Booleans
|
||||
|
||||
public override Vector3 Position()
|
||||
{
|
||||
throw new NotSupportedException("Position is not supported on Differenced objects.");
|
||||
return children[0].Position();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user