diff --git a/OSCADSharp/OSCADSharp/Difference.cs b/OSCADSharp/OSCADSharp/Difference.cs deleted file mode 100644 index 8542ab7..0000000 --- a/OSCADSharp/OSCADSharp/Difference.cs +++ /dev/null @@ -1,33 +0,0 @@ -using OSCADSharp.Spatial; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace OSCADSharp -{ - /// - /// Subtracts the 2nd (and all further) child nodes from the first one (logical and not). - /// - internal class Difference : MultiStatementObject - { - /// - /// Creates a subtraction of child nodes - /// - /// - internal Difference(IEnumerable children) : base("difference()", children) - { - } - - public override Vector3 Position() - { - return m_children[0].Position(); - } - - public override Bounds Bounds() - { - return m_children[0].Bounds(); - } - } -} diff --git a/OSCADSharp/OSCADSharp/Intersection.cs b/OSCADSharp/OSCADSharp/Intersection.cs deleted file mode 100644 index daad434..0000000 --- a/OSCADSharp/OSCADSharp/Intersection.cs +++ /dev/null @@ -1,33 +0,0 @@ -using OSCADSharp.Spatial; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace OSCADSharp -{ - /// - /// Creates the intersection of all child nodes - /// - internal class Intersection : MultiStatementObject - { - /// - /// Creates the intersection of all child nodes - /// - /// - internal Intersection(IEnumerable children) : base("intersection()", children) - { - } - - public override Vector3 Position() - { - throw new NotSupportedException("Position is not supported on Intersected objects."); - } - - public override Bounds Bounds() - { - throw new NotSupportedException("Bounds is not supported on Intersected objects."); - } - } -} diff --git a/OSCADSharp/OSCADSharp/OSCADObject.Booleans.cs b/OSCADSharp/OSCADSharp/OSCADObject.Booleans.cs new file mode 100644 index 0000000..3f66fca --- /dev/null +++ b/OSCADSharp/OSCADSharp/OSCADObject.Booleans.cs @@ -0,0 +1,80 @@ +using OSCADSharp.Spatial; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OSCADSharp +{ + public abstract partial class OSCADObject + { + #region Difference + /// + /// Subtracts the 2nd (and all further) child nodes from the first one (logical and not). + /// + private class DifferencedObject : MultiStatementObject + { + /// + /// Creates a subtraction of child nodes + /// + /// + internal DifferencedObject(IEnumerable children) : base("difference()", children) + { + } + + public override Vector3 Position() + { + return m_children[0].Position(); + } + + public override Bounds Bounds() + { + return m_children[0].Bounds(); + } + } + #endregion + + #region Intersection + /// + /// Creates the intersection of all child nodes + /// + private class IntersectedObject : MultiStatementObject + { + /// + /// Creates the intersection of all child nodes + /// + /// + internal IntersectedObject(IEnumerable children) : base("intersection()", children) + { + } + + public override Vector3 Position() + { + throw new NotSupportedException("Position is not supported on Intersected objects."); + } + + public override Bounds Bounds() + { + throw new NotSupportedException("Bounds is not supported on Intersected objects."); + } + } + #endregion + + #region Union + /// + /// A union of child nodes. This is the sum of all children (logical or). + /// + private class UnionedObject : MultiStatementObject + { + /// + /// Create a union that is the combination of all children + /// + /// OSCADObjects to combine + internal UnionedObject(IEnumerable children) : base("union()", children) + { + } + } + #endregion + } +} diff --git a/OSCADSharp/OSCADSharp/OSCADObject.cs b/OSCADSharp/OSCADSharp/OSCADObject.cs index 4d4253d..2433867 100644 --- a/OSCADSharp/OSCADSharp/OSCADObject.cs +++ b/OSCADSharp/OSCADSharp/OSCADObject.cs @@ -685,7 +685,7 @@ namespace OSCADSharp /// public OSCADObject Union(params OSCADObject[] objects) { - return doBlockStatement("Union", objects, (children) => { return new Union(children); }); + return doBlockStatement("Union", objects, (children) => { return new UnionedObject(children); }); } /// @@ -696,7 +696,7 @@ namespace OSCADSharp /// public OSCADObject Difference(params OSCADObject[] objects) { - return doBlockStatement("Difference", objects, (children) => { return new Difference(children); }); + return doBlockStatement("Difference", objects, (children) => { return new DifferencedObject(children); }); } /// @@ -708,7 +708,7 @@ namespace OSCADSharp /// public OSCADObject Intersection(params OSCADObject[] objects) { - return doBlockStatement("Intersection", objects, (children) => { return new Intersection(children); }); + return doBlockStatement("Intersection", objects, (children) => { return new IntersectedObject(children); }); } private OSCADObject doBlockStatement(string name, OSCADObject[] objects, Func, OSCADObject> factory) @@ -868,19 +868,19 @@ namespace OSCADSharp /// public static OSCADObject operator +(OSCADObject left, OSCADObject right) { - if(left.GetType() == typeof(Union)) + if(left.GetType() == typeof(UnionedObject)) { left.m_children.Add(right); return left; } - else if(right.GetType() == typeof(Union)) + else if(right.GetType() == typeof(UnionedObject)) { right.m_children.Add(left); return right; } else { - return new Union(new OSCADObject[] {left, right }); + return new UnionedObject(new OSCADObject[] {left, right }); } } @@ -892,19 +892,19 @@ namespace OSCADSharp /// public static OSCADObject operator -(OSCADObject left, OSCADObject right) { - if (left.GetType() == typeof(Difference)) + if (left.GetType() == typeof(DifferencedObject)) { left.m_children.Add(right); return left; } - else if (right.GetType() == typeof(Difference)) + else if (right.GetType() == typeof(DifferencedObject)) { right.m_children.Add(left); return right; } else { - return new Difference(new OSCADObject[] {left, right }); + return new DifferencedObject(new OSCADObject[] {left, right }); } } #endregion diff --git a/OSCADSharp/OSCADSharp/OSCADSharp.csproj b/OSCADSharp/OSCADSharp/OSCADSharp.csproj index 438a985..1079d67 100644 --- a/OSCADSharp/OSCADSharp/OSCADSharp.csproj +++ b/OSCADSharp/OSCADSharp/OSCADSharp.csproj @@ -46,6 +46,7 @@ + @@ -66,9 +67,6 @@ - - - diff --git a/OSCADSharp/OSCADSharp/Union.cs b/OSCADSharp/OSCADSharp/Union.cs deleted file mode 100644 index 9f5682e..0000000 --- a/OSCADSharp/OSCADSharp/Union.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace OSCADSharp -{ - /// - /// A union of child nodes. This is the sum of all children (logical or). - /// - internal class Union : MultiStatementObject - { - /// - /// Create a union that is the combination of all children - /// - /// OSCADObjects to combine - internal Union(IEnumerable children) : base("union()", children) - { - } - } -}