diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
index 024607b..650ae6b 100644
--- a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
+++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
@@ -13,15 +13,15 @@ namespace OSCADSharp.ConsoleTests
{
static void Main(string[] args)
{
- var cube = new Cube(13, 13, 13).Rotate(90, 37.5, -180);
+ var obj = new Text3D("Hello, it's Meeeee.");
- var pos = cube.Position();
+ 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 = cube.Union(axisHelper).ToString();
+ string script = obj.Union(axisHelper).ToString();
File.WriteAllLines("test.scad", new string[] { script.ToString() });
//Console.ReadKey();
diff --git a/OSCADSharp/OSCADSharp.UnitTests/CylinderTests.cs b/OSCADSharp/OSCADSharp.UnitTests/CylinderTests.cs
index ff3f83b..78396c5 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/CylinderTests.cs
+++ b/OSCADSharp/OSCADSharp.UnitTests/CylinderTests.cs
@@ -23,5 +23,21 @@ namespace OSCADSharp.UnitTests
Assert.IsTrue(script.Contains("h = 12.1"));
Assert.IsTrue(script.Contains("center = true"));
}
+
+ [TestMethod]
+ public void Cylinder_UncenteredPositionZValueIsHalfTheHeight()
+ {
+ var cylinder = new Cylinder(3, 40);
+
+ Assert.AreEqual(new Vector3(0, 0, 20), cylinder.Position());
+ }
+
+ [TestMethod]
+ public void Cylinder_CenteredCylinderPositionIsZero()
+ {
+ var cylinder = new Cylinder(5, 20, true);
+
+ Assert.AreEqual(new Vector3(), cylinder.Position());
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj b/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj
index bdc0d30..6822582 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj
+++ b/OSCADSharp/OSCADSharp.UnitTests/OSCADSharp.UnitTests.csproj
@@ -59,6 +59,7 @@
+
diff --git a/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs b/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs
index 292fe69..1e87047 100644
--- a/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs
+++ b/OSCADSharp/OSCADSharp.UnitTests/SphereTests.cs
@@ -69,5 +69,13 @@ namespace OSCADSharp.UnitTests
Assert.IsTrue(sphere.IsSameAs(clone));
}
+
+ [TestMethod]
+ public void Sphere_PositionIsAtZero()
+ {
+ var sphere = new Sphere();
+
+ Assert.AreEqual(new Vector3(), sphere.Position());
+ }
}
}
diff --git a/OSCADSharp/OSCADSharp.UnitTests/Text3DTests.cs b/OSCADSharp/OSCADSharp.UnitTests/Text3DTests.cs
new file mode 100644
index 0000000..e8ebcf3
--- /dev/null
+++ b/OSCADSharp/OSCADSharp.UnitTests/Text3DTests.cs
@@ -0,0 +1,22 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using OSCADSharp.Solids;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSCADSharp.UnitTests
+{
+ [TestClass]
+ public class Text3DTests
+ {
+ [TestMethod]
+ public void Text_PositionIsCentered()
+ {
+ var text = new Text3D("Bom chicka bow wow");
+
+ Assert.AreEqual(new Vector3(), text.Position());
+ }
+ }
+}
diff --git a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
index cd64f00..aaf6899 100644
--- a/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Cylinder.cs
@@ -140,7 +140,17 @@ namespace OSCADSharp.Solids
public override Vector3 Position()
{
- throw new NotImplementedException();
+ Vector3 position;
+ if (this.Center == false)
+ {
+ position = new Vector3(0, 0, this.Height / 2);
+ }
+ else
+ {
+ position = new Vector3();
+ }
+
+ return position;
}
#endregion
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Sphere.cs b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
index c397449..6316efc 100644
--- a/OSCADSharp/OSCADSharp/Solids/Sphere.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Sphere.cs
@@ -83,7 +83,7 @@ namespace OSCADSharp.Solids
public override Vector3 Position()
{
- throw new NotImplementedException();
+ return new Vector3();
}
#endregion
}
diff --git a/OSCADSharp/OSCADSharp/Solids/Text3D.cs b/OSCADSharp/OSCADSharp/Solids/Text3D.cs
index 18fd767..1468921 100644
--- a/OSCADSharp/OSCADSharp/Solids/Text3D.cs
+++ b/OSCADSharp/OSCADSharp/Solids/Text3D.cs
@@ -116,6 +116,11 @@ namespace OSCADSharp.Solids
sb.Append("\"");
appendIfValueNotNullOrEmpty("size", this.Size?.ToString(), sb);
+ // Text is always centered in OSCADSharp to ensure correctness of
+ // position interpolation
+ appendIfValueNotNullOrEmpty("halign", "\"center\"", sb);
+ appendIfValueNotNullOrEmpty("valign", "\"center\"", sb);
+
appendIfValueNotNullOrEmpty("font", this.Font, sb);
appendIfValueNotNullOrEmpty("spacing", this.Spacing?.ToString(), sb);
appendIfValueNotNullOrEmpty("direction", this.TextDirection?.ToString(), sb);
@@ -127,9 +132,16 @@ namespace OSCADSharp.Solids
return formatter.ToString();
}
+ ///
+ /// In reaction to the need for this value to be correct, halign and valign will always
+ /// be "center" by default, since non-centered text would vary dramatically in position based upon
+ /// the font of the text
+ /// - MLS 2/15/2016
+ ///
+ ///
public override Vector3 Position()
{
- throw new NotImplementedException();
+ return new Vector3();
}
#endregion
}