mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-02-01 01:09:44 +00:00
Merge pull request #528 from revarbat/revarbat_dev
Cuboid() asserts for negative roundings/chamferings.
This commit is contained in:
commit
3f25aa7d87
2 changed files with 40 additions and 5 deletions
42
edges.scad
42
edges.scad
|
@ -51,8 +51,21 @@
|
||||||
// Section: Sets of Edges
|
// Section: Sets of Edges
|
||||||
// Constants for specifying edges for `cuboid()`, etc.
|
// Constants for specifying edges for `cuboid()`, etc.
|
||||||
|
|
||||||
EDGES_NONE = [[0,0,0,0], [0,0,0,0], [0,0,0,0]]; // No edges.
|
|
||||||
EDGES_ALL = [[1,1,1,1], [1,1,1,1], [1,1,1,1]]; // All edges.
|
// Constant: EDGES_NONE
|
||||||
|
// Topics: Edges
|
||||||
|
// See Also: EDGES_ALL, edges()
|
||||||
|
// Description:
|
||||||
|
// The set of no edges.
|
||||||
|
EDGES_NONE = [[0,0,0,0], [0,0,0,0], [0,0,0,0]];
|
||||||
|
|
||||||
|
|
||||||
|
// Constant: EDGES_ALL
|
||||||
|
// Topics: Edges
|
||||||
|
// See Also: EDGES_NONE, edges()
|
||||||
|
// Description:
|
||||||
|
// The set of all edges.
|
||||||
|
EDGES_ALL = [[1,1,1,1], [1,1,1,1], [1,1,1,1]];
|
||||||
|
|
||||||
|
|
||||||
// Section: Edge Helpers
|
// Section: Edge Helpers
|
||||||
|
@ -218,7 +231,11 @@ function edges(v, except=[]) =
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
EDGE_OFFSETS = [ // Array of XYZ offsets to the center of each edge.
|
// Constant: EDGES_OFFSETS
|
||||||
|
// See Also: edges()
|
||||||
|
// Description:
|
||||||
|
// Array of XYZ offsets to the center of each edge.
|
||||||
|
EDGE_OFFSETS = [
|
||||||
[
|
[
|
||||||
[ 0,-1,-1],
|
[ 0,-1,-1],
|
||||||
[ 0, 1,-1],
|
[ 0, 1,-1],
|
||||||
|
@ -241,8 +258,19 @@ EDGE_OFFSETS = [ // Array of XYZ offsets to the center of each edge.
|
||||||
// Section: Corner Sets
|
// Section: Corner Sets
|
||||||
// Constants for specifying corners.
|
// Constants for specifying corners.
|
||||||
|
|
||||||
|
|
||||||
|
// Constant: CORNERS_NONE
|
||||||
|
// See Also: CORNERS_ALL, corners()
|
||||||
|
// Description:
|
||||||
|
// The set of no corners.
|
||||||
CORNERS_NONE = [0,0,0,0,0,0,0,0]; // No corners.
|
CORNERS_NONE = [0,0,0,0,0,0,0,0]; // No corners.
|
||||||
CORNERS_ALL = [1,1,1,1,1,1,1,1]; // All corners.
|
|
||||||
|
|
||||||
|
// Constant: CORNERS_ALL
|
||||||
|
// See Also: CORNERS_NONE, corners()
|
||||||
|
// Description:
|
||||||
|
// The set of all corners.
|
||||||
|
CORNERS_ALL = [1,1,1,1,1,1,1,1];
|
||||||
|
|
||||||
|
|
||||||
// Section: Corner Helpers
|
// Section: Corner Helpers
|
||||||
|
@ -377,7 +405,11 @@ function corners(v, except=[]) =
|
||||||
) normalize_corners(a - b);
|
) normalize_corners(a - b);
|
||||||
|
|
||||||
|
|
||||||
CORNER_OFFSETS = [ // Array of XYZ offsets to each corner.
|
// Constant: CORNER_OFFSETS
|
||||||
|
// See Also: corners()
|
||||||
|
// Description:
|
||||||
|
// Array of XYZ offsets to each corner.
|
||||||
|
CORNER_OFFSETS = [
|
||||||
[-1,-1,-1], [ 1,-1,-1], [-1, 1,-1], [ 1, 1,-1],
|
[-1,-1,-1], [ 1,-1,-1], [-1, 1,-1], [ 1, 1,-1],
|
||||||
[-1,-1, 1], [ 1,-1, 1], [-1, 1, 1], [ 1, 1, 1]
|
[-1,-1, 1], [ 1,-1, 1], [-1, 1, 1], [ 1, 1, 1]
|
||||||
];
|
];
|
||||||
|
|
|
@ -174,6 +174,7 @@ module cuboid(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (chamfer<0) {
|
} else if (chamfer<0) {
|
||||||
|
assert(edges == EDGES_ALL || edges[2] == [0,0,0,0], "Cannot use negative chamfer with Z aligned edges.");
|
||||||
ach = abs(chamfer);
|
ach = abs(chamfer);
|
||||||
cube(size, center=true);
|
cube(size, center=true);
|
||||||
|
|
||||||
|
@ -260,6 +261,7 @@ module cuboid(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (rounding<0) {
|
} else if (rounding<0) {
|
||||||
|
assert(edges == EDGES_ALL || edges[2] == [0,0,0,0], "Cannot use negative rounding with Z aligned edges.");
|
||||||
ard = abs(rounding);
|
ard = abs(rounding);
|
||||||
cube(size, center=true);
|
cube(size, center=true);
|
||||||
|
|
||||||
|
@ -322,6 +324,7 @@ module cuboid(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cuboid(
|
function cuboid(
|
||||||
size=[1,1,1],
|
size=[1,1,1],
|
||||||
p1, p2,
|
p1, p2,
|
||||||
|
|
Loading…
Reference in a new issue