getting this error with stlwrite

5 次查看(过去 30 天)
P Kamal Kumar
P Kamal Kumar 2019-11-30
编辑: DGM 2025-7-2
code:
model = createpde;
importGeometry(model,'ag455.stl');
pdegplot( model,'FaceLabels',"on");
u = generateMesh(model)
stlwrite(u,'mesh.stl','binary')
Error using stlwrite (line 25)
Input argument must be a triangulation object.

回答(2 个)

Rami Ali Al-Khulaidi
To save it using stlwrite, I should get triangulation from stlread.....
u=stlread('ag455.stl');
stlwrite(u,'mesh.stl','binary')

DGM
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
u =
FEMesh with properties: Nodes: [3×3040 double] Elements: [4×13433 double] MaxElementSize: 0.0693 MinElementSize: 0.0346 MeshGradation: 1.5000 GeometricOrder: 'linear'
T = triangulation(u.Elements.',u.Nodes.'); % supports Tx3 or Tx4
stlwrite(T,'mesh.stl','binary') % supports only _triangular_ meshes (Tx3)
Error using stlwrite (line 33)
Tetrahedron triangulation is not supported.
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.

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by