mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 08:19:36 +00:00
Added EDGE constants to constants.scad.
This commit is contained in:
parent
86f9c2ead9
commit
c684ea353d
2 changed files with 63 additions and 15 deletions
|
@ -40,4 +40,51 @@ V_DOWN = [ 0, 0, -1];
|
||||||
V_UP = [ 0, 0, 1];
|
V_UP = [ 0, 0, 1];
|
||||||
|
|
||||||
|
|
||||||
|
// Constants for defining edges for chamfer(), etc.
|
||||||
|
EDGE_TOP_BK = [[1,0,0,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGE_TOP_FR = [[0,1,0,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGE_BOT_FR = [[0,0,1,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGE_BOT_BK = [[0,0,0,1], [0,0,0,0], [0,0,0,0]];
|
||||||
|
|
||||||
|
EDGE_TOP_RT = [[0,0,0,0], [1,0,0,0], [0,0,0,0]];
|
||||||
|
EDGE_TOP_LF = [[0,0,0,0], [0,1,0,0], [0,0,0,0]];
|
||||||
|
EDGE_BOT_LF = [[0,0,0,0], [0,0,1,0], [0,0,0,0]];
|
||||||
|
EDGE_BOT_RT = [[0,0,0,0], [0,0,0,1], [0,0,0,0]];
|
||||||
|
|
||||||
|
EDGE_BK_RT = [[0,0,0,0], [0,0,0,0], [1,0,0,0]];
|
||||||
|
EDGE_BK_LF = [[0,0,0,0], [0,0,0,0], [0,1,0,0]];
|
||||||
|
EDGE_FR_LF = [[0,0,0,0], [0,0,0,0], [0,0,1,0]];
|
||||||
|
EDGE_FR_RT = [[0,0,0,0], [0,0,0,0], [0,0,0,1]];
|
||||||
|
|
||||||
|
EDGES_X_TOP = [[1,1,0,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGES_X_BOT = [[0,0,1,1], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGES_X_FR = [[0,1,1,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGES_X_BK = [[1,0,0,1], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGES_X_ALL = [[1,1,1,1], [0,0,0,0], [0,0,0,0]];
|
||||||
|
|
||||||
|
EDGES_Y_TOP = [[0,0,0,0], [1,1,0,0], [0,0,0,0]];
|
||||||
|
EDGES_Y_BOT = [[0,0,0,0], [0,0,1,1], [0,0,0,0]];
|
||||||
|
EDGES_Y_LF = [[0,0,0,0], [0,1,1,0], [0,0,0,0]];
|
||||||
|
EDGES_Y_RT = [[0,0,0,0], [1,0,0,1], [0,0,0,0]];
|
||||||
|
EDGES_Y_ALL = [[0,0,0,0], [1,1,1,1], [0,0,0,0]];
|
||||||
|
|
||||||
|
EDGES_Z_BK = [[0,0,0,0], [0,0,0,0], [1,1,0,0]];
|
||||||
|
EDGES_Z_FR = [[0,0,0,0], [0,0,0,0], [0,0,1,1]];
|
||||||
|
EDGES_Z_LF = [[0,0,0,0], [0,0,0,0], [0,1,1,0]];
|
||||||
|
EDGES_Z_RT = [[0,0,0,0], [0,0,0,0], [1,0,0,1]];
|
||||||
|
EDGES_Z_ALL = [[0,0,0,0], [0,0,0,0], [1,1,1,1]];
|
||||||
|
|
||||||
|
EDGES_LEFT = [[0,0,0,0], [0,1,1,0], [0,1,1,0]];
|
||||||
|
EDGES_RIGHT = [[0,0,0,0], [1,0,0,1], [1,0,0,1]];
|
||||||
|
|
||||||
|
EDGES_FRONT = [[0,1,1,0], [0,0,0,0], [0,0,1,1]];
|
||||||
|
EDGES_BACK = [[1,0,0,1], [0,0,0,0], [1,1,0,0]];
|
||||||
|
|
||||||
|
EDGES_BOTTOM = [[0,0,1,1], [0,0,1,1], [0,0,0,0]];
|
||||||
|
EDGES_TOP = [[1,1,0,0], [1,1,0,0], [0,0,0,0]];
|
||||||
|
|
||||||
|
EDGES_NONE = [[0,0,0,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
EDGES_ALL = [[1,1,1,1], [1,1,1,1], [1,1,1,1]];
|
||||||
|
|
||||||
|
|
||||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
31
masks.scad
31
masks.scad
|
@ -126,16 +126,17 @@ module chamfer_mask_x(l=1.0, chamfer=1.0) {
|
||||||
|
|
||||||
|
|
||||||
// Chamfers the edges of a cuboid region containing the given children.
|
// Chamfers the edges of a cuboid region containing the given children.
|
||||||
// chamfer = inset of the chamfer from the edge. (Default: 1)
|
// chamfer = Inset of the chamfer from the edge. (Default: 1)
|
||||||
// size = The size of the rectangular cuboid we want to chamfer.
|
// size = The size of the rectangular cuboid we want to chamfer.
|
||||||
// edges = which edges do we want to chamfer.
|
// edges = Which edges do we want to chamfer. Recommend to use EDGE constants from constants.scad.
|
||||||
// [
|
// [
|
||||||
// [Y+Z+, Y-Z+, Y-Z-, Y+Z-],
|
// [Y+Z+, Y-Z+, Y-Z-, Y+Z-],
|
||||||
// [X+Z+, X-Z+, X-Z-, X+Z-],
|
// [X+Z+, X-Z+, X-Z-, X+Z-],
|
||||||
// [X+Y+, X-Y+, X-Y-, X+Y-]
|
// [X+Y+, X-Y+, X-Y-, X+Y-]
|
||||||
// ]
|
// ]
|
||||||
// Example:
|
// Example:
|
||||||
// chamfer(chamfer=2, size=[10,40,30], edges=[[0,0,0,1], [1,1,0,0], [0,0,0,0]]) {
|
// include <BOSL/constants.scad>
|
||||||
|
// chamfer(chamfer=2, size=[10,40,30], edges=EDGE_BOT_BK + EDGE_TOP_RT + EDGE_TOP_LF) {
|
||||||
// cube(size=[10,40,30], center=true);
|
// cube(size=[10,40,30], center=true);
|
||||||
// }
|
// }
|
||||||
module chamfer(chamfer=1, size=[1,1,1], edges=[[0,0,0,0], [1,1,0,0], [0,0,0,0]])
|
module chamfer(chamfer=1, size=[1,1,1], edges=[[0,0,0,0], [1,1,0,0], [0,0,0,0]])
|
||||||
|
@ -152,31 +153,31 @@ module chamfer(chamfer=1, size=[1,1,1], edges=[[0,0,0,0], [1,1,0,0], [0,0,0,0]])
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
union() {
|
union() {
|
||||||
if (edges[0][0] != 0)
|
if (edges[0][0] > 0)
|
||||||
up(z/2) back(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
up(z/2) back(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
||||||
if (edges[0][1] != 0)
|
if (edges[0][1] > 0)
|
||||||
up(z/2) fwd(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
up(z/2) fwd(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
||||||
if (edges[0][2] != 0)
|
if (edges[0][2] > 0)
|
||||||
down(z/2) back(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
down(z/2) back(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
||||||
if (edges[0][3] != 0)
|
if (edges[0][3] > 0)
|
||||||
down(z/2) fwd(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
down(z/2) fwd(y/2) chamfer_mask_x(l=lx, chamfer=chamfer);
|
||||||
|
|
||||||
if (edges[1][0] != 0)
|
if (edges[1][0] > 0)
|
||||||
up(z/2) right(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
up(z/2) right(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
||||||
if (edges[1][1] != 0)
|
if (edges[1][1] > 0)
|
||||||
up(z/2) left(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
up(z/2) left(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
||||||
if (edges[1][2] != 0)
|
if (edges[1][2] > 0)
|
||||||
down(z/2) right(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
down(z/2) right(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
||||||
if (edges[1][3] != 0)
|
if (edges[1][3] > 0)
|
||||||
down(z/2) left(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
down(z/2) left(x/2) chamfer_mask_y(l=ly, chamfer=chamfer);
|
||||||
|
|
||||||
if (edges[2][0] != 0)
|
if (edges[2][0] > 0)
|
||||||
back(y/2) right(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
back(y/2) right(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
||||||
if (edges[2][1] != 0)
|
if (edges[2][1] > 0)
|
||||||
back(y/2) left(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
back(y/2) left(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
||||||
if (edges[2][2] != 0)
|
if (edges[2][2] > 0)
|
||||||
fwd(y/2) right(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
fwd(y/2) right(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
||||||
if (edges[2][3] != 0)
|
if (edges[2][3] > 0)
|
||||||
fwd(y/2) left(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
fwd(y/2) left(x/2) chamfer_mask_z(l=lz, chamfer=chamfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue