getting this error with stlwrite

조회 수: 7 (최근 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
Wu Yuqi
Wu Yuqi 2020년 2월 17일
Same error.
Adam Danz
Adam Danz 2020년 2월 17일
See the examples in the stlwrite documentation.
Note how the inputs are constructed.

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

답변 (2개)

Rami Ali Al-Khulaidi
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')

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