Clipper "Offset Polyline" rematch indices

Hi, just notice that after applying Clipper’s “Offset Polyline” the index order doesn’t align with starting list. Just a heads up for those using it in future usages :wink:
Clipper.gh (33.0 KB)

Use Graft and Flatten

Yeah, I know. (in which case you loose the option to get that nice contour polyline)
Also as a noticed that the curves get flipped (which could be an issue when making srf’s and wanting the get orientation (for normal maps for instance, they are flipped)).


Clipper2.gh (38.4 KB)

For Clipper there is an orientation for boundary and inverted for holes
http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Functions/Orientation.htm

You can use 2 Offset components, one for the contour (boundary)
and one for the holes.

You can use Clipper in GhPython to create two offsets and adjust seam, or use the suggestion of Laurent

Clipper2__.gh (29.7 KB)

3 Likes

Thanks Laurent and Seghier,

This python implementation great. I had no idea clipper was a library (and still actively developed by Angus Johnson (with a major update in oct 2022).

Hi @anon39580149 , just to optimize my code i try to extend your python code to include an output “a” that includes the new List order so I can reindex the curves . As you can tell I still new to python :wink: Any suggestions how to best do this?

a = 0
curves = []
for i, curve in enumerate(p):
    j = ghc.ClipperComponents.PolylineOffset(curve,d,pln,tol,cf,of,m)[1]
    if j:
        st = curve.PointAtStart
        t = j.ClosestPoint(st)[1]
        j.ChangeClosedCurveSeam(t)
        if not rg.Curve.DoDirectionsMatch(j,curve):
            j.Reverse()
        a += 1
        curves.append((a, j))

The indices are the same as the original , why you need the list?

Oeps, you’re right. I had a mis-wire concealed by a component :astonished: