------------------------------------------------------------------------------
| 33 | |
| 34 | //------------------------------------------------------------------------------ |
| 35 | vtkTypeBool vtkMemoryLimitImageDataStreamer ::ProcessRequest( |
| 36 | vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 37 | { |
| 38 | if (request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) |
| 39 | { |
| 40 | if (this->CurrentDivision == 0) |
| 41 | { |
| 42 | // we must set the extent on the input |
| 43 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 44 | |
| 45 | // get the requested update extent |
| 46 | int outExt[6]; |
| 47 | outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), outExt); |
| 48 | |
| 49 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 50 | |
| 51 | vtkExtentTranslator* translator = this->GetExtentTranslator(); |
| 52 | translator->SetWholeExtent(outExt); |
| 53 | |
| 54 | vtkPipelineSize* sizer = vtkPipelineSize::New(); |
| 55 | this->NumberOfStreamDivisions = 1; |
| 56 | unsigned long oldSize, size = 0; |
| 57 | float ratio; |
| 58 | translator->SetPiece(0); |
| 59 | |
| 60 | // watch for the limiting case where the size is the maximum size |
| 61 | // represented by an unsigned long. In that case we do not want to do |
| 62 | // the ratio test. We actual test for size < 0.5 of the max unsigned |
| 63 | // long which would indicate that oldSize is about at max unsigned |
| 64 | // long. |
| 65 | unsigned long maxSize; |
| 66 | maxSize = (((unsigned long)0x1) << (8 * sizeof(unsigned long) - 1)); |
| 67 | |
| 68 | // we also have to watch how many pieces we are creating. Since |
| 69 | // NumberOfStreamDivisions is an int, it cannot be more that say 2^31 |
| 70 | // (which is a bit much anyhow) so we also stop if the number of pieces |
| 71 | // is too large. |
| 72 | int count = 0; |
| 73 | |
| 74 | // double the number of pieces until the size fits in memory |
| 75 | // or the reduction in size falls to 20% |
| 76 | do |
| 77 | { |
| 78 | oldSize = size; |
| 79 | translator->SetNumberOfPieces(this->NumberOfStreamDivisions); |
| 80 | translator->PieceToExtentByPoints(); |
| 81 | |
| 82 | int inExt[6]; |
| 83 | translator->GetExtent(inExt); |
| 84 | // set the update extent |
| 85 | inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), inExt, 6); |
| 86 | // set a hint not to combine with previous requests |
| 87 | inInfo->Set( |
| 88 | vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT_INITIALIZED(), VTK_UPDATE_EXTENT_REPLACE); |
| 89 | |
| 90 | // then propagate it |
| 91 | vtkExecutive* exec = vtkExecutive::PRODUCER()->GetExecutive(inInfo); |
| 92 | int index = vtkExecutive::PRODUCER()->GetPort(inInfo); |
nothing calls this directly
no test coverage detected