diff --git a/common.scad b/common.scad index f0be6c1..d8941ee 100644 --- a/common.scad +++ b/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 false 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 @@ -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 diff --git a/errors.scad b/errors.scad deleted file mode 100644 index 8c174d9..0000000 --- a/errors.scad +++ /dev/null @@ -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 -// ``` -////////////////////////////////////////////////////////////////////// - - - -// 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("

", pfx, ": ", msg, "

")); -} - -function echo_error(msg, pfx="ERROR") = - echo(str("

", pfx, ": ", msg, "

")); - - -// 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("

", pfx, ": ", msg, "

")); -} - -function echo_warning(msg, pfx="WARNING") = - echo(str("

", pfx, ": ", msg, "

")); - - -// 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( - "`", name, "` is deprecated and should not be used.", - is_undef(suggest)? "" : str( - " You should use `", suggest, "` instead." - ) - ) - ); -} - -function deprecate(name, suggest=undef) = - echo_warning(pfx="DEPRECATED", - str( - "`", name, "` is deprecated and should not be used.", - is_undef(suggest)? "" : str( - " You should use `", suggest, "` 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 `", name, "`, ", - "the argument `", arg, "` ", - "is deprecated and should not be used.", - is_undef(suggest)? "" : str( - " You should use `", suggest, "` instead." - ) - )); -} - -function deprecate_argument(name, arg, suggest=undef) = - echo_warning(pfx="DEPRECATED ARG", str( - "In `", name, "`, ", - "the argument `", arg, "` ", - "is deprecated and should not be used.", - is_undef(suggest)? "" : str( - " You should use `", suggest, "` instead." - ) - )); - - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/polyhedra.scad b/polyhedra.scad index b199fe9..e845acd 100644 --- a/polyhedra.scad +++ b/polyhedra.scad @@ -710,7 +710,7 @@ function regular_polyhedron_info( info == "center" ? translation : info == "type" ? entry[class] : info == "name" ? entry[pname] : - echo_warning(str("Unknown info type '",info,"' requested")); + assert(false, str("Unknown info type '",info,"' requested")); diff --git a/skin.scad b/skin.scad index 920f4ed..30d8a17 100644 --- a/skin.scad +++ b/skin.scad @@ -1202,7 +1202,7 @@ function path_sweep(shape, path, method="incremental", normal, closed=false, twi let (pathnormal = path_normals(path, tangents, closed)) 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)], - 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( 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))) ) 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);