Overlapping Offsets

Another offset-question: I have a tree of multiple offsetted polygons (file attached). The offsets are irregular. That means there are sides that are offsetted by a different distance. E.g. “0” → No offset. Therefore I´m not using normal offset-components such as Clipper. As you can see in the images the offsets start overlapping when the offset-distance becomes bigger. I´ve tried a bunch of methods to remove those “wrong” offsets:

A) By area: Remove small offsets: Doesn´t work because the size of the input-geometry can be very small or very big.

B) By edge-length: Remove offset-segments that are below a certain length: Doesn´t work because “wrong” offsets can have high lengths as well.

C) By edge-amount: Remove those offsets whos segment-count does not equal the “parent” polygon: Doesn´t work because a wrong offset can have the same amount of segments as its parent.

D) By polygon-center: Keep only the polygons that surround the centeroid of the parent-polygon: Doesn´t work because correct offsets might not enclose the parent-centeroid.

I think a good approach would be to remove offsets that intersect with other offsets. But I can´t manage the tree-structure :confused: Help! Thanks in advance.

overlap_01.gh (20.2 KB)

Did you try with the winding direxction, if polygon is Clockwise and the offset Anti-clockwise you remove the offset.

Clipper is doing that for polygons, depending if it is an exterior or a hole the winding direction is not the same.
http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Types/PolyFillType.htm

I see in your example there is already the offsets that are cutted. Bad news the orientation is quite always the same. You must improve this and split the self intersecting curve and keeping the original direction. So you could them calculate the good winding direction and then cull the “bad” curves.

1 Like

Thanks for your fast response.

As you added to your answer: My polygons are all in the same direction. I´m using fennecs “Region” component to “cut” the offsets. How would you cut the offsets in order to correct the winding? That´s my definition:


overlap_02.gh (53.2 KB)

OK if you begin with a good topology.
What I understand from your tool is that.
For a polyline all segments have a factor of offset (0 to offset distance)
With that you make a new polyline.
You have to find the self intersection
Cut the curves at the self intersection and make N polygons
Calculate the winding of the polygon
Just keep the good winding polygons

I think you must do all the steps in your own program (Python C# …) in order to be sure to keep tracks of the good orientation. It is not clear how you manage to do that.

1 Like

Exact. It´s also not clear to me how I manage to do that :smiley: I mean I`m quiet close to what I want. Rewritting all operations is no option for me. What do you think about the method of removing offsets that simply intersect others? Correct offsets do not intersect with others - Wrong ones do. So that might be a way to cull the wrong ones? Thx.

Yes this recursive way of doing could work for you. You will surely have some problems for curves that overlaps (0 offset segment). You could surely filter by type of intersection (overlap or intersection).
https://developer.rhino3d.com/api/RhinoCommon/html/Properties_T_Rhino_Geometry_Intersect_IntersectionEvent.htm

it will not work there !!

Hello,

I went in a completely different direction, it works for these cases but may not for others.
The idea is to create planes from the initial polyline (one per segment), offset these planes accordingly (1 or 0), split the surface and retrieve the only piece of surface that is “inside” all the planes.

I made all efforts to remove custom plugins that would have made some operations significantly easier, but I’m still using Elefront’s Graft Parallel at some point.

overlap_01.gh (32.0 KB)

2 Likes

I´m going insane! Why is it so hard to build a robust algorithm :expressionless: Does the triangle not intersect on the top edge with another polygon? But I agree in this case the decission has to be done which offset is the correct one :frowning:

Maybe one could find the “first” bad offset and cull all the upcomings…

Good solution for Concave polygons.

Offset is not a so simple problem, you may know this discussion

You mean convex polygons, but I agree, so this is not a general solution but hopefully enough for this case.

I tried to remove curves based on their intersections with the previous curve (test if curve N intersects N+1, get all True statements and cut the list at the first occurence of True), but this fails for polygons where one edge is not offsetted.

2 Likes

My bad.

It is why I think Rhincommon could be used because Intersection could be a point or an overlap. I don’t know if a Grasshopper component was done to mimic this.

1 Like

It gives me exactly what I want. My polygons will only be convex so this is quiet an awesome solution. I certainly have to study and understand this definition. You guys are amazing.

Is there a method for concave polygons as well? Thanks!

The generic answer is probably no, unfortunately.

I tried something but this quite crazy. I split the concave region into convex regions using bisectors at concave points. Then use the script above to compute the paths for each convex region, assuming a 0mm offset along the bisector. Then merge the polylines by removing the overlapping segments…

A sample file with a concave curve would be appreciated to further test this strategy.

OffsetConcave.gh (46.6 KB)

And with my beloved Graft Parallel to the rescue in case there are several curves and/or several bisectors per curve…

OffsetConcave.gh (48.0 KB)

Thanks Magicteddy, I´ve also tried to “convert” the concave polygon into a convex one first using the convex decompose plugin: Convex Decompose - Box2D - Component for Grasshopper | Grasshopper Docs

Unfortunately this “random” segmentation is not suitable for me since I´m dealing with real-world geometry (buildings and properties). Does your definition take the “irregular” offset into account? E.g. one side should not be offseted at all?

You asked for a sample file (Thats rhino-only):

test.3dm (32.7 KB)

Your definition doesn´t work for this polygon :frowning: The provided polygon resembles the outline of a real-world-property. I want to generate an offsets to each side. Some sides might have different offset-values than others.

It could, but I was absolutely not ready for such a nightmare…
What is the offset value ? 1 ? That would give billions of polylines…

1 Like

I think I solved this problem: The aim was to create mulitple offsets of multiple polygons that
A) Are irregular meaning that some sides of the offsets had a offset distance of 0 m.
B) Work for concave and convex polygons.
C) Would not create “overlapping polygons” if the offset distance became to high.

To achieve this I created a “previous offset” meaning that I´ve moved sides that should have a 0 m-offset outwards by a high value. Then I used the clippr plugin to offset all polygons by multiple values (no overlaps (C) ). Then I trimmed all offsets by the polygon outline. This would create the 0-m-offsets where needed (A). This works for concave polygons as well (B).

1 Like

Nice solution !

The offsets have been reworked on Rhino 8. Haven’t tested on my side, but it should remove the necessity for Clipper.

1 Like