Simplify curves after solving intersections

I’m working with closed curves to find intersections between them and split them, at this point the definition I have works good (file attached), but the result I want is to get the list of lines and arcs in the order they conform the polygon, but the segments have to be the less as possible, I mean simplifying straight lines with the same angle and joining all kind of arcs and elliptical curves (without joining segments that was previously split in the process of finding intersections).

So I was trying to separate straight lines from curved lines, and then used the simplify curve component for the first, and join curve component for the second group, but I found two problems:

  1. can´t join all coincident curved curves because I can’t distinguish between the ones that was split before and the segments that was part of a polyline (lines and arcs)
  2. after merging the branches of clean curves and lines the order of the segments doesn’t describes the sequence to conform each polygon, since it lists all the lines and then all the curves for each polygon.
    The point 1. Is especially noticeable in the polygons with index 2 and 18 that have more segments of curved curves than they should (see image below)

thanks for your atention, hope someone can share any good idea


SM_44.gh (32.4 KB)