mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
Added Intersection boolean operation
This commit is contained in:
parent
9ccf494e81
commit
8435737df5
@ -31,7 +31,7 @@ namespace OSCADSharp.ConsoleTests
|
||||
Height = 50.8
|
||||
}.Translate(10, 5, 2);
|
||||
|
||||
var combined = cube.Difference(cylinder);
|
||||
var combined = cube.Intersection(cylinder);
|
||||
|
||||
Console.WriteLine(combined.ToString());
|
||||
Console.ReadKey();
|
||||
|
||||
22
OSCADSharp/OSCADSharp/Booleans/Intersection.cs
Normal file
22
OSCADSharp/OSCADSharp/Booleans/Intersection.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OSCADSharp.Booleans
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes
|
||||
/// </summary>
|
||||
internal class Intersection : BlockStatementObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes
|
||||
/// </summary>
|
||||
/// <param name="children"></param>
|
||||
public Intersection(IEnumerable<OSCADObject> children) : base("intersection()", children)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,11 +147,29 @@ namespace OSCADSharp
|
||||
return doBoolean("Union", objects, (children) => { return new Union(children); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts the 2nd (and all further) child nodes from the first one (logical and not).
|
||||
/// May be used with either 2D or 3D objects, but don't mix them.
|
||||
/// </summary>
|
||||
/// <param name="objects">child nodes</param>
|
||||
/// <returns></returns>
|
||||
public OSCADObject Difference(params OSCADObject[] objects)
|
||||
{
|
||||
return doBoolean("Difference", objects, (children) => { return new Difference(children); });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates the intersection of all child nodes. This keeps the overlapping portion (logical and).
|
||||
/// Only the area which is common or shared by all children is retained.
|
||||
/// May be used with either 2D or 3D objects, but don't mix them.
|
||||
/// </summary>
|
||||
/// <param name="objects">child nodes</param>
|
||||
/// <returns></returns>
|
||||
public OSCADObject Intersection(params OSCADObject[] objects)
|
||||
{
|
||||
return doBoolean("Intersection", objects, (children) => { return new Intersection(children); });
|
||||
}
|
||||
|
||||
private OSCADObject doBoolean(string name, OSCADObject[] objects, Func<IEnumerable<OSCADObject>, OSCADObject> factory)
|
||||
{
|
||||
if (objects == null || objects.Length < 1)
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
<Compile Include="BlockFormatter.cs" />
|
||||
<Compile Include="BlockStatementObject.cs" />
|
||||
<Compile Include="Booleans\Difference.cs" />
|
||||
<Compile Include="Booleans\Intersection.cs" />
|
||||
<Compile Include="Booleans\Union.cs" />
|
||||
<Compile Include="OSCADObject.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user