------------------------------------------------------------------------------ Write the cell data (e.g., scalars, vectors, ...) of a vtk dataset. Returns 0 if error.
| 251 | // Write the cell data (e.g., scalars, vectors, ...) of a vtk dataset. |
| 252 | // Returns 0 if error. |
| 253 | int vtkDataWriter::WriteCellData(ostream* fp, vtkDataSet* ds) |
| 254 | { |
| 255 | vtkIdType numCells; |
| 256 | vtkDataArray* scalars; |
| 257 | vtkDataArray* vectors; |
| 258 | vtkDataArray* normals; |
| 259 | vtkDataArray* tcoords; |
| 260 | vtkDataArray* tensors; |
| 261 | vtkDataArray* globalIds; |
| 262 | vtkAbstractArray* pedigreeIds; |
| 263 | vtkFieldData* field; |
| 264 | vtkCellData* cd = ds->GetCellData(); |
| 265 | |
| 266 | vtkDebugMacro(<< "Writing cell data..."); |
| 267 | |
| 268 | numCells = ds->GetNumberOfCells(); |
| 269 | if (numCells <= 0) |
| 270 | { |
| 271 | vtkDebugMacro(<< "No cell data to write!"); |
| 272 | return 1; |
| 273 | } |
| 274 | |
| 275 | scalars = cd->GetScalars(); |
| 276 | if (scalars && scalars->GetNumberOfTuples() <= 0) |
| 277 | scalars = nullptr; |
| 278 | |
| 279 | vectors = cd->GetVectors(); |
| 280 | if (vectors && vectors->GetNumberOfTuples() <= 0) |
| 281 | vectors = nullptr; |
| 282 | |
| 283 | normals = cd->GetNormals(); |
| 284 | if (normals && normals->GetNumberOfTuples() <= 0) |
| 285 | normals = nullptr; |
| 286 | |
| 287 | tcoords = cd->GetTCoords(); |
| 288 | if (tcoords && tcoords->GetNumberOfTuples() <= 0) |
| 289 | tcoords = nullptr; |
| 290 | |
| 291 | tensors = cd->GetTensors(); |
| 292 | if (tensors && tensors->GetNumberOfTuples() <= 0) |
| 293 | tensors = nullptr; |
| 294 | |
| 295 | globalIds = cd->GetGlobalIds(); |
| 296 | if (globalIds && globalIds->GetNumberOfTuples() <= 0) |
| 297 | globalIds = nullptr; |
| 298 | |
| 299 | pedigreeIds = cd->GetPedigreeIds(); |
| 300 | if (pedigreeIds && pedigreeIds->GetNumberOfTuples() <= 0) |
| 301 | pedigreeIds = nullptr; |
| 302 | |
| 303 | field = cd; |
| 304 | if (field && field->GetNumberOfTuples() <= 0) |
| 305 | field = nullptr; |
| 306 | |
| 307 | if (!(scalars || vectors || normals || tcoords || tensors || globalIds || pedigreeIds || field)) |
| 308 | { |
| 309 | vtkDebugMacro(<< "No cell data to write!"); |
| 310 | return 1; |
no test coverage detected