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