1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkMultiTimeStepAlgorithm.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 /** 16 * @class vtkMultiTimeStepAlgorithm 17 * @brief Superclass for algorithms that would like to 18 * make multiple time requests 19 * 20 * This class can be inherited by any algorithm that wishes to make multiple 21 * time requests upstream. 22 * The child class uses UPDATE_TIME_STEPS to make the time requests and 23 * use set of time-stamped data objects are stored in time order 24 * in a vtkMultiBlockDataSet object. 25 */ 26 27 #ifndef vtkMultiTimeStepAlgorithm_h 28 #define vtkMultiTimeStepAlgorithm_h 29 30 #include "vtkCommonExecutionModelModule.h" // For export macro 31 #include "vtkAlgorithm.h" 32 #include "vtkSmartPointer.h" //needed for a private variable 33 34 #include <vector> //needed for a private variable 35 #include "vtkDataObject.h" // needed for the smart pointer 36 37 class vtkInformationDoubleVectorKey; 38 class vtkMultiBlockDataSet; 39 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkMultiTimeStepAlgorithm : public vtkAlgorithm 40 { 41 public: 42 static vtkMultiTimeStepAlgorithm *New(); 43 vtkTypeMacro(vtkMultiTimeStepAlgorithm,vtkAlgorithm); 44 void PrintSelf(ostream& os, vtkIndent indent) override; 45 46 47 protected: 48 vtkMultiTimeStepAlgorithm(); 49 ~vtkMultiTimeStepAlgorithm()50 ~vtkMultiTimeStepAlgorithm() override 51 { 52 }; 53 54 /** 55 * This is filled by the child class to request multiple time steps 56 */ 57 static vtkInformationDoubleVectorKey* UPDATE_TIME_STEPS(); 58 59 60 //@{ 61 /** 62 * This is called by the superclass. 63 * This is the method you should override. 64 */ RequestDataObject(vtkInformation *,vtkInformationVector **,vtkInformationVector *)65 virtual int RequestDataObject(vtkInformation*, vtkInformationVector**, vtkInformationVector*) 66 { 67 return 1; 68 }; 69 //@} 70 71 //@{ 72 /** 73 * This is called by the superclass. 74 * This is the method you should override. 75 */ RequestInformation(vtkInformation *,vtkInformationVector **,vtkInformationVector *)76 virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) 77 { 78 return 1; 79 }; 80 //@} 81 82 /** 83 * This is called by the superclass. 84 * This is the method you should override. 85 */ RequestData(vtkInformation *,vtkInformationVector **,vtkInformationVector *)86 virtual int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) 87 { 88 return 1; 89 } 90 91 /** 92 * This is called by the superclass. 93 * This is the method you should override. 94 */ RequestUpdateExtent(vtkInformation *,vtkInformationVector **,vtkInformationVector *)95 virtual int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*) 96 { 97 return 1; 98 } 99 100 int ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; 101 102 bool CacheData; 103 unsigned int NumberOfCacheEntries; 104 105 private: 106 vtkMultiTimeStepAlgorithm(const vtkMultiTimeStepAlgorithm&) = delete; 107 void operator=(const vtkMultiTimeStepAlgorithm&) = delete; 108 109 110 vtkSmartPointer<vtkMultiBlockDataSet> MDataSet; //stores all the temporal data sets 111 int RequestUpdateIndex; //keep track of the time looping index 112 std::vector<double> UpdateTimeSteps; //store the requested time steps 113 114 bool IsInCache(double time, size_t& idx); 115 116 struct TimeCache 117 { TimeCacheTimeCache118 TimeCache(double time, vtkDataObject* data) : TimeValue(time), Data(data) 119 { 120 } 121 double TimeValue; 122 vtkSmartPointer<vtkDataObject> Data; 123 }; 124 125 std::vector<TimeCache> Cache; 126 }; 127 128 #endif 129