title: Algorithm to split self-intersected Path2D into several not self-intersected paths?
body: <p>I need to get rid of self-intersections in a shape. Shape is constructed from an array of points, so all segments of that shape are lines. (<b>only</b> lines, no curves and arcs)</p>
  
  <p>Previously, I tried to create Path2D from that points, construct an Area from it, and then using its PathIterator I created several Path2Ds, which <em>somehow</em> were subpaths of previous path, and so self-intersetions were gone. But this isn't working for some paths - self-intersections still remain there.</p>
  
  <p>So could you point me to some place where I can find good algorithm to do similar thing?</p>
  
  <p><strong>Edit:</strong> I haven't found anything useful anywhere, so I written my own algorithm. See the answers.</p>