summaryrefslogtreecommitdiff
path: root/testdata/scad/features
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/scad/features')
-rw-r--r--testdata/scad/features/child-child-test.scad12
-rw-r--r--testdata/scad/features/child-tests.scad7
-rw-r--r--testdata/scad/features/hull2-tests.scad8
-rw-r--r--testdata/scad/features/hull3-tests.scad9
-rw-r--r--testdata/scad/features/linear_extrude-scale-zero-tests.scad56
-rw-r--r--testdata/scad/features/linear_extrude-tests.scad11
-rw-r--r--testdata/scad/features/module-recursion.scad15
-rw-r--r--testdata/scad/features/modulevariables.scad7
-rw-r--r--testdata/scad/features/surface-simple.dat4
-rw-r--r--testdata/scad/features/surface-simple.scad2
-rw-r--r--testdata/scad/features/surface-simple2.dat3
11 files changed, 132 insertions, 2 deletions
diff --git a/testdata/scad/features/child-child-test.scad b/testdata/scad/features/child-child-test.scad
new file mode 100644
index 0000000..e5e6d93
--- /dev/null
+++ b/testdata/scad/features/child-child-test.scad
@@ -0,0 +1,12 @@
+module up() {
+ translate([0,0,1]) child(0);
+}
+
+module red() {
+ color("Red") child(0);
+}
+
+up() cylinder(r=5);
+translate([5,0,0]) up() up() cylinder(r=5);
+translate([10,0,0]) up() up() up() red() cylinder(r=5);
+translate([15,0,0]) red() up() up() up() up() cylinder(r=5);
diff --git a/testdata/scad/features/child-tests.scad b/testdata/scad/features/child-tests.scad
index e4e3572..cf983b4 100644
--- a/testdata/scad/features/child-tests.scad
+++ b/testdata/scad/features/child-tests.scad
@@ -1,7 +1,7 @@
$fn=16;
-module parent() {
- for (i=[0:2]) {
+module parent(range=[0:2]) {
+ for (i=range) {
translate([2.5*i,0,0]) child(i);
}
}
@@ -32,3 +32,6 @@ module parent3() {
}
translate([5,3,0]) parent3() { cube(); sphere(); }
+
+// Leaking variables to child list is not allowed
+translate([0,6,0]) parent(range=[0:1], testvar=10) { sphere(); cube(testvar, center=true);}
diff --git a/testdata/scad/features/hull2-tests.scad b/testdata/scad/features/hull2-tests.scad
index e656e6a..82b56e4 100644
--- a/testdata/scad/features/hull2-tests.scad
+++ b/testdata/scad/features/hull2-tests.scad
@@ -31,7 +31,15 @@ module hull2dForLoop() {
}
}
+module hull2null() {
+ hull() {
+ square(0);
+ circle(0);
+ }
+}
+
convex2dHole();
translate([40,0,0]) convex2dSimple();
translate([0,-20,0]) concave2dSimple();
translate([30,-25,0]) hull2dForLoop();
+hull2null(); \ No newline at end of file
diff --git a/testdata/scad/features/hull3-tests.scad b/testdata/scad/features/hull3-tests.scad
index e3fc8e7..0f48b8f 100644
--- a/testdata/scad/features/hull3-tests.scad
+++ b/testdata/scad/features/hull3-tests.scad
@@ -26,3 +26,12 @@ translate([-5,-5,-5]) {
}
}
}
+
+module hull3null() {
+ hull() {
+ cube(0);
+ sphere(0);
+ }
+}
+hull3null();
+
diff --git a/testdata/scad/features/linear_extrude-scale-zero-tests.scad b/testdata/scad/features/linear_extrude-scale-zero-tests.scad
new file mode 100644
index 0000000..8a85203
--- /dev/null
+++ b/testdata/scad/features/linear_extrude-scale-zero-tests.scad
@@ -0,0 +1,56 @@
+// test cases for linear extrude with scale
+// by TakeItAndRun 2013
+
+// syntax: linear_extrude(height=a, slices=b, twist=c, scale=[x,y])
+
+a=3;
+b=20;
+c=0;
+x=1;
+y=1;
+
+module linear_extrudes_of_different_shapes(a=a,b=b,c=c,x=x,y=y) {
+ translate(00*[4,0,0])
+ // linear_extrude of shape with hole
+ linear_extrude(height=a, slices=b, twist=c, scale=[x,y])
+ difference() {
+ square(2,true); square(1,true);
+ }
+
+ translate(01*[4,0,0])
+ // linear_extrude of disjoint polygons shapes
+ linear_extrude(height=a, slices=b, twist=c, scale=[x,y]) {
+ translate([1,0,0]) square(1,true);
+ translate([-1,0,0]) square(1,true);
+ }
+
+ translate(02*[4,0,0])
+ // linear_extrude with a coplanar face
+ linear_extrude(height=a, slices=b, twist=c, scale=[x,y]) {
+ translate([.5,0,0])square();
+ translate([-.5,0,0])square();
+ }
+
+ translate(03*[4,0,0])
+ // linear_extrude with internal hole and one coplanar edge
+ linear_extrude(height=a, slices=b, twist=c, scale=[x,y])
+ difference() {
+ square(2,true);
+ translate([-0.5,0,0]) square(1,true);
+ }
+}
+
+
+// Test varying parameters
+translate(00*[0,3,0])
+linear_extrudes_of_different_shapes(c=0,x=0,y=y);
+translate(01*[0,3,0])
+linear_extrudes_of_different_shapes(c=0,x=x,y=0);
+translate(02*[0,3,0])
+linear_extrudes_of_different_shapes(c=0,x=0,y=0);
+translate(03*[0,3,0])
+linear_extrudes_of_different_shapes(c=180,x=0,y=y);
+translate(04*[0,3,0])
+linear_extrudes_of_different_shapes(c=180,x=x,y=0);
+translate(05*[0,3,0])
+linear_extrudes_of_different_shapes(c=180,x=0,y=0);
diff --git a/testdata/scad/features/linear_extrude-tests.scad b/testdata/scad/features/linear_extrude-tests.scad
index 67de8e6..528eea2 100644
--- a/testdata/scad/features/linear_extrude-tests.scad
+++ b/testdata/scad/features/linear_extrude-tests.scad
@@ -11,3 +11,14 @@ translate([31.5,2.5,0]) linear_extrude(height=10, twist=-45) polygon(points = [[
translate([0,20,0]) linear_extrude(height=20, twist=45, slices=2) square([10,10]);
translate([19,20,0]) linear_extrude(height=20, twist=45, slices=10) square([10,10]);
+
+translate([0,-15,0]) linear_extrude(5) square([10,10]);
+
+// scale given as a scalar
+translate([-25,-10,0]) linear_extrude(height=10, scale=2) square(5, center=true);
+// scale given as a 3-dim vector
+translate([-15,20,0]) linear_extrude(height=20, scale=[4,5,6]) square(10);
+// scale is negative
+translate([-10,5,0]) linear_extrude(height=15, scale=-2) square(10, center=true);
+// scale given as undefined
+translate([-15,-15,0]) linear_extrude(height=10, scale=var_undef) square(10);
diff --git a/testdata/scad/features/module-recursion.scad b/testdata/scad/features/module-recursion.scad
new file mode 100644
index 0000000..f67a1d0
--- /dev/null
+++ b/testdata/scad/features/module-recursion.scad
@@ -0,0 +1,15 @@
+module tree(currentScale, levels)
+{
+ h = currentScale;
+ w = currentScale/5;
+ childScale = currentScale * 0.7;
+
+ if (levels > 0) {
+ cylinder(r=w, h=h);
+ translate([0,0,h]) for (i = [1:2]) {
+ rotate([40, 0, i * 180]) tree(childScale, levels-1);
+ }
+ }
+}
+
+tree(1, 4);
diff --git a/testdata/scad/features/modulevariables.scad b/testdata/scad/features/modulevariables.scad
new file mode 100644
index 0000000..fc7a183
--- /dev/null
+++ b/testdata/scad/features/modulevariables.scad
@@ -0,0 +1,7 @@
+module mymodule(modparam) {
+ inner_variable = 23;
+ inner_variable2 = modparam * 2;
+ cylinder(r1=inner_variable, r2=inner_variable2, h=10);
+}
+
+mymodule(5);
diff --git a/testdata/scad/features/surface-simple.dat b/testdata/scad/features/surface-simple.dat
index 32eba08..166c600 100644
--- a/testdata/scad/features/surface-simple.dat
+++ b/testdata/scad/features/surface-simple.dat
@@ -1,2 +1,6 @@
0 1
2 3
+
+# Comment
+
+
diff --git a/testdata/scad/features/surface-simple.scad b/testdata/scad/features/surface-simple.scad
index 9659143..1215a0b 100644
--- a/testdata/scad/features/surface-simple.scad
+++ b/testdata/scad/features/surface-simple.scad
@@ -1 +1,3 @@
surface("surface-simple.dat", center=true);
+// Surface without a trailing newline
+translate([2,0,0]) surface("surface-simple2.dat", center=true);
diff --git a/testdata/scad/features/surface-simple2.dat b/testdata/scad/features/surface-simple2.dat
new file mode 100644
index 0000000..a711970
--- /dev/null
+++ b/testdata/scad/features/surface-simple2.dat
@@ -0,0 +1,3 @@
+# Surface without a trailing newline
+0 1
+2 3 \ No newline at end of file
contact: Jan Huwald // Impressum