1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkThreadedImageAlgorithm.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 // .NAME vtkThreadedImageAlgorithm - Generic filter that has one input.. 16 // .SECTION Description 17 // vtkThreadedImageAlgorithm is a filter superclass that hides much of the 18 // pipeline complexity. It handles breaking the pipeline execution 19 // into smaller extents so that the vtkImageData limits are observed. It 20 // also provides support for multithreading. If you don't need any of this 21 // functionality, consider using vtkSimpleImageToImageAlgorithm instead. 22 // .SECTION See also 23 // vtkSimpleImageToImageAlgorithm 24 25 #ifndef vtkThreadedImageAlgorithm_h 26 #define vtkThreadedImageAlgorithm_h 27 28 #include "vtkCommonExecutionModelModule.h" // For export macro 29 #include "vtkImageAlgorithm.h" 30 31 class vtkImageData; 32 class vtkMultiThreader; 33 34 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkThreadedImageAlgorithm : public vtkImageAlgorithm 35 { 36 public: 37 vtkTypeMacro(vtkThreadedImageAlgorithm,vtkImageAlgorithm); 38 void PrintSelf(ostream& os, vtkIndent indent); 39 40 // Description: 41 // If the subclass does not define an Execute method, then the task 42 // will be broken up, multiple threads will be spawned, and each thread 43 // will call this method. It is public so that the thread functions 44 // can call this method. 45 virtual void ThreadedRequestData(vtkInformation *request, 46 vtkInformationVector **inputVector, 47 vtkInformationVector *outputVector, 48 vtkImageData ***inData, 49 vtkImageData **outData, 50 int extent[6], int threadId); 51 52 // also support the old signature 53 virtual void ThreadedExecute(vtkImageData *inData, 54 vtkImageData *outData, 55 int extent[6], int threadId); 56 57 // Description: 58 // Get/Set the number of threads to create when rendering 59 vtkSetClampMacro( NumberOfThreads, int, 1, VTK_MAX_THREADS ); 60 vtkGetMacro( NumberOfThreads, int ); 61 62 // Description: 63 // Putting this here until I merge graphics and imaging streaming. 64 virtual int SplitExtent(int splitExt[6], int startExt[6], 65 int num, int total); 66 67 protected: 68 vtkThreadedImageAlgorithm(); 69 ~vtkThreadedImageAlgorithm(); 70 71 vtkMultiThreader *Threader; 72 int NumberOfThreads; 73 74 // Description: 75 // This is called by the superclass. 76 // This is the method you should override. 77 virtual int RequestData(vtkInformation* request, 78 vtkInformationVector** inputVector, 79 vtkInformationVector* outputVector); 80 81 private: 82 vtkThreadedImageAlgorithm(const vtkThreadedImageAlgorithm&); // Not implemented. 83 void operator=(const vtkThreadedImageAlgorithm&); // Not implemented. 84 }; 85 86 #endif 87 88 89 90 91 92 93 94