[vtkusers] vtkXMLImageDataReader ProgressEvent
Slobodan Miskovic
bosshcco at gmail.com
Thu Apr 14 23:02:50 EDT 2005
> Don't do any multithreading thing. This very simple python script works with VTK CVS:
>
> import vtk
>
> reader = vtk.vtkDataSetReader()
> reader.SetFileName('foo.vtk')
>
> def MyProc(object, event):
> print "foo", reader.GetProgress()
>
> reader.AddObserver("ProgressEvent", MyProc)
> reader.Update()
>
> This should work the as well using the XML readers.
That is basically what what my C++ code does, but with a bit of
tracing around, this is a code from 4.2 xmlDataReader
function ReadCompressedData
...
unsigned int currentBlock = firstBlock+1;
for(;currentBlock != lastBlock; ++currentBlock)
{
if(!this->ReadBlock(currentBlock, outputPointer)) { return 0; }
outputPointer += this->FindBlockSize(currentBlock);
}
...
Obviously it dooesn't update progress anywhere. For comparison, this
is the latest CVS code (minus the comments):
unsigned int currentBlock = firstBlock+1;
for(;currentBlock != lastBlock && !this->Abort; ++currentBlock)
{
if(!this->ReadBlock(currentBlock, outputPointer)) { return 0; }
this->PerformByteSwap(outputPointer, blockSize / wordSize, wordSize);
outputPointer += this->FindBlockSize(currentBlock);
this->UpdateProgress(float(outputPointer-data)/length);
}
Lesson learned? I should stick with CVS :) Thanks to all (David,
Mathieu) who looked into this.
Slobo
More information about the vtkusers
mailing list