Я использую MATLAB R2019b. Я должен отредактировать .m
файл, который использует сопровождающий stlread()
. Этот возвращает структуру stl, и я могу использовать stl.vertices
для получения точек модели.
Начиная с R2018b и далее, stlread()
и stlwrite()
кажутся полностью переписан, возвращая триангуляцию ул. Точки доступны через stl.Points
. Однако количество точек (а также время загрузки) резко сокращаются. Этот новый stlread()
загружает мой пример файла в 5 раз быстрее и дает в 10 раз меньшее количество точек.
Что действительно изменилось в новом stlread()
? Могу ли я напрямую изменить stl.Points
(например, повернуть облако точек, ...)?
Обновление: Это файл stlread.m
, который пришел с моим заданием. Я думаю, что это из более старой версии MATLAB.
function varargout = stlread(file)
% STLREAD imports geometry from an STL file into MATLAB.
% FV = STLREAD(FILENAME) imports triangular faces from the ASCII or binary
% STL file idicated by FILENAME, and returns the patch struct FV, with fields
% 'faces' and 'vertices'.
%
% [F,V] = STLREAD(FILENAME) returns the faces F and vertices V separately.
%
% [F,V,N] = STLREAD(FILENAME) also returns the face normal vectors.
%
% The faces and vertices are arranged in the format used by the PATCH plot
% object.
% Copyright 2011 The MathWorks, Inc.
if ~exist(file,'file')
error(['File ''%s'' not found. If the file is not on MATLAB''s path' ...
', be sure to specify the full path to the file.'], file);
end
fid = fopen(file,'r');
if ~isempty(ferror(fid))
error(lasterror); %#ok
end
M = fread(fid,inf,'uint8=>uint8');
fclose(fid);
[f,v,n] = stlbinary(M);
%if( isbinary(M) ) % This may not be a reliable test
% [f,v,n] = stlbinary(M);
%else
% [f,v,n] = stlascii(M);
%end
varargout = cell(1,nargout);
switch nargout
case 2
varargout{1} = f;
varargout{2} = v;
case 3
varargout{1} = f;
varargout{2} = v;
varargout{3} = n;
otherwise
varargout{1} = struct('faces',f,'vertices',v);
end
end