目录
一、写函数DataStructure_Fnc
二、控件属性
三、生成2D格网代码
三、生成3D格网代码
一、写函数DataStructure_Fnc
函数代码,生成三角网需要调用此函数
function DataStructure=DataStructure_Fnc(Table)
[row col]=size(Table);
Table(1:end,5:7)=-1;
for j=1:row
v1=Table(j,2);
v2=Table(j,3);
v3=Table(j,4);
for n=1:row
c1=find(Table(n,2:4)==v1);
c2=find(Table(n,2:4)==v2);
c3=find(Table(n,2:4)==v3);
if length(c2)==1 & length(c3)==1 & length(c1)==0
Table(j,5)=n;
end
if length(c1)==1 & length(c3)==1 & length(c2)==0
Table(j,6)=n;
end
if length(c1)==1 & length(c2)==1 & length(c3)==0
Table(j,7)=n;
end
end
end
DataStructure=Table;
函数命名
二、控件属性
生成2D格网的Tag为pushbutton_2D
生成3D格网的Tag为pushbutton_2D
axes(显示处理好的格网的坐标轴控件)的Tag为axes_show
读入点坐标XYZ的列表Tag为uitable_pointXY
处理后的数据的列表Tag为uitable_dataStru
此list的列表编辑器内部行列设置如下
三、生成2D格网代码
function pushbutton_2D_Callback(hObject, eventdata, handles)%2D按钮
global Points DataStructure
dt=DelaunayTri(Points(:,2),Points(:,3));
hold on
triplot(dt,'r')
Table(:,2:4)=dt.Triangulation;
[row col]=size(dt.Triangulation);
Table(:,1)=1:row;
DataStructure=DataStructure_Fnc(Table);%函数DataStructure_Fnc调用
%set(handles.uitable_pointXY,'Data',DataStructure(:,2:7));%uitable_pointXY换成自己的ID
set(handles.uitable_dataStru,'Data',DataStructure(:,2:7));%uitable_dataStru 换成自己的ID
cc = incenters(dt);
text(cc(:,1),cc(:,2),int2str(Table(:,1)),'color','b','fontsize',8)
set(handles.pushbutton_2D,'Enable','off');
set(handles.pushbutton_3D,'Enable','off');
%set(handles.pushbutton_findTIN,'Enable','on');这个功能在这里不涉及,注释掉
三、生成3D格网代码
function pushbutton_3D_Callback(hObject, eventdata, handles)
global Points
dt=DelaunayTri(Points(:,2),Points(:,3));
hold off
Table(:,2:4)=dt.Triangulation;
trisurf(Table(:,2:4),Points(:,2),Points(:,3),Points(:,4));
[row col]=size(dt.Triangulation);
Table(:,1)=1:row;
DataStructure=DataStructure_Fnc(Table);%函数调用DataStructure_Fnc
set(handles.uitable_dataStru,'Data',DataStructure(:,2:7));%存放处理后数据的列表uitable_dataStru
cc = incenters(dt);
text(cc(:,1),cc(:,2),int2str(Table(:,1)),'color','b','fontsize',8)
set(handles.pushbutton_2D,'Enable','off');%pushbutton_2D
set(handles.pushbutton_3D,'Enable','off'); %pushbutton_3D