Skip to content

Commit 774d2c4

Browse files
committed
fix: update auto-detect plane when input (A) is empty
1 parent 542fac0 commit 774d2c4

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

ClipperComponents/BooleanComponent.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Drawing;
34
using System.Linq;
45
using System.Windows.Forms;
@@ -78,11 +79,43 @@ protected override void SolveInstance(IGH_DataAccess da)
7879
var polylinesA = Polyline3D.ConvertCurvesToPolyline(curvesA).ToList();
7980
var polylinesB = Polyline3D.ConvertCurvesToPolyline(curvesB).ToList();
8081

82+
// Further tests:
83+
// if (polylinesA.Count == 0 && (type == ClipType.ctIntersection || type == ClipType.ctDifference))
84+
// {
85+
// da.SetDataList("Result", new List<Polyline> ());
86+
// return;
87+
// }
88+
//
89+
// if (polylinesA.Count == 0 && (type == ClipType.ctXor || type == ClipType.ctUnion))
90+
// {
91+
// da.SetDataList("Result", polylinesB);
92+
// return;
93+
// }
94+
//
95+
// if (polylinesB.Count == 0 && (type == ClipType.ctIntersection || type == ClipType.ctDifference))
96+
// {
97+
// da.SetDataList("Result", new List<Polyline>());
98+
// return;
99+
// }
100+
101+
81102
// If we don't have a plane, let's try to create a plane from the first curve.
82103
if (pln.Equals(default) || !pln.IsValid)
83104
{
84105
// ReSharper disable once PossibleMultipleEnumeration
85-
pln = polylinesA.First().FitPlane();
106+
if (polylinesA.Count != 0)
107+
{
108+
pln = polylinesA.First().FitPlane();
109+
} else if (polylinesB.Count != 0)
110+
{
111+
pln = polylinesB.First().FitPlane();
112+
}
113+
else
114+
{
115+
// both are empty..
116+
da.SetDataList("Result", new List<Polyline>());
117+
return;
118+
}
86119
}
87120

88121
// do the boolean operation

0 commit comments

Comments
 (0)