diff --git a/base.scad b/base.scad new file mode 100644 index 0000000..8a2df46 --- /dev/null +++ b/base.scad @@ -0,0 +1 @@ +function default(val,comp) = val != undef ? val : comp; diff --git a/component.scad b/component.scad index 89c8056..fe9e27c 100644 --- a/component.scad +++ b/component.scad @@ -1,4 +1,4 @@ - +use <./debug.scad>; module component_get(name) { component_display(name) children(); } @@ -9,5 +9,8 @@ module component_display(name) { } module component(name) { - if($scaddy_component == undef || $scaddy_component == name) children(); + if($scaddy_component == undef || $scaddy_component == name) { + debug() echo(str("Displaying component ",name)); + children(); + } } diff --git a/debug.scad b/debug.scad index dc8b22b..1704c83 100644 --- a/debug.scad +++ b/debug.scad @@ -6,7 +6,7 @@ module debug(force=false) { } module _debug_mesh() { - %color([255,0,0,0.4]) children(); + %color([1,0,0,0.4]) children(); } module debug_points(vector) { diff --git a/functions.scad b/functions.scad index 359f07d..d9ea150 100644 --- a/functions.scad +++ b/functions.scad @@ -2,5 +2,4 @@ function circle_y(x,r,cx=0,cy=0) = (2*cy + sqrt(8*cx*x-4*cx*cx-4*(x)*(x)+4*r*r)) function curve_r(curve_h,curve_w)=(pow(curve_h,2)+pow(curve_w,2))/(2*abs(curve_w)); -function pow2(x)=x*x; -function pow3(x)=x*x*x; +function mix(base,target,ratio) = base*(1-ratio)+target*ratio; diff --git a/polyhedron.scad b/polyhedron.scad index 5e65732..d0984fb 100644 --- a/polyhedron.scad +++ b/polyhedron.scad @@ -26,6 +26,6 @@ module polyhedron_layers(layers) { bottom_f, top_f, walls_f - )); + ),convexity = lc); } diff --git a/preconditions.scad b/preconditions.scad index 413b446..3f41ed2 100644 --- a/preconditions.scad +++ b/preconditions.scad @@ -1,14 +1,23 @@ -module precondition(test,error) { +use <./base.scad>; + +ERROR_BEGIN=""; +ERROR_END=""; + +module precondition(test,error,m=undef) { if(!test) { - echo(str("",error,"")); + echo(str(ERROR_BEGIN,default(m,parent_module(1)),": ",error,ERROR_END)); assert(false); } else children(); } -module check_defined(val,error) { +function precondition(test,value,error)=test ? value : echo(str(ERROR_BEGIN,error,ERROR_END)) assert(false); + +module check_defined(val,error,m=undef) { precondition(val != undef,error) children(); } -module check_parent(parent,statement,error) { +function check_defined(value,error)=precondition(value != undef,error); + +module check_parent(parent,statement,error,m=undef) { precondition(parent_module(3) == parent,str(statement,"(): ",error)) children(); } diff --git a/scaddy.scad b/scaddy.scad index 74be9a0..c1b3f38 100644 --- a/scaddy.scad +++ b/scaddy.scad @@ -1,3 +1,4 @@ +include <./base.scad>; include <./debug.scad>; include <./config.scad>; include <./preconditions.scad>;