MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLBase/mlVecList.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00005 
00010 //
00011 // Defines the classes:
00012 // - VecListTemplate : List class template for lists of n-tupels of a given type
00013 // - Vec3iList, Vec3fList, Vec4iList, Vec4fList, Vec6iList, Vec6fList
00014 //----------------------------------------------------------------------------------
00015 
00016 
00017 
00018 #ifndef __mlVecList_H
00019 #define __mlVecList_H
00020 
00021 
00022 
00023 // ML includes
00024 #ifndef __mlBaseInit_H
00025 #include "mlBaseInit.h"
00026 #endif
00027 #ifndef __mlModuleIncludes_H
00028 #include "mlModuleIncludes.h"
00029 #endif
00030 #ifndef __mlLinearAlgebra_H
00031 #include "mlLinearAlgebra.h"
00032 #endif
00033 
00034 
00035 // Local includes
00036 #ifndef __mlListBase_H
00037 #include "mlListBase.h"
00038 #endif
00039 
00040 
00041 
00042 ML_START_NAMESPACE
00043 
00044 
00045   
00046 // ------------------------------------------------------------------
00047 // BaseObject template class VecListTemplate 
00048 
00051 // ------------------------------------------------------------------
00052 template <class T>
00053 class  VecListTemplate : public ListTemplate<T>
00054 {
00055 public:
00056 
00058   VecListTemplate () : ListTemplate<T>(true) {}
00059 
00060 
00061 protected:
00062 
00064 
00065 
00068   virtual char *getItemState (typename VecListTemplate<T>::const_iterator it) const;
00069 
00071   virtual void setItemState (typename VecListTemplate<T>::iterator it, const char *state);
00072 
00074 
00075 };
00076 
00077 
00078 
00081 template <class T>
00082 char *VecListTemplate<T>::getItemState (typename VecListTemplate<T>::const_iterator it) const
00083 {
00084   std::ostringstream ost;
00085   size_t n = it->getSize(), i=0;
00086 
00087   for (i = 0; i < n-1; i++){
00088     ost << (*it)[i] << ' ';
00089   }
00090   ost << (*it)[n-1];
00091 
00092   return this->newString(ost.str());
00093 }
00094 
00095 
00097 template <class T>
00098 void VecListTemplate<T>::setItemState (typename VecListTemplate<T>::iterator it, const char *state)
00099 {
00100   std::istringstream ist;
00101   size_t i=0;
00102 
00103   // Changed by Wolf because Jan-Martin said that's better in this way :-)
00104   // ist.str() = state;
00105   ist.str(state);
00106   for (i = 0; i < it->getSize(); i++){
00107     ist >> (*it)[i];
00108   }
00109 }
00110 
00111 
00112 
00113 // ------------------------------------------------------------------
00117 // ------------------------------------------------------------------
00118 typedef FloatingPointVector<int, 3> vec3i;
00119 
00120 
00121 // ------------------------------------------------------------------
00123 // ------------------------------------------------------------------
00124 
00125 class MLBASEEXPORT Vec3iList : public VecListTemplate<vec3i>
00126 {
00127 
00128 private:
00129 
00131   ML_CLASS_HEADER(Vec3iList);
00132 
00133 };
00134 
00135 
00136 
00137   
00138 
00139 // ------------------------------------------------------------------
00143 // ------------------------------------------------------------------
00144 typedef FloatingPointVector<int, 4> vec4i;
00145 
00146 // ------------------------------------------------------------------
00148 // ------------------------------------------------------------------
00149 
00150 class MLBASEEXPORT Vec4iList : public VecListTemplate<vec4i>
00151 {
00152 
00153 private:
00154 
00156   ML_CLASS_HEADER(Vec4iList);
00157 
00158 };
00159 
00160 
00161 
00162   
00163 
00164 // ------------------------------------------------------------------
00168 // ------------------------------------------------------------------
00169 typedef FloatingPointVector<int, 6> vec6i;
00170 
00171 // ------------------------------------------------------------------
00173 // ------------------------------------------------------------------
00174 
00175 class MLBASEEXPORT Vec6iList : public VecListTemplate<vec6i>
00176 {
00177 
00178 private:
00179 
00181   ML_CLASS_HEADER(Vec6iList);
00182 
00183 };
00184 
00185 
00186   
00187 // ------------------------------------------------------------------
00189 // ------------------------------------------------------------------
00190 
00191 class MLBASEEXPORT Vec3fList : public VecListTemplate<Vector3>
00192 {
00193 
00194 private:
00195 
00197   ML_CLASS_HEADER(Vec3fList);
00198 
00199 };
00200 
00201 
00202 
00203   
00204 // ------------------------------------------------------------------
00206 // ------------------------------------------------------------------
00207 
00208 class MLBASEEXPORT Vec4fList : public VecListTemplate<Vector4>
00209 {
00210 
00211 private:
00212 
00214   ML_CLASS_HEADER(Vec4fList);
00215 
00216 };
00217 
00218 
00219 
00220   
00221 // ------------------------------------------------------------------
00223 // ------------------------------------------------------------------
00224 
00225 class MLBASEEXPORT Vec6fList : public VecListTemplate<Vector6>
00226 {
00227 
00228 private:
00229 
00231   ML_CLASS_HEADER(Vec6fList);
00232 
00233 };
00234 
00235 
00236 
00237 ML_END_NAMESPACE
00238 
00239 #endif
00240 // __MLVECLIST_H__