diff options
| author | Andreas Grois <andreas.grois@jku.at> | 2015-11-10 13:39:56 +0100 |
|---|---|---|
| committer | Andreas Grois <andreas.grois@jku.at> | 2015-11-10 13:39:56 +0100 |
| commit | fc46d20e8411fe4b67269733f69d8a9dded4a42f (patch) | |
| tree | a3de639d552dd78ecdebc8cac8d703e3eb6bad4b /anglerange.h | |
| parent | 4aa67d78e9238a65eb94a762328465e2541fd4c4 (diff) | |
Add angle sets (disjoint ranges) - initial support
By adding a new angleset class, things get much easier to read. Also, the part of the previous commit that dealt with combining the individual ranges was kind of stupid.
Things missing:
o) functions to remove angle ranges from a set
o) deferred add functions, that allow adding multiple ranges without calling the O(n²) function angleset::combine() in between.
Diffstat (limited to 'anglerange.h')
| -rw-r--r-- | anglerange.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/anglerange.h b/anglerange.h index ab98cbc..6d6d286 100644 --- a/anglerange.h +++ b/anglerange.h @@ -38,14 +38,22 @@ #define ANGLERANGE_H #include "angleclass.h" +#include <stdexcept> class anglerange { +public: + typedef enum sorttype {SRT_LOWER,SRT_UPPER,SRT_SIZE} sorttype; private: angleclass lowerborder; angleclass upperborder; bool upperset; bool lowerset; + bool fullcircle; + sorttype sortby; //for comparison operators + //default value: SRT_SIZE + //lower means sort by lower border, upper sort by upper border, and size sort by (upper-lower) + //only size cares about zero-crossing, the others just compare numeric values. public: //Default constructor: Both limits 0.0, marked as empty anglerange(); @@ -54,9 +62,18 @@ public: void setupper(const angleclass &newupper); void setempty(); //marks the range as empty. + //to change sort field + void setsorttype(const sorttype value); + const sorttype getsorttype(); + bool isempty() const; //returns true when the range is empty (or when one limit isn't set) - angleclass getlower() const; //warning: Does not check if empty - angleclass getupper() const; //warning: Does not check if empty + angleclass getlower() const; //warning: Does not check if empty, does not check if circle + angleclass getupper() const; //warning: Does not check if empty, does not check if circle + bool isinside(const angleclass &val) const; //check if angleclas val is in the range. + + //to deal with full circles: + void setcircle(bool value); + bool iscircle() const; //this function calculates the overlap between this anglerange and another one, returning it as //a new anglerange. @@ -66,6 +83,16 @@ public: //if they are disjoint, an empty range is given back. anglerange combine(const anglerange &other); + bool operator<(const anglerange &other) const; + bool operator>(const anglerange &other) const; + bool operator<=(const anglerange &other) const; + bool operator>=(const anglerange &other) const; + + //these operators don't use sort order. They really compare by element! + //also: Two empty ranges are considered equal! + bool operator==(const anglerange &other) const; + bool operator!=(const anglerange &other) const; + }; #endif // ANGLERANGE_H |
