BHoM_Engine icon indicating copy to clipboard operation
BHoM_Engine copied to clipboard

Geometry_Engine: Improve Offset method (includes Fillet() and ExtendToPoint())

Open LMarkowski opened this issue 6 years ago • 5 comments
trafficstars

Description:

Following the discussion in PR #1314 following items should be improved in Offset() method for Polyline and PolyCurve classes:

  • Offset value below which method is split into two offsets one by one. For now it is arbitrarily set as 0.05 * Curve.Length(). Instead should be calculated or exposed as an input parameter. Link to the specific comment in a PR.
  • The way errors from nested methods are being erased. Currently it uses Reflection.Compute.ClearCurrentEvents(). Probably there is a better way to cover it. Link to the specific comment in a PR. Refers also to #1306.
  • Fillet() now works only on pairs of Lines and Arcs and rather trims/extends them to the intersection point than really fillet. It was inspired by Autocad Fillet method. Could be improved and added as separate public method or maybe renamed.
  • ExtendToPoint() as above. Extend(curve, double, double) is implemented for most of ICurve classes, only Nurbs are missing. Now we could decide if separate method for extending to a given point instead of extending by a given length would be useful. If so, there is a private method working on lines and arcs in Offset.cs file. It could be used as a draft.

LMarkowski avatar Nov 18 '19 16:11 LMarkowski

Besides what is said in the description there are many other ways in which Offest could be improved to be more error-proof. Here are some of my not implemented ideas:

  • first offset every SubPart. Extend them to maximum (Lines -> Infinite and maybe Arcs -> Circles) and split in intersection points. Then the logic from BooleanUnion could be adapt to find biggest possible polygon. Cons: works only on closed curves and positive values of offset. Pros: could work better than what we have now.
  • after offsetting SubParts search for intersections. If they occur, cull every item between two intersecting curves.
  • one of the main obstacles was to decide which ends of filleted curve should be kept. By default it would be curve[i].StartPoint and curve[i+1].EndPoint. It was not always possible but even so it doesn't always mean that this exact curve should be culled.
  • generally imo method for Polylines is much more reliable. Referring to it while offsetting PolyCurve could be considered as often as possible.

LMarkowski avatar Nov 18 '19 17:11 LMarkowski

@pawelbaran @IsakNaslundBh @FraserGreenroyd here's the issue mentioned in Friday's PR.

LMarkowski avatar Nov 18 '19 17:11 LMarkowski

Great, cheers @LMarkowski :smile:

Now just need to find someone to resolve it... 🤔

FraserGreenroyd avatar Nov 18 '19 17:11 FraserGreenroyd

#1868 is relevant to this issue when this issue gets addressed.

FraserGreenroyd avatar Jan 04 '24 14:01 FraserGreenroyd

#2503 is also relevant for this issue whenever it gets addressed.

albinber avatar Jan 04 '24 15:01 albinber