------------------------------------------------------------------------------
| 263 | |
| 264 | //------------------------------------------------------------------------------ |
| 265 | int vtkXMLStructuredDataWriter::WriteHeader() |
| 266 | { |
| 267 | vtkIndent indent = vtkIndent().GetNextIndent(); |
| 268 | |
| 269 | ostream& os = *(this->Stream); |
| 270 | |
| 271 | if (!this->WritePrimaryElement(os, indent)) |
| 272 | { |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | this->WriteFieldData(indent.GetNextIndent()); |
| 277 | |
| 278 | if (this->DataMode == vtkXMLWriter::Appended) |
| 279 | { |
| 280 | int begin = this->WritePiece; |
| 281 | int end = this->WritePiece + 1; |
| 282 | if (this->WritePiece < 0) |
| 283 | { |
| 284 | begin = 0; |
| 285 | end = this->NumberOfPieces; |
| 286 | } |
| 287 | vtkIndent nextIndent = indent.GetNextIndent(); |
| 288 | |
| 289 | this->AllocatePositionArrays(); |
| 290 | |
| 291 | // Loop over each piece and write its structure. |
| 292 | for (int i = begin; i < end; ++i) |
| 293 | { |
| 294 | // Update the piece's extent. |
| 295 | |
| 296 | os << nextIndent << "<Piece"; |
| 297 | // We allocate 66 characters because that is as big as 6 integers |
| 298 | // with spaces can get. |
| 299 | this->ExtentPositions[i] = this->ReserveAttributeSpace("Extent", 66); |
| 300 | os << ">\n"; |
| 301 | |
| 302 | if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError) |
| 303 | { |
| 304 | this->DeletePositionArrays(); |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | this->WriteAppendedPiece(i, nextIndent.GetNextIndent()); |
| 309 | |
| 310 | if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError) |
| 311 | { |
| 312 | this->DeletePositionArrays(); |
| 313 | return 0; |
| 314 | } |
| 315 | // Close the piece's element. |
| 316 | os << nextIndent << "</Piece>\n"; |
| 317 | } |
| 318 | |
| 319 | // Close the primary element. |
| 320 | os << indent << "</" << this->GetDataSetName() << ">\n"; |
| 321 | |
| 322 | os.flush(); |
no test coverage detected