Add test cases for offset().

master
Torsten Paul 2014-02-23 23:31:02 +01:00
parent f72e4047d2
commit 5d8507f725
7 changed files with 179 additions and 2 deletions

View File

@ -81,10 +81,14 @@ AbstractNode *OffsetModule::instantiate(const Context *ctx, const ModuleInstanti
} else if (std::string("miter") == jt) {
node->join_type = ClipperLib::jtMiter;
} else {
PRINTB("Unknown join_type for offset(): '%1'", jt);
PRINTB("WARNING: Unknown join_type for offset(): '%s'", jt);
}
if ((node->join_type != ClipperLib::jtMiter) && !miter_limit.isUndefined()) {
PRINTB("WARNING: miter_limit is ignored in offset() for join_type: '%s'", jt);
}
}
std::vector<AbstractNode *> instantiatednodes = inst->instantiateChildren(evalctx);
node->children.insert(node->children.end(), instantiatednodes.begin(), instantiatednodes.end());

View File

@ -0,0 +1,39 @@
module shape1(x, y) {
translate([50 * x, 50 * y]) difference() {
square([30, 30], center = true);
square([8, 8], center = true);
}
}
module shape2(x, y) {
translate([50 * x, 50 * y]) {
polygon(points=[
[-15, 80],[15, 80],[0,-15],[-8, 60],[8, 60],[0, 5]
], paths=[
[0,1,2],[3,4,5]
]);
}
}
offset(delta = -1, join_type = "miter") shape2(-1, 2);
shape2(0, 2);
offset(delta = 1, join_type = "miter") shape2(1, 2);
offset(delta = -1, join_type = "miter", miter_limit = 10) shape2(2, 2);
offset(delta = 1, join_type = "miter", miter_limit = 10) shape2(3, 2);
offset(delta = -1, join_type = "square", miter_limit = 10) shape2(2, -1);
offset(delta = 1, join_type = "square", miter_limit = 10) shape2(3, -1);
offset(delta = -5, join_type = "round") shape1(-1, 1);
shape1(0, 1);
offset(delta = 5, join_type = "round") shape1(1, 1);
offset(-4) shape1(-1, 0);
shape1(0, 0);
offset(4) shape1(1, 0);
offset(delta = -5) shape1(-1, -1);
shape1(0, -1);
offset(delta = 5) shape1(1, -1);

View File

@ -547,6 +547,7 @@ set(CORE_SOURCES
../src/rendersettings.cc
../src/dxfdata.cc
../src/dxfdim.cc
../src/offset.cc
../src/linearextrude.cc
../src/rotateextrude.cc
../src/printutils.cc

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -0,0 +1,133 @@
group() {
offset(delta = -1, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
offset(delta = 1, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -1, join_type = miter, miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = 1, join_type = miter, miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 150], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -1, join_type = bevel, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = 1, join_type = bevel, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 150], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -5, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
}
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
offset(delta = 5, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
}
offset(delta = -4, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
}
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
offset(delta = 4, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
}
offset(delta = -5, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
}
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
offset(delta = 5, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
square(size = [30, 30], center = true);
square(size = [8, 8], center = true);
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB