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

Method GetPartInfo

IO/EnSight/core/EnSightDataSet.cxx:1369–1505  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1367
1368//------------------------------------------------------------------------------
1369bool EnSightDataSet::GetPartInfo(vtkDataArraySelection* partSelection,
1370 vtkDataArraySelection* pointArraySelection, vtkDataArraySelection* cellArraySelection,
1371 vtkDataArraySelection* fieldArraySelection, vtkStringArray* partNames)
1372{
1373 // Since we just want to get info on all the parts, we'll just look at the first time step
1374 if (!this->GeometryFile.SetTimeStepToRead(0.0))
1375 {
1376 vtkGenericWarningMacro("couldn't correctly set time step to read. Aborting");
1377 return false;
1378 }
1379
1380 partNames->Initialize();
1381
1382 // now that geometry file has been opened and file type detected, set format for all variables
1383 this->SetVariableFileFormat();
1384
1385 this->GeometryFile.CheckForBeginTimeStepLine();
1386 this->GeometryFile.SkipNLines(2);
1387
1388 // read node id, which can be off/given/assign/ignore
1389 auto result = this->GeometryFile.ReadNextLine();
1390 std::regex nodeRegEx(R"((?:^|\s)(off|given|assign|ignore)(?=$|\s))");
1391 std::smatch sm;
1392 if (result.first && std::regex_search(result.second, sm, nodeRegEx))
1393 {
1394 if (sm[1] == "given" || sm[1] == "ignore")
1395 {
1396 this->NodeIdsListed = true;
1397 }
1398 }
1399
1400 // similarly for element id
1401 result = this->GeometryFile.ReadNextLine();
1402 if (result.first && std::regex_search(result.second, sm, nodeRegEx))
1403 {
1404 if (sm[1] == "given" || sm[1] == "ignore")
1405 {
1406 this->ElementIdsListed = true;
1407 }
1408 }
1409
1410 result = this->GeometryFile.ReadNextLine();
1411 if (result.second.find("extents") != std::string::npos)
1412 {
1413 if (this->GeometryFile.Format == FileType::ASCII)
1414 {
1415 // two values per line in ASCII case
1416 this->GeometryFile.SkipNLines(3);
1417 }
1418 else
1419 {
1420 this->GeometryFile.MoveReadPosition(6 * sizeof(float));
1421 }
1422 result = this->GeometryFile.ReadNextLine(); // "part"
1423 }
1424
1425 while (result.first && result.second.find("part") != std::string::npos)
1426 {

Callers 1

RequestInformationMethod · 0.80

Calls 15

SetVariableFileFormatMethod · 0.95
ReadPartIdMethod · 0.95
getGridOptionsFunction · 0.85
SetTimeStepToReadMethod · 0.80
SkipNLinesMethod · 0.80
ReadNextLineMethod · 0.80
MoveReadPositionMethod · 0.80

Tested by

no test coverage detected