Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "SMESH_vtkPVUpdateSuppressor.h"
00016
00017 #include "vtkAlgorithmOutput.h"
00018 #include "vtkCollection.h"
00019 #include "vtkCommand.h"
00020 #include "vtkCompositeDataPipeline.h"
00021 #include "vtkDataObject.h"
00022 #include "vtkDemandDrivenPipeline.h"
00023 #include "vtkInformation.h"
00024 #include "vtkInformationDoubleVectorKey.h"
00025 #include "vtkInformationExecutivePortKey.h"
00026 #include "vtkInformationVector.h"
00027 #include "vtkObjectFactory.h"
00028 #include "vtkPolyData.h"
00029
00030 #include "vtkSmartPointer.h"
00031 #include "vtkUnstructuredGrid.h"
00032
00033
00034 #include <vtkstd/map>
00035
00036 #ifdef MYDEBUG
00037 # define vtkMyDebug(x)\
00038 cout << x;
00039 #else
00040 # define vtkMyDebug(x)
00041 #endif
00042
00043 vtkCxxRevisionMacro(vtkPVUpdateSuppressor, "$Revision: 1.1.4.2 $")
00044 ;
00045 vtkStandardNewMacro(vtkPVUpdateSuppressor)
00046 ;
00047
00048 vtkPVUpdateSuppressor::vtkPVUpdateSuppressor()
00049 {
00050 this->UpdatePiece = 0;
00051 this->UpdateNumberOfPieces = 1;
00052
00053 this->UpdateTime = 0.0;
00054 this->UpdateTimeInitialized = false;
00055
00056 this->Enabled = 1;
00057
00058
00059
00060
00061
00062
00063
00064
00065 }
00066
00067
00068 vtkPVUpdateSuppressor::~vtkPVUpdateSuppressor()
00069 {
00070 }
00071
00072
00073 void vtkPVUpdateSuppressor::SetUpdateTime(double utime)
00074 {
00075 this->UpdateTimeInitialized = true;
00076 if (this->UpdateTime != utime)
00077 {
00078 this->Modified();
00079 this->UpdateTime = utime;
00080 }
00081 }
00082
00083
00084 void vtkPVUpdateSuppressor::SetEnabled(int enable)
00085 {
00086 if (this->Enabled == enable)
00087 {
00088 return;
00089 }
00090 this->Enabled = enable;
00091 this->Modified();
00092
00093
00094
00095
00096
00097
00098 }
00099
00100
00101 void vtkPVUpdateSuppressor::ForceUpdate()
00102 {
00103
00104 this->UpdateInformation();
00105
00106 vtkDataObject *input = this->GetInput();
00107 if (input == 0)
00108 {
00109 vtkErrorMacro("No valid input.");
00110 return;
00111 }
00112 vtkDataObject *output = this->GetOutput();
00113
00114
00115
00116
00117
00118 vtkAlgorithm *source = input->GetProducerPort()->GetProducer();
00119 if (source && (source->IsA("vtkMPIMoveData")
00120 || source->IsA("vtkCollectPolyData") || source->IsA("vtkM2NDuplicate")
00121 || source->IsA("vtkM2NCollect")
00122 || source->IsA("vtkOrderedCompositeDistributor")
00123 || source->IsA("vtkClientServerMoveData")))
00124 {
00125 source->Modified();
00126 }
00127
00128 vtkInformation* info = input->GetPipelineInformation();
00129 vtkStreamingDemandDrivenPipeline
00130 * sddp =
00131 vtkStreamingDemandDrivenPipeline::SafeDownCast(
00132 vtkExecutive::PRODUCER()->GetExecutive(
00133 info));
00134 if (sddp)
00135 {
00136 sddp->SetUpdateExtent(info, this->UpdatePiece,
00137 this->UpdateNumberOfPieces, 0);
00138 }
00139 else
00140 {
00141 input->SetUpdatePiece(this->UpdatePiece);
00142 input->SetUpdateNumberOfPieces(this->UpdateNumberOfPieces);
00143 input->SetUpdateGhostLevel(0);
00144 } vtkMyDebug("ForceUpdate ");
00145 if (this->UpdateTimeInitialized)
00146 {
00147 info->Set(vtkCompositeDataPipeline::UPDATE_TIME_STEPS(),
00148 &this->UpdateTime, 1);
00149 vtkMyDebug(this->UpdateTime);
00150 } vtkMyDebug(endl);
00151
00152 input->Update();
00153
00154 input = this->GetInput();
00155
00156 output->ShallowCopy(input);
00157 this->PipelineUpdateTime.Modified();
00158 }
00159
00160
00161 vtkExecutive* vtkPVUpdateSuppressor::CreateDefaultExecutive()
00162 {
00163 vtkUpdateSuppressorPipeline* executive = vtkUpdateSuppressorPipeline::New();
00164 executive->SetEnabled(this->Enabled);
00165 return executive;
00166 }
00167
00168
00169 int vtkPVUpdateSuppressor::RequestDataObject(
00170 vtkInformation* vtkNotUsed(reqInfo),
00171 vtkInformationVector** inputVector,
00172 vtkInformationVector* outputVector)
00173 {
00174 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
00175 if (!inInfo)
00176 {
00177 return 0;
00178 }
00179
00180 vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
00181 if (input)
00182 {
00183
00184 for (int i = 0; i < this->GetNumberOfOutputPorts(); ++i)
00185 {
00186 vtkInformation* outInfo = outputVector->GetInformationObject(i);
00187 vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
00188
00189 if (!output || !output->IsA(input->GetClassName()))
00190 {
00191 vtkDataObject* newOutput = input->NewInstance();
00192 newOutput->SetPipelineInformation(outInfo);
00193 newOutput->Delete();
00194 this->GetOutputPortInformation(i)->Set(
00195 vtkDataObject::DATA_EXTENT_TYPE(),
00196 newOutput->GetExtentType());
00197 }
00198 }
00199 return 1;
00200 }
00201 return 0;
00202
00203 }
00204
00205
00206 int vtkPVUpdateSuppressor::RequestData(vtkInformation* vtkNotUsed(reqInfo),
00207 vtkInformationVector** inputVector,
00208 vtkInformationVector* outputVector)
00209 {
00210
00211
00212 vtkInformation *outInfo = outputVector->GetInformationObject(0);
00213 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
00214 vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
00215 vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
00216
00217 output->ShallowCopy(input);
00218 return 1;
00219 }
00220
00221
00222 void vtkPVUpdateSuppressor::PrintSelf(ostream& os, vtkIndent indent)
00223 {
00224 this->Superclass::PrintSelf(os, indent);
00225 os << indent << "UpdatePiece: " << this->UpdatePiece << endl;
00226 os << indent << "UpdateNumberOfPieces: " << this->UpdateNumberOfPieces
00227 << endl;
00228 os << indent << "Enabled: " << this->Enabled << endl;
00229 os << indent << "UpdateTime: " << this->UpdateTime << endl;
00230 }