00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveChunkManager.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 ClassImp(TEveChunkManager);
00025 ClassImp(TEveChunkManager::iterator);
00026
00027
00028 void TEveChunkManager::ReleaseChunks()
00029 {
00030
00031
00032 for (Int_t i=0; i<fVecSize; ++i)
00033 delete fChunks[i];
00034 fChunks.clear();
00035 }
00036
00037
00038 TEveChunkManager::TEveChunkManager() :
00039 fS(0), fN(0),
00040 fSize(0), fVecSize(0), fCapacity(0)
00041 {
00042
00043
00044 }
00045
00046
00047 TEveChunkManager::TEveChunkManager(Int_t atom_size, Int_t chunk_size) :
00048 fS(atom_size), fN(chunk_size),
00049 fSize(0), fVecSize(0), fCapacity(0)
00050 {
00051
00052 }
00053
00054
00055 TEveChunkManager::~TEveChunkManager()
00056 {
00057
00058
00059 ReleaseChunks();
00060 }
00061
00062
00063
00064
00065 void TEveChunkManager::Reset(Int_t atom_size, Int_t chunk_size)
00066 {
00067
00068
00069 ReleaseChunks();
00070 fS = atom_size;
00071 fN = chunk_size;
00072 fSize = fVecSize = fCapacity = 0;
00073 }
00074
00075
00076 void TEveChunkManager::Refit()
00077 {
00078
00079
00080
00081 if (fSize == 0 || (fVecSize == 1 && fSize == fCapacity))
00082 return;
00083
00084 TArrayC* one = new TArrayC(fS*fSize);
00085 Char_t* pos = one->fArray;
00086 for (Int_t i=0; i<fVecSize; ++i)
00087 {
00088 Int_t size = fS * NAtoms(i);
00089 memcpy(pos, fChunks[i]->fArray, size);
00090 pos += size;
00091 }
00092 ReleaseChunks();
00093 fN = fCapacity = fSize;
00094 fVecSize = 1;
00095 fChunks.push_back(one);
00096 }
00097
00098
00099
00100
00101 Char_t* TEveChunkManager::NewChunk()
00102 {
00103
00104
00105 fChunks.push_back(new TArrayC(fS*fN));
00106 ++fVecSize;
00107 fCapacity += fN;
00108 return fChunks.back()->fArray;
00109 }
00110
00111
00112
00113
00114 Bool_t TEveChunkManager::iterator::next()
00115 {
00116
00117
00118 if (fSelection == 0)
00119 {
00120 if (fAtomsToGo <= 0)
00121 {
00122 if (fNextChunk < fPlex->VecSize())
00123 {
00124 fCurrent = fPlex->Chunk(fNextChunk);
00125 fAtomsToGo = fPlex->NAtoms(fNextChunk);
00126 ++fNextChunk;
00127 }
00128 else
00129 {
00130 return kFALSE;
00131 }
00132 }
00133 else
00134 {
00135 fCurrent += fPlex->S();
00136 }
00137 ++fAtomIndex;
00138 --fAtomsToGo;
00139 return kTRUE;
00140 }
00141 else
00142 {
00143 if (fAtomIndex == -1)
00144 fSelectionIterator = fSelection->begin();
00145 else
00146 ++fSelectionIterator;
00147
00148 if (fSelectionIterator != fSelection->end())
00149 {
00150 fAtomIndex = *fSelectionIterator;
00151 fCurrent = fPlex->Atom(fAtomIndex);
00152 return kTRUE;
00153 }
00154 else
00155 {
00156 return kFALSE;
00157 }
00158 }
00159 }