Skip to content

Material name containing space - incorrectly read from .vol #235

Description

@QubaB

When I am creating mesh, I am using material names containing spaces "Coil 1". Everything works correctly in ngsolve.

When I save mesh to .vol and read it back, only "Coil" is read.

I am not sure if material name containing space is correct.

Problem is with code

  void ReadNumberAndName( istream & infile, int & i, string & s )
  {
    string line;
    std::istringstream iline;

    bool empty_line = true;

    while(empty_line && infile)
      {
        std::getline(infile, line);
        iline = std::istringstream{line};
        iline >> i;

        if(iline)
            empty_line = false;

        iline >> s;
      }

    if(!infile)
        throw Exception("Reached end of file while parsing");
  }

which reads string only to the first space.

If instead iline >> s; will be used std::getline(iline >> std::ws, s); then string containing spaces will be read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions