From 3ef430902b6fcd259c6871ceaf1fa56fdf2c2f36 Mon Sep 17 00:00:00 2001 From: Jochen Vothknecht <jochen3120@gmail.com> Date: Fri, 24 Sep 2021 06:56:32 +0200 Subject: [PATCH] Split the code out of CyanLight, restructured and added it --- scad/Piping.scad | 10 ++++ scad/Util.scad | 8 +++ scad/piping/fittings.scad | 3 + scad/piping/flanges.scad | 3 + scad/piping/pipes.scad | 118 ++++++++++++++++++++++++++++++++++++++ scad/util/common.scad | 39 +++++++++++++ 6 files changed, 181 insertions(+) create mode 100644 scad/Piping.scad create mode 100644 scad/Util.scad create mode 100644 scad/piping/fittings.scad create mode 100644 scad/piping/flanges.scad create mode 100644 scad/piping/pipes.scad create mode 100644 scad/util/common.scad diff --git a/scad/Piping.scad b/scad/Piping.scad new file mode 100644 index 0000000..25f06d2 --- /dev/null +++ b/scad/Piping.scad @@ -0,0 +1,10 @@ + + +// This file is just an inclusion proxy +// It is designed to be included by the `use`-statement without +// needing to mention every single of it's sub-components + + +include <piping/pipes.scad> +include <piping/flanges.scad> +include <piping/fittings.scad> diff --git a/scad/Util.scad b/scad/Util.scad new file mode 100644 index 0000000..5729612 --- /dev/null +++ b/scad/Util.scad @@ -0,0 +1,8 @@ + + +// This file is just an inclusion proxy +// It is designed to be included by the `use`-statement without +// needing to mention every single of it's sub-components + + +include <util/common.scad> diff --git a/scad/piping/fittings.scad b/scad/piping/fittings.scad new file mode 100644 index 0000000..a1fdaef --- /dev/null +++ b/scad/piping/fittings.scad @@ -0,0 +1,3 @@ + + +// TODO: write the code LoL diff --git a/scad/piping/flanges.scad b/scad/piping/flanges.scad new file mode 100644 index 0000000..a1fdaef --- /dev/null +++ b/scad/piping/flanges.scad @@ -0,0 +1,3 @@ + + +// TODO: write the code LoL diff --git a/scad/piping/pipes.scad b/scad/piping/pipes.scad new file mode 100644 index 0000000..956d2fc --- /dev/null +++ b/scad/piping/pipes.scad @@ -0,0 +1,118 @@ + +use <../Util.scad> + + +// TODO: documentation!!!!!! +module straightPipe(width, height, length, radius, strength, center=false) { + w = width; + h = height; + l = length; + r = radius; + _str = strength; + + tz = center ? -l/2 : 0; + + translate([0, 0, tz]) linear_extrude(l) difference() { + roundRect(w, h, r); + roundRect(w - _str*2, h - _str*2, r - _str); + } +} + +// straightPipe(20, 10, 30, 1, 1); + + +// center only applies to Z-axis +// TODO: write documentation! +module cornerPipe(width, height, diameter, angle, radius, strength, center=false) { + w = width; + h = height; + d = diameter; // "size" of the corner. inner diameter of where it is virtually wound onto + a = angle; + r = radius; + _str = strength; + + tz = center ? 0 : h/2; + + translate([0, 0, tz]) rotate_extrude(angle=a, convexity=8) translate([w/2 + d/2, 0, 0]) difference() { + roundRect(w, h, r); + roundRect(w - _str*2, h - _str*2, r - _str); + } +} + +// cornerPipe(20, 10, 5, 90, 1, 1, true); + + +// Not what I wanted to code - but may come in handy anywhere in the future… +module helixPipe(width, height, length, diameter, angle, radius, strength, center=false) { + w = width; + h = height; + l = length; + a = angle; + r = radius; + _str = strength; + + tz = center ? 0 : h/2; + + translate([0, 0, tz]) linear_extrude(l, twist=a, convexity=8) translate([0, 0, 0]) difference() { + roundRect(w, h, r); + roundRect(w - _str*2, h - _str*2, r - _str); + } +} + +// helixPipe(20, 10, 20, 5, 90, 1, 1, true); + + +// TODO: documentation! +module adapterPipe( + w0, h0, r0, str0, w1, h1, r1, str1, + length, x_off=0, y_off=0, center=false +) { + + l = length; + epsilon = 0.001; + tz = center ? -l/2 : 0; + + difference() { + // outer shell + hull() { + linear_extrude(epsilon) roundRect(w0, h0, r0); + translate([x_off, y_off, l - epsilon]) linear_extrude(epsilon) roundRect(w1, h1, r1); + } + + // inner hole + hull() { + linear_extrude(epsilon) roundRect(w0 - str0*2, h0 - str0*2, r0 - str0); + translate([x_off, y_off, l - epsilon]) linear_extrude(epsilon) roundRect(w1 - str1*2, h1 - str1*2, r1 - str1); + } + } +} + +// adapterPipe(20, 30, 6, 1, 20, 10, 1, 2, 30, x_off = 23, center=true); + + +// N is the number of pipe endings +// length means length of each pipe measured from the centre +module crossNPipe(width, height, length, radius, strength, N, center=false) { + w = width; + h = height; + l = length; + r = radius; + _str = strength; + + epsilon = 0.001; // TODO: may need adjustment + + tz = center ? h/2 : 0; + + translate([0, 0, tz]) difference() { + for (rz=[0:360/N:360]) rotate([-90, 0, rz]) linear_extrude(l) { + roundRect(w, h, r); + } + + for (rz=[0:360/N:360]) rotate([-90, 0, rz]) linear_extrude(l + epsilon) { + roundRect(w - _str*2, h - _str*2, r - _str); + } + } +} + +// crossNPipe(20, 10, 40, 1, 1, 6); + diff --git a/scad/util/common.scad b/scad/util/common.scad new file mode 100644 index 0000000..034b6a1 --- /dev/null +++ b/scad/util/common.scad @@ -0,0 +1,39 @@ + + +/** + * + * TODO: Moar documentation! + * + */ +module roundRect(w, h, r, d=4) { + if (r > 0) { + _dw2 = (w - 2*r) / 2; + _dh2 = (h - 2*r) / 2; + + hull() for (tx=[-_dw2, _dw2], ty=[-_dh2, _dh2]) translate([tx, ty, 0]) circle(r=r); + } else { + square([w, h], center=true); + } +} + + +/** + * A round triangle pointing along the X-Axis + * + * `w` width; length along X + * `h` height; Y size + * `r` corner radius + * `style` use "inner" for the included area or anything else for the `outer` area, this is the included area plus corner size + * + */ +module roundTri(w, h, r, style="inner") { + + _r = style == "inner" ? r : 0; + + hull () { + translate([_r, -h/2 + _r, 0]) circle(r=r); + translate([_r, h/2 - _r, 0]) circle(r=r); + translate([w - _r, 0, 0]) circle(r=r); + } +} + -- GitLab