Offset Curve in C#

Like I mentioned here Curve Offset method can sometimes produce strange results like the one shown here. I found that if I increase the document precision the offsets fails less. This only works up to a certain point, when computation time starts to increase dramatically. So my two questions are:
Is there a work around for offsetting polylines in order to avoid this problem?
Is there any way to filter offset failures in C#?

C#_IceRay3.gh (10.7 KB)

Pherpas the author of Bowerbird BB plugin can help you. He as implemented Clipper library which is very good for offsetting polylines

Thanks @laurent_delrieu. I’ll have a look at what he has done.