• 大小: 1KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-04-21
  • 语言: Matlab
  • 标签: Matlab  IGES  

资源简介

matlab读入IGS文件,实现三维数据点的显示,有利于matlab编辑

资源截图

代码片段和文件信息

function [ParameterData]=iges2matlab2(igsfile)
[fidmsg]=fopen(igsfile);

if fid==-1
    error(msg);
end
c = fread(fid‘uint8=>uint8‘)‘;
fclose(fid);
nwro=sum((c((81:82))==10))+sum((c((81:82))==13));

edfi=nwro-sum(c(((end-1):end))==10)-sum(c(((end-1):end))==13);

siz=length(c);

ro=round((siz+edfi)/(80+nwro));

if rem((siz+edfi)(80+nwro))~=0
   error(‘Input file must be an IGES-file!‘);
end
roind=1:ro;

SGDPT=c(roind*(80+nwro)-7-nwro);

Sfind=SGDPT==83;
Gfind=SGDPT==71;
Dfind=SGDPT==68;
Pfind=SGDPT==80;
Tfind=SGDPT==84;

sumSfind=sum(Sfind);
sumGfind=sum(Gfind);
sumDfind=sum(Dfind);
sumPfind=sum(Pfind);
sumTfind=sum(Tfind);
noent=round(sumDfind/2);

ParameterData=cell(1noent+1);

ParameterData{end}=noent;
roP=sumSfind+sumGfind+sumDfind;
ential1=0;
for i=(sumSfind+sumGfind+1):2:(roP-1)
   ential1=ential1+1;

    Dstr=c(((i-1)*(80+nwro)+1):(i*(80+nwro)-8-nwro));
    Pstart=str2num(char(Dstr(9:16)))+roP;

    if i==roP-1
        Pend=ro-sumTfind;
    else
        Pend=str2num(char(c(((i+1)*(80+nwro)+9):((i+1)*(80+nwro)+16))))+roP-1;
    end

    Pstr=zeros(164*(Pend-Pstart+1));
    j=1;
    for k = Pstart : Pend
        Pstr( ((j-1)*64+1) : (j*64) )=c( ((k-1)*(80+nwro)+1) : ((k-1)*(80+nwro)+64));
        j=j+1;
    end
    Pvec=str2num(char(Pstr));
    if Pvec(2)==1
        ParameterData{ential1}.X=zeros(1Pvec(3));
        ParameterData{ential1}.Y=zeros(1Pvec(3));
        ParameterData{ential1}.Z=zeros(1Pvec(3));
        for n = 1 :  Pvec(3)
            ZT=Pvec(4); 
            ParameterData{ential1}.X(n)=Pevc(3+2*n);
            ParameterData{ential1}.Y(n)=Pevc(4+2*n);
            ParameterData{ential1}.Z(n)=ZT;
        end
    else
        ParameterData{ential1}.X=zeros(1Pvec(3));
        ParameterData{ential1}.Y=zeros(1Pvec(3));
        ParameterData{ential1}.Z=zeros(1Pvec(3));
        for n = 1 : Pvec(3)
          ParameterData{ential1}.X(n)=Pvec(1+3*n);
          ParameterData{ential1}.Y(1n)=Pvec(2+3*n);
          ParameterData{ential1}.Z(1n)=Pvec(3+3*n);
        end
    end
end   
          
          
    
    
    
    

























 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2208  2012-05-05 19:01  iges2matlab2.m

----------- ---------  ---------- -----  ----

                 2208                    1


评论

共有 条评论