diff options
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/scad/bugs/issue95-normalization-crash.scad | 128 | ||||
-rw-r--r-- | testdata/scad/features/text-search-test.scad | 29 | ||||
-rw-r--r-- | testdata/scad/misc/search-tests.scad | 63 | ||||
-rw-r--r-- | testdata/scad/misc/vector-values.scad | 40 |
4 files changed, 260 insertions, 0 deletions
diff --git a/testdata/scad/bugs/issue95-normalization-crash.scad b/testdata/scad/bugs/issue95-normalization-crash.scad new file mode 100644 index 0000000..10a3f66 --- /dev/null +++ b/testdata/scad/bugs/issue95-normalization-crash.scad @@ -0,0 +1,128 @@ +// +// Reported by Triffid Hunter. +// Causes a crash in CCGTermNormalizer::normalizePass() +// + +pi = 3.141592653589; +sl = 0.5; + +w = 400; + +pulley_diam = 28; +bearing_diam = 22; //include size of bearing guides + +module crx(size=[1, 1, 1]) { + linear_extrude(height=size[2]) + square([size[0], size[1]], center=true); +} + +module cyl(r=1, h=1, center=false) { + cylinder(r=r, h=h, center=center, $fn=r * 2 * pi / sl); +} + +module lm8uu() { + cyl(r=15 /2, h=24); +} + +module nema17() { + translate([0, 0, -48]) crx([42, 42, 48]); + translate([0, 0, -1]) { + cyl(r=2.5, h=26); + cyl(r=22.5 / 2, h=3.1); + } + translate([0, 0, 2.1]) { + difference() { + cyl(r=pulley_diam / 2, h=11.5); + translate([0, 0, (11.5 - 8) / 2]) rotate_extrude() + translate([21.5 / 2, 0]) + square(8); + } + } + cyl(r=17.5 / 2, h=19.5); + for (i=[0:3]) { + rotate([0, 0, i * 90]) + translate([31 / 2, 31 / 2, -1]) { + cyl(r=1.5, h=11); + translate([0, 0, 5.5]) + cyl(r=4, h=30); + } + } +} + +module bearing608() { + cyl(r=bearing_diam / 2, h = 7); +} + +module rods() { + for (i=[0:1]) { + translate([25, 0, i * 70]) + rotate([0, -90, 0]) + cyl(r=4, h=420); + } + + translate([0, 10, -40]) { + cyl(r=3, h=150); + translate([0, 0, 34]) cylinder(r=10 / cos(180 / 6) / 2, h=6, $fn=6); + } + + translate([30, 10, -40]) { + cyl(r=4, h=150); + } +} + +module lm8uu_holder() { + render() + difference() { + union() { + translate([0, 0, -13]) difference() { + hull() { + translate([-9, -9, -1]) cube([18, 1, 28]); + translate([0, 1, -1]) cyl(r=18 / 2, h = 28); + } + translate([-10, 5, -1]) cube([20, 10, 28]); + translate([-10, -3, 11 - 5]) cube([20, 20, 4]); + translate([-10, -3, 11 + 5]) cube([20, 20, 4]); + } + } + translate([0, 0, -11]) { + hull() { + #lm8uu(); + translate([0, 10, 0]) cyl(r=6, h=24); + } + translate([0, 0, -3]) hull() { + cyl(r=5, h=30); + translate([0, 10, 0]) cyl(r=5, h=30); + } + } + } +} + +module x_end_motor() { + difference() { + union() { + translate([-10, -18, -19]) #cube([50, 2, 90]); + translate([30, 10, 60]) lm8uu_holder(); + translate([30, 10, -5]) lm8uu_holder(); + } + #rods(); + + translate([15.5, -19, 14]) { + rotate([90, 0, 0]) cyl(r=30 / 2, h= 50, center=true); + rotate([-90, 45, 0]) + #nema17(); + translate([-w, 4, 0]) + rotate([-90, 0, 0]) + bearing608(); + translate([0, 5, 0]) hull() { + #translate([0, 0, 24 / 2 - 1.5]) cube([1, 5, 1.5]); + #translate([-w, 0, bearing_diam / 2 ]) cube([1, 5, 1.5]); + } + translate([0, 5, 0]) hull() { + #translate([0, 0, 24 / -2]) cube([1, 5, 1.5]); + #translate([-w, 0, bearing_diam / -2 - 1.5]) cube([1, 5, 1.5]); + } + } + } +} + +x_end_motor();
\ No newline at end of file diff --git a/testdata/scad/features/text-search-test.scad b/testdata/scad/features/text-search-test.scad new file mode 100644 index 0000000..8b6047f --- /dev/null +++ b/testdata/scad/features/text-search-test.scad @@ -0,0 +1,29 @@ +// fonts test + +use <MCAD/fonts.scad> + +thisFont=8bit_polyfont(); +thisText="OpenSCAD Rocks!"; +// Find one letter matches from 2nd column (index 1) +theseIndicies=search(thisText,thisFont[2],1,1); +// Letter spacing, x direction. +x_shift=thisFont[0][0]; +y_shift=thisFont[0][1]; +echo(theseIndicies); +// Simple polygon usage. +for(i=[0:len(theseIndicies)-1]) translate([i*x_shift-len(theseIndicies)*x_shift/2,0]) { + polygon(points=thisFont[2][theseIndicies[i]][6][0],paths=thisFont[2][theseIndicies[i]][6][1]); +} + +theseIndicies2=search("ABC",thisFont[2],1,1); +// outline_2d() example +for(i=[0:len(theseIndicies2)-1]) translate([i*x_shift-len(theseIndicies2)*x_shift,-y_shift]) { + outline_2d(outline=true,points=thisFont[2][theseIndicies2[i]][6][0],paths=thisFont[2][theseIndicies2[i]][6][1],width=0.25); +} + +theseIndicies3=search("123",thisFont[2],1,1); +// bold_2d() outline_2d(false) example +for(i=[0:len(theseIndicies3)-1]) translate([i*x_shift,-2*y_shift]) { + bold_2d(bold=true,width=0.25,resolution=8) + outline_2d(false,thisFont[2][theseIndicies3[i]][6][0],thisFont[2][theseIndicies3[i]][6][1]); +}
\ No newline at end of file diff --git a/testdata/scad/misc/search-tests.scad b/testdata/scad/misc/search-tests.scad new file mode 100644 index 0000000..fb85109 --- /dev/null +++ b/testdata/scad/misc/search-tests.scad @@ -0,0 +1,63 @@ +// string searches + +simpleSearch1=search("a","abcdabcd"); +echo(str("Characters in string (\"a\"): ",simpleSearch1)); + +simpleSearch2=search("adeq","abcdeabcd",0); +echo(str("Characters in string (\"adeq\"): ",simpleSearch2)); + +sTable1=[ ["a",1],["b",2],["c",3],["d",4],["a",5],["b",6],["c",7],["d",8],["e",9] ]; +s1= search("abe",sTable1); +echo(str("Default string search (\"abe\"): ",s1)); + +sTable2=[ ["a",1],["b",2],["c",3],["d",4],["a",5],["b",6],["c",7],["d",8],["e",9],["a",10],["a",11] ]; +s2= search("abe",sTable2,0); +echo(str("Return all matches for string search (\"abe\"): ",s2)); + +sTable3=[ ["a",1],["b",2],["c",3],["d",4],["a",5],["b",6],["c",7],["d",8],["e",9],["a",10],["a",11] ]; +s3= search("abe",sTable3,2); +echo(str("Return up to 2 matches for string search (\"abe\"): ",s3)); + +sTable4=[ [1,"a",[20]],[2,"b",21],[3,"c",22],[4,"d",23],[5,"a",24],[6,"b",25],[7,"c",26],[8,"d",27],[9,"e",28],[10,"a",29],[11,"a",30] ]; +s4= search("aebe",sTable4,2,1); +echo(str("Return up to 2 matches for string search; alternate columns (\"aebe\"): ",s4)); + +// s5= search("abe",sTable4,2,1,3); // bounds checking needs fixing. +// echo(str("Return up to 2 matches for string search; alternate columns: ",s4)); + + +// number searches +nTable1=[ [1,"a"],[3,"b"],[2,"c"],[4,"d"],[1,"a"],[7,"b"],[2,"c"],[8,"d"],[9,"e"],[10,"a"],[1,"a"] ]; +n1 = search(7,nTable1); +echo(str("Default number search (7): ",n1)); +n2 = search(1,nTable1,0); +echo(str("Return all matches for number search (1): ",n2)); +n3 = search(1,nTable1,2); +echo(str("Return up to 2 matches for number search (1): ",n3)); + +// list searches +lTable1=[ [1,"a"],[3,"b"],[2,"c"],[4,"d"],[1,"a"],[7,"b"],[2,"c"],[8,"d"],[9,"e"],[10,"a"],[1,"a"] ]; +lSearch1=[1,3,1000]; +l1=search(lSearch1,lTable1); +echo(str("Default list number search (",lSearch1,"): ",l1)); + +lTable2=[ ["cat",1],["b",2],["c",3],["dog",4],["a",5],["b",6],["c",7],["d",8],["e",9],["apple",10],["a",11] ]; +lSearch2=["b","zzz","a","c","apple","dog"]; +l2=search(lSearch2,lTable2); +echo(str("Default list string search (",lSearch2,"): ",l2)); + +lTable3=[ ["cat",1],["b",2],["c",3],[4,"dog"],["a",5],["b",6],["c",7],["d",8],["e",9],["apple",10],["a",11] ]; +lSearch3=["b",4,"zzz","c","apple",500,"a",""]; +l3=search(lSearch3,lTable3); +echo(str("Default list mixed search (",lSearch3,"): ",l3)); + +l4=search(lSearch3,lTable3,0); +echo(str("Return all matches for mixed search (",lSearch3,"): ",l4)); + +lSearch5=[1,"zz","dog",500,11]; +l5=search(lSearch5,lTable3,0,1); +echo(str("Return all matches for mixed search; alternate columns (",lSearch5,"): ",l5)); + + +// for completeness +cube(1.0); diff --git a/testdata/scad/misc/vector-values.scad b/testdata/scad/misc/vector-values.scad new file mode 100644 index 0000000..1872b39 --- /dev/null +++ b/testdata/scad/misc/vector-values.scad @@ -0,0 +1,40 @@ +// Value vector tests. + +a1=[0,1,2]; +b1=[3,4,5]; +c1=a1*b1; +echo(str("Testing vector dot product: ",c1)); + +d1=[1,0]; +echo(str(" Bounds check: ",a1*d1)); + +m2=[[0,1],[1,0]]; +v2=[2,3]; +p2=m2*v2; +echo(str("Testing matrix * vector: ",p2)); + +d2=[0,0,1]; +echo(str(" Bounds check: ",m2*d2)); + +m3=[[1,-1,1],[1,0,-1]]; +v3=[1,1]; +p3=v3*m3; +echo(str("Testing vector * matrix: ",p3)); + +echo(str(" Bounds check: ",m3*v3)); + +ma4=[ [1,0],[0,1] ]; +mb4=[ [1,0],[0,1] ]; +echo(str("Testing id matrix * id matrix: ",ma4*mb4)); + +ma5=[ [1, 0, 1] + ,[0, 1,-1] ]; +mb5=[ [1,0] + ,[0,1] + ,[1,1] ]; +echo(str("Testing asymmetric matrix * matrix: ",ma5*mb5)); +echo(str("Testing alternate asymmetric matrix * matrix: ",mb5*ma5)); + +echo(str(" Bounds check: ",ma5*ma4)); + +cube(1.0); |