Coplanar surfaces: Boolean vs Planar for union, difference and intersect

(This thread was inspired by a posts 39 and 42 in Bug: Boolean Difference creates weird Boolean Union instead - #39 by encephalon)

For coplanar surfaces PlanarUnion, PlanarDifference and PlanarIntersect return the results which most user would expect. These results are consistent with the usual definitions of Boolean operations in a 2D space.

In contrast for coplanar surfaces BooleanUnion, BooleanDifference and BooleanIntersect return results which few users would expect. It is difficult to envision when a user might be expecting these results nor how these results could be consistent with the usual definitions of Boolean operations in a 2D space.

This very unusual behavior of BooleanUnion, BooleanDifference and BooleanIntersect

Recommendation: Disable the Boolean commands when the input is only coplanar surfaces. PlanarUnion, PlanarDifference and PlanarIntersect provide the expected functionality. The Boolean commands appear to currently always fail when used with non-planar open surfaces as the input (no solids). Retain the Boolean commands working when the input is a mixture of open surfaces and solids.

Simple example: [PlanarVsBoolDC01.3dm|attachment] Version 7 SR26 (7.26.22343.17001, 2022-12-09)(upload://q8o6akgmb8nvtsGnpuC2TbDUL30.3dm) (2.8 MB)

Well, I might suggest to simply try to detect the presence of only coplanar surfaces when the standard BooleanDiference operation is called, and if so, execute the code for PlanarDifference instead. However…

Right now PlanarDifference and PlanarIntersect only work on one pair of surfaces. They do not allow multiple surface inputs for either side of the equation. That needs to be fixed IMO.

2 Likes

This would work for me.

hi @davidcockey thanks for posting. I created a YT for this but it’s not public RH-72034

@davidcockey merging the Boolean commands into one seems to have its downsides. I therefore created RH-72076 Regular Boolean operations should be disabled when input is just Planar Surfaces

1 Like

@Gijs Thanks for the follow-up.

why? i think booleans are just one. it should always work on two sets and on all types of geometry (crv, mesh, nurbs, subd). prove me wrong

@Juan_Gallo our dev mentioned this has been considered but since for planar booleans other rules and optimizations apply it is not feasible to combine the commands.

I actually have some scripts that can help here, but they were originally made for curves. I am in the process of converting a couple of them to use with surfaces, but I was traveling for 6 days and seem to have caught something (not COVID) while there and am only working at about 10% right now. Hopefully better in a couple of days - but then it will be Xmas.

My guess is the planar booleans share algorithms with CurveBoolean. Algorithms for boolean operations on closed planar curves are much simpler than algorithms for equivalent operations on arbitrary surfaceds.

A strategy for the planar booleans would be to extract the boundary curves of the input surfaces, use the algorithms, and then use the resulting boundary curve to create a new surface, trimmed if needed. I don’t know if this is how the planar boolean commands actually work.

Partially. The Rhino surface planar (Brep) Booleans are basically calling these methods in RhinoCommon:


Both difference and intersection can only take interactions between two individual surfaces - the Rhino functions are the same.

The curve equivalent has more possibilities - notably that of being able to have multipe inputs for at least one of the sets, and the “CreateRegions” possibility which is used by CurveBoolean.

Region creation for surfaces (Breps) also exists with GetRegions but the possibilities seem a bit more limited. I’m sure the native Rhino PlanarBoolean commands will eventually catch up with their solid counterparts.

So I finally managed to get some stuff ready for testing. I was plagued by some weird inconsistency in the results and I finally had to resort to an odd workaround to make it more reliable.

Here are a couple of scripts to test if you want:

PlanarSrfBooleanDifference.py (8.3 KB)
PlanarSrfBooleanIntersection.py (8.3 KB)

The difference between these is that unlike PlanarDifference and PlanarIntersection which allow you to only select two single surfaces, these allow you to select two sets, much like the normal BooleanDifference and BooleanIntersection commands. In fact, all it does is actually extrude the surfaces and do a volume Boolean difference/intersection and then re-extract the resulting surfaces that are in the original plane.

FWIW - I would hope that in the future PlanarDifference and PlanarIntersection will allow sets of objects to be used like this.

1 Like

Hi Mitch -

Thanks, we have these on the list as
RH-60378 Make PlanarDifference able to handle more than two objects
RH-60379 Make PlanarIntersection able to handle more than two objects
-wim