没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
%Copyright 2018 John Moosemiller
%Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
%The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
%THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function [vertices, faces, color] = stlread(filename)
% This function reads an STL file in binary format into matrixes
vertices
% and faces which can be used by patch to view the stl.
%
% MATLAB code by Doron Harlev
% Octave edits by John Moosemiller && @zmughal
read_norm = 0; % whether we want to read the face normals
% Process arguments {{{
if nargout > 3
error('Too many output arguments');
end
use_color = ( nargout == 3 );% }}}
% Open the file, assumes STL Binary format. {{{
fid=fopen(filename, 'r');
if ( fid == -1)
error('File could not be opened, check name or path.')
end% }}}
% Read in header {{{
ftitle = fread(fid, 80, 'uchar=>schar'); % Read file title
num_facet = fread(fid, 1, 'int32'); % Read number of Facets
fprintf('Title: %s', char(ftitle'));
fprintf('Num Facets: %d', num_facet);
% }}}
% Preallocate memory to save running time {{{
vertices = zeros( 3 * num_facet, 3 );
faces = zeros( num_facet, 3 );
if use_color
color = uint8( zeros( 3, num_facet ) );
end
资源评论
weixin_42239936
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功