MeVisLab Toolbox Reference
mlVecList.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_VEC_LIST_H
14 #define ML_VEC_LIST_H
15 
16 
19 
20 // Defines the classes:
21 // - VecListTemplate : List class template for lists of n-tupels of a given type
22 // - Vec3iList, Vec3fList, Vec4iList, Vec4fList, Vec6iList, Vec6fList
23 
24 // ML includes
25 #include "mlBaseInit.h"
26 #include "mlModuleIncludes.h"
27 #include "mlLinearAlgebra.h"
28 
29 
30 
31 #include "mlListBase.h"
32 
33 
34 
35 ML_START_NAMESPACE
36 
37 
38 
39 // ------------------------------------------------------------------
40 // BaseObject template class VecListTemplate
41 
44 // ------------------------------------------------------------------
45 template <class T>
46 class VecListTemplate : public ListTemplate<T>
47 {
48 public:
49 
52 
53 
54 protected:
55 
59  std::string itemState(typename VecListTemplate<T>::const_iterator it) const override;
60 
62  void setItemState(typename VecListTemplate<T>::iterator it, const std::string& state) override;
63 
64 #if ML_DEPRECATED_SINCE(3,5,0)
68  [[nodiscard]]
69  [[deprecated]]char *getItemState(typename VecListTemplate<T>::const_iterator it) const override;
70 
73  [[deprecated]] void setItemState(typename VecListTemplate<T>::iterator it, const char *state) override;
74 #endif
76 
77 };
78 
79 
80 #if ML_DEPRECATED_SINCE(3,5,0)
83 template <class T>
85 {
86  std::ostringstream ost;
87  size_t n = it->getSize(), i=0;
88 
89  for (i = 0; i < n-1; i++){
90  ost << (*it)[i] << ' ';
91  }
92  ost << (*it)[n-1];
93 
94  return this->newString(ost.str());
95 }
96 
97 #endif
98 
99 
100 template <class T> std::string VecListTemplate<T>::itemState(
101  typename VecListTemplate<T>::const_iterator it) const
102 {
103  std::ostringstream ost;
104  size_t n = it->getSize(), i = 0;
105 
106  for (i = 0; i < n - 1; i++) {
107  ost << (*it)[i] << ' ';
108  }
109  ost << (*it)[n - 1];
110 
111  return ost.str();
112 }
113 
114 #if ML_DEPRECATED_SINCE(3,5,0)
116 template <class T>
117 void VecListTemplate<T>::setItemState(typename VecListTemplate<T>::iterator it, const char *state)
118 {
119  std::istringstream ist;
120  size_t i=0;
121 
122  // Changed by Wolf because Jan-Martin said that's better in this way :-)
123  // ist.str() = state;
124  ist.str(state);
125  for (i = 0; i < it->getSize(); i++){
126  ist >> (*it)[i];
127  }
128 }
129 
130 #endif
131 
133  const std::string &state)
134 {
135  std::istringstream ist;
136  size_t i = 0;
137  ist.str(state);
138  for (i = 0; i < it->getSize(); i++) {
139  ist >> (*it)[i];
140  }
141 }
142 
143 
144 // ------------------------------------------------------------------
148 // ------------------------------------------------------------------
150 
151 
152 // ------------------------------------------------------------------
154 // ------------------------------------------------------------------
155 
157 {
158 
159 private:
160 
163 
164 };
165 
166 
167 
168 
169 
170 // ------------------------------------------------------------------
174 // ------------------------------------------------------------------
176 
177 // ------------------------------------------------------------------
179 // ------------------------------------------------------------------
180 
182 {
183 
184 private:
185 
188 
189 };
190 
191 
192 
193 
194 
195 // ------------------------------------------------------------------
199 // ------------------------------------------------------------------
201 
202 // ------------------------------------------------------------------
204 // ------------------------------------------------------------------
205 
207 {
208 
209 private:
210 
213 
214 };
215 
216 
217 
218 // ------------------------------------------------------------------
220 // ------------------------------------------------------------------
221 
222 class MLBASEEXPORT Vec3fList : public VecListTemplate<Vector3>
223 {
224 
225 private:
226 
229 
230 };
231 
232 
233 
234 
235 // ------------------------------------------------------------------
237 // ------------------------------------------------------------------
238 
239 class MLBASEEXPORT Vec4fList : public VecListTemplate<Vector4>
240 {
241 
242 private:
243 
246 
247 };
248 
249 
250 
251 
252 // ------------------------------------------------------------------
254 // ------------------------------------------------------------------
255 
256 class MLBASEEXPORT Vec6fList : public VecListTemplate<Vector6>
257 {
258 
259 private:
260 
263 
264 };
265 
266 
267 
268 ML_END_NAMESPACE
269 
270 #endif
271 // __MLVECLIST_H__
@ T
Definition: SoKeyGrabber.h:71
Template class for vector arithmetic with floating point data types.
Basic list class template combining properties of ListBase and a vector of the template argument type...
Definition: mlListBase.h:312
size_t getSize() const override
Get number of list elements.
Definition: mlListBase.h:338
Base object class Vec3fList derived from VecListTemplate.
Definition: mlVecList.h:223
Base object class Vec3iList derived from VecListTemplate.
Definition: mlVecList.h:157
Base object class Vec4fList derived from VecListTemplate.
Definition: mlVecList.h:240
Base object class Vec4iList derived from VecListTemplate.
Definition: mlVecList.h:182
Base object class Vec6fList derived from VecListTemplate.
Definition: mlVecList.h:257
Base object class Vec6iList derived from VecListTemplate.
Definition: mlVecList.h:207
BaseObject list class template (derived from ListTemplate) for lists of n-tupels of a given type.
Definition: mlVecList.h:47
VecListTemplate()
Default constructor.
Definition: mlVecList.h:51
void setItemState(typename VecListTemplate< T >::iterator it, const std::string &state) override
Initialize the item object from the string state.
Definition: mlVecList.h:132
std::string itemState(typename VecListTemplate< T >::const_iterator it) const override
Definition: mlVecList.h:100
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition: mlBaseInit.h:22
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non existing export symbol.
FloatingPointVector< int, 3 > vec3i
A type definition of a 3D integer vector derived from FloatingPointVector; note that some FloatingPoi...
Definition: mlVecList.h:149
FloatingPointVector< int, 4 > vec4i
A type definition of a 4D integer vector derived from FloatingPointVector; note that some FloatingPoi...
Definition: mlVecList.h:175
FloatingPointVector< int, 6 > vec6i
A type definition of a 6D integer vector derived from FloatingPointVector; note that some FloatingPoi...
Definition: mlVecList.h:200