Opening STL file using stlread function

22 次查看(过去 30 天)
Hi
This is a line from a code to open binary stl files. My understanding was that the x,y,z vertex coordinates and colours would be stored using this
[x,y,z,c] = stlread(Filename.stl);
I tried to rewrite it as
random.stl=stlread('01_random.stl');
x = random.stl.Points(:,1);
y = random.stl.Points(:,2);
z = random.stl.Points(:,3);
The first line returns
  • x - xxxx*3 triangulation
  • y-binary
  • z xxxx*1 uint16
  • c xxxx*1 double
but my code returns
  • stl xxxx*3 triangulation
  • x,y,z all as xxxx*1 double
  • the x,y,z coordinates are stored
Can some explain the first line? What was it meant to do because the values of x,y,z and c are not of the same type.

回答(1 个)

T.Nikhil kumar
T.Nikhil kumar 2023-10-20
Hello Angel,
I understand that you want to know why the outputs of ‘stlread’ function are different from your expectation.
In the first case, the ‘stlread’ function returns:
  • ‘TR’ (triangulation object) in ‘x’
  • file format in ‘y’(binary/text)
  • attributes when the file is binary in ‘z’
  • solid identification numbers when the file is text in ‘c’.
It follows the below mentioned syntax:
[TR,fileformat,attributes,solidID] = stlread(filename);
In the second case, a struct of the name ‘random’ is created which has ‘stl’ as a field. This ‘stl’ field contains the ‘triangulation’ type object that is read from the input file. This ‘triangulation’ object has a ‘Points’ property and each row of this property represents the coordinates of a vertex.
You can refer to the following documentation to understand more about ‘stlread’ function.
Hope this helps!

标签

Community Treasure Hunt

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

Start Hunting!

Translated by