codac 1.5.6
Loading...
Searching...
No Matches
codac2_TubeComponent.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_Interval.h"
13
14namespace codac2
15{
16 #if 0
17 template<class T>
18 class TubeComponent //: public AbstractConstTube<Interval,TubeComponent<T>>
19 {
20 protected:
21
22 TubeComponent(Tube<T>& tubevector, size_t i) :
23 _i(i), _tubevector(tubevector)
24 {
25 assert(i >= 0 && i < tubevector.size());
26 }
27
28 public:
29
30 TubeComponent(const TubeComponent<T>& tubevector_i) :
31 _i(tubevector_i._i), _tubevector(tubevector_i._tubevector)
32 {
33
34 }
35
36 size_t size() const
37 {
38 return 1;
39 }
40
41 const std::shared_ptr<TDomain>& tdomain() const
42 {
43 return _tubevector.tdomain();
44 }
45
46 Interval t0_tf() const
47 {
48 return _tubevector.t0_tf();
49 }
50
51 Interval codomain() const
52 {
53 Interval codomain(Interval::empty());
54 for(const auto& s : _tubevector)
55 codomain |= s.codomain()[_i];
56 return codomain;
57 }
58
59 /*bool contains(const Trajectory& value) const
60 {
61 assert(false);
62 return true;
63 }*/
64
65 void set(const Interval& codomain)
66 {
67 for(auto& s : _tubevector)
68 s.set_component(_i, codomain);
69 }
70
71 const TubeComponent<T>& operator=(const TubeComponent<T>& x)
72 {
73 assert(x.tdomain() == tdomain());
74 for(auto& s : _tubevector)
75 s.set_component(_i, std::static_pointer_cast<Slice<T>>(s._it_tslice->_slices.at(&x._tubevector))->codomain()[x._i]);
76 return *this;
77 }
78
79 const TubeComponent<T>& operator=(std::pair<std::function<Interval(const Interval&)>,const TubeComponent<T>> rel)
80 {
81 assert(rel.second.tdomain() == tdomain());
82 for(auto& s : _tubevector)
83 s.set_component(_i, rel.first(std::static_pointer_cast<Slice<T>>(s._it_tslice->_slices.at(&rel.second._tubevector))->codomain()[rel.second._i]));
84 return *this;
85 }
86
87 friend std::ostream& operator<<(std::ostream& os, const TubeComponent<T>& x)
88 {
89 os << "Component " << x._i << " of: " << x._tubevector << std::flush;
90 return os;
91 }
92
93 std::pair<std::function<Interval(const Interval&)>,const TubeComponent<T>> cos(const TubeComponent<T>& x)
94 {
95 return std::make_pair(static_cast<Interval(*)(const Interval&)>(cos), x);
96 }
97
98
99 protected:
100
101 size_t _i;
102 Tube<T>& _tubevector;
103
104 template<typename U>
105 friend class Tube;
106 };
107
108 template<class T>
109 std::pair<std::function<Interval(const Interval&)>,const TubeComponent<T>> cos(const TubeComponent<T>& x);
110 #endif
111}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62
std::ostream & operator<<(std::ostream &os, const BoolInterval &x)
Streams out a BoolInterval.
Definition codac2_BoolInterval.h:45
Interval cos(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:98