资源简介
主要用于MATLAB读取ply格式的三维模型,共有三个m文件,plyread.m,plywrite.m,plywritetri.m.

代码片段和文件信息
function [Elementsvarargout] = plyread(PathStr)
%PLYREAD Read a PLY 3D data file.
% [DATACOMMENTS] = PLYREAD(FILENAME) reads a version 1.0 PLY file
% FILENAME and returns a structure 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.
%
% [TRIPTS] = PLYREAD(FILENAME‘tri‘) or
% [TRIPTSDATACOMMENTS] = PLYREAD(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:
% [TriPts] = PLYREAD(‘cow.ply‘‘tri‘);
% trisurf(TriPts(:1)Pts(:2)Pts(:3));
% colormap(gray); axis equal;
%
% See also: PLYWRITE
% Pascal Getreuer 2004
[fidMsg] = fopen(Path‘rt‘); % open file in read text mode
if fid == -1 error(Msg); end
Buf = fscanf(fid‘%s‘1);
if ~strcmp(Buf‘ply‘)
fclose(fid);
error(‘Not a PLY file.‘);
end
%%% read header %%%
Position = ftell(fid);
Format = ‘‘;
NumComments = 0;
Comments = {}; % for storing any file comments
NumElements = 0;
NumProperties = 0;
Elements = []; % structure for holding the element data
ElementCount = []; % number of each type of element in file
PropertyTypes = []; % corresponding structure recording property types
ElementNames = {}; % list of element names in the order they are stored in the file
PropertyNames = []; % structure of lists of property names
while 1
Buf = fgetl(fid); % read one line from file
BufRem = Buf;
Token = {};
Count = 0;
while ~isempty(BufRem) % split line into tokens
[tmpBufRem] = strtok(BufRem);
if ~isempty(tmp)
Count = Count + 1; % count tokens
Token{Count} = tmp;
end
end
if Count % parse line
switch lower(Token{1})
case ‘format‘ % read data format
if Count >= 2
Format = lower(Token{2});
if Count == 3 & ~strcmp(Token{3}‘1.0‘)
fclose(fid);
error(‘Only PLY format version 1.0 supported.‘);
end
end
case ‘comment‘ % read file comment
NumComments = NumComments + 1;
Comments{NumComments} = ‘‘;
for i = 2:Count
Comments{NumComments} = [Comments{NumComments}Token{i}‘ ‘];
end
case ‘element‘ % element name
if Count >= 3
if isfield(ElementsToken{2})
fclose(fid);
error([‘Duplicate element name ‘‘‘Token{2}‘‘‘.‘]);
end
NumElements = NumElements + 1;
NumProperties = 0;
Elements
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 734 2004-07-18 21:41 README.TXT
文件 75683 2004-07-12 02:52 cow.ply
文件 1336 2009-05-28 18:56 license.txt
文件 13212 2004-07-12 03:34 ply.htm
文件 15640 2004-07-18 21:37 plyread.m
文件 8845 2004-07-12 03:41 plywrite.m
文件 1098 2004-07-18 21:37 plywritetri.m
- 上一篇:matlab 图像形状识别
- 下一篇:结合维纳滤波的小波域去噪
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论