FYI, from a C++ programming standpoint any mention of STL without any qualifiers (hint, stereolighography) is gonna make people think you want to something to a Standard Template Library file. I know that is what I thought until I did a 'net search.
@George P thanks for your answer. I already knew about the mesh converter. but I'm specifically looking for c++ code for this purpose. I know I shouldn't be asking about code here but I have no idea about this stuff in c++. That's why I'm looking for an example code.
A .mesh file contains an entire finite-element or finite-volume 3-d mesh. That might well be generated from the surface information, but it isn't the surface.
They aren't the same type of thing. Are you sure that you don't just want a mesh-generator?
@lastchance thanks for your answer. It's been a long time that I haven't used fluent but now due to some reasons I have to. I tried the Spaceclaim but fluent failed to read the case. I think during the conversion from stl to .msh or solid geometry something is going worng. For example once I was working with finite element and I was trying to open the mesh in paraview but after reading the mesh paraview crashed everytime. Then I found out that there are some miscamputing with connectivity. I thinks something similar is happening here.
I created an STL file of my own, imported it into StarCCM+, meshed it (with StarCCM+'s built-in mesher) and then exported it as Ensight Gold format, which I could successfully view in Paraview.
However, when I tried to do the same with your file it didn't like it. Are you sure that your STL file is correct (closed boundary with no discontinuities etc.)?
I was thinking about the same but I don't know how to check it. As far as I can check in SpaceClaim it includes 4 bodies merged together. How can I check for any discontinuties? I used online mesh converter before posting this question, then converted it to .obj. Then opened the file with notepad and copied the data into a file in notepad++ (.msh). That's how I got .msh at the beginning. When I was looking at the data it looked like normal but I can't say there is no discontinuties.
The problem is not about discontinuties. I have another stl file and it's. Msh file. I'm able to run .msh in Fluent. But when I try to convert the stl to .msh and run in Fluent it fails. So the problem is the way I'm converting the stl file.
@OP
On close inspection of the file you shared it appears to be a .stl file prepared in Blender - that's what it plainly says, despite being generally binary-like or whatever vs plain text.
So, importing it into Blender and displaying it with the shader turned off it appears as a triangulated surface mesh in 3D. It's fully rotatable etc etc.
Export that as a .obj file and the .obj file is readable as text, and fully displayable in Blender
As far as discontinuities are concerned, keep in mind blender is graphics software and is not concerned about discontinuities that might/probably will affect a Fluent analysis. i.e. Blender is probably not a good way to develop 3D analytical models.
The problem is not your conversion method - it is the original STL file.
I can load it and view it in StarCCM+ - the surface triangulation is clear: https://imgur.com/WwCwarq
If you then run an error check on it then 8 free edges are reported. This prevents me from meshing it directly.
I can (sort of) mend it with StarCCM+'s surface wrapper. Then I can successfully mesh it and export it. .msh is not an option to me, so I used Ensight Gold. Here it is with the exported mesh viewed in Paraview: https://imgur.com/eyfZq53
So, you need to fix your STL file, ideally in whatever software you used to create it in the first place, or, failing that, with whatever ANSYS's software will allow you to mend it with.
@lastchance I can see the surface in SpaceClaim and paraview as well. In SpaceClaim when I run an error check I'll get the errors as you mentioned. I doubt that the problem is stl file, because for one specific geometry I have both stl and .mesh. when I run .msh in Fluent it's fine but when I convert the stl to .msh it doesn't work in Fluent. I tried this with other cases as well.
@Cplusc,
You misread my answer. I am not viewing the STL file in Paraview: I am viewing an Ensight Gold file that contains a volume mesh (not just the surface) created once I managed to circumvent the errors in the STL file and hence create a mesh from it.