How does stlread work?

조회 수: 14 (최근 30일)
Ernst Wehtje
Ernst Wehtje 2016년 3월 27일
댓글: DGM 2025년 7월 4일
Hi, Im not familiar with stlread but have a project at school where I want to create Gcode for 3d printers. I wanted to try to write a script of my own to understand and Matlab is the language I know the best.
I was trying to run a script I found on http://www.mathworks.com/matlabcentral/fileexchange/22409-stl-file-reader , but get "Not enough input arguments" for fid=fopen(file).
Does someone know what might be the problem, what I might do wrong?
Regards, Ernst
  댓글 수: 5
nvmnghia
nvmnghia 2020년 4월 20일
From R2018b, it seems that the stlread() and stlwrite() is completely rewritten, leading to breaking changes. One point though, why the old stl.vertices and the new stl.Points return different number?
DGM
DGM 2025년 7월 4일
Each facet in an STL file is a direct representation of the numerical position of its vertices, not a set of indices into a global vertex list. That means that each vertex is described redundantly by each of its neighboring facets.
A decoder should remove those redundant vertices from the vertex list, but FEX #22409 does not. Instead of V being a concise list of the unique model vertices, and F being a concise descriptor of the model faces, V contains all the meaningful model information and F is a trivial linear ramp of indices from 1:size(V,1). In other words, V it is a complete description of both vertices and faces. Most of these decoders on the FEX are at least as half-baked, so it's not an inelegance unique to #22409.
If you have a decoder that doesn't do pruning, you can expect the length of V to be 3x the length of F, regardless of how many unique vertices there actually are. For most practical solid models, you should usually expect V to be shorter than F, not the other way around.
TL;DR The built-in stlread() from R2018b does properly prune the vertex list, that's why V will be so much shorter than with #22409

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

답변 (1개)

DGM
DGM 2025년 4월 4일
It looks like you edited the variable names in the function, and then you called the function with no arguments. Don't mess with the function file. Just call the function with your filename.
FV = stlread('myfile.stl'); % FEX #22409 returns a struct
That said, after R2018b, there are STL read/write tools in the base toolbox, so you don't need to mess with #22409 anymore.
T = stlread('myfile.stl'); % R2018b+ stlread() returns a triangulation object

카테고리

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