------------------------------------------------------------------------------
| 102 | |
| 103 | //------------------------------------------------------------------------------ |
| 104 | vtkTypeBool vtkXMLStructuredDataWriter::ProcessRequest( |
| 105 | vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 106 | { |
| 107 | |
| 108 | if (request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_INFORMATION())) |
| 109 | { |
| 110 | if (this->WritePiece >= 0) |
| 111 | { |
| 112 | this->CurrentPiece = this->WritePiece; |
| 113 | } |
| 114 | return 1; |
| 115 | } |
| 116 | |
| 117 | if (request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) |
| 118 | { |
| 119 | this->SetInputUpdateExtent(this->CurrentPiece); |
| 120 | |
| 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | // generate the data |
| 125 | else if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) |
| 126 | { |
| 127 | this->SetErrorCode(vtkErrorCode::NoError); |
| 128 | |
| 129 | if (!this->Stream && !this->FileName && !this->WriteToOutputString) |
| 130 | { |
| 131 | this->SetErrorCode(vtkErrorCode::NoFileNameError); |
| 132 | vtkErrorMacro("The FileName or Stream must be set first or " |
| 133 | "the output must be written to a string."); |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | // We are just starting to write. Do not call |
| 138 | // UpdateProgressDiscrete because we want a 0 progress callback the |
| 139 | // first time. |
| 140 | this->UpdateProgress(0); |
| 141 | this->SetProgressText("vtkXMLStructuredDataWriter"); |
| 142 | // Initialize progress range to entire 0..1 range. |
| 143 | float wholeProgressRange[] = { 0.0f, 1.0f }; |
| 144 | vtkIdType fieldDataValues = 0; |
| 145 | vtkFieldData* fieldData = this->GetInput()->GetFieldData(); |
| 146 | for (int i = 0; i < fieldData->GetNumberOfArrays(); ++i) |
| 147 | { |
| 148 | vtkAbstractArray* array = fieldData->GetAbstractArray(i); |
| 149 | fieldDataValues += array->GetNumberOfValues(); |
| 150 | } |
| 151 | vtkIdType dataSetValues = fieldDataValues + GetNumberOfValues(this->GetDataSetInput()); |
| 152 | if (dataSetValues == 0) |
| 153 | { |
| 154 | dataSetValues = 1; |
| 155 | } |
| 156 | float fraction[] = { 0.0f, static_cast<float>(fieldDataValues) / dataSetValues, 1.0f }; |
| 157 | this->SetProgressRange(wholeProgressRange, 0, fraction); |
| 158 | int result = 1; |
| 159 | if ((this->CurrentPiece == 0 || this->WritePiece >= 0) && this->CurrentTimeIndex == 0) |
| 160 | { |
| 161 | if (!this->OpenStream()) |
nothing calls this directly
no test coverage detected