摘要
在激光雕刻系统中,需要加工的图形通常是以DXF文件提供的,为了获取加工路径,必须要对DXF文件进行解析。笔者提出一种基于Visual C++编程实现的DXF文件解析方法,首先通过分析DXF文件的组成,采用面向对象的程序设计思想,设计各种图元类;然后逐行读取DXF文件的内容,根据读取到的组码和组值,提取实体段中每个图元的属性值,将属性值封装成对应的图元类对象,并将对象及时添加到动态链表容器中;最后顺序遍历链表中的每个图元对象,即可获取所需的加工路径信息,并将其绘制出来。实例表明,文章所设计的模块不仅能有效解析出DXF文件中的路径信息,而且可以兼容AutoCAD R12及其以后的所有版本。
In laser engraving system, the graphs which need to be processed are usually provided by DXF files. So, in order to access machining path, an analysis of DXF files is needed. This paper demonstrates an DXF analytic method which is based on Visual C++ programming. Firstly, an analysis of the DXF files formation is finished to design the object-oriented graphic class. Secondly, after reading those DXF files line by line, basing on the collected data, the attribute value of graphic primitives in entity sections is detected and encapsulated into the corresponding primitives objects which will be added to the dynamic lists promptly. Finally, orderly traversing the graphic primitives objects on the list, the needed path information is obtained and drew out. The examples show that the module which is designed in this paper can not only efficiently extract the path information from DXF files, but also be compatible with AutoCAD R12 and its later versions.
出处
《科技创新与生产力》
2016年第11期25-28,31,共5页
Sci-tech Innovation and Productivity