BHoM_Engine
BHoM_Engine copied to clipboard
Geometry_Engine: Improve Offset method (includes Fillet() and ExtendToPoint())
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 ofICurveclasses, 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 inOffset.csfile. It could be used as a draft.
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
BooleanUnioncould 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].StartPointandcurve[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
Polylinesis much more reliable. Referring to it while offsettingPolyCurvecould be considered as often as possible.
@pawelbaran @IsakNaslundBh @FraserGreenroyd here's the issue mentioned in Friday's PR.
Great, cheers @LMarkowski :smile:
Now just need to find someone to resolve it... 🤔
#1868 is relevant to this issue when this issue gets addressed.
#2503 is also relevant for this issue whenever it gets addressed.