summaryrefslogtreecommitdiff
path: root/src/value.h
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-10-13 17:19:34 (GMT)
committerMarius Kintel <marius@kintel.net>2013-10-13 17:19:34 (GMT)
commite77615be3027cfe365e3e52f3ed609dae9711028 (patch)
tree21babea118b3bc59037e4e487a4c6bd6811b5412 /src/value.h
parent0f22d6e9ad562e87ae484a82df56ddee30e87343 (diff)
parent4401a136b9cbf01aa99cfdf5d9d67d62579dd853 (diff)
Merge branch 'children' of git://github.com/vicnet/openscad into vicnet-children
Conflicts: tests/CMakeLists.txt
Diffstat (limited to 'src/value.h')
-rw-r--r--src/value.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/value.h b/src/value.h
index 24e1b45..388b721 100644
--- a/src/value.h
+++ b/src/value.h
@@ -3,6 +3,8 @@
#include <vector>
#include <string>
+#include <algorithm>
+#include <limits>
// Workaround for https://bugreports.qt-project.org/browse/QTBUG-22829
#ifndef Q_MOC_RUN
@@ -39,6 +41,20 @@ public:
this->end == other.end;
}
+ /// inverse begin/end if begin is upper than end
+ void normalize() {
+ if ((step>0) && (end < begin)) {
+ std::swap(begin,end);
+ }
+ }
+ /// return number of steps, max int value if step is null
+ int nbsteps() const {
+ if (step<=0) {
+ return std::numeric_limits<int>::max();
+ }
+ return (int)((begin-end)/step);
+ }
+
double begin;
double step;
double end;
@@ -65,7 +81,6 @@ public:
Value(const char v);
Value(const VectorType &v);
Value(const RangeType &v);
- Value(double begin, double step, double end);
~Value() {}
ValueType type() const;
contact: Jan Huwald // Impressum