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

Method GetPointZoneMesh

IO/Geometry/vtkOpenFOAMReader.cxx:10461–10588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10459// Populate point zone(s) mesh
10460
10461bool vtkOpenFOAMReaderPrivate::GetPointZoneMesh(vtkMultiBlockDataSet* zoneMesh, vtkPoints* points)
10462{
10463 const bool supportFields = false; // this->Parent->GetCopyDataToCellZones();
10464
10465 typedef vtkPolyData zoneVtkType;
10466 constexpr const char* const zonePrefix = "pointZone";
10467 constexpr const char* const zoneFileName = "pointZones";
10468 constexpr const char* const labelsName = "pointLabels";
10469 const vtkIdType maxLabels = this->NumPoints;
10470 auto& zoneMap = pointZoneMap;
10471
10472 zoneMap.clearAll(); // Remove all old ids and errors
10473
10474 auto zonesDictPtr(this->GetPolyMeshFile(zoneFileName, false));
10475 if (zonesDictPtr == nullptr)
10476 {
10477 // Not an error if mesh zones are missing
10478 return true;
10479 }
10480
10481 const vtkFoamDict& zones = *zonesDictPtr;
10482 const bool use64BitLabels = zones.IsLabel64();
10483
10484 vtkFoamError warnings;
10485 const unsigned nZones = static_cast<unsigned>(zones.size());
10486
10487 // Detect duplicates
10488 std::unordered_map<std::string, unsigned> zoneNames;
10489
10490 for (unsigned zonei = 0; zonei < nZones; ++zonei)
10491 {
10492 const std::string& zoneName = zones[zonei]->GetKeyword();
10493 const vtkFoamDict& dict = zones[zonei]->Dictionary();
10494
10495 // Look up pointLabels
10496 vtkFoamEntry* eptr = dict.Lookup(labelsName);
10497 if (eptr == nullptr)
10498 {
10499 vtkErrorMacro(<< labelsName << " not found in " << zonePrefix);
10500 return false;
10501 }
10502 vtkFoamEntryValue& labelsEntry = eptr->FirstValue();
10503
10504 // Need mesh, even if the list is empty
10505 vtkNew<zoneVtkType> zm;
10506
10507 // Some OpenFOAM versions write an empty list as zero label only (in binary)
10508 if (labelsEntry.GetType() == vtkFoamToken::EMPTYLIST || labelsEntry.IsLabel(0))
10509 {
10510 // For empty list - store empty mesh (for proper block ordering)
10511 ::SetBlock(zoneMesh, zonei, zm, zoneName);
10512 continue;
10513 }
10514 else if (labelsEntry.GetType() != vtkFoamToken::LABELLIST)
10515 {
10516 vtkErrorMacro(<< labelsName << " is not a labelList");
10517 return false;
10518 }

Callers 1

RequestDataMethod · 0.95

Calls 15

GetPolyMeshFileMethod · 0.95
SetBlockFunction · 0.85
GetLabelValueFunction · 0.85
LookupMethod · 0.80
SetNumberOfIdsMethod · 0.80
AllocateEstimateMethod · 0.80
NewFunction · 0.50
clearAllMethod · 0.45
IsLabel64Method · 0.45
sizeMethod · 0.45
GetTypeMethod · 0.45
IsLabelMethod · 0.45

Tested by

no test coverage detected