diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle new file mode 100644 index 0000000..9b7ca06 Binary files /dev/null and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree new file mode 100644 index 0000000..0a6ff3b Binary files /dev/null and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/_build/doctrees/solidLib.doctree b/docs/_build/doctrees/solidLib.doctree new file mode 100644 index 0000000..9b3513c Binary files /dev/null and b/docs/_build/doctrees/solidLib.doctree differ diff --git a/docs/_build/html/.buildinfo b/docs/_build/html/.buildinfo new file mode 100644 index 0000000..dcc9d1b --- /dev/null +++ b/docs/_build/html/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 6fb14a20676cdf10ce34e995f460b5ec +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_build/html/_images/bin_toolinlay1.png b/docs/_build/html/_images/bin_toolinlay1.png new file mode 100644 index 0000000..e758915 Binary files /dev/null and b/docs/_build/html/_images/bin_toolinlay1.png differ diff --git a/docs/_build/html/_images/bin_toolinlay2.png b/docs/_build/html/_images/bin_toolinlay2.png new file mode 100644 index 0000000..5f7f0ea Binary files /dev/null and b/docs/_build/html/_images/bin_toolinlay2.png differ diff --git a/docs/_build/html/_images/grid.png b/docs/_build/html/_images/grid.png new file mode 100644 index 0000000..9671c46 Binary files /dev/null and b/docs/_build/html/_images/grid.png differ diff --git a/docs/_build/html/_images/round_box.png b/docs/_build/html/_images/round_box.png new file mode 100644 index 0000000..83fd4e8 Binary files /dev/null and b/docs/_build/html/_images/round_box.png differ diff --git a/docs/_build/html/_images/round_flat_box.png b/docs/_build/html/_images/round_flat_box.png new file mode 100644 index 0000000..9a6d536 Binary files /dev/null and b/docs/_build/html/_images/round_flat_box.png differ diff --git a/docs/_build/html/_modules/index.html b/docs/_build/html/_modules/index.html new file mode 100644 index 0000000..55040ed --- /dev/null +++ b/docs/_build/html/_modules/index.html @@ -0,0 +1,101 @@ + + + + +
+ + +
+import numpy as np
+import solid as scad
+from . import primitives as slp
+
+from typing import Union, Iterable
+# import .primitives as slp
+
+
+[docs]def grid(
+ x_dim: int,
+ y: int,
+ w: float = 3,
+ h: float = 1.5,
+ fillet: bool = False,
+ dim: float = 59,
+ segments: int = 36,
+):
+ """generate a grid of (flattened) triangles with or without fillet
+
+ the generated grid is x by y in size with a gridspace of size dim,
+ the triangles used for the base structure is given by their height and width
+
+ .. image:: img/grid.png
+ :alt: 2x3 grid with defaults
+ """
+
+ if w > h * 2:
+ out = scad.polygon([[0, 0], [w / 2, 0], [w / 2 - h, h], [0, h]])
+ else:
+ out = scad.polygon([[0, 0], [w / 2, 0], [0, h]])
+ out = scad.linear_extrude(dim)(out)
+ out = scad.rotate([90, 0, 90])(out)
+
+ if fillet:
+ # scallop = scad.cube([dim - 2 * h - (w - 2 * h), 0.0001, 0.0001])
+ # scallop = scad.minkowski()(scallop, scad.sphere(r=h, segments=segments))
+ scallop = slp.pill(
+ [
+ [0, 0, 0],
+ [dim - 2 * h - (w - 2 * h), 0, 0],
+ # [0,0,h], [dim - 2 * h - (w - 2 * h),0,h]
+ ],
+ h,
+ segments=segments,
+ )
+ scallop += scad.rotate((0, -90, 0))(scallop) + scad.translate([dim - w, 0, 0])(
+ scad.rotate([0, -90, 0])(scallop)
+ )
+ scallop = scad.translate((w / 2, w / 2, h))(scallop)
+ out -= scallop
+
+ out += scad.translate((0, dim, 0))(scad.rotate((0, 0, -90))(out))
+ out += scad.translate((dim, dim, 0))(scad.rotate((0, 0, 180))(out))
+
+ result = out
+ for dx in range(x_dim):
+ for dy in range(y):
+ result += scad.translate((dim * dx, dim * dy, 0))(out)
+
+ return result
+
+
+[docs]def grid_inv(
+ x: float,
+ y: float,
+ w: float = 3,
+ h: float = 1.5,
+ fillet: bool = False,
+ dim: float = 59,
+ segments: int = 36,
+):
+ g = grid(x, y, w, h, fillet, dim, segments)
+ return scad.cube([x * dim, y * dim, h]) - g
+
+
+[docs]def bin(x: float, y: float, h: float = 67, segments: int = 36, dim: float = 59):
+ class dims:
+ wall = 2
+ r_in = 2
+ r_out = r_in + wall
+
+ bulk = slp.round_flat_box(dim * x, dim * y, h, dims.r_out)
+ hole = slp.round_box(dim * x - dims.wall * 2, dim * y - dims.wall * 2, h, dims.r_in)
+ hole = scad.translate([dims.wall, dims.wall, dims.wall])(hole)
+
+ wall_o = scad.cylinder(r=dims.r_out, h=dims.r_out, segments=segments)
+
+ g = grid(x, y)
+
+ goverlay = grid(x, y, w=2 + 2 * dims.wall, h=dims.r_in, fillet=True)
+ goverlay = scad.translate([0, 0, dims.wall])(goverlay)
+ goverlay = scad.intersection()(goverlay, hole)
+
+ return bulk - hole - g + goverlay
+
+
+[docs]def toolinlay1(
+ height: float,
+ *args,
+ r_tool: float = 7,
+ inset: float = 4,
+ maxh: float = 67,
+ dim: float = 59,
+ segments: int = 36
+):
+ """toolinlay1
+
+ creates a tooltray for alex container bins (2x3)
+
+ .. image:: img/bin_toolinlay1.png
+
+ :param height: height of inset above lower bin
+ :param inset: depth of inset
+ """
+ x = 2
+ y = 3
+ wall = 2
+ r_in = 2
+ tool_ins = 3
+
+ base = slp.round_flat_box(x * dim, y * dim, height + inset, r_in + wall)
+
+ toolindent = 0.1
+ toolindent_w = 2
+ toolbase_l = dim * x - 2 * wall - 2 * r_tool
+ toolbase_t = scad.cube([toolbase_l * (1 - toolindent), 0.001, tool_ins])
+ toolbase_b = scad.translate([toolbase_l * (1 - toolindent), 0, 0])(
+ scad.cube([toolbase_l * toolindent - toolindent_w, 0.001, tool_ins])
+ )
+ toolcutout = scad.minkowski()(
+ toolbase_t, scad.sphere(r=r_tool, segments=segments)
+ ) + scad.minkowski()(
+ toolbase_b, scad.sphere(r=r_tool + toolindent_w, segments=segments)
+ )
+
+ toolcutout = scad.translate(
+ [r_tool + wall, r_tool + wall + toolindent_w, maxh - tool_ins]
+ )(toolcutout)
+
+ toolcutouts = []
+ for i in range((dim * y - 3 * wall) // (r_tool * 2 + 2 * toolindent_w)):
+ toolcutouts.append(
+ scad.translate([0, i * (2 * r_tool + 2 * toolindent_w + 1.4), 0])(
+ scad.color("yellow")(toolcutout)
+ )
+ )
+
+ lower = bin(2, 3, h=maxh - height, dim=dim)
+ lower = scad.color("red", 0.5)(lower)
+ base = scad.translate([0, 0, maxh - height - inset])(base)
+
+ return base - lower - toolcutouts
+
+
+[docs]def toolinlay2(
+ height: float,
+ r_tool: Union[float, Iterable[float]] = 7,
+ inset: float = 4,
+ inset_tool: float = 3,
+ maxh: float = 67,
+ dim: float = 59,
+ wall: float = 2,
+ segments: int = 36,
+):
+ """toolinlay2
+
+ creates a tooltray for alex container bins (2x3)
+
+ .. image:: img/bin_toolinlay2.png
+
+ :param height: height of inset above lower bin
+ :param r_tool: toolspace radius as float or list of floats
+ :param inset: depth of toolinlay inset
+ :param inset_tool: depth of additional toolspace inset
+ :param maxh: system height restriction
+ :param dim: system raster dimension
+ :param segments: circular object segments
+ """
+ x_dim = 2
+ y_dim = 3
+ r_in = 2
+
+ base = slp.round_flat_box(x_dim * dim, y_dim * dim, height + inset, r_in + wall)
+
+ toolindent = 0.1
+ toolindent_w = 2
+
+ toolcutouts = []
+ tool_rs = []
+ if not isinstance(r_tool, list):
+ tool_rs = [r_tool] * (
+ (dim * x_dim - 3 * wall) // (r_tool * 2 + 2 * toolindent_w) - 1
+ )
+ else:
+ tool_rs = r_tool
+
+ toolbase_l = dim * y_dim - 2 * wall - 2 * np.max(tool_rs)
+ for i, r in enumerate(tool_rs):
+ toolbase_t = scad.cube([0.001, toolbase_l * (1 - toolindent), inset_tool])
+ # toolbase_b = scad.translate([0, toolbase_l * (1 - toolindent), 0])(
+ # scad.cube([0.001, toolbase_l * toolindent - toolindent_w, tool_ins])
+ # )
+ toolcutout = slp.pill(
+ np.array([[0, 0, 0], [0, toolbase_l, 0], [0, toolbase_l, 10], [0, 0, 10]])
+ + [0, 0, -np.max(tool_rs) + r]
+ + [i * (toolindent_w + 1.4) + np.sum(tool_rs[0:i]) * 2, 0, 0],
+ r,
+ )
+
+ toolcutout = scad.translate(
+ (
+ np.max(tool_rs) + wall + toolindent_w,
+ np.max(tool_rs) + wall,
+ maxh - inset_tool,
+ )
+ )(toolcutout)
+ toolcutouts.append(scad.color("yellow")(toolcutout))
+
+ toolcutouts.append(
+ slp.pill(
+ np.array(
+ [
+ [0, 0, 0],
+ [0, toolindent * toolbase_l, 0],
+ [dim * x_dim - 2 * wall - 2 * 9, 0, 0],
+ [dim * x_dim - 2 * wall - 2 * 9, toolindent * toolbase_l, 0],
+ [0, 0, 10],
+ [0, toolindent * toolbase_l, 10],
+ [dim * x_dim - 2 * wall - 2 * 9, 0, 10],
+ [dim * x_dim - 2 * wall - 2 * 9, toolindent * toolbase_l, 10],
+ ]
+ )
+ + [9 + wall, 9 + wall, maxh - inset_tool],
+ 9,
+ )
+ )
+ toolcutouts.append(
+ scad.translate((wall * 2,wall * 2,0))(
+ slp.round_flat_box(
+ toolindent * toolbase_l + 2 * 9, toolindent * toolbase_l + 2 * 9 - wall, 100, 9-wall, segments=segments
+ )
+ )
+ )
+
+ lower = bin(2, 3, h=maxh - height, dim=dim)
+ lower = scad.color("red", 0.5)(lower)
+ base = scad.translate([0, 0, maxh - height - inset])(base)
+
+ return base - lower - toolcutouts
+
+from typing import List
+
+import solid as scad
+
+from .globals import SEGMENTS
+
+import numpy as np
+import logging as log
+
+log.basicConfig(level=log.INFO)
+
+[docs]def round_box(x_dim: float, y_dim: float, z_dim: float, radius: float, segments: int = 32):
+ """creates a round box with radius r
+
+ .. image:: img/round_box.png
+ """
+ box = scad.cube([x_dim - 2 * radius, y_dim - 2 * radius, z_dim - 2 * radius])
+ wall = scad.sphere(r=radius, segments=segments)
+
+ return scad.translate([radius, radius, radius])(
+ scad.minkowski()(box, wall)
+ )
+
+
+[docs]def round_flat_box(x: float, y: float, z: float, r: float, segments: int = 32):
+ """creates a round box with radius r and flat top/bottom
+
+ .. image:: img/round_flat_box.png
+ """
+ box = scad.cube([x - 2 * r, y - 2 * r, z- 2 * r])
+ wall = scad.cylinder(r=r, h=2*r, segments=SEGMENTS)
+
+ return scad.translate([r, r, 0])(
+ scad.minkowski()(box, wall)
+ )
+
+
+[docs]def pill(ps: List[List[float]], r, segments: int = 36):
+ if len(ps) < 2:
+ raise Exception("requires 2 or more points")
+ s = scad.sphere(r=r, segments=segments)
+
+ spheres = []
+ # log.info(ps)
+ for p in ps:
+ spheres.append(
+ scad.translate(p)(s)
+ )
+
+ return scad.hull()(*spheres)
+