summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/example017.scad19
-rw-r--r--value.cc25
2 files changed, 33 insertions, 11 deletions
diff --git a/examples/example017.scad b/examples/example017.scad
index 98e540f..9013d4e 100644
--- a/examples/example017.scad
+++ b/examples/example017.scad
@@ -1,4 +1,11 @@
+// To render the DXF file from the command line:
+// openscad -x example017.dxf -D'mode="parts"' example017.scad
+
+// mode = "parts";
+// mode = "exploded";
+mode = "assembled";
+
thickness = 6;
locklen1 = 15;
locklen2 = 10;
@@ -139,6 +146,12 @@ module assembled()
% translate([ 0, 0, thickness*2]) bottle();
}
-// parts();
-// exploded();
-assembled();
+if (mode == "parts")
+ parts();
+
+if (mode == "exploded")
+ exploded();
+
+if (mode == "assembled")
+ assembled();
+
diff --git a/value.cc b/value.cc
index 2778e58..f51b057 100644
--- a/value.cc
+++ b/value.cc
@@ -203,18 +203,27 @@ Value Value::operator == (const Value &v) const
if (type == NUMBER && v.type == NUMBER) {
return Value(num == v.num);
}
- return Value();
+ if (type == RANGE && v.type == RANGE) {
+ return Value(range_begin == v.range_begin && range_step == v.range_step && range_end == v.range_end);
+ }
+ if (type == VECTOR && v.type == VECTOR) {
+ if (vec.size() != v.vec.size())
+ return Value(false);
+ for (int i=0; i<vec.size(); i++)
+ if (!(*vec[i] == *v.vec[i]).b)
+ return Value(false);
+ return Value(true);
+ }
+ if (type == STRING && v.type == STRING) {
+ return Value(text == v.text);
+ }
+ return Value(false);
}
Value Value::operator != (const Value &v) const
{
- if (type == BOOL && v.type == BOOL) {
- return Value(b != v.b);
- }
- if (type == NUMBER && v.type == NUMBER) {
- return Value(num != v.num);
- }
- return Value();
+ Value eq = *this == v;
+ return Value(!eq.b);
}
Value Value::operator >= (const Value &v) const
contact: Jan Huwald // Impressum