Clamp linear_extrude height to 0. Fixes #405

epec-fast
Marius Kintel 2013-06-15 12:48:09 -04:00
parent 75a5dad6b7
commit 3f936099fa
5 changed files with 14 additions and 4 deletions

View File

@ -324,6 +324,7 @@ PolySet *PolySetCGALEvaluator::extrudeDxfData(const LinearExtrudeNode &node, Dxf
{
PolySet *ps = new PolySet();
ps->convexity = node.convexity;
if (node.height <= 0) return ps;
double h1, h2;

View File

@ -88,7 +88,8 @@ AbstractNode *LinearExtrudeModule::instantiate(const Context *ctx, const ModuleI
}
node->layername = layer.isUndefined() ? "" : layer.toString();
node->height = height.toDouble();
node->height = 100;
height.getDouble(node->height);
node->convexity = (int)convexity.toDouble();
origin.getVec2(node->origin_x, node->origin_y);
node->scale_x = node->scale_y = 1;
@ -99,8 +100,7 @@ AbstractNode *LinearExtrudeModule::instantiate(const Context *ctx, const ModuleI
if (center.type() == Value::BOOL)
node->center = center.toBool();
if (node->height <= 0)
node->height = 100;
if (node->height <= 0) node->height = 0;
if (node->convexity <= 0)
node->convexity = 1;

View File

@ -16,4 +16,5 @@ translate([22,11,0]) cylinder(h=15, r=5, r2=5);
// tend to "abuse" this for captured nut slots
translate([-10,0,0]) cylinder(h=2, r=3, $fn=6);
translate([-10, -10, 0]) sphere(5, $fn=0.1);
// Test that we clamp number of sections to a minimum of 3
translate([-10, -10, 0]) cylinder(r=3.5356, h=7.0711, $fn=0.1, center=true);

View File

@ -22,3 +22,6 @@ translate([-15,20,0]) linear_extrude(height=20, scale=[4,5,6]) square(10);
translate([-10,5,0]) linear_extrude(height=15, scale=-2) square(10, center=true);
// scale given as undefined
translate([-15,-15,0]) linear_extrude(height=10, scale=var_undef) square(10);
// height is negative
translate([0,-25,0]) linear_extrude(-1) square(10, center=true);

View File

@ -54,4 +54,9 @@
square(size = [10, 10], center = false);
}
}
multmatrix([[1, 0, 0, 0], [0, 1, 0, -25], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 0, center = false, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) {
square(size = [10, 10], center = true);
}
}