mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Merge pull request #313 from revarbat/revarbat_dev
Added mod_indent() and mod_trace()
This commit is contained in:
commit
75a4fb1069
3 changed files with 65 additions and 27 deletions
|
@ -1308,13 +1308,12 @@ module show(tags="")
|
||||||
// diff(neg, [keep]) ...
|
// diff(neg, [keep]) ...
|
||||||
// diff(neg, pos, [keep]) ...
|
// diff(neg, pos, [keep]) ...
|
||||||
// Description:
|
// Description:
|
||||||
// If `neg` is given, takes the union of all children with tags
|
// If `neg` is given, takes the union of all children with tags that are in `neg`, and differences
|
||||||
// that are in `neg`, and differences them from the union of all
|
// them from the union of all children with tags in `pos`. If `pos` is not given, then all items in
|
||||||
// children with tags in `pos`. If `pos` is not given, then all
|
// `neg` are differenced from all items not in `neg`. If `keep` is given, all children with tags in
|
||||||
// items in `neg` are differenced from all items not in `neg`. If
|
// `keep` are then unioned with the result. If `keep` is not given, all children without tags in
|
||||||
// `keep` is given, all children with tags in `keep` are then unioned
|
// `pos` or `neg` are then unioned with the result.
|
||||||
// with the result. If `keep` is not given, all children without
|
// Cannot be used in conjunction with `intersect()` or `hulling()` on the same parent object.
|
||||||
// tags in `pos` or `neg` are then unioned with the result.
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// neg = String containing space delimited set of tag names of children to difference away.
|
// neg = String containing space delimited set of tag names of children to difference away.
|
||||||
// pos = String containing space delimited set of tag names of children to be differenced away from.
|
// pos = String containing space delimited set of tag names of children to be differenced away from.
|
||||||
|
@ -1367,14 +1366,12 @@ module diff(neg, pos=undef, keep=undef)
|
||||||
// intersect(a, [keep]) ...
|
// intersect(a, [keep]) ...
|
||||||
// intersect(a, b, [keep]) ...
|
// intersect(a, b, [keep]) ...
|
||||||
// Description:
|
// Description:
|
||||||
// If `a` is given, takes the union of all children with tags that
|
// If `a` is given, takes the union of all children with tags that are in `a`, and `intersection()`s
|
||||||
// are in `a`, and intersection()s them with the union of all
|
// them with the union of all children with tags in `b`. If `b` is not given, then the union of all
|
||||||
// children with tags in `b`. If `b` is not given, then the union
|
// items with tags in `a` are intersection()ed with the union of all items without tags in `a`. If
|
||||||
// of all items with tags in `a` are intersection()ed with the union
|
// `keep` is given, then the result is unioned with all the children with tags in `keep`. If `keep`
|
||||||
// of all items without tags in `a`. If `keep` is given, then the
|
// is not given, all children without tags in `a` or `b` are unioned with the result.
|
||||||
// result is unioned with all the children with tags in `keep`. If
|
// Cannot be used in conjunction with `diff()` or `hulling()` on the same parent object.
|
||||||
// `keep` is not given, all children without tags in `a` or `b` are
|
|
||||||
// unioned with the result.
|
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// a = String containing space delimited set of tag names of children.
|
// a = String containing space delimited set of tag names of children.
|
||||||
// b = String containing space delimited set of tag names of children.
|
// b = String containing space delimited set of tag names of children.
|
||||||
|
@ -1413,15 +1410,14 @@ module intersect(a, b=undef, keep=undef)
|
||||||
|
|
||||||
// Module: hulling()
|
// Module: hulling()
|
||||||
// Usage:
|
// Usage:
|
||||||
// hulling(a, [keep]) ...
|
// hulling(a) ...
|
||||||
// Description:
|
// Description:
|
||||||
// Takes the union of all children with tags that are in `a`, and hull()s them.
|
// If `a` is not given, then all children are `hull()`ed together.
|
||||||
// If `keep` is given, then the result is unioned with all the children with
|
// If `a` is given as a string, then all children with `$tags` that are in `a` are
|
||||||
// tags in `keep`. If `keep` is not given, all children without tags in `a` are
|
// `hull()`ed together and the result is then unioned with all the remaining children.
|
||||||
// unioned with the result.
|
// Cannot be used in conjunction with `diff()` or `intersect()` on the same parent object.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// a = String containing space delimited set of tag names of children.
|
// a = String containing space delimited set of tag names of children to hull.
|
||||||
// keep = String containing space delimited set of tag names of children to keep whole.
|
|
||||||
// Example:
|
// Example:
|
||||||
// hulling("body")
|
// hulling("body")
|
||||||
// sphere(d=100, $tags="body") {
|
// sphere(d=100, $tags="body") {
|
||||||
|
@ -1430,8 +1426,12 @@ module intersect(a, b=undef, keep=undef)
|
||||||
// }
|
// }
|
||||||
module hulling(a)
|
module hulling(a)
|
||||||
{
|
{
|
||||||
hull() show(a) children();
|
if (is_undef(a)) {
|
||||||
children();
|
hull() children();
|
||||||
|
} else {
|
||||||
|
hull() show(a) children();
|
||||||
|
children();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
42
debug.scad
42
debug.scad
|
@ -254,11 +254,19 @@ module debug_polyhedron(points, faces, convexity=10, txtsize=1, disabled=false)
|
||||||
|
|
||||||
|
|
||||||
// Function: standard_anchors()
|
// Function: standard_anchors()
|
||||||
|
// Usage:
|
||||||
|
// anchs = standard_anchors(<two_d>);
|
||||||
// Description:
|
// Description:
|
||||||
// Return the vectors for all standard anchors.
|
// Return the vectors for all standard anchors.
|
||||||
function standard_anchors() = [
|
// Arguments:
|
||||||
|
// two_d = If true, returns only the anchors where the Z component is 0. Default: false
|
||||||
|
function standard_anchors(two_d=false) = [
|
||||||
for (
|
for (
|
||||||
zv = [TOP, CENTER, BOTTOM],
|
zv = [
|
||||||
|
if (!two_d) TOP,
|
||||||
|
CENTER,
|
||||||
|
if (!two_d) BOTTOM
|
||||||
|
],
|
||||||
yv = [FRONT, CENTER, BACK],
|
yv = [FRONT, CENTER, BACK],
|
||||||
xv = [LEFT, CENTER, RIGHT]
|
xv = [LEFT, CENTER, RIGHT]
|
||||||
) xv+yv+zv
|
) xv+yv+zv
|
||||||
|
@ -448,5 +456,35 @@ module ruler(length=100, width=undef, thickness=1, depth=3, labels=false, pipsca
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Function: mod_indent()
|
||||||
|
// Usage:
|
||||||
|
// str = mod_indent(<indent>);
|
||||||
|
// Description:
|
||||||
|
// Returns a string that is the total indentation for the module level you are at.
|
||||||
|
// Arguments:
|
||||||
|
// indent = The string to indent each level by. Default: " " (Two spaces)
|
||||||
|
// Example:
|
||||||
|
// x = echo(str(mod_indent(), parent_module(0)));
|
||||||
|
function mod_indent(indent=" ") =
|
||||||
|
str_join([for (i=[1:1:$parent_modules-1]) indent]);
|
||||||
|
|
||||||
|
|
||||||
|
// Function: mod_trace()
|
||||||
|
// Usage:
|
||||||
|
// str = mod_trace(<levs>, <indent>);
|
||||||
|
// Description:
|
||||||
|
// Returns a string that shows the current module and its parents, indented for each unprinted parent module.
|
||||||
|
// Arguments:
|
||||||
|
// levs = This is the number of levels to print the names of. Prints the N most nested module names. Default: 2
|
||||||
|
// indent = The string to indent each level by. Default: " " (Two spaces)
|
||||||
|
// modsep = Multiple module names will be separated by this string. Default: "->"
|
||||||
|
// Example:
|
||||||
|
// x = echo(mod_trace());
|
||||||
|
function mod_trace(levs=2, indent=" ", modsep="->") =
|
||||||
|
str(
|
||||||
|
str_join([for (i=[1:1:$parent_modules+1-levs]) indent]),
|
||||||
|
str_join([for (i=[min(levs-1,$parent_modules-1):-1:0]) parent_module(i)], modsep)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,463];
|
BOSL_VERSION = [2,0,465];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue