------------------------------------------------------------------------------
| 141 | |
| 142 | //------------------------------------------------------------------------------ |
| 143 | int vtkExtractDataOverTime::AllocateOutputData(vtkPointSet* input, vtkPointSet* output) |
| 144 | { |
| 145 | // by default vtkPointSetAlgorithm::RequestDataObject already |
| 146 | // created an output of the same type as the input |
| 147 | if (!output) |
| 148 | { |
| 149 | vtkErrorMacro("Output not created as expected!"); |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | // 1st the points |
| 154 | vtkPoints* points = output->GetPoints(); |
| 155 | if (!points) |
| 156 | { |
| 157 | points = vtkPoints::New(); |
| 158 | output->SetPoints(points); |
| 159 | points->Delete(); |
| 160 | } |
| 161 | points->SetNumberOfPoints(this->NumberOfTimeSteps); |
| 162 | |
| 163 | // now the point data |
| 164 | output->GetPointData()->CopyAllocate(input->GetPointData(), this->NumberOfTimeSteps); |
| 165 | |
| 166 | // and finally add an array to hold the time at each step |
| 167 | vtkDoubleArray* timeArray = vtkDoubleArray::New(); |
| 168 | timeArray->SetNumberOfComponents(1); |
| 169 | timeArray->SetNumberOfTuples(this->NumberOfTimeSteps); |
| 170 | if (input->GetPointData()->GetArray("Time")) |
| 171 | { |
| 172 | timeArray->SetName("TimeData"); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | timeArray->SetName("Time"); |
| 177 | } |
| 178 | output->GetPointData()->AddArray(timeArray); |
| 179 | timeArray->Delete(); |
| 180 | |
| 181 | return 1; |
| 182 | } |
| 183 | VTK_ABI_NAMESPACE_END |
no test coverage detected