Ejemplo n.º 1
0
    def fillet_path(self, row):
        """Output the filleted path.
        Args:
            row (DataFrame): Row to fillet.
        Returns:
            Polygon of the new filleted path.
        """
        path = row["geometry"].coords
        if len(path) <= 2:  # only start and end points, no need to fillet
            return row["geometry"]
        newpath = np.array([path[0]])

        # Get list of vertices that can't be filleted
        no_fillet = bad_fillet_idxs(path, row["fillet"],
                                    self.design.template_options.PRECISION)

        # Iterate through every three-vertex corner
        for (i, (start, corner,
                 end)) in enumerate(zip(path, path[1:], path[2:])):
            if i + 1 in no_fillet:  # don't fillet this corner
                newpath = np.concatenate((newpath, np.array([corner])))
            else:
                fillet = self._calc_fillet(np.array(start), np.array(corner),
                                           np.array(end), row["fillet"],
                                           int(self.options['resolution']))
                if fillet is not False:
                    newpath = np.concatenate((newpath, fillet))
                else:
                    newpath = np.concatenate((newpath, np.array([corner])))
        newpath = np.concatenate((newpath, np.array([end])))
        return LineString(newpath)
Ejemplo n.º 2
0
 def test_utility_bad_fillet_idxs(self):
     """
     Test functionality of bad_fillet_idxs in utility_functions.py.
     """
     results = utility_functions.bad_fillet_idxs([(1.0, 1.0), (1.5, 1.5),
                                                  (1.51, 1.5), (2.0, 2.0)],
                                                 0.1)
     self.assertEqual(results, [1, 2])
Ejemplo n.º 3
0
def good_fillet_idxs(coords: list,
                     fradius: float,
                     precision: int = 9,
                     isclosed: bool = False):
    """
    Get list of vertex indices in a linestring (isclosed = False) or polygon (isclosed = True) that can be filleted based on
    proximity to neighbors.

    Args:
        coords (list): Ordered list of tuples of vertex coordinates.
        fradius (float): User-specified fillet radius from QGeometry table.
        precision (int, optional): Digits of precision used for round(). Defaults to 9.
        isclosed (bool, optional): Boolean denoting whether the shape is a linestring or polygon. Defaults to False.

    Returns:
        list: List of indices of vertices that can be filleted.
    """
    if isclosed:
        return toggle_numbers(
            bad_fillet_idxs(coords, fradius, precision, isclosed=True),
            len(coords))
    return toggle_numbers(
        bad_fillet_idxs(coords, fradius, precision, isclosed=False),
        len(coords))[1:-1]