资源简介
本程序可以很好地读取DXF文件,可以输出直线(c_Line)多段线(c_Poly)圆(c_Cir)圆弧(c_Arc)顶点(c_Poi),很实用
代码片段和文件信息
function [c_Linec_Polyc_Circ_Arcc_Poi] = f_LectDxf(nomArch)
%% Read entities information of dxf file
%author = SebaTM
%Jul 27 2009
%based in dxf2coord 1.1 matrix of lukas wischounig but is not dependent of the Code
%Group relative position. That is better way to read dxf format. Don‘t fail if the
%polyline has arcs (budges) but yet don‘t read them. Don‘t read arcs as circles. Read
%properties (see case ‘LINE‘ by examples of modifications). Group Codes and Associated
%Values is read in accurately way (accept associated values with space).
%
%Use cell2mat(cell(:1)) to acquire geometry data in matrix
%by example cell2mat(c_Cir(:1))
%% Read file
fId = fopen(nomArch);
c_ValAsoc = textscan(fId‘%d%s‘‘Delimiter‘‘\n‘);
fclose(fId);
% Code Group Matrix
m_GrCode = c_ValAsoc{1};
% Associated value String Cell
c_ValAsoc = c_ValAsoc{2};
%[m_GrCodec_ValAsoc] = c_ValAsoc{:};
%% Entities
m_PosCero = find(m_GrCode==0);
%Is searched by (0SECTION)(2ENTITIES)
indInSecEnt = strmatch(‘ENTITIES‘c_ValAsoc(m_PosCero(1:end-1)+1)‘exact‘);
%(0ENDSEC)
m_indFinSecEnt = strmatch(‘ENDSEC‘c_ValAsoc(m_PosCero(indInSecEnt:end))‘exact‘);
% Entities Position
m_PosCero = m_PosCero(indInSecEnt:indInSecEnt-1+m_indFinSecEnt(1));
% Variable initiation
%accelerate?
% c_Line = cell(sum(strcmp(‘LINE‘c_ValAsoc(m_PosCero)))2);
% c_Poly = cell(sum(strcmp(‘LWPOLYLINE‘c_ValAsoc(m_PosCero)))2);
% c_Cir = cell(sum(strcmp(‘CIRCLE‘c_ValAsoc(m_PosCero)))2);
% c_Arc = cell(sum(strcmp(‘ARC‘c_ValAsoc(m_PosCero)))2);
% c_Poi = cell(sum(strcmp(‘POINT‘c_ValAsoc(m_PosCero)))2);
c_Line = cell(12);
c_Poly = cell(12);
c_Cir = cell(12);
c_Arc = cell(12);
c_Poi = cell(12);
%
iLine = 1;
iPoly = 1;
iCir = 1;
iArc = 1;
iPoi = 1;
% Loop on the Entities
for iEnt = 1:length(m_PosCero)-2
m_GrCodeEnt = m_GrCode(m_PosCero(iEnt+1):m_PosCero(iEnt+2)-1);
c_ValAsocEnt = c_ValAsoc(m_PosCero(iEnt+1):m_PosCero(iEnt+2)-1);
nomEnt = c_ValAsocEnt{1}; %c_ValAsocEnt{m_PosCero(iEnt+1)}
%In the entitie‘s name is assumed uppercase
switch nomEnt
case ‘LINE‘
% (XiYiZiXjYjZj) start and end points
c_Line{iLine1} = [str2double(f_ValGrCode(10m_GrCodeEntc_ValAsocEnt))...
str2double(f_ValGrCode(20m_GrCodeEntc_ValAsocEnt))...
str2double(f_ValGrCode(30m_GrCodeEntc_ValAsocEnt))...
str2double(f_ValGrCode(11m_GrCodeEntc_ValAsocEnt))...
str2double(f_ValGrCode(21m_GrCodeEntc_ValAsocEnt))...
str2double(f_ValGrCode(31m_GrCodeEntc_ValAsocEnt))];
% layer
c_Line(iLine2) = f_ValGrCode(8m_GrCodeEntc_ValAsocEnt);
- 上一篇:matlab读取STL文件
- 下一篇:捷联惯导粗对准
相关资源
- matlab读取STL文件
- 基于matlab的应用图像处理进行癌细胞
- 人工免疫算法寻优最大值
- MATLAB求解SEIR模型.zip
- MATLAB中的harq重传
- matlab解决旅行者问题的三种算法遗传
- 集成学习方法matlab实现
- MIT数据库的心电信号预处理matlab程序
- delta机械手工作空间matlab程序
- MATLAB_EOF.zip
- 车牌识别的matlab程序
- 阵列天线切比雪夫分布幅度计算
- GA+SVM的MATLAB程序
- 牛顿拉夫逊法解潮流计算MATLAB程序附
- SAR ADC模型
- 曲面拟合程序MATLAB
- 差分方程的阻滞增长模型 matlab
- 小波神经网络matlab详细代码
- 多目标perota优化MATLAB算法
- 概率数据关联算法matlab程序.zip
- 车牌号识别程序,基于matlab可直接运
- matlab单纯形法程序
- 基于dft的图像压缩matlab实现
- 粒子群SVM.rar
- MATLAB实现SVPWM
- matlab-朴素贝叶斯-鸢尾花数据集
- LSTM-regression-master.zip
- LSTM算法推导及代码.zip
- 一维高斯随机粗糙面建模.zip
- 贝叶斯分类Matlab代码
评论
共有 条评论