summaryrefslogtreecommitdiff
path: root/src/linearextrude.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2012-03-27 22:05:00 (GMT)
committerMarius Kintel <marius@kintel.net>2012-03-27 22:05:58 (GMT)
commit327310f190bbd81c7b71b568d5bf72bb900cc9db (patch)
tree9399bb490ecafe9f0c7fd209c680311d829eb631 /src/linearextrude.cc
parent4394c7a030ce7a08c95bd1af2e8c38ffcf972439 (diff)
Rewrote the Value class to be based on boost::variant - this should reduce memory footprint and improve performance
Diffstat (limited to 'src/linearextrude.cc')
-rw-r--r--src/linearextrude.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/linearextrude.cc b/src/linearextrude.cc
index 4f5fd14..b193181 100644
--- a/src/linearextrude.cc
+++ b/src/linearextrude.cc
@@ -56,9 +56,9 @@ AbstractNode *LinearExtrudeModule::evaluate(const Context *ctx, const ModuleInst
Context c(ctx);
c.args(argnames, argexpr, inst->argnames, inst->argvalues);
- node->fn = c.lookup_variable("$fn").num;
- node->fs = c.lookup_variable("$fs").num;
- node->fa = c.lookup_variable("$fa").num;
+ node->fn = c.lookup_variable("$fn").toDouble();
+ node->fs = c.lookup_variable("$fs").toDouble();
+ node->fa = c.lookup_variable("$fa").toDouble();
Value file = c.lookup_variable("file");
Value layer = c.lookup_variable("layer", true);
@@ -70,19 +70,19 @@ AbstractNode *LinearExtrudeModule::evaluate(const Context *ctx, const ModuleInst
Value twist = c.lookup_variable("twist", true);
Value slices = c.lookup_variable("slices", true);
- if (!file.text.empty()) {
+ if (!file.isUndefined()) {
PRINT("DEPRECATED: Support for reading files in linear_extrude will be removed in future releases. Use a child import() instead.");
- node->filename = c.getAbsolutePath(file.text);
+ node->filename = c.getAbsolutePath(file.toString());
}
- node->layername = layer.text;
- node->height = height.num;
- node->convexity = (int)convexity.num;
- origin.getv2(node->origin_x, node->origin_y);
- node->scale = scale.num;
+ node->layername = layer.isUndefined() ? "" : layer.toString();
+ node->height = height.toDouble();
+ node->convexity = (int)convexity.toDouble();
+ origin.getVec2(node->origin_x, node->origin_y);
+ node->scale = scale.toDouble();
- if (center.type == Value::BOOL)
- node->center = center.b;
+ if (center.type() == Value::BOOL)
+ node->center = center.toBool();
if (node->height <= 0)
node->height = 100;
@@ -93,10 +93,10 @@ AbstractNode *LinearExtrudeModule::evaluate(const Context *ctx, const ModuleInst
if (node->scale <= 0)
node->scale = 1;
- if (twist.type == Value::NUMBER) {
- node->twist = twist.num;
- if (slices.type == Value::NUMBER) {
- node->slices = (int)slices.num;
+ if (twist.type() == Value::NUMBER) {
+ node->twist = twist.toDouble();
+ if (slices.type() == Value::NUMBER) {
+ node->slices = (int)slices.toDouble();
} else {
node->slices = (int)fmax(2, fabs(get_fragments_from_r(node->height,
node->fn, node->fs, node->fa) * node->twist / 360));
contact: Jan Huwald // Impressum