------------------------------------------------------------------------------
| 290 | |
| 291 | //------------------------------------------------------------------------------ |
| 292 | void vtkGAMBITReader::ReadMaterialTypes(vtkUnstructuredGrid* output) |
| 293 | { |
| 294 | int grp, f, flag, elt; |
| 295 | char c, buf[128]; |
| 296 | |
| 297 | vtkIntArray* materials = vtkIntArray::New(); |
| 298 | materials->SetNumberOfComponents(1); |
| 299 | materials->SetNumberOfTuples(this->NumberOfCells); |
| 300 | materials->SetName("Material Type"); |
| 301 | |
| 302 | for (grp = 1; grp <= this->NumberOfElementGroups; grp++) |
| 303 | { |
| 304 | this->FileStream->get(buf, 128, '\n'); |
| 305 | this->FileStream->get(c); |
| 306 | this->FileStream->get(buf, 128, '\n'); |
| 307 | this->FileStream->get(c); |
| 308 | auto result = vtk::scan<int, int, int, int>( |
| 309 | std::string_view(buf), "GROUP:{:d} ELEMENTS: {:d} MATERIAL: {:d} NFLAGS:{:d}"); |
| 310 | auto& [id, nbelts, mat, nbflags] = result->values(); |
| 311 | vtkDebugMacro(<< "\nid " << id << "\tnbelts " << nbelts << "\tmat " << mat << "\tnbflags " |
| 312 | << nbflags); |
| 313 | |
| 314 | this->FileStream->get(buf, 128, '\n'); |
| 315 | this->FileStream->get(c); |
| 316 | for (f = 0; f < nbflags; f++) |
| 317 | { |
| 318 | *(this->FileStream) >> flag; |
| 319 | } |
| 320 | this->FileStream->get(c); |
| 321 | for (f = 0; f < nbelts; f++) |
| 322 | { |
| 323 | *(this->FileStream) >> elt; |
| 324 | materials->SetValue(elt - 1, mat); |
| 325 | } |
| 326 | this->FileStream->get(c); |
| 327 | // read here the end of section |
| 328 | this->FileStream->get(buf, 128, '\n'); |
| 329 | this->FileStream->get(c); |
| 330 | if (strncmp(buf, "ENDOFSECTION", 12) != 0) |
| 331 | { |
| 332 | vtkErrorMacro(<< "Error reading ENDOFSECTION tag at end of group"); |
| 333 | } |
| 334 | } |
| 335 | vtkDebugMacro(<< "All groups read successfully"); |
| 336 | |
| 337 | output->GetCellData()->AddArray(materials); |
| 338 | if (!output->GetCellData()->GetScalars()) |
| 339 | { |
| 340 | output->GetCellData()->SetScalars(materials); |
| 341 | } |
| 342 | materials->Delete(); |
| 343 | } |
| 344 | |
| 345 | //------------------------------------------------------------------------------ |
| 346 | void vtkGAMBITReader::ReadCellConnectivity(vtkUnstructuredGrid* output) |
no test coverage detected