How to export stl file from triangles.

조회 수: 3 (최근 30일)
Nicolas Rogalski
Nicolas Rogalski 2019년 5월 26일
답변: DGM 2025년 10월 7일
Hello,
I want to export a stl file from triangulated points. The outputs of my code are the points id contained in triangles (nx3 array) and the outwards normals of trianglesm (nx3 array).
I tried the functions stlwrite or surf2stl but the results are not good.
Thank you for your help!
  댓글 수: 2
Rik
Rik 2019년 5월 26일
Normally stl files contain the vertices, not the normals.

댓글을 달려면 로그인하십시오.

답변 (1개)

DGM
DGM 2025년 10월 7일
If you have a list of vertices (coordinate positions), and a list of triangular faces (indices into the vertex list), then you can just write that directly to an STL. You don't need the normals. The encoder will calculate them internally.
Since R2018b, MATLAB has built-in STL tools. You don't need to download anything. stlread() stlwrite()
For legacy versions needing third-party tools, I'd strongly recommend these tools. This explains why.
FEX surf2stl() works on gridded data, not on triangulations. If you're using "stlwrite", then you're probably using FEX #20922, and probably using it by feeding it XYZ coordinate data in the same way you had used surf2stl(), which would be the wrong way to use it for the same reason.
That said, there are any number of ways to represent mesh triangles other than as references to a vertex list. If it's stored in a direct manner, then obviously one would need to know how it was arranged in order to put it into a usable format.

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by