27 January 2021 at 1 h 06 min #18389
I have recently downloaded the precompiled binary sofa+soft robotics files and have been going through the tutorials. Everything has been fine, however now I am trying to convert my own CAD model into a 3D mesh to be used in SOFA. To begin, I am trying to convert a simple cube into a mesh using GMSH, and then import that into SOFA before using more complex files.
The issue is, I cant seem to create a 3D mesh using GMSH. I am using Solidworks, so I export my file to .igs and then open it in GMSH. I am following this past forum post linked below:
I can create a 2D surface mesh, however, when I try a 3D mesh nothing happens and I cannot use it in SOFA (I get errors stating the mesh needs tetrahedron topology).
I think the issue is that converting to the .igs file in solidworks results in there not being any volume in the model, however I am not sure how to fix this issue.
Any help is appreciated.
Thanks27 January 2021 at 9 h 38 min #18391
if I understand correctly from your question, you can successfully import your geometry in Gmsh. There, you are able to generate the surface mesh by clicking on Mesh->Define->2D, however, for Mesh->Define->3D there is no result, right?
One thing that this could indicate is, that your geometry does not specify a volume, only surfaces. Visually, they can look the same, but Gmsh is only able to generate volumetric meshes for volumes. To verify this, you can go to the menu Tools-Visibility. This will show a list of all the geometrical entities present. On the top of the list there should be at least one volume. If not, then the issue is what I just stated and you need to verify that you are correctly constructing the geometry in your CAD-program.
Stefan27 January 2021 at 10 h 44 min #18396JonnyParticipant
I don’t know for sure if this helps with .igs but I had a similar issue when using stl files in Gmsh that also only contain surface information. I opened my file with File -> Merge and used Geometry -> Elementary entities -> Add -> Volume. After selecting your mesh and following the on-screen instructions you should be able to 3D Mesh, export the resulting vtk/msh file, and use it in sofa.
Jonny27 January 2021 at 19 h 13 min #18399
Thank you for the help. It seems that I do not have any volumes as @sescaida mentioned. I have made a simple cube in solidworks to test the meshing software so I am sure that I have created the shape correctly, it is exporting to an STL or igs file that is the issue.
I am trying to add a volume in gmsh as @Jonny suggested. I have selected the boundaries of the cube however there is not an option to create a volume? It just says press u to under or q to abort?
How do I create a volume after selecting the boundaries?27 January 2021 at 19 h 25 min #18400
I have attached my attempt at creating a mesh. I have added all faces of the cube but I cant create the volume? Any help is appreciated.
Thanks27 January 2021 at 19 h 48 min #18401
can you share your .igs-file?
I think @jonny’s hint might actually work for your case as well. After selecting the boundaries you should be able to press ‘e’ and that should create the volume (not the volumetric mesh). You will know this worked when a yellow sphere at the center of the object appears. This indicates the geometry has a volume.
In any case, I could quickly verify with the geometry file if you share it.
Best27 January 2021 at 19 h 55 min #18402
Thank you for your help. I have attached the .igs file below.
Please let me know if you need anything else.
Thanks27 January 2021 at 20 h 25 min #18403
Alright, I think I found a lead.
The problem seems to come from the igs-format. If you look at the geometric entities in Gmsh when loading the .igs-file, there’s more than 12 lines (curves in Gmsh-language) making up the cube. This means that there’s repeated edges in the cube and therefore adjacent faces cannot be made to a volume, because they actually don’t share common edges!
I also tried exporting to .igs from FreeCAD and encountered the same problem. If I export to .step instead, I can immediately create the volumetric mesh, meaning the geometry is well-defined. In fact, the same cube has only 12 lines/edges, which is the correct amount.
Can you try to export to step from you CAD-software and see if it works then?
Best27 January 2021 at 20 h 40 min #18407
Ah I see to issue is with the .igs file then. I exported to a .STEP file and it seems that a volume is visible automatically.
I can now create the mesh for the cube and import it into SOFA. Thank you for your help.
I tried quickly to create a mesh for a more complex part now, but I am getting the errors “could not recover boundary mesh: error 2” and “no elements in volume 1 2”. I think this has to do with the CAD model, most likely intersecting planes/invalid geometry however I will have to take a look deeper.
Thank you for your help, it is greatly appreciated.27 January 2021 at 20 h 51 min #18408
Good to hear 🙂 Actually, I’ve come to expect that a properly defined geometry exported to STEP will immediately be meshable as volumetric in Gmsh. However, it’s possible, I think, to have STEP files that don’t define volumes. For instance, if you extrude an open contour and it’s not generating a proper solid. Anyways, good luck with the next steps 😉
Edit: If the issue is solved (for now), you can close the topic!
- You must be logged in to reply to this topic.