00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00041 #ifndef vtkOffsetsManager_DoNotInclude
00042 #error "do not include unless you know what you are doing"
00043 #endif
00044
00045 #ifndef __vtkOffsetsManagerArray_h
00046 #define __vtkOffsetsManagerArray_h
00047
00048 #include "vtkSystemIncludes.h"
00049 #include <vtkstd/vector>
00050 #include <assert.h>
00051
00052
00053 class OffsetsManager
00054 {
00055 public:
00056
00057
00058
00059
00060 typedef vtkIdType OffsetType;
00061
00062
00063 OffsetsManager()
00064 {
00065 this->LastMTime = static_cast<unsigned long>(-1);
00066 }
00067 ~OffsetsManager()
00068 {
00069 }
00070 void Allocate(int numTimeStep)
00071 {
00072 assert( numTimeStep > 0);
00073 this->Positions.resize(numTimeStep);
00074 this->RangeMinPositions.resize(numTimeStep);
00075 this->RangeMaxPositions.resize(numTimeStep);
00076 this->OffsetValues.resize(numTimeStep);
00077 }
00078 OffsetType &GetPosition(unsigned int t)
00079 {
00080 assert( t < this->Positions.size());
00081 return this->Positions[t];
00082 }
00083 OffsetType &GetRangeMinPosition(unsigned int t)
00084 {
00085 assert( t < this->RangeMinPositions.size());
00086 return this->RangeMinPositions[t];
00087 }
00088 OffsetType &GetRangeMaxPosition(unsigned int t)
00089 {
00090 assert( t < this->RangeMaxPositions.size());
00091 return this->RangeMaxPositions[t];
00092 }
00093 OffsetType &GetOffsetValue(unsigned int t)
00094 {
00095 assert( t < this->OffsetValues.size());
00096 return this->OffsetValues[t];
00097 }
00098 unsigned long &GetLastMTime()
00099 {
00100 return this->LastMTime;
00101 }
00102 private:
00103 unsigned long LastMTime;
00104
00105
00106
00107
00108
00109 vtkstd::vector<OffsetType> Positions;
00110 vtkstd::vector<OffsetType> RangeMinPositions;
00111 vtkstd::vector<OffsetType> RangeMaxPositions;
00112
00113 vtkstd::vector<OffsetType> OffsetValues;
00114 };
00115
00116
00117 class OffsetsManagerGroup
00118 {
00119 public:
00120
00121
00122
00123
00124
00125
00126 OffsetsManager &GetPiece(unsigned int index)
00127 {
00128 assert( index < this->Internals.size());
00129 OffsetsManager &e = this->Internals[index];
00130 return e;
00131 }
00132
00133 OffsetsManager &GetElement(unsigned int index)
00134 {
00135
00136
00137
00138
00139 OffsetsManager &e = this->Internals[index];
00140 return e;
00141 }
00142 unsigned int GetNumberOfElements()
00143 {
00144 return static_cast<unsigned int>(this->Internals.size());
00145 }
00146 void Allocate(int numElements)
00147 {
00148 assert(numElements >= 0);
00149 this->Internals.resize(numElements);
00150 }
00151 void Allocate(int numElements, int numTimeSteps)
00152 {
00153 assert(numElements > 0);
00154 assert(numTimeSteps > 0);
00155 this->Internals.resize(numElements);
00156 for(int i=0; i<numElements; i++)
00157 {
00158 this->Internals[i].Allocate(numTimeSteps);
00159 }
00160 }
00161 private:
00162 vtkstd::vector<OffsetsManager> Internals;
00163 };
00164
00165
00166 class OffsetsManagerArray
00167 {
00168 public:
00169 OffsetsManagerGroup &GetPiece(unsigned int index)
00170 {
00171 assert( index < this->Internals.size());
00172 return this->Internals[index];
00173 }
00174 void Allocate(int numPieces)
00175 {
00176 assert(numPieces > 0);
00177
00178 this->Internals.resize(0);
00179 this->Internals.resize(numPieces);
00180 }
00181 void Allocate(int numPieces, int numElements, int numTimeSteps)
00182 {
00183 assert(numPieces > 0);
00184 assert(numElements > 0);
00185 assert(numTimeSteps > 0);
00186
00187
00188 this->Internals.resize(0);
00189 this->Internals.resize(numPieces);
00190 for(int i=0; i<numPieces; i++)
00191 {
00192 this->Internals[i].Allocate(numElements, numTimeSteps);
00193 }
00194 }
00195 private:
00196 vtkstd::vector<OffsetsManagerGroup> Internals;
00197 };
00198
00199 #endif