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 OffsetsManager()
00056 {
00057 this->LastMTime = (unsigned long)-1;
00058 }
00059 ~OffsetsManager()
00060 {
00061 }
00062 void Allocate(int numTimeStep)
00063 {
00064 assert( numTimeStep > 0);
00065 this->Positions.resize(numTimeStep);
00066 this->OffsetValues.resize(numTimeStep);
00067 }
00068 unsigned long &GetPosition(unsigned int t)
00069 {
00070 assert( t < this->Positions.size());
00071 return this->Positions[t];
00072 }
00073 unsigned long &GetOffsetValue(unsigned int t)
00074 {
00075 assert( t < this->OffsetValues.size());
00076 return this->OffsetValues[t];
00077 }
00078 unsigned long &GetLastMTime()
00079 {
00080 return this->LastMTime;
00081 }
00082 private:
00083 unsigned long LastMTime;
00084 vtkstd::vector<unsigned long> Positions;
00085 vtkstd::vector<unsigned long> OffsetValues;
00086 };
00087
00088
00089 class OffsetsManagerGroup
00090 {
00091 public:
00092
00093
00094
00095
00096
00097 OffsetsManager &GetPiece(unsigned int index)
00098 {
00099 assert( index < this->Internals.size());
00100 OffsetsManager &e = this->Internals[index];
00101 return e;
00102 }
00103
00104 OffsetsManager &GetElement(unsigned int index)
00105 {
00106
00107
00108
00109
00110 OffsetsManager &e = this->Internals[index];
00111 return e;
00112 }
00113 unsigned int GetNumberOfElements()
00114 {
00115 return this->Internals.size();
00116 }
00117 void Allocate(int numElements)
00118 {
00119 assert(numElements >= 0);
00120 this->Internals.resize(numElements);
00121 }
00122 void Allocate(int numElements, int numTimeSteps)
00123 {
00124 assert(numElements > 0);
00125 assert(numTimeSteps > 0);
00126 this->Internals.resize(numElements);
00127 for(int i=0; i<numElements; i++)
00128 {
00129 this->Internals[i].Allocate(numTimeSteps);
00130 }
00131 }
00132 private:
00133 vtkstd::vector<OffsetsManager> Internals;
00134 };
00135
00136
00137 class OffsetsManagerArray
00138 {
00139 public:
00140 OffsetsManagerGroup &GetPiece(unsigned int index)
00141 {
00142 assert( index < this->Internals.size());
00143 return this->Internals[index];
00144 }
00145 void Allocate(int numPieces)
00146 {
00147 assert(numPieces > 0);
00148
00149 this->Internals.resize(0);
00150 this->Internals.resize(numPieces);
00151 }
00152 void Allocate(int numPieces, int numElements, int numTimeSteps)
00153 {
00154 assert(numPieces > 0);
00155 assert(numElements > 0);
00156 assert(numTimeSteps > 0);
00157
00158
00159 this->Internals.resize(0);
00160 this->Internals.resize(numPieces);
00161 for(int i=0; i<numPieces; i++)
00162 {
00163 this->Internals[i].Allocate(numElements, numTimeSteps);
00164 }
00165 }
00166 private:
00167 vtkstd::vector<OffsetsManagerGroup> Internals;
00168 };
00169
00170 #endif