Merge pull request #796 from OskarLinde/offset_bugfix

Offset bug with delta < 1
master
Marius Kintel 2014-05-17 11:57:50 -04:00
commit 6a0d70033d
6 changed files with 14 additions and 3 deletions

View File

@ -413,7 +413,7 @@ Response GeometryEvaluator::visit(State &state, const OffsetNode &node)
// ClipperLib documentation: The formula for the number of steps in a full
// circular arc is ... Pi / acos(1 - arc_tolerance / abs(delta))
double n = Calc::get_fragments_from_r(10, node.fn, node.fs, node.fa);
double arc_tolerance = abs(node.delta) * (1 - cos(M_PI / n));
double arc_tolerance = std::abs(node.delta) * (1 - cos(M_PI / n));
const Polygon2d *result = ClipperUtils::applyOffset(*polygon, node.delta, node.join_type, node.miter_limit, arc_tolerance);
assert(result);
geom.reset(result);

View File

@ -34,6 +34,10 @@ offset(-4) shape1(-1, 0);
shape1(0, 0);
offset(4) shape1(1, 0);
offset(delta = -5) shape1(-1, -1);
offset(delta = -5) shape1(2, 1);
shape1(0, -1);
offset(delta = 5) shape1(1, -1);
// Bug with fragment calculateion with delta < 1 due to abs() instead of std::abs()
translate([-50,-50]) scale([25,25,1])
offset(delta = 0.9, join_type="round") square(.1);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -104,7 +104,7 @@ group() {
}
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]]) {
multmatrix([[1, 0, 0, 100], [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);
@ -130,4 +130,11 @@ group() {
}
}
}
multmatrix([[1, 0, 0, -50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[25, 0, 0, 0], [0, 25, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
offset(delta = 0.9, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
square(size = [0.1, 0.1], center = false);
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 11 KiB