diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
index fcf0791..be3eea2 100644
--- a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
+++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
@@ -31,7 +31,7 @@ namespace OSCADSharp.ConsoleTests
Height = 50.8
}.Translate(10, 5, 2);
- var combined = cube.Union(cylinder);
+ var combined = cube.Difference(cylinder);
Console.WriteLine(combined.ToString());
Console.ReadKey();
diff --git a/OSCADSharp/OSCADSharp/Booleans/Difference.cs b/OSCADSharp/OSCADSharp/Booleans/Difference.cs
new file mode 100644
index 0000000..363fec8
--- /dev/null
+++ b/OSCADSharp/OSCADSharp/Booleans/Difference.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSCADSharp.Booleans
+{
+ ///
+ /// Subtracts the 2nd (and all further) child nodes from the first one (logical and not).
+ ///
+ internal class Difference : BlockStatementObject
+ {
+ ///
+ /// Creates a subtraction of child nodes
+ ///
+ ///
+ public Difference(IEnumerable children) : base("difference()", children)
+ {
+ }
+ }
+}
diff --git a/OSCADSharp/OSCADSharp/OSCADObject.cs b/OSCADSharp/OSCADSharp/OSCADObject.cs
index 6ba8083..a74fd5d 100644
--- a/OSCADSharp/OSCADSharp/OSCADObject.cs
+++ b/OSCADSharp/OSCADSharp/OSCADObject.cs
@@ -136,16 +136,32 @@ namespace OSCADSharp
#endregion
#region Boolean Operations
+ ///
+ /// Creates a union of all its child nodes. This is the sum of all children (logical or).
+ /// May be used with either 2D or 3D objects, but don't mix them.
+ ///
+ /// child nodes
+ ///
public OSCADObject Union(params OSCADObject[] objects)
+ {
+ return doBoolean("Union", objects, (children) => { return new Union(children); });
+ }
+
+ public OSCADObject Difference(params OSCADObject[] objects)
+ {
+ return doBoolean("Difference", objects, (children) => { return new Difference(children); });
+ }
+
+ private OSCADObject doBoolean(string name, OSCADObject[] objects, Func, OSCADObject> factory)
{
if (objects == null || objects.Length < 1)
{
- throw new ArgumentException("Union requires at least one non-null entities");
+ throw new ArgumentException(name + " requires at least one non-null entities");
}
IEnumerable children = new List() { this };
children = children.Concat(objects);
- return new Union(children);
+ return factory(children);
}
#endregion
}
diff --git a/OSCADSharp/OSCADSharp/OSCADSharp.csproj b/OSCADSharp/OSCADSharp/OSCADSharp.csproj
index f84b9c2..47ffa97 100644
--- a/OSCADSharp/OSCADSharp/OSCADSharp.csproj
+++ b/OSCADSharp/OSCADSharp/OSCADSharp.csproj
@@ -42,6 +42,7 @@
+