MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadMaterialTypes

Method ReadMaterialTypes

IO/Geometry/vtkGAMBITReader.cxx:292–343  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

290
291//------------------------------------------------------------------------------
292void 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//------------------------------------------------------------------------------
346void vtkGAMBITReader::ReadCellConnectivity(vtkUnstructuredGrid* output)

Callers 1

ReadGeometryMethod · 0.95

Calls 12

SetScalarsMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
SetNameMethod · 0.45
getMethod · 0.45
valuesMethod · 0.45
SetValueMethod · 0.45
AddArrayMethod · 0.45
GetCellDataMethod · 0.45
GetScalarsMethod · 0.45

Tested by

no test coverage detected