📄 xml2seg.asv
字号:
m=m+1;
end
end
end
if m==0 %如果在junction中找不到匹配点,说明该起始点是孤立点,赋予degree属性为1
fprintf(nodeH, '%d', 1);
fprintf(nodeH, '%s',' ');
end
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(1,j)/8));%xcoordinate
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(2,j)/8));%ycoordinat
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%intensity=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%rcolor=0,gcolor=0,bcolor=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%s\n',' ');
nodeID=nodeID+1;
end
if (j~=1)&&(j~=nodenum)%对curve中间的点degree的处理
fprintf(nodeH, '%d', nodeID);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0); %不是curve的端点,type=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 2); %curve非端点的degree
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(1,j)/8));%xcoordinate
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(2,j)/8));%ycoordinat
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%intensity=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%rcolor=0,gcolor=0,bcolor=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%s\n',' ');
nodeID=nodeID+1;
end
if j==nodenum
if j~=length(Xmlf.contours{1,i}.pts) %如果闭合
fprintf(nodeH, '%d', nodeID);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0); %不是curve的端点,type=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 2); %curve非端点的degree
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(1,j)/8));%xcoordinate
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(2,j)/8));%ycoordinat
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%intensity=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%rcolor=0,gcolor=0,bcolor=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%s\n',' ');
nodeID=nodeID+1;
fprintf(nodeH, '%d', start_end_node);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 1); %是curve结束点,type=1
fprintf(nodeH, '%s',' ');
m=0;
for k=1:length(Xmlf.junctions) %排除border的junction,从一条curve结束点在junction中匹配,若找到匹配点,则得到其degree属性,赋给node的degree
if length(Xmlf.junctions{1,k})~=0
if (Xmlf.contours{1,i}.pts(1,length(Xmlf.contours{1,i}.pts))==Xmlf.junctions{1,k}.loc(1,1))&&(Xmlf.contours{1,i}.pts(2,length(Xmlf.contours{1,i}.pts))==Xmlf.junctions{1,k}.loc(2,1))
fprintf(nodeH, '%d', length(Xmlf.junctions{1,k}.cids)); %curve结束点的degree
fprintf(nodeH, '%s',' ');
m=m+1;
end
end
end
if m==0 %如果在junction中找不到匹配点,说明该结束点是孤立点,赋予degree属性为1
fprintf(nodeH, '%d', 1);
fprintf(nodeH, '%s',' ');
end
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(1,j+1)/8));%xcoordinate
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(2,j+1)/8));%ycoordinat
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%intensity=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%rcolor=0,gcolor=0,bcolor=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%s\n',' ');
else %不闭合时的情况
fprintf(nodeH, '%d', nodeID);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 1); %是curve结束点,type=1
fprintf(nodeH, '%s',' ');
m=0;
for k=1:length(Xmlf.junctions) %排除border的junction,从一条curve结束点在junction中匹配,若找到匹配点,则得到其degree属性,赋给node的degree
if length(Xmlf.junctions{1,k})~=0
if (Xmlf.contours{1,i}.pts(1,length(Xmlf.contours{1,i}.pts))==Xmlf.junctions{1,k}.loc(1,1))&&(Xmlf.contours{1,i}.pts(2,length(Xmlf.contours{1,i}.pts))==Xmlf.junctions{1,k}.loc(2,1))
fprintf(nodeH, '%d', length(Xmlf.junctions{1,k}.cids)); %curve结束点的degree
fprintf(nodeH, '%s',' ');
m=m+1;
end
end
end
if m==0 %如果在junction中找不到匹配点,说明该结束点是孤立点,赋予degree属性为1
fprintf(nodeH, '%d', 1);
fprintf(nodeH, '%s',' ');
end
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(1,j)/8));%xcoordinate
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%f', (Xmlf.contours{1,i}.pts(2,j)/8));%ycoordinat
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%intensity=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);%rcolor=0,gcolor=0,bcolor=0
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%d', 0);
fprintf(nodeH, '%s',' ');
fprintf(nodeH, '%s\n',' ');
nodeID=nodeID+1;
end
end
end
%如果curve不闭合,则把该contour的最后一个点作为curve的尾节点
if isempty(Xmlf.contours{1,i}.jids)==0
%if (Xmlf.contours{1,i}.pts(1,1)~=Xmlf.contours{1,i}.pts(1,length(Xmlf.contours{1,i}.pts)))||(Xmlf.contours{1,i}.pts(2,1)~=Xmlf.contours{1,i}.pts(2,length(Xmlf.contours{1,i}.pts)))
fprintf(curveH, '%d', nodeID-1);%curve的endnodeID
fprintf(curveH, '%s',' ');
else
fprintf(curveH, '%d', tempnodeID);%curve的endnodeID
fprintf(curveH, '%s',' ');
end
fprintf(curveH, '%d', 0);%curve的profile=0
fprintf(curveH, '%s',' ');
fprintf(curveH, '%d', length(Xmlf.contours{1,i}.pts)-1);%curve的size
fprintf(curveH, '%s',' ');
%把linelet的ID写入curve文件中
%把linelet的ID,开始、结束数据写入文件中
for n=1:length(Xmlf.contours{1,i}.pts)-1
lineletID=lineletID+1;
fprintf(curveH, '%d', lineletID);%linelet的ID存放到curve文件中
fprintf(curveH, '%s',' ');
fprintf(lineH, '%d', lineletID);%linelet的ID存放到linelet的文件中
fprintf(lineH, '%s',' ');
fprintf(lineH, '%d', getnodeid(Xmlf.contours{1,i}.pts(1,n)/8,Xmlf.contours{1,i}.pts(2,n)/8)); %linelet的startnodeID
fprintf(lineH, '%s',' ');
fprintf(lineH, '%d', getnodeid(Xmlf.contours{1,i}.pts(1,n+1)/8,Xmlf.contours{1,i}.pts(2,n+1)/8));%linelet的endnodeID
fprintf(lineH, '%s\n',' ');
end
fprintf(curveH, '%s\n',' ');
end
end
end
fclose(contH);
fclose(nodeH);
fclose(lineH);
fclose(curveH);
end
tt=cputime-tt;
tt=tt/60
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -