欢迎来到冰豆网! | 帮助中心 分享价值,成长自我!
冰豆网
全部分类
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • 党团工作>
  • ImageVerifierCode 换一换
    首页 冰豆网 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    MATLAB对ply文件格式读取及显示.docx

    • 资源ID:9090705       资源大小:168.07KB        全文页数:28页
    • 资源格式: DOCX        下载积分:12金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要12金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    MATLAB对ply文件格式读取及显示.docx

    1、MATLAB对ply文件格式读取及显示MATLAB对ply文件格式的读取和显示首先是这个ply_read.m文件plain view plain copy print?在CODE上查看代码片派生到我的代码片function Elements, varargout = PLY_READ ( Path, Str ) %*80 % % PLY_READ reads a PLY 3D data file. % % DATA,COMMENTS = PLY_READ(FILENAME) reads a version 1.0 PLY file % FILENAME and returns a struct

    2、ure DATA. The fields in this structure % are defined by the PLY header; each element type is a field and each % element property is a subfield. If the file contains any comments, % they are returned in a cell string array COMMENTS. % % TRI,PTS = PLY_READ(FILENAME,tri) or % TRI,PTS,DATA,COMMENTS = PL

    3、Y_READ(FILENAME,tri) converts vertex % and face data into triangular connectivity and vertex arrays. The % mesh can then be displayed using the TRISURF command. % % Note: This function is slow for large mesh files (+50K faces), % especially when reading data with list type properties. % % Example: %

    4、 Tri,Pts = PLY_READ(cow.ply,tri); % Tri,Pts = PLY_READ(bunny.ply,tri); % trisurf(Tri,Pts(:,1),Pts(:,2),Pts(:,3); % colormap(gray); axis equal; % % Discussion: % % The original version of this program had a mistake that meant it % did not properly triangulate files whose faces were not already triang

    5、ular. % This has been corrected (JVB, 25 February 2007). % % Glenn Ramsey pointed out and corrected a problem that occurred % with an uninitialized value of Type2, 27 August 2012. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 27 August 2012 % % Author: % %

    6、 Pascal Getreuer 2004 % % Parameters: % % Local Parameters: % % COMMENTS, any comments from the file. % % ELEMENTCOUNT, the number of each type of element in file. % % ELEMENTS, the element data. % % PROPERTYTYPES, the element property types. % % SIZEOF, size in bytes of each type. % % % Open the in

    7、put file in read text mode. % fid, Msg = fopen ( Path, rt ); if ( fid = -1 ) error ( Msg ); end Buf = fscanf ( fid, %s, 1 ); if ( strcmp ( Buf, ply ) ) fclose ( fid ); error(Not a PLY file.); end % % Read the header. % Position = ftell(fid); Format = ; NumComments = 0; Comments = ; NumElements = 0;

    8、NumProperties = 0; Elements = ; ElementCount = ; PropertyTypes = ; ElementNames = ; % list of element names in the order they are stored in the file PropertyNames = ; % structure of lists of property names while ( 1 ) % % Read a line from the file. % Buf = fgetl ( fid ); BufRem = Buf; Token = ; Coun

    9、t = 0; % % Split the line into tokens. % while ( isempty(BufRem) ) tmp, BufRem = strtok(BufRem); % % Count the tokens. % if ( isempty ( tmp ) ) Count = Count + 1; TokenCount = tmp; end end % % Parse the line. % if ( Count ) switch lower ( Token1 ) % % Read the data format. % case format if ( 2 = Cou

    10、nt ) Format = lower ( Token2 ); if ( Count = 3 & strcmp ( Token3, 1.0 ) ) fclose ( fid ); error(Only PLY format version 1.0 supported.); end end % % Read a comment. % case comment NumComments = NumComments + 1; CommentsNumComments = ; for i = 2 : Count CommentsNumComments = CommentsNumComments,Token

    11、i, ; end % % Read an element name. % case element if ( 3 = 3 ) NumProperties = NumProperties + 1; eval(tmp=isfield(Elements.,CurElement,TokenCount);,. fclose(fid);error(Error reading property: ,Buf); if ( tmp ) error(Duplicate property name, ,CurElement,.,Token2,.); end % % Add property subfield to

    12、Elements. % eval(Elements.,CurElement,.,TokenCount,=;, . fclose(fid);error(Error reading property: ,Buf); % % Add property subfield to PropertyTypes and save type. % eval(PropertyTypes.,CurElement,.,TokenCount,=Token2:Count-1;, . fclose(fid);error(Error reading property: ,Buf); % % Record property n

    13、ame order. % eval(PropertyNames.,CurElement,NumProperties=TokenCount;, . fclose(fid);error(Error reading property: ,Buf); else fclose ( fid ); if ( isempty(CurElement) ) error(Property definition without element definition: ,Buf); else error(Bad property definition: ,Buf); end end % % End of header.

    14、 % case end_header break; end end end % % Set reading for specified data format. % if ( isempty ( Format ) ) warning(Data format unspecified, assuming ASCII.); Format = ascii; end switch Format case ascii Format = 0; case binary_little_endian Format = 1; case binary_big_endian Format = 2; otherwise

    15、fclose ( fid ); error(Data format ,Format, not supported.); end % % Read the rest of the file as ASCII data. % if ( Format ) Buf = fscanf ( fid, %f ); BufOff = 1; else % % .or, close the file, and reopen in read binary mode. % fclose ( fid ); % % Reopen the binary file as LITTLE_ENDIAN or BIG_ENDIAN

    16、. % if ( Format = 1 ) fid = fopen ( Path, r, ieee-le.l64 ); else fid = fopen ( Path, r, ieee-be.l64 ); end % % Find the end of the header again. % Using ftell on the old handle doesnt give the correct position. % BufSize = 8192; Buf = blanks(10), char(fread(fid,BufSize,uchar) ; i = ; tmp = -11; whil

    17、e ( isempty(i) ) i = findstr(Buf,end_header,13,10); % look for end_header + CR/LF i = i,findstr(Buf,end_header,10); % look for end_header + LF if ( isempty(i) ) tmp = tmp + BufSize; Buf = Buf(BufSize+1:BufSize+10),char(fread(fid,BufSize,uchar); end end % % seek to just after the line feed % fseek (

    18、fid, i + tmp + 11 + (Buf(i + 10) = 13), -1 ); end % % Read element data. % % PLY and MATLAB data types (for fread) % PlyTypeNames = char,uchar,short,ushort,int,uint,float,double, . char8,uchar8,short16,ushort16,int32,uint32,float32,double64; MatlabTypeNames = schar,uchar,int16,uint16,int32,uint32,si

    19、ngle,double; SizeOf = 1,1,2,2,4,4,4,8; for i = 1 : NumElements % % get current element property information % eval(CurPropertyNames=PropertyNames.,ElementNamesi,;); eval(CurPropertyTypes=PropertyTypes.,ElementNamesi,;); NumProperties = size(CurPropertyNames,2); % fprintf(Reading %s.n,ElementNamesi);

    20、 % % Read ASCII data. % if ( Format ) for j = 1 : NumProperties Token = getfield(CurPropertyTypes,CurPropertyNamesj); if ( strcmpi(Token1,list) ) Type(j) = 1; else Type(j) = 0; end % % Glenn Ramsey 20120827 % Initialise Type2 to prevent uninitialised value error. % Type2j = ; end % % Parse the buffe

    21、r. % if ( any(Type) ) % no list types Data = reshape ( . Buf(BufOff:BufOff+ElementCount(i)*NumProperties-1), . NumProperties, ElementCount(i) ); BufOff = BufOff + ElementCount(i) * NumProperties; else ListData = cell(NumProperties,1); for k = 1 : NumProperties ListDatak = cell(ElementCount(i),1); en

    22、d % % list type % for j = 1 : ElementCount(i) for k = 1 : NumProperties if ( Type(k) ) Data(j,k) = Buf(BufOff); BufOff = BufOff + 1; else tmp = Buf(BufOff); ListDatakj = Buf(BufOff+(1:tmp); BufOff = BufOff + tmp + 1; end end end end % % Read binary data. % else % translate PLY data type names to MAT

    23、LAB data type names ListFlag = 0; % = 1 if ere is a list type SameFlag = 1; % = 1 if all types are the same for j = 1 : NumProperties Token = getfield(CurPropertyTypes,CurPropertyNamesj); % % Non-list type. % if ( strcmp(Token1,list ) ) tmp = rem(strmatch(Token1,PlyTypeNames,exact)-1,8)+1; if ( isem

    24、pty(tmp) ) TypeSize(j) = SizeOf(tmp); Typej = MatlabTypeNamestmp; TypeSize2(j) = 0; Type2j = ; SameFlag = SameFlag & strcmp(Type1,Typej); else fclose(fid); error(Unknown property data type, ,Token1, in , . ElementNamesi,.,CurPropertyNamesj,.); end else % list type if ( length(Token) = 3 ) ListFlag =

    25、 1; SameFlag = 0; tmp = rem(strmatch(Token2,PlyTypeNames,exact)-1,8)+1; tmp2 = rem(strmatch(Token3,PlyTypeNames,exact)-1,8)+1; if ( isempty(tmp) & isempty(tmp2) ) TypeSize(j) = SizeOf(tmp); Typej = MatlabTypeNamestmp; TypeSize2(j) = SizeOf(tmp2); Type2j = MatlabTypeNamestmp2; lse fclose(fid); error(Unknown property data type, list ,Token2, ,Token3, in , . ElementNamesi,.,CurPropertyNamesj,.); end else


    注意事项

    本文(MATLAB对ply文件格式读取及显示.docx)为本站会员主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2022 冰点文档网站版权所有

    经营许可证编号:鄂ICP备2022015515号-1

    收起
    展开