mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
Shifted all booleans to OSCADObject.Booleans and made them private
This commit is contained in:
parent
8c53176d38
commit
5c0faaf469
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Subtracts the 2nd (and all further) child nodes from the first one (logical and not).
|
||||
/// </summary>
|
||||
internal class Difference : MultiStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a subtraction of child nodes
|
||||
/// </summary>
|
||||
/// <param name="children"></param>
|
||||
internal Difference(IEnumerable<OSCADObject> children) : base("difference()", children)
|
||||
{
|
||||
}
|
||||
|
||||
public override Vector3 Position()
|
||||
{
|
||||
return m_children[0].Position();
|
||||
}
|
||||
|
||||
public override Bounds Bounds()
|
||||
{
|
||||
return m_children[0].Bounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes
|
||||
/// </summary>
|
||||
internal class Intersection : MultiStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes
|
||||
/// </summary>
|
||||
/// <param name="children"></param>
|
||||
internal Intersection(IEnumerable<OSCADObject> 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
80
OSCADSharp/OSCADSharp/OSCADObject.Booleans.cs
Normal file
80
OSCADSharp/OSCADSharp/OSCADObject.Booleans.cs
Normal file
@ -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
|
||||
/// <summary>
|
||||
/// Subtracts the 2nd (and all further) child nodes from the first one (logical and not).
|
||||
/// </summary>
|
||||
private class DifferencedObject : MultiStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a subtraction of child nodes
|
||||
/// </summary>
|
||||
/// <param name="children"></param>
|
||||
internal DifferencedObject(IEnumerable<OSCADObject> 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
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes
|
||||
/// </summary>
|
||||
private class IntersectedObject : MultiStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes
|
||||
/// </summary>
|
||||
/// <param name="children"></param>
|
||||
internal IntersectedObject(IEnumerable<OSCADObject> 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
|
||||
/// <summary>
|
||||
/// A union of child nodes. This is the sum of all children (logical or).
|
||||
/// </summary>
|
||||
private class UnionedObject : MultiStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a union that is the combination of all children
|
||||
/// </summary>
|
||||
/// <param name="children">OSCADObjects to combine</param>
|
||||
internal UnionedObject(IEnumerable<OSCADObject> children) : base("union()", children)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -685,7 +685,7 @@ namespace OSCADSharp
|
||||
/// <returns></returns>
|
||||
public OSCADObject Union(params OSCADObject[] objects)
|
||||
{
|
||||
return doBlockStatement("Union", objects, (children) => { return new Union(children); });
|
||||
return doBlockStatement("Union", objects, (children) => { return new UnionedObject(children); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -696,7 +696,7 @@ namespace OSCADSharp
|
||||
/// <returns></returns>
|
||||
public OSCADObject Difference(params OSCADObject[] objects)
|
||||
{
|
||||
return doBlockStatement("Difference", objects, (children) => { return new Difference(children); });
|
||||
return doBlockStatement("Difference", objects, (children) => { return new DifferencedObject(children); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -708,7 +708,7 @@ namespace OSCADSharp
|
||||
/// <returns></returns>
|
||||
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<IEnumerable<OSCADObject>, OSCADObject> factory)
|
||||
@ -868,19 +868,19 @@ namespace OSCADSharp
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// <returns></returns>
|
||||
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
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
<Compile Include="DataBinding\VariableCalculator.cs" />
|
||||
<Compile Include="DataBinding\CompoundVariable.cs" />
|
||||
<Compile Include="OSCADObject.BasicTransforms.cs" />
|
||||
<Compile Include="OSCADObject.Booleans.cs" />
|
||||
<Compile Include="Utility\Dependencies.cs" />
|
||||
<Compile Include="IO\DefaultFileInvoker.cs" />
|
||||
<Compile Include="IO\DefaultFileWriter.cs" />
|
||||
@ -66,9 +67,6 @@
|
||||
<Compile Include="HulledObject.cs" />
|
||||
<Compile Include="Utility\SingleBlockFormatter.cs" />
|
||||
<Compile Include="MultiStatementObject.cs" />
|
||||
<Compile Include="Difference.cs" />
|
||||
<Compile Include="Intersection.cs" />
|
||||
<Compile Include="Union.cs" />
|
||||
<Compile Include="OSCADObject.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Solids\Cube.cs" />
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OSCADSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A union of child nodes. This is the sum of all children (logical or).
|
||||
/// </summary>
|
||||
internal class Union : MultiStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a union that is the combination of all children
|
||||
/// </summary>
|
||||
/// <param name="children">OSCADObjects to combine</param>
|
||||
internal Union(IEnumerable<OSCADObject> children) : base("union()", children)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user