codac 1.5.6
Loading...
Searching...
No Matches
codac2_TubeComponent.h
Go to the documentation of this file.
1
12#ifndef __CODAC2_TUBECOMPONENT_H__
13#define __CODAC2_TUBECOMPONENT_H__
14
15template<class T>
16class TubeComponent //: public AbstractConstTube<Interval,TubeComponent<T>>
17{
18 protected:
19
20 TubeComponent(Tube<T>& tubevector, size_t i) :
21 _i(i), _tubevector(tubevector)
22 {
23 assert(i >= 0 && i < tubevector.size());
24 }
25
26 public:
27
28 TubeComponent(const TubeComponent<T>& tubevector_i) :
29 _i(tubevector_i._i), _tubevector(tubevector_i._tubevector)
30 {
31
32 }
33
34 size_t size() const
35 {
36 return 1;
37 }
38
39 const std::shared_ptr<TDomain>& tdomain() const
40 {
41 return _tubevector.tdomain();
42 }
43
44 Interval t0_tf() const
45 {
46 return _tubevector.t0_tf();
47 }
48
49 Interval codomain() const
50 {
51 Interval codomain(Interval::EMPTY_SET);
52 for(const auto& s : _tubevector)
53 codomain |= s.codomain()[_i];
54 return codomain;
55 }
56
57 bool contains(const Trajectory& value) const
58 {
59 assert(false);
60 return true;
61 }
62
63 void set(const Interval& codomain)
64 {
65 for(auto& s : _tubevector)
66 s.set_component(_i, codomain);
67 }
68
69 const TubeComponent<T>& operator=(const TubeComponent<T>& x)
70 {
71 assert(x.tdomain() == tdomain());
72 for(auto& s : _tubevector)
73 s.set_component(_i, std::static_pointer_cast<Slice<T>>(s._it_tslice->_slices.at(&x._tubevector))->codomain()[x._i]);
74 return *this;
75 }
76
77 const TubeComponent<T>& operator=(std::pair<std::function<Interval(const Interval&)>,const TubeComponent<T>> rel)
78 {
79 assert(rel.second.tdomain() == tdomain());
80 for(auto& s : _tubevector)
81 s.set_component(_i, rel.first(std::static_pointer_cast<Slice<T>>(s._it_tslice->_slices.at(&rel.second._tubevector))->codomain()[rel.second._i]));
82 return *this;
83 }
84
85 friend std::ostream& operator<<(std::ostream& os, const TubeComponent<T>& x)
86 {
87 os << "Component " << x._i << " of: " << x._tubevector << std::flush;
88 return os;
89 }
90
91 std::pair<std::function<Interval(const Interval&)>,const TubeComponent<T>> cos(const TubeComponent<T>& x)
92 {
93 return std::make_pair(static_cast<Interval(*)(const Interval&)>(ibex::cos), x);
94 }
95
96 codac::Tube to_codac1() const
97 {
98 codac::Tube x(t0_tf());
99 for(const auto& s : _tubevector)
100 if(!s.t0_tf().is_unbounded())
101 x.set(s.codomain()[_i], s.t0_tf());
102 for(const auto& s : _tubevector) // setting gate (were overwritten)
103 if(s.t0_tf().is_degenerated())
104 x.set(s.codomain()[_i], s.t0_tf());
105 return x;
106 }
107
108
109 protected:
110
111 size_t _i;
112 Tube<T>& _tubevector;
113
114 template<typename U>
115 friend class Tube;
116};
117
118template<class T>
119std::pair<std::function<Interval(const Interval&)>,const TubeComponent<T>> cos(const TubeComponent<T>& x);
120
121#endif
One dimensional tube , defined as an interval of scalar trajectories.
Definition codac_Tube.h:48