codac 2.0.0
Loading...
Searching...
No Matches
codac2_SepUnion.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <type_traits>
13#include "codac2_Sep.h"
14#include "codac2_Collection.h"
15#include "codac2_SepWrapper.h"
16
17namespace codac2
18{
19 class SepUnion : public Sep<SepUnion>
20 {
21 public:
22
23 template<typename S>
24 requires (IsSepBaseOrPtr<S> && !std::is_same_v<SepUnion,S>)
25 SepUnion(const S& s)
26 : Sep<SepUnion>(size_of(s)), _seps(s)
27 { }
28
29 template<typename... S>
30 requires (IsSepBaseOrPtr<S> && ...)
31 SepUnion(const S&... s)
32 : Sep<SepUnion>(size_first_item(s...)), _seps(s...)
33 {
34 assert_release(all_same_size(s...));
35 }
36
37 size_t nb() const
38 {
39 return _seps.size();
40 }
41
42 BoxPair separate(const IntervalVector& x) const;
43
44 template<typename S>
45 requires IsSepBaseOrPtr<S>
46 SepUnion& operator|=(const S& s)
47 {
48 assert_release(size_of(s) == this->size());
49 _seps.push_back(s);
50 return *this;
51 }
52
53 protected:
54
55 Collection<SepBase> _seps;
56 };
57
58 template<typename S1, typename S2>
59 requires (IsSepBaseOrPtr<S1> && IsSepBaseOrPtr<S2>)
60 inline SepUnion operator|(const S1& s1, const S2& s2)
61 {
62 return SepUnion(s1,s2);
63 }
64
65 template<typename S2>
66 requires IsSepBaseOrPtr<S2>
67 inline SepUnion operator|(const IntervalVector& s1, const S2& s2)
68 {
69 assert_release(s1.size() == s2.size());
70 return SepUnion(SepWrapper(s1),s2);
71 }
72
73 template<typename S1>
74 requires IsSepBaseOrPtr<S1>
75 inline SepUnion operator|(const S1& s1, const IntervalVector& s2)
76 {
77 assert_release(s1.size() == s2.size());
78 return SepUnion(s1,SepWrapper(s2));
79 }
80}
Definition codac2_OctaSym.h:21
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25