How to use the pyclipper.scale_from_clipper function in pyclipper

To help you get started, we’ve selected a few pyclipper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TUDelft-CNS-ATM / bluesky / bluesky / traffic / asas / SSD.py View on Github external
def area(vset):
    """ This function calculates the area of the set of FRV or ARV """
    # Initialize A as it could be calculated iteratively
    A = 0
    # Check multiple exteriors
    if type(vset[0][0]) == list:
        # Calc every exterior separately
        for i in range(len(vset)):
            A += pyclipper.scale_from_clipper(pyclipper.scale_from_clipper(pyclipper.Area(pyclipper.scale_to_clipper(vset[i]))))
    else:
        # Single exterior
        A = pyclipper.scale_from_clipper(pyclipper.scale_from_clipper(pyclipper.Area(pyclipper.scale_to_clipper(vset))))
    return A
github ecopoesis / nek-type-a / body / body.py View on Github external
def expand_shape(poly, expansion):
    """
    make a polygon larger
    :param poly: list of point tuples describing the polygon
    :param expansion: mm to expand (1 will make the entire poly 2mm wider and taller)
    :return: list of points representing the expanded polygon
    """
    scaled_exp = expansion * 2 ** 31

    pco = pyclipper.PyclipperOffset()
    pco.ArcTolerance = arc_tolerance
    pco.AddPath(pyclipper.scale_to_clipper(poly), pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
    expanded = pyclipper.scale_from_clipper(pco.Execute(scaled_exp))
    return map(lambda point: (point[0], point[1]), expanded[0])
github revarbat / mandoline-py / mandoline / geometry2d.py View on Github external
def orient_path(path, dir):
    orient = pyclipper.Orientation(path)
    path = pyclipper.scale_to_clipper(path, SCALING_FACTOR)
    if orient != dir:
        path = pyclipper.ReversePath(path)
    path = pyclipper.scale_from_clipper(path, SCALING_FACTOR)
    return path
github revarbat / mandoline-py / mandoline / geometry2d.py View on Github external
def offset(paths, amount):
    pco = pyclipper.PyclipperOffset()
    pco.ArcTolerance = SCALING_FACTOR / 40
    paths = pyclipper.scale_to_clipper(paths, SCALING_FACTOR)
    pco.AddPaths(paths, pyclipper.JT_SQUARE, pyclipper.ET_CLOSEDPOLYGON)
    outpaths = pco.Execute(amount * SCALING_FACTOR)
    outpaths = pyclipper.scale_from_clipper(outpaths, SCALING_FACTOR)
    return outpaths
github jamiebull1 / geomeppy / geomeppy / geom / clippers.py View on Github external
def _process(self, results):
        """Process and return the results of a clipping operation.

        :param results: A list of lists of coordinates .
        :returns: A list of Polygon2D results of the clipping operation.

        """
        if not results:
            return []
        scaled = [pc.scale_from_clipper(r) for r in results]
        polys = [self.as_2d(r) for r in scaled]
        processed = []
        for poly in polys:
            if almostequal(poly.normal_vector, self.normal_vector):
                processed.append(poly)
            else:
                processed.append(poly.invert_orientation())
        return processed
github ecopoesis / nek-type-a / body / body.py View on Github external
:param convex: if true fillet the convex corners, if false fillet the concave corners
    :return: list of points representing the filleted polygon
    """
    scaled_radius = radius * 2 ** 31

    pco = pyclipper.PyclipperOffset()
    pco.ArcTolerance = arc_tolerance

    # shrink
    pco.AddPath(pyclipper.scale_to_clipper(poly), pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
    expanded = pco.Execute(-scaled_radius if convex else scaled_radius)

    # expand
    pco.Clear()
    pco.AddPath(expanded[0], pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
    result = pyclipper.scale_from_clipper(pco.Execute(scaled_radius if convex else -scaled_radius))

    return map(lambda point: (point[0], point[1]), result[0])