getting this error with stlwrite
5 次查看(过去 30 天)
显示 更早的评论
2 个评论
Adam Danz
2020-2-17
See the examples in the stlwrite documentation.
Note how the inputs are constructed.
回答(2 个)
Rami Ali Al-Khulaidi
2021-10-7
To save it using stlwrite, I should get triangulation from stlread.....
u=stlread('ag455.stl');
stlwrite(u,'mesh.stl','binary')
0 个评论
DGM
2025-7-2
编辑:DGM
2025-7-2
I think @Rami Ali Al-Khulaidi is about right in an oblique way. If you want the object geometry, you already have it. You don't need to save anything.
However, if you want an STL containing the (I presume) tetrahedral mesh generated by generateMesh(), then you're out of luck. The input to the built-in stlwrite() must be a triangulation object. While triangulation() supports both triangular and tetrahedral meshes, stlwrite() only supports plain triangular meshes.
If your model is 3D, what you have is a quadratic tetrahedral mesh represented by a 10xT list. The triangulation class does not support such a thing. As far as I know, there are no STL writers or readers which will support such a thing. I might be missing one, but most STL tools I've seen on the FEX presume that meshes are triangular. A cursory glance at references suggests that that's the specification.
If you were to try to reduce the model to a 4xT tetrahedral mesh using the 'linear' option, you could generate a triangulation object, but you're still not going to write it with stlwrite().
unzip stepholecube.stl.zip
model = createpde;
importGeometry(model,'stepholecube.stl');
pdegplot( model,'FaceLabels',"on");
%u = generateMesh(model) % default is 'quadratic'; tetrahedron list is 10xT
u = generateMesh(model,'geometricorder','linear') % list is 4xT
T = triangulation(u.Elements.',u.Nodes.'); % supports Tx3 or Tx4
stlwrite(T,'mesh.stl','binary') % supports only _triangular_ meshes (Tx3)
If there were an STL writer that can support a quadratic tetrahedral representation of a mesh, are there any external applications that can read such a file? If the answer is "no", then there's no point creating such a file. Save it as a .mat file or something else.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geometry and Mesh 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
