Exemple #1
0
def difference(a, b):
    """ Subtracts the second shape from the first
    """
    args = [Shape.wrap(a), Shape.wrap(b)]
    return Shape(stdlib.difference(
        args[0].ptr,
        args[1].ptr))
Exemple #2
0
def shell(a, offset):
    """ Returns a shell of a shape with the given offset
    """
    args = [Shape.wrap(a), Shape.wrap(offset)]
    return Shape(stdlib.shell(
        args[0].ptr,
        args[1].ptr))
Exemple #3
0
def intersection(a, b):
    """ Returns the intersection of two shapes
    """
    args = [Shape.wrap(a), Shape.wrap(b)]
    return Shape(stdlib.intersection(
        args[0].ptr,
        args[1].ptr))
Exemple #4
0
def union(a, b):
    """ Returns the union of two shapes
    """
    args = [Shape.wrap(a), Shape.wrap(b)]
    return Shape(stdlib._union(
        args[0].ptr,
        args[1].ptr))
Exemple #5
0
def symmetric_y(t):
    """ Clips the given shape at the y origin, then duplicates the remaining
        shape reflected on the other side of the origin
    """
    args = [Shape.wrap(t)]
    return Shape(stdlib.symmetric_y(
        args[0].ptr))
Exemple #6
0
def sphere(radius, center=(0, 0, 0)):
    """ A sphere with the given radius and (optional) center
    """
    args = [Shape.wrap(radius), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.sphere(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]])))
Exemple #7
0
def loft(a, b, zmin, zmax):
    """ Produces a blended loft between a (at zmin) and b (at zmax)
        a and b should be 2D shapes (i.e. invariant along the z axis)
    """
    args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(zmin), Shape.wrap(zmax)]
    return Shape(
        stdlib.loft(args[0].ptr, args[1].ptr, args[2].ptr, args[3].ptr))
Exemple #8
0
def move(t, offset):
    """ Moves the given shape in 2D or 3D space
    """
    args = [Shape.wrap(t), list([Shape.wrap(i) for i in offset])]
    return Shape(stdlib.move(
        args[0].ptr,
        tvec3(*[a.ptr for a in args[1]])))
Exemple #9
0
def rectangle_centered_exact(size, center=(0, 0)):
    """ An exact-field rectangle at the (optional) center
    """
    args = [list([Shape.wrap(i) for i in size]), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.rectangle_centered_exact(
        tvec2(*[a.ptr for a in args[0]]),
        tvec2(*[a.ptr for a in args[1]])))
Exemple #10
0
def blend_expt_unit(a, b, m):
    """ Blends two shapes by the given amount using exponents,
        with the blend term adjusted to produce results approximately
        resembling blend_rough for values between 0 and 1.
    """
    args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m)]
    return Shape(stdlib.blend_expt_unit(args[0].ptr, args[1].ptr, args[2].ptr))
Exemple #11
0
def rectangle(a, b):
    """ A rectangle with the given bounding corners
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])]
    return Shape(
        stdlib.rectangle(tvec2(*[a.ptr for a in args[0]]),
                         tvec2(*[a.ptr for a in args[1]])))
Exemple #12
0
def array_xy(shape, nx, ny, delta):
    """ Iterates a part in a 2D array
    """
    args = [Shape.wrap(shape), nx, ny, list([Shape.wrap(i) for i in delta])]
    return Shape(
        stdlib.array_xy(args[0].ptr, args[1], args[2],
                        tvec2(*[a.ptr for a in args[3]])))
Exemple #13
0
def array_polar_z(shape, n, center=(0, 0)):
    """ Iterates a shape about an optional center position
    """
    args = [Shape.wrap(shape), n, list([Shape.wrap(i) for i in center])]
    return Shape(
        stdlib.array_polar_z(args[0].ptr, args[1],
                             tvec2(*[a.ptr for a in args[2]])))
Exemple #14
0
def box_exact(a, b):
    """ A box with the given bounds with a Euclidean distance metric
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])]
    return Shape(
        stdlib.box_exact(tvec3(*[a.ptr for a in args[0]]),
                         tvec3(*[a.ptr for a in args[1]])))
Exemple #15
0
def reflect_z(t, z0=0):
    """ Reflects a shape about the z origin or an optional offset
    """
    args = [Shape.wrap(t), Shape.wrap(z0)]
    return Shape(stdlib.reflect_z(
        args[0].ptr,
        args[1].ptr))
