------------------------------------------------------------------------------
| 5603 | |
| 5604 | //------------------------------------------------------------------------------ |
| 5605 | void vtkOpenFOAMReaderPrivate::AddFieldName( |
| 5606 | const std::string& fieldName, const std::string& fieldType, bool isLagrangian) |
| 5607 | { |
| 5608 | if (fieldName.empty() || fieldType.empty()) |
| 5609 | { |
| 5610 | return; |
| 5611 | } |
| 5612 | |
| 5613 | size_t len = fieldType.find("Field"); |
| 5614 | bool isInternalField = false; |
| 5615 | |
| 5616 | if (len == std::string::npos) |
| 5617 | { |
| 5618 | return; |
| 5619 | } |
| 5620 | else if ((len + 5) == fieldType.size()) |
| 5621 | { |
| 5622 | // OK: ends_with("Field") |
| 5623 | } |
| 5624 | else if (fieldType.compare(len, std::string::npos, "Field::Internal") == 0) |
| 5625 | { |
| 5626 | // OK: ends_with("Field::Internal") |
| 5627 | // but only valid for volScalarField::Internal, etc |
| 5628 | |
| 5629 | isInternalField = true; |
| 5630 | if (isLagrangian || (fieldType.compare(0, 3, "vol") != 0)) |
| 5631 | { |
| 5632 | return; |
| 5633 | } |
| 5634 | } |
| 5635 | else |
| 5636 | { |
| 5637 | // Some other (unknown) type - ignore |
| 5638 | return; |
| 5639 | } |
| 5640 | |
| 5641 | if (isLagrangian) |
| 5642 | { |
| 5643 | // Lagrangian (point) fields: labelField, scalarField, vectorField, ... |
| 5644 | |
| 5645 | const auto fieldDataType(vtkFoamTypes::FieldToEnum(fieldType)); |
| 5646 | if (fieldDataType != vtkFoamTypes::NO_TYPE) |
| 5647 | { |
| 5648 | // NB: Cloud has labelField too |
| 5649 | this->LagrangianFieldFiles->InsertNextValue(fieldName); |
| 5650 | } |
| 5651 | return; |
| 5652 | } |
| 5653 | |
| 5654 | size_t prefix = 0; |
| 5655 | vtkStringArray* target = nullptr; |
| 5656 | if (fieldType.compare(0, 3, "vol") == 0) // starts_with("vol") |
| 5657 | { |
| 5658 | // Volume fields: volScalarField, volVectorField, ... |
| 5659 | // or Dimensioned (internal) fields: volScalarField::Internal, ... |
| 5660 | prefix = 3; |
| 5661 | len -= prefix; |
| 5662 |
no test coverage detected