资源简介
主要用于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 图像形状识别
- lm算法的matlab实现
- 太阳板光照强度与板倾斜角和方位角
- matlab官方的arrow.m
- Matlab中LMI(线性矩阵不等式)工具箱
- 基于MATLAB的时域采样定理演示系统
- 完全自主研发的粒子群算法来求解约
- Matlab2014_(32and64).txt
- 惯性导航 MATLAB程序
- 基于卡尔曼滤波的目标跟踪matlab经典
- crc32的matlab程序
- 云模型的matlab实现
- matlab实现jpeg压缩过程_MATLAB程序
- Shape Context(matlab)
- lorenz混沌系统 MATLAB仿真
- 《无人驾驶车辆模型预测控制》书中
- 产生4FSK的matlab程序
- 基于MATLAB的SADSSD模板匹配算法
- 支持向量机matlab代码
- DOA与频率联合估计算法的MATLAB仿真
- 三维重建程序 MATLAB语言
- MATLAB代码最小风险贝叶斯决策
- CEEMD代码,matlab亲测可用
- MATLAB实现AM调制
- 太阳能电池matlabm模型
-
LQG主动悬架 maltab simuli
nk实现 - 双门限法语音信号端点检测matlab可实
- 基于遗传神经网络的图像分割MATLAB源
- 用MATLAB生成OFDM信号
- matlab生日祝福音乐动画
评论
共有 条评论