diff --git a/examples/Basics/rotate_extrude.scad b/examples/Basics/rotate_extrude.scad index f2fac408..ee8c5479 100644 --- a/examples/Basics/rotate_extrude.scad +++ b/examples/Basics/rotate_extrude.scad @@ -1,8 +1,8 @@ echo(version=version()); -// rotate_extrude() always rotates the 2D shape 360 degrees -// around the Z axis. Note that the 2D shape must be either -// completely on the positive or negative side of the X axis. +// rotate_extrude() rotates a 2D shape around the Z axis. +// Note that the 2D shape must be either completely on the +// positive or negative side of the X axis. color("red") rotate_extrude() translate([10, 0]) @@ -23,6 +23,26 @@ color("green") polygon( points=[[0,0],[8,4],[4,8],[4,12],[12,16],[0,20]] ); +// By default rotate_extrude forms a full 360 degree circle, +// but a partial rotation can be performed by using the angle parameter. +// Positive angles create an arc starting from the X axis, going counter-clockwise. +// Negative angles generate an arc in the clockwise direction. +color("magenta") + translate([40,40]){ + rotate_extrude(angle=180) + translate([12.5,0]) + square(5); + translate([7.5,0]) + rotate_extrude(angle=180) + translate([5,0]) + square(5); + translate([-7.5,0]) + rotate_extrude(angle=-180) + translate([5,0]) + square(5); + } + + // Written in 2015 by Torsten Paul // // To the extent possible under law, the author(s) have dedicated all diff --git a/src/rotateextrude.cc b/src/rotateextrude.cc index be8fc699..926067a7 100644 --- a/src/rotateextrude.cc +++ b/src/rotateextrude.cc @@ -52,7 +52,7 @@ AbstractNode *RotateExtrudeModule::instantiate(const Context *ctx, const ModuleI RotateExtrudeNode *node = new RotateExtrudeNode(inst); AssignmentList args; - args += Assignment("file"), Assignment("layer"), Assignment("origin"), Assignment("scale"), Assignment("angle"); + args += Assignment("file"), Assignment("layer"), Assignment("origin"), Assignment("scale"); Context c(ctx); c.setVariables(args, evalctx); @@ -115,8 +115,8 @@ std::string RotateExtrudeNode::toString() const ; } stream << - "convexity = " << this->convexity << ", " "angle = " << this->angle << ", " + "convexity = " << this->convexity << ", " "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; return stream.str(); diff --git a/testdata/scad/3D/features/rotate_extrude-angle.scad b/testdata/scad/3D/features/rotate_extrude-angle.scad new file mode 100644 index 00000000..6f4c4d1e --- /dev/null +++ b/testdata/scad/3D/features/rotate_extrude-angle.scad @@ -0,0 +1,40 @@ +$fa=15; +$fs=4; + +module face(x) { + translate([x,0]) difference() { + square(10,center=true); + square(5,center=true); + } +} + +module face2() { + translate([5,0]) square(5); +} + +// test negative partial angles and geometries on -X side +rotate_extrude(angle=45) face(10); +rotate_extrude(angle=45) face(-10); +rotate_extrude(angle=-45) face(21); +rotate_extrude(angle=-45) face(-21); + +// test small angles, angle < $fa, render a single segment +rotate([0,0,90]) { + rotate_extrude(angle=5) face(10); + rotate_extrude(angle=5) face(-10); + rotate_extrude(angle=-5) face(21); + rotate_extrude(angle=-5) face(-21); +} + +// show nothing +rotate_extrude(angle=0) face(5); // 0 angle + +// various angles treated as full circle +translate([-40,40]) rotate_extrude() face2(); // unspecified +translate([0,40]) rotate_extrude(angle=0/0) face2(); // NaN +translate([40,40]) rotate_extrude(angle=1/0) face2(); // Infinity +translate([-40,0]) rotate_extrude(angle=-1/0) face2(); // -Infinity +translate([40,0]) rotate_extrude(angle=360) face2(); // 360 +translate([-40,-40]) rotate_extrude(angle=-360) face2(); // -360 +translate([0,-40]) rotate_extrude(angle=1000) face2(); // > 360 +translate([40,-40]) rotate_extrude(angle=-1000) face2(); // < -360 diff --git a/tests/regression/cgalpngtest/rotate_extrude-angle-expected.png b/tests/regression/cgalpngtest/rotate_extrude-angle-expected.png new file mode 100644 index 00000000..c7db18e6 Binary files /dev/null and b/tests/regression/cgalpngtest/rotate_extrude-angle-expected.png differ diff --git a/tests/regression/cgalpngtest/rotate_extrude-expected.png b/tests/regression/cgalpngtest/rotate_extrude-expected.png index c2420a09..dd09ac0d 100644 Binary files a/tests/regression/cgalpngtest/rotate_extrude-expected.png and b/tests/regression/cgalpngtest/rotate_extrude-expected.png differ diff --git a/tests/regression/dumptest-examples/example007-expected.csg b/tests/regression/dumptest-examples/example007-expected.csg index 1d98c485..79bb8af3 100644 --- a/tests/regression/dumptest-examples/example007-expected.csg +++ b/tests/regression/dumptest-examples/example007-expected.csg @@ -3,25 +3,25 @@ group() { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { group() { difference() { - rotate_extrude(convexity = 3, $fn = 0, $fa = 12, $fs = 2) { - import(file = "example007.dxf", layer = "dorn", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 3, $fn = 0, $fa = 12, $fs = 2) { + import(file = "example007.dxf", layer = "dorn", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } group() { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { group() { intersection() { - multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 0], [0, 6.12323e-17, -1, 0], [0, 1, 6.12323e-17, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -50], [0, 0, 0, 1]]) { linear_extrude(height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example007.dxf", layer = "cutout1", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example007.dxf", layer = "cutout1", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } } - multmatrix([[0, -1, 0, 0], [1, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { - multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[6.12323e-17, -1, 0, 0], [1, 6.12323e-17, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 0], [0, 6.12323e-17, -1, 0], [0, 1, 6.12323e-17, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -50], [0, 0, 0, 1]]) { linear_extrude(height = 100, center = false, convexity = 2, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example007.dxf", layer = "cutout2", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example007.dxf", layer = "cutout2", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } } @@ -29,21 +29,21 @@ group() { } } } - multmatrix([[0, -1, 0, 0], [1, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[6.12323e-17, -1, 0, 0], [1, 6.12323e-17, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { group() { intersection() { - multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 0], [0, 6.12323e-17, -1, 0], [0, 1, 6.12323e-17, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -50], [0, 0, 0, 1]]) { linear_extrude(height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example007.dxf", layer = "cutout1", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example007.dxf", layer = "cutout1", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } } - multmatrix([[0, -1, 0, 0], [1, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { - multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[6.12323e-17, -1, 0, 0], [1, 6.12323e-17, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 0], [0, 6.12323e-17, -1, 0], [0, 1, 6.12323e-17, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -50], [0, 0, 0, 1]]) { linear_extrude(height = 100, center = false, convexity = 2, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example007.dxf", layer = "cutout2", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example007.dxf", layer = "cutout2", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } } diff --git a/tests/regression/dumptest-examples/example009-expected.csg b/tests/regression/dumptest-examples/example009-expected.csg index 8be43202..50d81a83 100644 --- a/tests/regression/dumptest-examples/example009-expected.csg +++ b/tests/regression/dumptest-examples/example009-expected.csg @@ -1,26 +1,26 @@ group() { group(); % linear_extrude(height = 22, center = true, convexity = 10, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example009.dxf", layer = "body", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example009.dxf", layer = "body", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } % group() { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 12], [0, 0, 0, 1]]) { linear_extrude(height = 2, center = true, convexity = 10, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example009.dxf", layer = "plate", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example009.dxf", layer = "plate", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -12], [0, 0, 0, 1]]) { linear_extrude(height = 2, center = true, convexity = 10, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example009.dxf", layer = "plate", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example009.dxf", layer = "plate", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } } intersection() { linear_extrude(height = 20, center = true, convexity = 10, twist = -57.5288, slices = 4, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "example009.dxf", layer = "fan_top", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "example009.dxf", layer = "fan_top", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } - rotate_extrude(convexity = 10, $fn = 0, $fa = 12, $fs = 2) { - import(file = "example009.dxf", layer = "fan_side", origin = [0, -40], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 10, $fn = 0, $fa = 12, $fs = 2) { + import(file = "example009.dxf", layer = "fan_side", origin = [0, -40], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } } } diff --git a/tests/regression/dumptest-examples/example017-expected.csg b/tests/regression/dumptest-examples/example017-expected.csg index d9787e5b..4f47a7b8 100644 --- a/tests/regression/dumptest-examples/example017-expected.csg +++ b/tests/regression/dumptest-examples/example017-expected.csg @@ -15,12 +15,12 @@ group() { square(size = [6, 10], center = true); } } - multmatrix([[-0.5, -0.86602540378, 0, 0], [0.86602540378, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[-0.5, -0.866025, 0, 0], [0.866025, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 36], [0, 0, 1, 0], [0, 0, 0, 1]]) { square(size = [6, 10], center = true); } } - multmatrix([[-0.5, 0.86602540378, 0, 0], [-0.86602540378, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[-0.5, 0.866025, 0, 0], [-0.866025, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 36], [0, 0, 1, 0], [0, 0, 0, 1]]) { square(size = [6, 10], center = true); } @@ -41,12 +41,12 @@ group() { square(size = [6, 15], center = true); } } - multmatrix([[-0.5, -0.86602540378, 0, 0], [0.86602540378, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[-0.5, -0.866025, 0, 0], [0.866025, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 88.5], [0, 0, 1, 0], [0, 0, 0, 1]]) { square(size = [6, 15], center = true); } } - multmatrix([[-0.5, 0.86602540378, 0, 0], [-0.86602540378, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[-0.5, 0.866025, 0, 0], [-0.866025, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 88.5], [0, 0, 1, 0], [0, 0, 0, 1]]) { square(size = [6, 15], center = true); } @@ -60,7 +60,7 @@ group() { group() { multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 102], [0, 0, 1, 0], [0, 0, 0, 1]]) { - multmatrix([[0, 0, -1, 0], [-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[2.22045e-16, 2.22045e-16, -1, 0], [-1, 0, -2.22045e-16, 0], [0, 1, 2.22045e-16, 0], [0, 0, 0, 1]]) { linear_extrude(height = 6, center = true, convexity = 10, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { group() { union() { @@ -101,9 +101,9 @@ group() { } } } - multmatrix([[-0.5, -0.86602540378, 0, 0], [0.86602540378, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[-0.5, -0.866025, 0, 0], [0.866025, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 102], [0, 0, 1, 0], [0, 0, 0, 1]]) { - multmatrix([[0, 0, -1, 0], [-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[2.22045e-16, 2.22045e-16, -1, 0], [-1, 0, -2.22045e-16, 0], [0, 1, 2.22045e-16, 0], [0, 0, 0, 1]]) { linear_extrude(height = 6, center = true, convexity = 10, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { group() { union() { @@ -144,9 +144,9 @@ group() { } } } - multmatrix([[-0.5, 0.86602540378, 0, 0], [-0.86602540378, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + multmatrix([[-0.5, 0.866025, 0, 0], [-0.866025, -0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 102], [0, 0, 1, 0], [0, 0, 0, 1]]) { - multmatrix([[0, 0, -1, 0], [-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) { + multmatrix([[2.22045e-16, 2.22045e-16, -1, 0], [-1, 0, -2.22045e-16, 0], [0, 1, 2.22045e-16, 0], [0, 0, 0, 1]]) { linear_extrude(height = 6, center = true, convexity = 10, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { group() { union() { @@ -191,7 +191,7 @@ group() { } % multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 12], [0, 0, 0, 1]]) { group() { - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { square(size = [25, 68], center = false); multmatrix([[1, 0, 0, 0], [0, 1, 0, 68], [0, 0, 1, 0], [0, 0, 0, 1]]) { intersection() { diff --git a/tests/regression/dumptest-examples/rotate_extrude-expected.csg b/tests/regression/dumptest-examples/rotate_extrude-expected.csg index 8e648c76..2e3491f2 100644 --- a/tests/regression/dumptest-examples/rotate_extrude-expected.csg +++ b/tests/regression/dumptest-examples/rotate_extrude-expected.csg @@ -1,7 +1,7 @@ group() { group(); color([1, 0, 0, 1]) { - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { square(size = [5, 5], center = false); } @@ -9,16 +9,39 @@ group() { } color([0, 1, 1, 1]) { multmatrix([[1, 0, 0, 40], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { - rotate_extrude(convexity = 2, $fn = 80, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 80, $fa = 12, $fs = 2) { text(text = " J", size = 10, spacing = 1, font = "", direction = "ltr", language = "en", script = "Latn", halign = "left", valign = "baseline", $fn = 80, $fa = 12, $fs = 2); } } } color([0, 0.501961, 0, 1]) { multmatrix([[1, 0, 0, 0], [0, 1, 0, 30], [0, 0, 1, 0], [0, 0, 0, 1]]) { - rotate_extrude(convexity = 2, $fn = 80, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 80, $fa = 12, $fs = 2) { polygon(points = [[0, 0], [8, 4], [4, 8], [4, 12], [12, 16], [0, 20]], paths = undef, convexity = 1); } } } + color([1, 0, 1, 1]) { + multmatrix([[1, 0, 0, 40], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 180, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + multmatrix([[1, 0, 0, 12.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + multmatrix([[1, 0, 0, 7.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 180, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + multmatrix([[1, 0, 0, -7.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = -180, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + } } diff --git a/tests/regression/dumptest/allmodules-expected.csg b/tests/regression/dumptest/allmodules-expected.csg index ef8a1d8f..126f6f3d 100644 --- a/tests/regression/dumptest/allmodules-expected.csg +++ b/tests/regression/dumptest/allmodules-expected.csg @@ -16,12 +16,12 @@ group() { intersection(); linear_extrude(height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2); linear_extrude(height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2); - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2); - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2); - import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); - import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); - import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); - import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 0); + import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 0); + import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 0); + import(file = "", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 0); group(); cube(size = [1, 1, 1], center = false); sphere($fn = 0, $fa = 12, $fs = 2, r = 1); @@ -32,7 +32,7 @@ group() { polygon(points = undef, paths = undef, convexity = 1); projection(cut = false, convexity = 0); render(convexity = 1); - surface(file = "", center = false, invert = false); + surface(file = "", center = false, invert = false, timestamp = 0); multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]); multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]); multmatrix([[-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]); diff --git a/tests/regression/dumptest/linear_extrude-tests-expected.csg b/tests/regression/dumptest/linear_extrude-tests-expected.csg index 23bdb899..b8b74451 100644 --- a/tests/regression/dumptest/linear_extrude-tests-expected.csg +++ b/tests/regression/dumptest/linear_extrude-tests-expected.csg @@ -1,7 +1,7 @@ group() { - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2); - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2); - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { cube(size = [1, 1, 1], center = false); } linear_extrude(height = 10, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { diff --git a/tests/regression/dumptest/localfiles-compatibility-test-expected.csg b/tests/regression/dumptest/localfiles-compatibility-test-expected.csg index e3be61a8..e963f567 100644 --- a/tests/regression/dumptest/localfiles-compatibility-test-expected.csg +++ b/tests/regression/dumptest/localfiles-compatibility-test-expected.csg @@ -1,17 +1,17 @@ group() { group() { linear_extrude(height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } multmatrix([[1, 0, 0, -250], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { - linear_extrude(file = "localfile.dxf", layer = "", origin = [0, 0], height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2); + linear_extrude(file = "localfile.dxf", layer = "", origin = [0, 0], timestamp = 1447128393, height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2); } multmatrix([[1, 0, 0, 0], [0, 1, 0, 350], [0, 0, 1, 0], [0, 0, 0, 1]]) { - rotate_extrude(file = "localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(file = "localfile.dxf", layer = "", origin = [0, 0], scale = 1, timestamp = 1447128393, angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); } multmatrix([[1, 0, 0, 250], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[200, 0, 0, 0], [0, 200, 0, 0], [0, 0, 50, 0], [0, 0, 0, 1]]) { - surface(file = "localfile.dat", center = false, invert = false); + surface(file = "localfile.dat", center = false, invert = false, timestamp = 1447128393); } } multmatrix([[1, 0, 0, 0], [0, 1, 0, -200], [0, 0, 1, 0], [0, 0, 0, 1]]) { diff --git a/tests/regression/dumptest/localfiles-test-expected.csg b/tests/regression/dumptest/localfiles-test-expected.csg index 8649c3b8..9f1e391b 100644 --- a/tests/regression/dumptest/localfiles-test-expected.csg +++ b/tests/regression/dumptest/localfiles-test-expected.csg @@ -1,17 +1,17 @@ group() { group() { linear_extrude(height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) { - import(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); + import(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2, timestamp = 1447128393); } multmatrix([[1, 0, 0, -250], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { - linear_extrude(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2); + linear_extrude(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], timestamp = 1447128393, height = 100, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2); } multmatrix([[1, 0, 0, 0], [0, 1, 0, 350], [0, 0, 1, 0], [0, 0, 0, 1]]) { - rotate_extrude(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, timestamp = 1447128393, angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); } multmatrix([[1, 0, 0, 250], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { multmatrix([[200, 0, 0, 0], [0, 200, 0, 0], [0, 0, 50, 0], [0, 0, 0, 1]]) { - surface(file = "localfiles_dir/localfile.dat", center = false, invert = false); + surface(file = "localfiles_dir/localfile.dat", center = false, invert = false, timestamp = 1447128393); } } multmatrix([[1, 0, 0, 0], [0, 1, 0, -200], [0, 0, 1, 0], [0, 0, 0, 1]]) { diff --git a/tests/regression/dumptest/rotate_extrude-angle-expected.csg b/tests/regression/dumptest/rotate_extrude-angle-expected.csg new file mode 100644 index 00000000..72aacc69 --- /dev/null +++ b/tests/regression/dumptest/rotate_extrude-angle-expected.csg @@ -0,0 +1,166 @@ +group() { + rotate_extrude(angle = 45, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + rotate_extrude(angle = 45, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, -10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + rotate_extrude(angle = -45, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 21], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + rotate_extrude(angle = -45, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, -21], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + multmatrix([[2.22045e-16, -1, 0, 0], [1, 2.22045e-16, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 5, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + rotate_extrude(angle = 5, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, -10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + rotate_extrude(angle = -5, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 21], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + rotate_extrude(angle = -5, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, -21], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + } + rotate_extrude(angle = 0, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + square(size = [10, 10], center = true); + square(size = [5, 5], center = true); + } + } + } + } + multmatrix([[1, 0, 0, -40], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, 40], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, -40], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, 40], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, -40], [0, 1, 0, -40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, -40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } + multmatrix([[1, 0, 0, 40], [0, 1, 0, -40], [0, 0, 1, 0], [0, 0, 0, 1]]) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 15, $fs = 4) { + group() { + multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 5], center = false); + } + } + } + } +} diff --git a/tests/regression/dumptest/rotate_extrude-tests-expected.csg b/tests/regression/dumptest/rotate_extrude-tests-expected.csg index d97d4376..dc1db378 100644 --- a/tests/regression/dumptest/rotate_extrude-tests-expected.csg +++ b/tests/regression/dumptest/rotate_extrude-tests-expected.csg @@ -1,17 +1,17 @@ group() { - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2); - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2); - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { cube(size = [1, 1, 1], center = false); } - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { circle($fn = 0, $fa = 12, $fs = 2, r = 10); } } multmatrix([[1, 0, 0, 50], [0, 1, 0, -20], [0, 0, 1, 0], [0, 0, 0, 1]]) { difference() { - rotate_extrude(convexity = 4, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 4, $fn = 0, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { difference() { circle($fn = 0, $fa = 12, $fs = 2, r = 10); @@ -27,12 +27,12 @@ group() { multmatrix([[1, 0, 0, 50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) { difference() { difference() { - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { circle($fn = 0, $fa = 12, $fs = 2, r = 10); } } - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { circle($fn = 0, $fa = 12, $fs = 2, r = 8); } @@ -44,14 +44,14 @@ group() { } } multmatrix([[1, 0, 0, 0], [0, 1, 0, -60], [0, 0, 1, 0], [0, 0, 0, 1]]) { - rotate_extrude(convexity = 2, $fn = 1, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 1, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { circle($fn = 1, $fa = 12, $fs = 2, r = 10); } } } multmatrix([[1, 0, 0, 0], [0, 1, 0, 60], [0, 0, 1, 0], [0, 0, 0, 1]]) { - rotate_extrude(convexity = 2, $fn = 0, $fa = 12, $fs = 2) { + rotate_extrude(angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2) { multmatrix([[1, 0, 0, -20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { square(size = [10, 10], center = false); } diff --git a/tests/regression/dumptest/rotate_extrude_dxf-tests-expected.csg b/tests/regression/dumptest/rotate_extrude_dxf-tests-expected.csg index 5f4d6c9c..8eeab9e8 100644 --- a/tests/regression/dumptest/rotate_extrude_dxf-tests-expected.csg +++ b/tests/regression/dumptest/rotate_extrude_dxf-tests-expected.csg @@ -1,3 +1,3 @@ group() { - rotate_extrude(file = "../../../dxf/open-polyline.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 2, $fn = 0, $fa = 12, $fs = 2); + rotate_extrude(file = "../../../dxf/open-polyline.dxf", layer = "", origin = [0, 0], scale = 1, timestamp = 1447128393, angle = 360, convexity = 2, $fn = 0, $fa = 12, $fs = 2); } diff --git a/tests/regression/opencsgtest/rotate_extrude-angle-expected.png b/tests/regression/opencsgtest/rotate_extrude-angle-expected.png new file mode 100644 index 00000000..c7db18e6 Binary files /dev/null and b/tests/regression/opencsgtest/rotate_extrude-angle-expected.png differ diff --git a/tests/regression/opencsgtest/rotate_extrude-expected.png b/tests/regression/opencsgtest/rotate_extrude-expected.png index de01e6d0..f1f0747a 100644 Binary files a/tests/regression/opencsgtest/rotate_extrude-expected.png and b/tests/regression/opencsgtest/rotate_extrude-expected.png differ diff --git a/tests/regression/throwntogethertest/rotate_extrude-angle-expected.png b/tests/regression/throwntogethertest/rotate_extrude-angle-expected.png new file mode 100644 index 00000000..c7db18e6 Binary files /dev/null and b/tests/regression/throwntogethertest/rotate_extrude-angle-expected.png differ diff --git a/tests/regression/throwntogethertest/rotate_extrude-expected.png b/tests/regression/throwntogethertest/rotate_extrude-expected.png index de01e6d0..f1f0747a 100644 Binary files a/tests/regression/throwntogethertest/rotate_extrude-expected.png and b/tests/regression/throwntogethertest/rotate_extrude-expected.png differ