Matlab产生IGES文件代码matlab源码Word格式文档下载.docx
- 文档编号:22536961
- 上传时间:2023-02-04
- 格式:DOCX
- 页数:17
- 大小:18.94KB
Matlab产生IGES文件代码matlab源码Word格式文档下载.docx
《Matlab产生IGES文件代码matlab源码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《Matlab产生IGES文件代码matlab源码Word格式文档下载.docx(17页珍藏版)》请在冰豆网上搜索。
Data=[xxzzyy];
iges_peaks.igs'
%产生抛物线文件
[x,y]=meshgrid(-1:
1);
z=x.^2+y.^2;
xx=x(:
Data=[xxyyzz];
iges_paowu.igs'
%产生解释文件
xx=[10;
0];
yy=[0;
10];
zz=[0;
igesforexplain.igs'
Data,0)%产生Matlab图标
[x,y]=meshgrid(linspace(-1,1,16));
z=membrane;
z=z(1:
2:
end,1:
end);
iges_matlab.igs'
写文件结束。
add_start_global函数文件:
%构造开始段和全局段字符串
function[filename,file_str]=add_start_global(FileName)
%开始段信息
start='
Matlab-IGES-UG,Proe'
%全局段信息
timedata=clock;
Time=sprintf('
%4s%2s%2s.%2s%2s%2s'
num2str(timedata
(1)),num2str(timeda
ta
(2)),num2str(timedata(3)),num2str(timedata(4)),num2str(timedata(5)),
num2str(floor(timedata(6))));
Author='
USTCGJ_QSQ'
G_1='
1H,'
G_2='
1H;
'
G_3='
7HPRT0001'
G_4=strcat(num2str(length(FileName)),'
H'
FileName);
%FileName
G_5='
49HPro/ENGINEERbyParametricTechnologyCorporation'
G_6='
7H2007170'
G_7='
32'
G_8='
38'
G_9='
7'
G_10='
G_11='
15'
G_12='
G_13='
1.'
G_14='
2'
G_15='
2HMM'
G_16='
32768'
G_17='
0.5'
G_18=strcat(num2str(length(Time)),'
Time);
%Time;
G_19='
0.0865991'
G_20='
866.025'
G_21=strcat(num2str(length(Author)),'
Author);
%Author;
G_22='
4HUSTC'
G_23='
10'
G_24='
0'
G_25=strcat(num2str(length(Time)),'
%构造字符串
file_str='
%start
start=add_section_index(start,'
S'
1);
file_str=strcat(file_str,start,'
%global
rowstr='
count=0;
fori=1:
25
ifi==25
temp=strcat((['
G_'
num2str(i)]),'
else
'
end
iflength(rowstr)+length(temp)&
gt;
72
count=count+1;
rowstr=add_section_index(rowstr,'
G'
count);
file_str=strcat(file_str,rowstr,'
rowstr=temp;
rowstr=strcat(rowstr,temp);
filename=FileName;
functionresult=add_section_index(str,section,index)
result=sprintf('
%-72s%s}'
str,section,index);
end
write_iges函数文件:
%写igs文件
%FileName为写入的文件名,Data为待写入的数据
functionwrite_iges(FileName,Data,PointOrLine)Index=0;
[filename,file_str]=add_start_global(FileName);
%构造索引段和参数段
ifnargin==2
pointorline=2;
pointorline=PointOrLine;
ifpointorline==0
%写点
[strDir2strPara2Index]=
writePoint(Data(1:
end,1),Data(1:
end,2),Data(1:
end,3),Index);
file_str=strcat(file_str,strDir2);
file_str=strcat(file_str,strPara2);
elseifpointorline==1
%写线
[strDir1strPara1Index]=
writeLine(Data(1:
end-1,1),Data(1:
end-1,2),Data(1:
end-1,3),Data(2:
end,1),Data(2:
end,2),Data(2:
file_str=strcat(file_str,strDir1);
file_str=strcat(file_str,strPara1);
elseifpointorline==2
%构造结束段
str_end=sprintf('
%s}%s}%s}%s}As}'
1,'
4,'
D'
2*Index,'
P'
Index,'
T'
file_str=strcat(file_str,str_end,'
%写入文件
fid=fopen(FileName,'
wt'
fprintf(fid,file_str);
fclose(fid);
writeLine函数文件:
%Index为总元素的个数
function[strDir,strPara,Index]=writeLine(x1,y1,z1,x2,y2,z2,
Index)
if
length(x1)~=length(y1)||length(x1)~=length(z1)||length(x2)~=length(y2)
||length(x2)~=length(z2)||length(x2)~=length(y1)
disp('
2了,几个线呀~'
Direction=struct('
type'
[],...%
paraPtr'
version'
1'
...
lineStyle'
layer'
view'
matrix'
label'
status'
00000001'
section'
type1'
lineWeight'
color'
rowNum'
form'
reserved'
reserved1'
elementLabel'
elementIndex'
section1'
...
Line=struct('
pointDir'
Direction,...
x1'
[],...
y1'
z1'
x2'
y2'
z2'
ptr'
[]...
strDir='
strPara='
length(x1)
Index=Index+1;
Line.pointDir.type='
110'
Line.pointDir.elementLabel='
LINE'
Line.pointDir.elementIndex=num2str(count);
Line.pointDir.paraPtr=num2str(Index);
Line.pointDir.type1=Line.pointDir.type;
Line.x1=x1;
Line.y1=y1;
Line.z1=z1;
Line.x2=x2;
Line.y2=y2;
Line.z2=z2;
Line.ptr=2*Index-1;
strDir_temp=sprintf('
%8s%8s%8s%8s%8s%8s%8s%8s%8s%s}\n%8s%8s%8s%8s%8s%8
s%8s%8s%8s%s}'
Line.pointDir.type,...
Line.pointDir.paraPtr,...
Line.pointDir.version,...
Line.pointDir.lineStyle,...
Line.pointDir.layer,...
Line.pointDir.view,...
Line.pointDir.matrix,...
Line.pointDir.label,...
Line.pointDir.status,...
Line.pointDir.section,2*Index-1,...
Line.pointDir.type1,...
Line.pointDir.lineWeight,...
Line.pointDir.color,...
Line.pointDir.rowNum,...
Line.pointDir.form,...
Line.pointDir.reserved,...
Line.pointDir.reserved1,...
Line.pointDir.elementLabel,...
Line.pointDir.elementIndex,...
Line.pointDir.section1,2*Index);
strPara_temp=sprintf('
%s,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f;
Line.x1(i),...
Line.y1(i),...
Line.z1(i),...
Line.x2(i),...
Line.y2(i),...
Line.z2(i));
%-64s&
#65533;
P%7s'
strPara_temp,2*Index-1,Line.p
ointDir.paraPtr);
strDir=strcat(strDir,strDir_temp,'
strPara=strcat(strPara,strPara_temp,'
writePoint函数文件:
function[strDir,strPara,Index]=writePoint(x,y,z,Index)
iflength(x)~=length(y)||length(x)~=length(z)
2了,几个点呀~'
Point=struct('
x'
y'
z'
length(x)
Point.pointDir.type='
116'
Point.pointDir.elementLabel='
POINT'
Point.pointDir.elementIndex=num2str(count);
Point.pointDir.paraPtr=num2str(Index);
Point.pointDir.type1=Point.pointDir.type;
Point.x=x;
Point.y=y;
Point.z=z;
Point.ptr=2*Index-1;
Point.pointDir.type,...
Point.pointDir.paraPtr,...
Point.pointDir.version,...
Point.pointDir.lineStyle,...
Point.pointDir.layer,...
Point.pointDir.view,...
Point.pointDir.matrix,...
Point.pointDir.label,...
Point.pointDir.status,...
Point.pointDir.section,2*Index-1,...
Point.pointDir.type1,...
Point.pointDir.lineWeight,...
Point.pointDir.color,...
Point.pointDir.rowNum,...
Point.pointDir.form,...
Point.pointDir.reserved,...
Point.pointDir.reserved1,...
Point.pointDir.elementLabel,...
Point.pointDir.elementIndex,...
Point.pointDir.section1,2*Index);
%s,%.2f,%.2f,%.2f;
Point.x(i),...
Point.y(i),...
Point.z(i));
%-64s?
strPara_temp,2*Index-1,Point.pointDi
r.paraPtr);
writeColor函数文件:
function[strDir,strPara,Index]=writeColor(r,g,b,Index)
iflength(r)~=length(g)||length(r)~=length(b)
01000200'
Color=struct('
r'
g'
b'
length(r)
Color.pointDir.type='
314'
Color.pointDir.elementLabel='
COLOR'
Color.pointDir.elementIndex=num2str(count);
Color.pointDir.paraPtr=num2str(Index);
Color.pointDir.type1=Color.pointDir.type;
Color.r=r;
Color.g=g;
Color.b=b;
Color.ptr=2*Index-1;
Color.pointDir.type,...
Color.pointDir.paraPtr,...
Color.pointDir.version,...
Color.pointDir.lineStyle,...
Color.pointDir.layer,...
Color.pointDir.view,...
Color.pointDir.matrix,...
Color.pointDir.label,...
Color.pointDir.status,...
Color.pointDir.section,2*Index-1,...
Color.pointDir.type1,...
Color.pointDir.lineWeight,...
Color.pointDir.color,...
Color.pointDir.rowNum,...
Color.pointDir.form,...
Color.pointDir.rese
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 产生 IGES 文件 代码 源码
![提示](https://static.bdocx.com/images/bang_tan.gif)