case.scad: factor out the body dilation and cutout creation

This commit is contained in:
2023-12-22 22:49:30 +00:00
parent 9cb68f226d
commit 6432d98aff

View File

@@ -25,6 +25,48 @@ module _PhoneBulkLayer(tol=tol)
}
}
module _DilatedBody(ButtonStyle) {
body = 0;
buttons = 1;
minkowski() {
sphere(r=Thickness);
union() {
children(body);
if (ButtonStyle=="extrude") {
children(buttons);
};
}
}
}
module _PeripheralCutouts(ButtonStyle) {
buttons = 0;
ports = 1;
camera = 2;
union() {
minkowski() {
sphere(r=MarginCameraCut);
children(camera);
};
// restrict these cutouts to just the phone bulk -- don't let them impact the back of the case
intersection() {
_PhoneBulkLayer();
union() {
if (ButtonStyle == "cut") {
minkowski() {
sphere(r=MarginButtonsCut);
children(buttons);
};
};
minkowski() {
sphere(r=MarginPortsCut);
children(ports);
};
};
};
};
};
module _FrontFace(tol=tol) {
color("thistle")
difference() {
@@ -75,37 +117,17 @@ module Case(ButtonStyle="extrude")
color("DarkSlateGray")
difference() {
// start by dilating the phone
minkowski() {
sphere(r=Thickness);
union() {
children(body);
if (ButtonStyle=="extrude") {
children(buttons);
};
}
}
_DilatedBody(ButtonStyle=ButtonStyle) {
children(body);
children(buttons);
};
// then subtract away phone and cutouts
union() {
minkowski() {
sphere(r=MarginCameraCut);
_PeripheralCutouts(ButtonStyle=ButtonStyle) {
children(buttons);
children(ports);
children(camera);
};
// restrict these cutouts to just the phone bulk -- don't let them impact the back of the case
intersection() {
_PhoneBulkLayer();
union() {
if (ButtonStyle == "cut") {
minkowski() {
sphere(r=MarginButtonsCut);
children(buttons);
};
};
minkowski() {
sphere(r=MarginPortsCut);
children(ports);
};
};
};
// subtract the phone
children(body);
// subtract the buttons (we want to give them a buffer)