-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SofaHelper] Handle recent MSH format in MeshGmshLoader #2155
Merged
epernod
merged 15 commits into
sofa-framework:master
from
Camille-K:issue_1528_gmsh_recent_format
Oct 21, 2021
Merged
[SofaHelper] Handle recent MSH format in MeshGmshLoader #2155
epernod
merged 15 commits into
sofa-framework:master
from
Camille-K:issue_1528_gmsh_recent_format
Oct 21, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
At the moment the test fails, because there seem to be some discrepancy between the topology that the MeshGmshLoader is able to retrieve in a scene, and the data it actually contains. This might come from the fact that the doLoad() method of MeshGmshLoader doesn't call anymore its method readGmsh, and that the mesh is in fact retrieved in the scene at the MeshGmsh level. This has yet to be clarified.
Parsing method readGmsh is updated to handle more recent MSH file formats (<= 4.1). Detail of the format is available here: https://gmsh.info/doc/texinfo/gmsh.html#File-formats Handling of versions <= 2 is not changed, so this commit should not be breaking.
Instead of assuming that the MSH file format version is either 1 or 2, we read it from the file in order to handle the most recent format (4.1 at the time). The version is then passed to the parser in MeshGmsh.cpp. With this commit, versions >= 4 are not yet handled by the parser.
Method readGmsh of MeshGmshLoader is left unused.
In case the MSH file format is only partially respected by the input file.
[ci-build][with-all-tests] |
The use of std::getLine instead of the >> operator caused the parsing to read the last " " character of the last line in the "Element" section in the MSH files, instead of the line closing the section, for file formats older than 2.0.
Using the data obtained via the official Gmsh loader as a reference.
This was
linked to
issues
Oct 19, 2021
[ci-build][with-all-tests] |
The first line of old .msh files (version = 1.x) seems to be "$NOD\r" instead of "$NOD", which caused them not to be detected by the MeshGmshLoader parser. This issue comes from the fact that before the update of the loader, if the header line was not recognised, then the version of the parsed .msh file was assumed to be 2.x. This fix simply adds $NOD\r$ as a recognised header line for .msh files with version 1.x, mainly to maintain compatibility with the unit tests.
Basic modification of examples/Components/loader/MeshGmshLoader.scn adding a new node which parses a .msh file with version 4.1
[ci-build][with-all-tests] |
Some tests in the CI use .msh files with slightly different syntax than the standard. Namely, the problem comes from the presence of a carriage return character "\r", sometimes preceeded by a space " " character, at the end of main section lines such as "$MeshFormat \r", or "$Nodes\r". A solution to this is to make the parser a little bit more permessive, by only parsing the beginning of these lines and see if it corresponds to the expected section titles ("$MeshFormat", "$Nodes"). This is only implemented for versions <= 2, as it is not actually part of the standard (i.e. a .msh file starting with "$MeshFormat \r" instead of "$MeshFormat" is not technically a .msh file). The issue could come from .msh files commited from different OS, with lines ending differently. If so, the more permessive parsing should also be extended for versions >= 4.
">" instead of ">=" caused (logically) some header lines not to be detected as .msh header lines
[ci-build][with-all-tests] |
epernod
approved these changes
Oct 21, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
About a possible enhancement
pr: status ready
Approved a pull-request, ready to be squashed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt at fixing #1528.
At the moment, file parsing in MeshGmsh.cpp and MeshGmshLoader.cpp is (hopefully) correctly handled, including more recent MSH file formats (=>4.0).
EDIT: I don't fully understand how the loader works, mainly why MeshGmshLoader::readGmsh() is temporarily not used (commented in l.111), with the parsing apparently relying only on MeshGmsh::readGmsh(). However I tried to keep the same structure as before, simply taking into account the case where the .msh version is > 2.
A .msh file with version 4.1 is added (share/mesh/msh4_cube.msh), and its parsing by the MeshGmshLoader is tested both in examples/Components/loader/MeshGmshLoader.scn and in a new unit test. Both tests are working locally.
Regarding the original purpose of #1528, the PR should be sufficient.
Fixes #2433 #1528
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if