資源簡介
matlab 讀取三維文檔,.ply格式。
包括點、三角面和顏色。
代碼片段和文件信息
function?[triMesh?h]?=?myPLYread(FILENAME?FLAG)
%?input
%?FILENAME:?file?name?of?.ply
%?FLAG:?0?-?default:?no?drawing
%???????1?or?else:?
%?
%?output
%???????triMesh:?a?struct?that?is?similar?with?class?ptCloud?
%???????h:?handle?of?trisurf?(patch)
%
%?author/copyright?Matthew
%?date:?2015-10-05
%%?input?checking?and?initialize?variables
if?nargin?==?0
????error(‘Error!?Please?input?the?file?name.‘);
elseif?nargin?==?1
????FLAG?=?0;
end
nFace?=?[];
nHeader?=?[];?%?number?of?head?lines
%?struct?triMesh?similar?with?ptCloud
triMesh.Location?=?[];
triMesh.Color?=?[];
triMesh.Normal?=?[];
triMesh.Intensity?=?[];
triMesh.Face?=?[];
triMesh.cntVetext?=?[];
triMesh.cntFace?=?[];
%%?import?vertex?and?colors?(texture)
ptCloud?=?pcread(FILENAME);?%?pcread?can?import?vertex?and?colors
triMesh.Location?=?ptCloud.Location;
triMesh.Color?=?ptCloud.Color;
triMesh.Normal?=?ptCloud.Normal;
triMesh.Intensity?=?ptCloud.Intensity;
triMesh.cntVetext?=?ptCloud.Count;
clear?ptCloud;
%%?import?faces
fid?=?fopen(FILENAME‘rt‘);
for?i?=?1:20?
????tline?=?fgetl(fid);
????k1?=?strfind(tline?‘element?face‘);
????k2?=?strfind(tline?‘end_header‘);
????%?get?the?number?of?faces
????if?k1?==1
????????m=?length(tline);
????????nFace?=?str2num(tline(
- 上一篇:西門子s7-200換熱站控制程序
- 下一篇:郭濤算法的MATLAB實現(xiàn)
評論
共有 條評論