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

Method ReadHeader

IO/Geometry/vtkOpenFOAMReader.cxx:4490–4561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4488// Code: vtkFoamIOobject
4489
4490void vtkFoamIOobject::ReadHeader()
4491{
4492 this->Superclass::ReadExpecting("FoamFile");
4493 this->Superclass::ReadExpecting('{');
4494
4495 vtkFoamDict headerDict;
4496 headerDict.SetStreamOption(this->GetStreamOption());
4497 headerDict.Read(*this, true); // Read as sub-dict. Throw exception in case of error
4498
4499 const vtkFoamEntry* eptr;
4500
4501 // Essentials
4502 if ((eptr = headerDict.Lookup("class")) == nullptr)
4503 {
4504 throw vtkFoamError() << "No 'class' in FoamFile header";
4505 }
4506 this->headerClassName_ = eptr->ToString();
4507
4508 if ((eptr = headerDict.Lookup("object")) == nullptr)
4509 {
4510 throw vtkFoamError() << "No 'object' in FoamFile header";
4511 }
4512 this->objectName_ = eptr->ToString();
4513
4514 if ((eptr = headerDict.Lookup("format")) == nullptr)
4515 {
4516 // Note (2021-03-19): may make this optional in the future, defaulting to ascii
4517 throw vtkFoamError() << "No 'format' (ascii|binary) in FoamFile header";
4518 }
4519 this->SetBinaryFormat("binary" == eptr->ToString()); // case sensitive
4520
4521 // The arch entry has "label=(32|64) scalar=(32|64)"
4522 // If missing/incomplete, use fallback values from reader (defined in constructor and Close)
4523 if ((eptr = headerDict.Lookup("arch")) != nullptr)
4524 {
4525 const std::string archValue(eptr->ToString());
4526
4527 // Match "label=(32|64)"
4528 {
4529 auto pos = archValue.find("label=");
4530 if (pos != std::string::npos)
4531 {
4532 pos += 6; // Skip past "label="
4533 if (archValue.compare(pos, 2, "32") == 0)
4534 {
4535 this->SetLabel64(false);
4536 }
4537 else if (archValue.compare(pos, 2, "64") == 0)
4538 {
4539 this->SetLabel64(true);
4540 }
4541 }
4542 }
4543
4544 // Match "scalar=(32|64)"
4545 {
4546 auto pos = archValue.find("scalar=");
4547 if (pos != std::string::npos)

Callers 1

OpenFileMethod · 0.95

Calls 10

vtkFoamErrorClass · 0.85
LookupMethod · 0.80
SetBinaryFormatMethod · 0.80
SetLabel64Method · 0.80
SetStreamOptionMethod · 0.45
ReadMethod · 0.45
ToStringMethod · 0.45
findMethod · 0.45
compareMethod · 0.45
SetFloat64Method · 0.45

Tested by

no test coverage detected