-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintervals.h
35 lines (30 loc) · 1.11 KB
/
intervals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <vector>
#include <set>
#include <limits>
#include <Eigen/Dense>
class DisjointIntervals {
public:
struct Interval {
float left, right;
Eigen::Vector3f normalLeft, normalRight;
bool operator<(Interval const &other) const;
bool operator==(Interval const &other) const;
};
constexpr static float NEG_INF = -std::numeric_limits<float>::infinity();
constexpr static float POS_INF = std::numeric_limits<float>::infinity();
DisjointIntervals(std::vector<Interval> const &intervals);
DisjointIntervals();
DisjointIntervals &intersectionWith(DisjointIntervals const &other);
DisjointIntervals &unionWith(DisjointIntervals const &other);
DisjointIntervals &inverse();
void print();
bool operator==(DisjointIntervals const &other) const;
std::set<Interval>::const_iterator begin() const { return intervals.cbegin(); }
std::set<Interval>::const_iterator end() const { return intervals.cend(); }
static DisjointIntervals empty();
static DisjointIntervals all();
private:
std::set<Interval> intervals;
void sanitize();
};