| 25 | vtkStandardNewMacro(vtkUnstructuredGridWriter); |
| 26 | |
| 27 | void vtkUnstructuredGridWriter::WriteData() |
| 28 | { |
| 29 | ostream* fp; |
| 30 | vtkUnstructuredGridBase* input = vtkUnstructuredGridBase::SafeDownCast(this->GetInput()); |
| 31 | int *types, ncells, cellId; |
| 32 | |
| 33 | vtkDebugMacro(<< "Writing vtk unstructured grid data..."); |
| 34 | |
| 35 | if (!(fp = this->OpenVTKFile()) || !this->WriteHeader(fp)) |
| 36 | { |
| 37 | if (fp) |
| 38 | { |
| 39 | vtkErrorMacro("Ran out of disk space; deleting file: " << this->FileName); |
| 40 | this->CloseVTKFile(fp); |
| 41 | unlink(this->FileName); |
| 42 | } |
| 43 | return; |
| 44 | } |
| 45 | // |
| 46 | // Write unstructured grid specific stuff |
| 47 | // |
| 48 | *fp << "DATASET UNSTRUCTURED_GRID\n"; |
| 49 | |
| 50 | // Write data owned by the dataset |
| 51 | if (!this->WriteDataSetData(fp, input)) |
| 52 | { |
| 53 | vtkErrorMacro("Ran out of disk space; deleting file: " << this->FileName); |
| 54 | this->CloseVTKFile(fp); |
| 55 | unlink(this->FileName); |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | if (!this->WritePoints(fp, input->GetPoints())) |
| 60 | { |
| 61 | vtkErrorMacro("Ran out of disk space; deleting file: " << this->FileName); |
| 62 | this->CloseVTKFile(fp); |
| 63 | unlink(this->FileName); |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | // Handle face data: |
| 68 | if (!this->WriteCellsAndFaces(fp, input, "CELLS")) |
| 69 | { |
| 70 | vtkErrorMacro("Ran out of disk space; deleting file: " << this->FileName); |
| 71 | this->CloseVTKFile(fp); |
| 72 | unlink(this->FileName); |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | // |
| 77 | // Cell types are a little more work |
| 78 | // |
| 79 | |
| 80 | ncells = input->GetNumberOfCells(); |
| 81 | if (ncells > 0) |
| 82 | { |
| 83 | types = new int[ncells]; |
| 84 | for (cellId = 0; cellId < ncells; cellId++) |
nothing calls this directly
no test coverage detected