def fracture(self, max_points=199, precision=1e-3):
        """
        Slice these polygons in the horizontal and vertical directions
        so that each resulting piece has at most ``max_points``.  This
        operation occurs in place.

        Parameters
        ----------
        max_points : integer
            Maximal number of points in each resulting polygon (must be
            greater than 4).
        precision : float
            Desired precision for rounding vertice coordinates.

        Returns
        -------
        out : ``PolygonSet``
            This object.
        """
        if max_points > 4:
            ii = 0
            while ii < len(self.polygons):
                if len(self.polygons[ii]) > max_points:
                    pts0 = sorted(self.polygons[ii][:, 0])
                    pts1 = sorted(self.polygons[ii][:, 1])
                    ncuts = len(pts0) // max_points
                    if pts0[-1] - pts0[0] > pts1[-1] - pts1[0]:
                        # Vertical cuts
                        cuts = [
                            pts0[int(i * len(pts0) / (ncuts + 1.0) + 0.5)]
                            for i in range(1, ncuts + 1)
                        ]
                        chopped = clipper._chop(self.polygons[ii], cuts, 0,
                                                1 / precision)
                    else:
                        # Horizontal cuts
                        cuts = [
                            pts1[int(i * len(pts1) / (ncuts + 1.0) + 0.5)]
                            for i in range(1, ncuts + 1)
                        ]
                        chopped = clipper._chop(self.polygons[ii], cuts, 1,
                                                1 / precision)
                    self.polygons.pop(ii)
                    layer = self.layers.pop(ii)
                    datatype = self.datatypes.pop(ii)
                    self.polygons.extend(
                        numpy.array(x)
                        for x in itertools.chain.from_iterable(chopped))
                    npols = sum(len(c) for c in chopped)
                    self.layers.extend(layer for _ in range(npols))
                    self.datatypes.extend(datatype for _ in range(npols))
                else:
                    ii += 1
        return self
def fracture ( self , max_points = 199 , precision = 1e-3 ) : if max_points > 4 : ii = 0 while ii < len ( self . polygons ) : if len ( self . polygons [ ii ] ) > max_points : pts0 = sorted ( self . polygons [ ii ] [ : , 0 ] ) pts1 = sorted ( self . polygons [ ii ] [ : , 1 ] ) ncuts = len ( pts0 ) // max_points if pts0 [ - 1 ] - pts0 [ 0 ] > pts1 [ - 1 ] - pts1 [ 0 ] : cuts = [ pts0 [ int ( i * len ( pts0 ) / ( ncuts + 1.0 ) + 0.5 ) ] for i in range ( 1 , ncuts + 1 ) ] chopped = clipper . _chop ( self . polygons [ ii ] , cuts , 0 , 1 / precision ) else : cuts = [ pts1 [ int ( i * len ( pts1 ) / ( ncuts + 1.0 ) + 0.5 ) ] for i in range ( 1 , ncuts + 1 ) ] chopped = clipper . _chop ( self . polygons [ ii ] , cuts , 1 , 1 / precision ) self . polygons . pop ( ii ) layer = self . layers . pop ( ii ) datatype = self . datatypes . pop ( ii ) self . polygons . extend ( numpy . array ( x ) for x in itertools . chain . from_iterable ( chopped ) ) npols = sum ( len ( c ) for c in chopped ) self . layers . extend ( layer for _ in range ( npols ) ) self . datatypes . extend ( datatype for _ in range ( npols ) ) else : ii += 1 return self
Slice these polygons in the horizontal and vertical directions
        so that each resulting piece has at most ``max_points``.  This
        operation occurs in place.

        Parameters
        ----------
        max_points : integer
            Maximal number of points in each resulting polygon (must be
            greater than 4).
        precision : float
            Desired precision for rounding vertice coordinates.

        Returns
        -------
        out : ``PolygonSet``
            This object.