mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Moved no_children to common.scad, and changed references to
echo_warning in skin.scad and polyhedra.scad.
This commit is contained in:
parent
046266778c
commit
45a8b3ec6a
4 changed files with 17 additions and 130 deletions
15
common.scad
15
common.scad
|
@ -148,7 +148,7 @@ function _list_pattern(list) =
|
||||||
// is_consistent([[3,[3,4,[5]]], [5,[2,9,[9]]]]); // Returns true
|
// is_consistent([[3,[3,4,[5]]], [5,[2,9,[9]]]]); // Returns true
|
||||||
// is_consistent([[3,[3,4,[5]]], [5,[2,9,9]]]); // Returns false
|
// is_consistent([[3,[3,4,[5]]], [5,[2,9,9]]]); // Returns false
|
||||||
function is_consistent(list) =
|
function is_consistent(list) =
|
||||||
is_list(list) && is_list_of(list, _list_pattern(list[0]));
|
/*is_list(list) &&*/ is_list_of(list, _list_pattern(list[0]));
|
||||||
|
|
||||||
|
|
||||||
//Internal function
|
//Internal function
|
||||||
|
@ -346,6 +346,19 @@ function segs(r) =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Module: no_children()
|
||||||
|
// Usage:
|
||||||
|
// no_children($children);
|
||||||
|
// Description:
|
||||||
|
// Assert that the calling module does not support children. Prints an error message to this effect and fails if children are present,
|
||||||
|
// as indicated by its argument.
|
||||||
|
// Arguments:
|
||||||
|
// $children = number of children the module has.
|
||||||
|
module no_children(count) {
|
||||||
|
assert(count==0, str("Module ",parent_module(1),"() does not support child modules"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Section: Testing Helpers
|
// Section: Testing Helpers
|
||||||
|
|
||||||
|
|
||||||
|
|
126
errors.scad
126
errors.scad
|
@ -1,126 +0,0 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// LibFile: errors.scad
|
|
||||||
// Functions and modules to facilitate error reporting.
|
|
||||||
// To use, include this line at the top of your file:
|
|
||||||
// ```
|
|
||||||
// use <BOSL2/std.scad>
|
|
||||||
// ```
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Section: Warnings and Errors
|
|
||||||
|
|
||||||
|
|
||||||
// Module: no_children()
|
|
||||||
// Usage:
|
|
||||||
// no_children($children);
|
|
||||||
// Description:
|
|
||||||
// Assert that the calling module does not support children. Prints an error message to this effect and fails if children are present,
|
|
||||||
// as indicated by its argument.
|
|
||||||
// Arguments:
|
|
||||||
// $children = number of children the module has.
|
|
||||||
module no_children(count) {
|
|
||||||
assert(count==0, str("Module ",parent_module(1),"() does not support child modules"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function&Module: echo_error()
|
|
||||||
// Usage:
|
|
||||||
// echo_error(msg, [pfx]);
|
|
||||||
// Description:
|
|
||||||
// Emulates printing of an error message. The text will be shaded red.
|
|
||||||
// You can also use this as a function call from a function.
|
|
||||||
// Arguments:
|
|
||||||
// msg = The message to print.
|
|
||||||
// pfx = The prefix to print before `msg`. Default: `ERROR`
|
|
||||||
module echo_error(msg, pfx="ERROR") {
|
|
||||||
echo(str("<p style=\"background-color: #ffb0b0\"><b>", pfx, ":</b> ", msg, "</p>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
function echo_error(msg, pfx="ERROR") =
|
|
||||||
echo(str("<p style=\"background-color: #ffb0b0\"><b>", pfx, ":</b> ", msg, "</p>"));
|
|
||||||
|
|
||||||
|
|
||||||
// Function&Module: echo_warning()
|
|
||||||
// Usage:
|
|
||||||
// echo_warning(msg, [pfx]);
|
|
||||||
// Description:
|
|
||||||
// Emulates printing of a warning message. The text will be shaded yellow.
|
|
||||||
// You can also use this as a function call from a function.
|
|
||||||
// Arguments:
|
|
||||||
// msg = The message to print.
|
|
||||||
// pfx = The prefix to print before `msg`. Default: `WARNING`
|
|
||||||
module echo_warning(msg, pfx="WARNING") {
|
|
||||||
echo(str("<p style=\"background-color: #ffffb0\"><b>", pfx, ":</b> ", msg, "</p>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
function echo_warning(msg, pfx="WARNING") =
|
|
||||||
echo(str("<p style=\"background-color: #ffffb0\"><b>", pfx, ":</b> ", msg, "</p>"));
|
|
||||||
|
|
||||||
|
|
||||||
// Function&Module: deprecate()
|
|
||||||
// Usage:
|
|
||||||
// deprecate(name, [suggest]);
|
|
||||||
// Description:
|
|
||||||
// Show module deprecation warnings.
|
|
||||||
// You can also use this as a function call from a function.
|
|
||||||
// Arguments:
|
|
||||||
// name = The name of the module that is deprecated.
|
|
||||||
// suggest = If given, the module to recommend using instead.
|
|
||||||
module deprecate(name, suggest=undef) {
|
|
||||||
echo_warning(pfx="DEPRECATED",
|
|
||||||
str(
|
|
||||||
"`<code>", name, "</code>` is deprecated and should not be used.",
|
|
||||||
is_undef(suggest)? "" : str(
|
|
||||||
" You should use `<code>", suggest, "</code>` instead."
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deprecate(name, suggest=undef) =
|
|
||||||
echo_warning(pfx="DEPRECATED",
|
|
||||||
str(
|
|
||||||
"`<code>", name, "</code>` is deprecated and should not be used.",
|
|
||||||
is_undef(suggest)? "" : str(
|
|
||||||
" You should use `<code>", suggest, "</code>` instead."
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Function&Module: deprecate_argument()
|
|
||||||
// Usage:
|
|
||||||
// deprecate(name, arg, [suggest]);
|
|
||||||
// Description:
|
|
||||||
// Show argument deprecation warnings.
|
|
||||||
// You can also use this as a function call from a function.
|
|
||||||
// Arguments:
|
|
||||||
// name = The name of the module/function the deprecated argument is used in.
|
|
||||||
// arg = The name of the deprecated argument.
|
|
||||||
// suggest = If given, the argument to recommend using instead.
|
|
||||||
module deprecate_argument(name, arg, suggest=undef) {
|
|
||||||
echo_warning(pfx="DEPRECATED ARG", str(
|
|
||||||
"In `<code>", name, "</code>`, ",
|
|
||||||
"the argument `<code>", arg, "</code>` ",
|
|
||||||
"is deprecated and should not be used.",
|
|
||||||
is_undef(suggest)? "" : str(
|
|
||||||
" You should use `<code>", suggest, "</code>` instead."
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function deprecate_argument(name, arg, suggest=undef) =
|
|
||||||
echo_warning(pfx="DEPRECATED ARG", str(
|
|
||||||
"In `<code>", name, "</code>`, ",
|
|
||||||
"the argument `<code>", arg, "</code>` ",
|
|
||||||
"is deprecated and should not be used.",
|
|
||||||
is_undef(suggest)? "" : str(
|
|
||||||
" You should use `<code>", suggest, "</code>` instead."
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
|
|
@ -710,7 +710,7 @@ function regular_polyhedron_info(
|
||||||
info == "center" ? translation :
|
info == "center" ? translation :
|
||||||
info == "type" ? entry[class] :
|
info == "type" ? entry[class] :
|
||||||
info == "name" ? entry[pname] :
|
info == "name" ? entry[pname] :
|
||||||
echo_warning(str("Unknown info type '",info,"' requested"));
|
assert(false, str("Unknown info type '",info,"' requested"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1202,7 +1202,7 @@ function path_sweep(shape, path, method="incremental", normal, closed=false, twi
|
||||||
let (pathnormal = path_normals(path, tangents, closed))
|
let (pathnormal = path_normals(path, tangents, closed))
|
||||||
assert(all_defined(pathnormal),"Natural normal vanishes on your curve, select a different method")
|
assert(all_defined(pathnormal),"Natural normal vanishes on your curve, select a different method")
|
||||||
let( testnormals = [for(i=[0:len(pathnormal)-1-(closed?1:2)]) pathnormal[i]*select(pathnormal,i+2)],
|
let( testnormals = [for(i=[0:len(pathnormal)-1-(closed?1:2)]) pathnormal[i]*select(pathnormal,i+2)],
|
||||||
dummy = min(testnormals) < .5 ? echo_warning("abrupt change in normal direction. Consider a different method") :0
|
dummy = min(testnormals) < .5 ? echo("WARNING: ***** Abrupt change in normal direction. Consider a different method *****") :0
|
||||||
)
|
)
|
||||||
[for(i=[0:L-(closed?0:1)]) let(
|
[for(i=[0:L-(closed?0:1)]) let(
|
||||||
rotation = affine_frame_map(x=pathnormal[i%L], z=tangents[i%L])
|
rotation = affine_frame_map(x=pathnormal[i%L], z=tangents[i%L])
|
||||||
|
@ -1216,7 +1216,7 @@ function path_sweep(shape, path, method="incremental", normal, closed=false, twi
|
||||||
end = reindex_polygon(start, apply(transform_list[L],path3d(shape)))
|
end = reindex_polygon(start, apply(transform_list[L],path3d(shape)))
|
||||||
)
|
)
|
||||||
all([for(i=idx(start)) approx(start[i],end[i])]),
|
all([for(i=idx(start)) approx(start[i],end[i])]),
|
||||||
dummy = ends_match ? 0 :echo_warning("The points do not match when closing the model")
|
dummy = ends_match ? 0 : echo("WARNING: ***** The points do not match when closing the model *****")
|
||||||
)
|
)
|
||||||
transforms ? transform_list : sweep(shape, transform_list, closed=false, caps=fullcaps);
|
transforms ? transform_list : sweep(shape, transform_list, closed=false, caps=fullcaps);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue