diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-01-14 10:15:22 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-01-14 10:15:22 (GMT) |
commit | b81d72acb0e63dc0ef81cf8ef972c40719d3674e (patch) | |
tree | c918cf03c17b5d45a66ccddcc70a2b508cf1b875 | |
parent | f1240de7f06166b4857c419b2b617629ebf95c46 (diff) |
Clifford Wolf:
Added == support for all value types
git-svn-id: http://svn.clifford.at/openscad/trunk@286 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r-- | examples/example017.scad | 19 | ||||
-rw-r--r-- | value.cc | 25 |
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(); + @@ -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 |