Skip to content

Commit

Permalink
Sometimes DHI Mesh Generater generates mesh files with separators con…
Browse files Browse the repository at this point in the history
…sisting of a mix of tab characters and spaces, so we need to replace the tab characters with spaces before using the MDAL::split function to process the data.
  • Loading branch information
aka863 committed Jan 9, 2025
1 parent 3efa57f commit 501ba6a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mdal/frmts/mdal_mike21.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

#define DRIVER_NAME "Mike21"

void replaceTabsWithSpaces(std::string& str) {
for (size_t i = 0; i < str.length(); ++i) {
if (str[i] == '\t') {
str[i] = ' ';
}
}
}

static bool parse_vertex_id_gaps( std::map<size_t, size_t> &vertexIDtoIndex, size_t vertexIndex, size_t vertexID )
{
Expand Down Expand Up @@ -239,6 +246,7 @@ std::unique_ptr<MDAL::Mesh> MDAL::DriverMike21::load( const std::string &meshFil
{
if ( 0 < lineNumber && lineNumber < mVertexCount + 1 )
{
replaceTabsWithSpaces(line);
chunks = MDAL::split( MDAL::trim( line ),' ');
if ( chunks.size() != 5 )
{
Expand Down Expand Up @@ -276,6 +284,7 @@ std::unique_ptr<MDAL::Mesh> MDAL::DriverMike21::load( const std::string &meshFil

if ( mVertexCount + 1 < lineNumber )
{
replaceTabsWithSpaces(line);
chunks = MDAL::split( MDAL::trim( line ),' ');
assert( faceIndex < faceCount );

Expand Down

0 comments on commit 501ba6a

Please sign in to comment.