Exemple #16
0
def box_mitered(a, b):
    """ A box with the given bounds, which will stay creased if offset
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])]
    return Shape(
        stdlib.box_mitered(tvec3(*[a.ptr for a in args[0]]),
                           tvec3(*[a.ptr for a in args[1]])))
Exemple #17
0
def gyroid(period, thickness):
    """ A volume-filling gyroid with the given periods and thickness
    """
    args = [list([Shape.wrap(i) for i in period]), Shape.wrap(thickness)]
    return Shape(stdlib.gyroid(
        tvec3(*[a.ptr for a in args[0]]),
        args[1].ptr))
Exemple #18
0
def rectangle_exact(a, b):
    """ A rectangle from an exact distance field
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])]
    return Shape(
        stdlib.rectangle_exact(tvec2(*[a.ptr for a in args[0]]),
                               tvec2(*[a.ptr for a in args[1]])))
Exemple #19
0
def circle(r, center=(0, 0)):
    """ A 2D circle with the given radius and optional center
    """
    args = [Shape.wrap(r), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.circle(
        args[0].ptr,
        tvec2(*[a.ptr for a in args[1]])))
Exemple #20
0
def cylinder_z(r, h, base=(0, 0, 0)):
    """ A cylinder with the given radius and height, extruded from the
        (optional) base position.
    """
    args = [Shape.wrap(r), Shape.wrap(h), list([Shape.wrap(i) for i in base])]
    return Shape(
        stdlib.cylinder_z(args[0].ptr, args[1].ptr,
                          tvec3(*[a.ptr for a in args[2]])))
Exemple #21
0
def torus_z(ro, ri, center=(0, 0, 0)):
    """ A torus with the given outer radius, inner radius, and (optional) center
    """
    args = [Shape.wrap(ro), Shape.wrap(ri), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.torus_z(
        args[0].ptr,
        args[1].ptr,
        tvec3(*[a.ptr for a in args[2]])))
Exemple #22
0
def blend_difference(a, b, m, o=0):
    """ Blends the subtraction of b, with optional offset o,
        from a, with smoothness m
    """
    args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m), Shape.wrap(o)]
    return Shape(
        stdlib.blend_difference(args[0].ptr, args[1].ptr, args[2].ptr,
                                args[3].ptr))
Exemple #23
0
def rounded_rectangle(a, b, r):
    """ A rectangle with rounded corners
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b]), Shape.wrap(r)]
    return Shape(stdlib.rounded_rectangle(
        tvec2(*[a.ptr for a in args[0]]),
        tvec2(*[a.ptr for a in args[1]]),
        args[2].ptr))
Exemple #24
0
def polygon(r, n, center=(0, 0)):
    """ A polygon with center-to-vertex distance r and n sides
    """
    args = [Shape.wrap(r), n, list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.polygon(
        args[0].ptr,
        args[1],
        tvec2(*[a.ptr for a in args[2]])))
Exemple #25
0
def ring(ro, ri, center=(0, 0)):
    """ A 2D ring with the given outer/inner radii and optional center
    """
    args = [Shape.wrap(ro), Shape.wrap(ri), list([Shape.wrap(i) for i in center])]
    return Shape(stdlib.ring(
        args[0].ptr,
        args[1].ptr,
        tvec2(*[a.ptr for a in args[2]])))
Exemple #26
0
def array_x(shape, nx, dx):
    """ Iterates a part in a 1D array
    """
    args = [Shape.wrap(shape), nx, Shape.wrap(dx)]
    return Shape(stdlib.array_x(
        args[0].ptr,
        args[1],
        args[2].ptr))
Exemple #27
0
def triangle(a, b, c):
    """ A 2D triangle
    """
    args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b]), list([Shape.wrap(i) for i in c])]
    return Shape(stdlib.triangle(
        tvec2(*[a.ptr for a in args[0]]),
        tvec2(*[a.ptr for a in args[1]]),
        tvec2(*[a.ptr for a in args[2]])))
Exemple #28
0
def cone_z(radius, height, base=(0, 0, 0)):
    """ A cone defined by its radius, height, and (optional) base location
    """
    args = [Shape.wrap(radius), Shape.wrap(height), list([Shape.wrap(i) for i in base])]
    return Shape(stdlib.cone_z(
        args[0].ptr,
        args[1].ptr,
        tvec3(*[a.ptr for a in args[2]])))
Exemple #29
0
def extrude_z(t, zmin, zmax):
    """ Extrudes a 2D shape between zmin and zmax
    """
    args = [Shape.wrap(t), Shape.wrap(zmin), Shape.wrap(zmax)]
    return Shape(stdlib.extrude_z(
        args[0].ptr,
        args[1].ptr,
        args[2].ptr))
Exemple #30
0
def half_space(norm, point=(0, 0, 0)):
    """ A plane which divides the world into inside and outside, defined by its
        normal and a single point on the plane
    """
    args = [list([Shape.wrap(i) for i in norm]), list([Shape.wrap(i) for i in point])]
    return Shape(stdlib.half_space(
        tvec3(*[a.ptr for a in args[0]]),
        tvec3(*[a.ptr for a in args[1]])))