------------------------------------------------------------------------------
| 108 | |
| 109 | //------------------------------------------------------------------------------ |
| 110 | int vtkFacetWriter::WriteDataToStream(ostream* ost, vtkPolyData* data) |
| 111 | { |
| 112 | *ost << "Element" << data << std::endl |
| 113 | << "0" << std::endl |
| 114 | << data->GetNumberOfPoints() << " 0 0" << std::endl; |
| 115 | vtkIdType point; |
| 116 | for (point = 0; point < data->GetNumberOfPoints(); point++) |
| 117 | { |
| 118 | double xyz[3]; |
| 119 | data->GetPoint(point, xyz); |
| 120 | *ost << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl; |
| 121 | } |
| 122 | *ost << "1" << std::endl << "Element" << data << std::endl; |
| 123 | int written = 0; |
| 124 | vtkCellArray* ca; |
| 125 | vtkIdType numCells; |
| 126 | vtkIdType totalCells = 0; |
| 127 | int material = 0; |
| 128 | int part = 0; |
| 129 | vtkIdType cc; |
| 130 | |
| 131 | if (data->GetVerts()->GetNumberOfCells()) |
| 132 | { |
| 133 | // This test is needed if another cell type is written above this |
| 134 | // block. We must remove it here because it produces an |
| 135 | // unreachable code warning. |
| 136 | // |
| 137 | // if ( written ) |
| 138 | // { |
| 139 | // vtkErrorMacro("Multiple different cells in the poly data"); |
| 140 | // return 0; |
| 141 | // } |
| 142 | ca = data->GetVerts(); |
| 143 | numCells = ca->GetNumberOfCells(); |
| 144 | vtkIdType numPts = 0; |
| 145 | const vtkIdType* pts = nullptr; |
| 146 | ca->InitTraversal(); |
| 147 | while (ca->GetNextCell(numPts, pts)) |
| 148 | { |
| 149 | // Each vertex is one cell |
| 150 | for (cc = 0; cc < numPts; cc++) |
| 151 | { |
| 152 | totalCells++; |
| 153 | } |
| 154 | } |
| 155 | *ost << totalCells << " 1" << std::endl; |
| 156 | ca->InitTraversal(); |
| 157 | while (ca->GetNextCell(numPts, pts)) |
| 158 | { |
| 159 | for (cc = 0; cc < numPts; cc++) |
| 160 | { |
| 161 | // Indices of point starts with 1 |
| 162 | vtkIdType pointIndex = pts[cc] + 1; |
| 163 | *ost << pointIndex << " " << material << " " << part << std::endl; |
| 164 | } |
| 165 | } |
| 166 | written = 1; |
| 167 | } |
no test coverage detected