You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importclickimportvpypeasvpimportvpype_clifromshapely.geometryimportPolygon, LineString, MultiLineString, GeometryCollection, MultiPoint@click.command()@click.argument("X", type=vpype_cli.LengthType())@click.argument("Y", type=vpype_cli.LengthType())@click.argument("R", type=vpype_cli.LengthType())@click.option("-q","--quantization",type=vpype_cli.LengthType(),default="0.1mm",help="Quantization used for the circular area",)@vpype_cli.layer_processordefcirclecrop(lines: vp.LineCollection, x: float, y: float, r: float, quantization: float):
"""Crop to a circular area."""# Create a circular polygoncircle=Polygon(vp.as_vector(vp.circle(x, y, r, quantization)))
# Convert LineCollection to MultiLineStringmls=lines.as_mls()
# Perform the intersectionintersection=mls.intersection(circle)
# Handle GeometryCollection and MultiPoint specificallyifisinstance(intersection, (GeometryCollection, MultiPoint)):
# Extract only LineString geometriesline_strings= [geomforgeominintersection.geomsifisinstance(geom, LineString)]
returnvp.LineCollection(line_strings)
# For all other types, pass directly to LineCollectionreturnvp.LineCollection(intersection)
The text was updated successfully, but these errors were encountered:
Used to live in https://github.com/abey79/vpype-explorations, should be integrated to vpype using this corrected version:
The text was updated successfully, but these errors were encountered: