@@ -439,35 +439,39 @@ def __init__(self, x, y, z, levels, wrap_x=False, keep_unclose=False):
439439
440440 keep_path = list ()
441441
442- for contour in collection .get_paths ():
443- # Contour with less vertices than 4 are popped
444- if contour .vertices .shape [0 ] < 4 :
445- continue
446- # Remove unclosed path
447- d_closed = (
448- (contour .vertices [0 , 0 ] - contour .vertices [- 1 , 0 ]) ** 2
449- + (contour .vertices [0 , 1 ] - contour .vertices [- 1 , 1 ]) ** 2
450- ) ** 0.5
451- if d_closed > self .DELTA_SUP and not keep_unclose :
452- continue
453- elif d_closed != 0 and d_closed <= self .DELTA_SUP :
454- # Repair almost closed contour
455- if d_closed > self .DELTA_PREC :
456- almost_closed_contours += 1
457- else :
458- closed_contours += 1
459- contour .vertices [- 1 ] = contour .vertices [0 ]
460- x_min , y_min = contour .vertices .min (axis = 0 )
461- x_max , y_max = contour .vertices .max (axis = 0 )
462- ptp_min = self .DELTA_PREC * 100
463- if abs (x_min - x_max ) < ptp_min or abs (y_min - y_max ) < ptp_min :
442+ #for contour in collection.get_paths():
443+ for contour_to_split in collection .get_paths ():
444+ for contour in contour_to_split ._iter_connected_components ():
445+ # Contour with less vertices than 4 are popped
446+ if contour .vertices .shape [0 ] < 4 :
464447 continue
465- # Store to use latter
466- contour .xmin = x_min
467- contour .xmax = x_max
468- contour .ymin = y_min
469- contour .ymax = y_max
470- keep_path .append (contour )
448+ # Remove unclosed path
449+ d_closed = (
450+ (contour .vertices [0 , 0 ] - contour .vertices [- 1 , 0 ]) ** 2
451+ + (contour .vertices [0 , 1 ] - contour .vertices [- 1 , 1 ]) ** 2
452+ ) ** 0.5
453+ if d_closed > self .DELTA_SUP and not keep_unclose :
454+ continue
455+ elif d_closed != 0 and d_closed <= self .DELTA_SUP :
456+ # Repair almost closed contour
457+ if d_closed > self .DELTA_PREC :
458+ almost_closed_contours += 1
459+ else :
460+ closed_contours += 1
461+ contour .vertices [- 1 ] = contour .vertices [0 ]
462+ x_min , y_min = contour .vertices .min (axis = 0 )
463+ x_max , y_max = contour .vertices .max (axis = 0 )
464+ ptp_min = self .DELTA_PREC * 100
465+ if abs (x_min - x_max ) < ptp_min or abs (y_min - y_max ) < ptp_min :
466+ continue
467+ # Store to use latter
468+ contour .xmin = x_min
469+ contour .xmax = x_max
470+ contour .ymin = y_min
471+ contour .ymax = y_max
472+ keep_path .append (contour )
473+ # END for countour block
474+
471475 collection ._paths = keep_path
472476 for contour in collection .get_paths ():
473477 contour .used = False
0 commit comments