bugfix: #562 didn't take into account that it's allowed with all X coordinates being negative

vector-concat
Marius Kintel 2013-12-14 17:44:05 -05:00
parent a3aa61bab2
commit cca80a1559
6 changed files with 17 additions and 5 deletions

View File

@ -455,19 +455,21 @@ PolySet *PolySetCGALEvaluator::rotateDxfData(const RotateExtrudeNode &node, DxfD
for (size_t i = 0; i < dxf.paths.size(); i++)
{
double min_x = 0;
double max_x = 0;
for (size_t j = 0; j < dxf.paths[i].indices.size(); j++) {
double point_x = dxf.points[dxf.paths[i].indices[j]][0];
if (point_x < 0) {
PRINT("ERROR: all points for rotate_extrude() must have non-negative X coordinates");
PRINTB("[Point %d on path %d has X coordinate %f]", j % i % point_x);
min_x = fmin(min_x, point_x);
max_x = fmax(max_x, point_x);
if ((max_x - min_x) > max_x && (max_x - min_x) > fabs(min_x)) {
PRINTB("ERROR: all points for rotate_extrude() must have the same X coordinate sign (range is %.2f -> %.2f)", min_x % max_x);
delete ps;
return NULL;
}
max_x = fmax(max_x, point_x);
}
int fragments = get_fragments_from_r(max_x, node.fn, node.fs, node.fa);
int fragments = get_fragments_from_r(max_x-min_x, node.fn, node.fs, node.fa);
double ***points;
points = new double**[fragments];

View File

@ -32,3 +32,6 @@ translate([50,50,0]) {
// Minimal $fn
translate([0,-60,0]) rotate_extrude($fn=1) translate([20,0,0]) circle(r=10,$fn=1);
// Object in negative X
translate([0,60,0]) rotate_extrude() translate([-20,0]) square(10);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -50,4 +50,11 @@ group() {
}
}
}
multmatrix([[1, 0, 0, 0], [0, 1, 0, 60], [0, 0, 1, 0], [0, 0, 0, 1]]) {
rotate_extrude(convexity = 1, $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);
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB