How can I save Matlab FEM mesh information to *.stl or *.ply
14 views (last 30 days)
Show older comments
Hi omnipotent expert,
I encountered some issues after writing Matlab FEM mesh information into *.stl or *.ply then try to import it to some mesh handling software, such as Space Claim, Icem, etc. But these software can not correctly open *.stl or *.ply file from Matlab saved results. Did anybody have workful experience of transter these data to these mesh handling software or other software? Please share these experience, thank you.
Regards,
Bin
0 Comments
Accepted Answer
Shubham
on 22 Feb 2024
Hi Bin,
There could be some compatibility issues when importing the mesh generated in MATLAB into other third-party software. Before exporting the mesh, try validating it first.
Remove duplicate points present in mesh. You can use the “unique” function to obtain unique rows in a matrix. Refer to the following code snippet:
% Find the unique vertices and their indices
[uniqueVertices, ~, indexn] = unique(V, 'rows', 'stable');
% Map the face indices to the new set of vertices
newFaces = indexn(F);
For more information on “unique” function, you can refer to the following documentation: https://www.mathworks.com/help/releases/R2020b/matlab/ref/double.unique.html
You can assess the quality of Mesh objects using the “meshQuality” function present in PDE toolbox documentation: https://www.mathworks.com/help/releases/R2020b/pde/ug/pde.femesh.meshquality.html?s_tid=doc_ta
Align mesh normal to point in a consistent direction using the “unifyMeshNormals” File Exchange submission: https://www.mathworks.com/matlabcentral/fileexchange/43013-unifymeshnormals
Finally, check the file format required for importing the mesh. You can write in ASCII and binary format. Refer to the following File Exchange function “stlwrite” which can be used to write in both file formats: https://www.mathworks.com/matlabcentral/fileexchange/20922-stlwrite-write-ascii-or-binary-stl-files
I hope this helps!
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!