Skip to content

Commit

Permalink
fix: update auto-detect plane when input (A) is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
arendvw committed Oct 12, 2021
1 parent 542fac0 commit 774d2c4
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion ClipperComponents/BooleanComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
Expand Down Expand Up @@ -78,11 +79,43 @@ protected override void SolveInstance(IGH_DataAccess da)
var polylinesA = Polyline3D.ConvertCurvesToPolyline(curvesA).ToList();
var polylinesB = Polyline3D.ConvertCurvesToPolyline(curvesB).ToList();

// Further tests:
// if (polylinesA.Count == 0 && (type == ClipType.ctIntersection || type == ClipType.ctDifference))
// {
// da.SetDataList("Result", new List<Polyline> ());
// return;
// }
//
// if (polylinesA.Count == 0 && (type == ClipType.ctXor || type == ClipType.ctUnion))
// {
// da.SetDataList("Result", polylinesB);
// return;
// }
//
// if (polylinesB.Count == 0 && (type == ClipType.ctIntersection || type == ClipType.ctDifference))
// {
// da.SetDataList("Result", new List<Polyline>());
// return;
// }


// If we don't have a plane, let's try to create a plane from the first curve.
if (pln.Equals(default) || !pln.IsValid)
{
// ReSharper disable once PossibleMultipleEnumeration
pln = polylinesA.First().FitPlane();
if (polylinesA.Count != 0)
{
pln = polylinesA.First().FitPlane();
} else if (polylinesB.Count != 0)
{
pln = polylinesB.First().FitPlane();
}
else
{
// both are empty..
da.SetDataList("Result", new List<Polyline>());
return;
}
}

// do the boolean operation
Expand Down

0 comments on commit 774d2c4

Please sign in to comment.