Divide ClosedPolyline in rectangles