CN103761376A - Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts - Google Patents

Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts Download PDF

Info

Publication number
CN103761376A
CN103761376A CN201410013304.1A CN201410013304A CN103761376A CN 103761376 A CN103761376 A CN 103761376A CN 201410013304 A CN201410013304 A CN 201410013304A CN 103761376 A CN103761376 A CN 103761376A
Authority
CN
China
Prior art keywords
dimensional
coordinates
file format
points
display method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410013304.1A
Other languages
Chinese (zh)
Inventor
张滢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenyang Aerospace University
Original Assignee
Shenyang Aerospace University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenyang Aerospace University filed Critical Shenyang Aerospace University
Priority to CN201410013304.1A priority Critical patent/CN103761376A/en
Publication of CN103761376A publication Critical patent/CN103761376A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本发明属于图像处理技术领域,具体涉及一种基于二维DXF文件格式的零件三维真实感显示方法。具体步骤如下:步骤1:读取DXF文件格式中母线和轴线的数据;步骤2:利用步骤1中读取的数据构造旋转曲面;步骤2.1:利用圆弧切割算法计算出圆弧的圆心坐标:步骤2.2:利用旋转成形算法计算旋转曲面的坐标:步骤2.2.1:对已知曲线进行横向切割;步骤2.2.2:对横向切割所得的点进行纵向切割:步骤3:利用法向矢量算法的进行光照效果处理;步骤4:利用OpenGL功能函数对三维实体进行显示。最终实现零件三维真实感显示。

Figure 201410013304

The invention belongs to the technical field of image processing, and in particular relates to a three-dimensional realistic display method for parts based on a two-dimensional DXF file format. The specific steps are as follows: Step 1: Read the data of the busbar and axis in the DXF file format; Step 2: Use the data read in Step 1 to construct a rotating surface; Step 2.1: Use the arc cutting algorithm to calculate the center coordinates of the arc: Step 2.2: Use the rotation forming algorithm to calculate the coordinates of the rotating surface: Step 2.2.1: Cut the known curve horizontally; Step 2.2.2: Cut the points obtained by the horizontal cutting vertically: Step 3: Use the normal vector algorithm Perform lighting effect processing; step 4: use OpenGL function to display the three-dimensional entity. Finally, the three-dimensional realistic display of parts is realized.

Figure 201410013304

Description

基于二维DXF文件格式的零件三维真实感显示方法3D Realistic Display Method of Parts Based on 2D DXF File Format

技术领域technical field

本发明属于图像处理技术领域,具体涉及一种基于二维DXF文件格式的零件三维真实感显示方法。The invention belongs to the technical field of image processing, and in particular relates to a three-dimensional realistic display method for parts based on a two-dimensional DXF file format.

背景技术Background technique

在实际工程零件的设计和制造中,经车削和镗削加工而成的回转体类型零件占有很大的比重。在计算机辅助车削加工系统中,主要的工作均是围绕这一类零件进行的。这一类图形常常是由AutoCAD绘制的二维图形,我们不便于观察其三维立体结构。AutoCAD默认的文件格式是DWG格式,这种格式AutoCAD公司对外是不公开的,我们无法对其进行处理。In the design and manufacture of actual engineering parts, the rotating body type parts processed by turning and boring occupy a large proportion. In the computer-aided turning system, the main work is carried out around this type of parts. This type of graphics is often two-dimensional graphics drawn by AutoCAD, and it is not convenient for us to observe its three-dimensional structure. The default file format of AutoCAD is DWG format, which is not open to the outside world by AutoCAD, and we cannot process it.

计算机图形学是近年来发展迅速、应用广泛的新兴学科。它主要研究图形输入、表示、变换、真实感绘制技术、运算和输入图形的原理、算法及系统。计算机图形学的最新研究成果在机械CAD/CAM领域中也得到了广泛应用。工程技术人员完成机械零件的设计后,往往希望马上看到零件的立体效果图,对其结构产生直观、感性的认识,以利于评价产品的结构、设计是否合理。这就需要利用计算机图形学的知识进行真实感图形显示。但在目前所广泛使用的CAD/CAM系统软件中,真实感图形显示功能仅被一些大型软件作为功能模块之一得以应用,而能够独立运行的实用真实感显示软件还较为少见。Computer graphics is an emerging subject that has developed rapidly and is widely used in recent years. It mainly studies the principles, algorithms and systems of graphics input, representation, transformation, realistic rendering technology, computing and input graphics. The latest research results of computer graphics have also been widely used in the field of mechanical CAD/CAM. After engineering and technical personnel complete the design of mechanical parts, they often hope to see the three-dimensional renderings of the parts immediately, so as to have an intuitive and perceptual understanding of its structure, so as to evaluate whether the structure and design of the product are reasonable. This requires the use of knowledge of computer graphics for realistic graphics display. However, in the currently widely used CAD/CAM system software, the realistic graphics display function is only used as one of the functional modules by some large-scale software, and the practical realistic display software that can run independently is relatively rare.

真实感图形显示技术的产生可以追溯到60年代中期,随着计算机技术与图形学的发展以及光栅显示器的出现,加上包括显示存储器在内的各种计算机硬件性能的大幅度提高,使得需要海量高速存储器的真实感图形的生成成为可能。目前,真实感图形显示技术已广泛应用于CAD/CAM、虚拟制造、模拟训练、数控仿真等领域中。The emergence of realistic graphic display technology can be traced back to the mid-1960s. With the development of computer technology and graphics and the emergence of raster displays, coupled with the substantial improvement in the performance of various computer hardware including display memory, the need for massive Generation of realistic graphics with high-speed memory becomes possible. At present, realistic graphics display technology has been widely used in CAD/CAM, virtual manufacturing, simulation training, numerical control simulation and other fields.

在实际工程零件的设计和制造中,经车削和镗削加工而成的回转体类型零件占有很大的比重。在计算机辅助车削加工系统中,主要的工作均是围绕这一类零件进行的。这一类图形常常是由AutoCAD绘制的二维图形,我们不便于观察其三维立体结构。AutoCAD默认的文件格式是DWG格式,这种格式AutoCAD公司对外是不公开的,我们无法对其进行处理。In the design and manufacture of actual engineering parts, the rotating body type parts processed by turning and boring occupy a large proportion. In the computer-aided turning system, the main work is carried out around this type of parts. This type of graphics is often two-dimensional graphics drawn by AutoCAD, and it is not convenient for us to observe its three-dimensional structure. The default file format of AutoCAD is DWG format, which is not open to the outside world by AutoCAD, and we cannot process it.

发明内容Contents of the invention

针对现有技术存在的不足,本发明提供一种基于二维DXF文件格式的零件三维真实感显示方法。Aiming at the deficiencies in the prior art, the present invention provides a three-dimensional realistic display method for parts based on the two-dimensional DXF file format.

本发明采取按如下步骤进行:基于二维DXF文件格式的零件三维真实感显示方法,具体The present invention adopts the following steps to carry out: based on the three-dimensional realistic display method of parts in the two-dimensional DXF file format, specifically

步骤如下:Proceed as follows:

步骤1:读取DXF文件格式中母线和轴线的数据;回转体零件图形构造,实际上就是已Step 1: Read the data of the busbar and axis in the DXF file format; the graphic structure of the rotary part is actually the

知轴线和母线,构造相应的旋转曲面。Know the axis and generatrix, construct the corresponding surface of revolution.

步骤2:利用步骤1中读取的数据构造旋转曲面;Step 2: Use the data read in step 1 to construct a surface of revolution;

步骤2.1:利用圆弧切割算法计算出圆弧的圆心坐标:Step 2.1: Use the arc cutting algorithm to calculate the center coordinates of the arc:

步骤2.2:利用旋转成形算法计算旋转曲面的坐标:Step 2.2: Calculate the coordinates of the surface of revolution using the rotational forming algorithm:

步骤2.2.1:对已知曲线进行横向切割:Step 2.2.1: Transversally cut the known curve:

步骤2.2.2:对横向切割所得的点进行纵向切割:Step 2.2.2: Carry out vertical cutting on the points obtained by horizontal cutting:

步骤3:利用法向矢量算法的进行光照效果处理;Step 3: Use the normal vector algorithm to perform lighting effect processing;

步骤4:利用OpenGL功能函数对三维实体进行显示。Step 4: Use the OpenGL function to display the three-dimensional entity.

所述的步骤1中,用AutoCAD所提供的多义线来描述母线,同时通过设置线型来识别轴线,在实体节中,LINE和LWPOLYLINE中分别存有轴线和母线的信息,在读取数据过程中,可以根据组码0和组码6的值来搜索线型为中心线的轴线,然后按照文件格式依次读取轴线的起始点坐标;对于多义线,首先根据子类标记值搜索作为母线的多义线,然后按照文件格式依次读取多义线所有顶点坐标值。经过以上分析和处理,可以将旋转成形所需的数据读入程序,以便于进行下一步数据操作。In the above step 1, the polyline provided by AutoCAD is used to describe the busbar, and at the same time, the axis is identified by setting the line type. In the entity section, the information of the axis and the busbar are respectively stored in LINE and LWPOLYLINE. When reading the data During the process, you can search for the axis whose line type is the center line according to the values of group code 0 and group code 6, and then read the coordinates of the starting point of the axis in sequence according to the file format; The polyline of the bus, and then read the coordinate values of all vertices of the polyline sequentially according to the file format. After the above analysis and processing, the data required for rotational forming can be read into the program for the next step of data manipulation.

所述的步骤2.1的计算出圆弧的圆心坐标(xo,yo)的具体过程如下:The specific process of calculating the center coordinates (xo, yo) of the arc in the described step 2.1 is as follows:

l = ( c - a ) 2 + ( d - b ) 2 2 make l = ( c - a ) 2 + ( d - b ) 2 2

由拱度的定义可知

Figure BDA0000455268860000022
所以h=l*bowFrom the definition of camber we know
Figure BDA0000455268860000022
So h=l*bow

由图中三角关系可得:r2-l2=(r-h)2 From the triangle relationship in the figure, it can be obtained: r 2 -l 2 = (rh) 2

即圆弧半径 r = h 2 + l 2 2 × h the radius of the arc r = h 2 + l 2 2 × h

ω = arctan ( d - b c - a ) make ω = arctan ( d - b c - a )

则弧线圆心坐标为:Then the coordinates of the center of the arc are:

xoxo == aa ++ cc 22 -- (( rr -- hh )) ×× sinsin ωω yothe yo == bb ++ dd 22 ++ (( rr -- hh )) ×× coscos ωω

式中:设(a,b)为起点坐标,(c,d)为终点坐标,l为(a,b)与(c,d)构成的弦的长度,bow为拱度,h为弦高,ω为l对应的圆心角。所述的步骤2.2.1具体切割过程如下:在母线上逐段均匀地提取若干个点,并把它们的坐标存入三个二维数组x[1,j],y[1,j],z[1,j]。所取的点数在程序中由横向切割密度控制,横向切割密度越高,所生成立体图形母线越接近于原母线。In the formula: let (a, b) be the coordinates of the starting point, (c, d) the coordinates of the end point, l is the length of the chord formed by (a, b) and (c, d), bow is the camber, h is the chord height , ω is the central angle corresponding to l. The specific cutting process of the step 2.2.1 is as follows: uniformly extract several points on the bus line segment by segment, and store their coordinates into three two-dimensional arrays x[1, j], y[1, j], z[1,j]. The number of points taken is controlled by the transverse cutting density in the program. The higher the transverse cutting density is, the closer the generated three-dimensional graphic generatrix is to the original generatrix.

所述的步骤2.2.2具体切割过程如下:在横向切割完成以后,对所得的点进行三维旋转,并对每一个点的旋转轨迹进行插值点坐标计算,插值点的数目由纵向切割密度控制。纵向切割密度越高,所生成立体图形横截面越光滑,但同样也会导致数据量增多。由横向切割操作可以得到曲线上的坐标点数组x[1,j],y[1,j],z[1,j],设纵向切割为绕x轴作360°的旋转,为了求出曲线上的每一点在旋转轨迹上所形成的n个点的坐标,可设旋转步长为t=2π/n,旋转变换矩阵为:The specific cutting process of the step 2.2.2 is as follows: After the horizontal cutting is completed, the obtained points are three-dimensionally rotated, and the rotation trajectory of each point is calculated for interpolation point coordinates, and the number of interpolation points is controlled by the vertical cutting density. The higher the longitudinal cutting density, the smoother the cross-section of the generated three-dimensional graphics, but it will also lead to an increase in the amount of data. The coordinate point array x[1, j], y[1, j], z[1, j] on the curve can be obtained by the horizontal cutting operation, and the vertical cutting is set to rotate 360° around the x-axis, in order to find the curve The coordinates of n points formed by each point on the rotation trajectory, the rotation step size can be set to t=2π/n, and the rotation transformation matrix is:

TT == 11 00 00 00 coscos tt -- sinsin tt 00 sinsin tt coscos tt

设曲线上的点为(x,y,z),则旋转后的坐标为:Let the point on the curve be (x, y, z), then the coordinates after rotation are:

[x* y* z*]=[x y z]*T[x * y * z * ]=[x y z]*T

x * = x y * = y cos t + z sin t z * = - y sin t + z cos t Right now x * = x the y * = the y cos t + z sin t z * = - the y sin t + z cos t

所述的步骤3的具体步骤如下:计算法向矢量,所需条件为三个不共线的点的坐标值,它们的排列顺序决定了法向矢量的方向,在右手空间坐标系中,设已知点A、B、C、的坐标值分别为(xA,yA,zA),(xB,yB,zB),(xC,yC,zC),计算三点构成的平面的法向矢量,其算法如下:The specific steps of described step 3 are as follows: calculate the normal vector, the required condition is the coordinate values of three non-collinear points, and their order of arrangement determines the direction of the normal vector, in the right-hand space coordinate system, set The coordinates of points A, B, and C are known as (x A , y A , z A ), (x B , y B , z B ), (x C , y C , z C ), and calculate the three points The normal vector of the formed plane, the algorithm is as follows:

首先求出矢量

Figure BDA0000455268860000034
Figure BDA0000455268860000035
利用空间解析几何的方法,平面法矢量的空间描述为 i j k x AC y AC z AC x BC y BC z BC First find the vector
Figure BDA0000455268860000034
and
Figure BDA0000455268860000035
Using the method of spatial analytic geometry, the space description of the plane normal vector is i j k x AC the y AC z AC x BC the y BC z BC

其中 x AC = x A - x C , y AC = y A - y C , z AC = z A - z C x BC = x B - x C , y BC = y B - y C , z BC = z B - z C in x AC = x A - x C , the y AC = the y A - the y C , z AC = z A - z C x BC = x B - x C , the y BC = the y B - the y C , z BC = z B - z C

将平面法矢量空间描述的矩阵形式展开,可以得到其数学表达式为:(yACzBC-zACyBC)i+(zACxBC-zBCxAC)j+(xACyBC-xBCyAC)k。Expanding the matrix form described by the plane normal vector space, the mathematical expression can be obtained: (y AC z BC -z AC y BC )i+(z AC x BC -z BC x AC )j+(x AC y BC -x BC y AC )k.

本发明的优点为:1、由于多种典型三维CAD/CAM软件产品(AutoCAD、Pro-Engineer、Master CAM、CATIA、UG II、3DSMAX)都支持DXF文件格式,所以基于这种文件格式开发的应用程序具有广泛的实用性。Advantages of the present invention are: 1, because multiple typical three-dimensional CAD/CAM software products (AutoCAD, Pro-Engineer, Master CAM, CATIA, UG II, 3DSMAX) all support DXF file format, so the application based on this file format development The program has wide applicability.

2、利用对已知曲线进行横向切割和纵向切割来构造旋转曲面,由切割密度控制所生成立体图形横截面的光滑度,从而实现了二维图形数据向三维的转化。2. The surface of revolution is constructed by cutting the known curve horizontally and vertically, and the smoothness of the cross-section of the generated three-dimensional figure is controlled by the cutting density, thus realizing the conversion of two-dimensional figure data to three-dimensional.

3、本发明利用真实感图形显示技术选择OpenGL作为图形软件包,实现一个实用的交互式真实感图形显示,在本专利用OpenGL功能函数对所读取的图形文件主要实现了以下几种功能:视窗初始化,图形绘制功能,坐标变换功能,光照与材质设置,图像与纹理操作功能,线框图、面模型、体模型处理等功能。从而通过物体材质和光源的设置,可以较准确地模拟真实世界的光照效果,达到三维实体计算机真实感显示的目的。通过增加雾化效果及纹理贴图,能够实现实体的一些特殊效果显示。3, the present invention utilizes realistic graphic display technology to select OpenGL as a graphic software package to realize a practical interactive realistic graphic display. In this patent, the OpenGL function function has mainly realized the following functions for the graphic file read: Window initialization, graphic drawing function, coordinate transformation function, lighting and material setting, image and texture operation function, wireframe drawing, surface model, volume model processing and other functions. Therefore, through the setting of the object material and the light source, the lighting effect of the real world can be simulated more accurately, and the purpose of realistic display of the three-dimensional entity computer can be achieved. By adding atomization effects and texture maps, some special effects of entities can be displayed.

附图说明Description of drawings

图1是本发明的总体流程图;Fig. 1 is the general flowchart of the present invention;

图2是圆弧切割示意图;Fig. 2 is a schematic diagram of arc cutting;

图3是纵向切割示意图;Fig. 3 is a schematic diagram of longitudinal cutting;

图4是本发明图形的真实感显示。Fig. 4 is a realistic display of graphics of the present invention.

具体实施方式Detailed ways

如图1至图3所示,本发明采取按如下步骤进行:基于二维DXF文件格式的零件三维真As shown in Figures 1 to 3, the present invention takes the following steps: based on the two-dimensional DXF file format of the part three-dimensional real

实感显示方法,具体步骤如下:Real sense display method, the specific steps are as follows:

步骤1:读取DXF文件格式中母线和轴线的数据;回转体零件图形构造,实际上就是已知轴线和母线,构造相应的旋转曲面。Step 1: Read the data of the busbar and the axis in the DXF file format; the graphic construction of the part of the revolving body is actually to know the axis and the busbar, and construct the corresponding rotating surface.

步骤2:利用步骤1中读取的数据构造旋转曲面;Step 2: Use the data read in step 1 to construct a surface of revolution;

步骤2.1:利用圆弧切割算法计算出圆弧的圆心坐标:Step 2.1: Use the arc cutting algorithm to calculate the center coordinates of the arc:

步骤2.2:利用旋转成形算法计算旋转曲面的坐标:Step 2.2: Calculate the coordinates of the surface of revolution using the rotational forming algorithm:

步骤2.2.1:对已知曲线进行横向切割:Step 2.2.1: Transversally cut the known curve:

步骤2.2.2:对横向切割所得的点进行纵向切割:Step 2.2.2: Carry out vertical cutting on the points obtained by horizontal cutting:

步骤3:利用法向矢量算法的进行光照效果处理;Step 3: Use the normal vector algorithm to perform lighting effect processing;

步骤4:利用OpenGL功能函数对三维实体进行显示。Step 4: Use the OpenGL function to display the three-dimensional entity.

所述的步骤1中,用AutoCAD所提供的多义线来描述母线,同时通过设置线型来识别轴线,在实体节中,LINE和LWPOLYLINE中分别存有轴线和母线的信息,在读取数据过程中,可以根据组码0和组码6的值来搜索线型为中心线的轴线,然后按照文件格式依次读取轴线的起始点坐标;对于多义线,首先根据子类标记值搜索作为母线的多义线,然后按照文件格式依次读取多义线所有顶点坐标值。经过以上分析和处理,可以将旋转成形所需的数据读入程序,以便于进行下一步数据操作。In the above step 1, the polyline provided by AutoCAD is used to describe the busbar, and at the same time, the axis is identified by setting the line type. In the entity section, the information of the axis and the busbar are respectively stored in LINE and LWPOLYLINE. When reading the data During the process, you can search for the axis whose line type is the center line according to the values of group code 0 and group code 6, and then read the coordinates of the starting point of the axis in sequence according to the file format; The polyline of the bus, and then read the coordinate values of all vertices of the polyline sequentially according to the file format. After the above analysis and processing, the data required for rotational forming can be read into the program for the next step of data manipulation.

所述的步骤2.1的计算出圆弧的圆心坐标(xo,yo)的具体过程如下:The specific process of calculating the center coordinates (xo, yo) of the arc in the described step 2.1 is as follows:

l = ( c - a ) 2 + ( d - b ) 2 2 make l = ( c - a ) 2 + ( d - b ) 2 2

由拱度的定义可知

Figure BDA0000455268860000052
所以h=l*bowFrom the definition of camber we know
Figure BDA0000455268860000052
So h=l*bow

由图中三角关系可得:r2-l2=(r-h)2 From the triangle relationship in the figure, it can be obtained: r 2 -l 2 = (rh) 2

即圆弧半径 r = h 2 + l 2 2 × h the radius of the arc r = h 2 + l 2 2 × h

ω = arctan ( d - b c - a ) make ω = arctan ( d - b c - a )

则弧线圆心坐标为:Then the coordinates of the center of the arc are:

xoxo == aa ++ cc 22 -- (( rr -- hh )) ×× sinsin ωω yothe yo == bb ++ dd 22 ++ (( rr -- hh )) ×× coscos ωω

式中:设(a,b)为起点坐标,(c,d)为终点坐标,l为(a,b)与(c,d)构成的弦的长度,bow为拱度,h为弦高,ω为l对应的圆心角。所述的步骤2.2.1具体切割过程如下:在母线上逐段均匀地提取若干个点,并把它们的坐标存入三个二维数组x[1,j],y[1,j],z[1,j]。所取的点数在程序中由横向切割密度控制,横向切割密度越高,所生成立体图形母线越接近于原母线。In the formula: let (a, b) be the coordinates of the starting point, (c, d) the coordinates of the end point, l is the length of the chord formed by (a, b) and (c, d), bow is the camber, h is the chord height , ω is the central angle corresponding to l. The specific cutting process of the step 2.2.1 is as follows: uniformly extract several points segment by segment on the bus, and store their coordinates into three two-dimensional arrays x[1, j], y[1, j], z[1,j]. The number of points taken is controlled by the transverse cutting density in the program. The higher the transverse cutting density is, the closer the generated three-dimensional graphic generatrix is to the original generatrix.

所述的步骤2.2.2具体切割过程如下:在横向切割完成以后,对所得的点进行三维旋转,并对每一个点的旋转轨迹进行插值点坐标计算,插值点的数目由纵向切割密度控制。纵向切割密度越高,所生成立体图形横截面越光滑,但同样也会导致数据量增多。由横向切割操作可以得到曲线上的坐标点数组x[1,j],y[1,j],z[1,j],设纵向切割为绕x轴作360°的旋转,为了求出曲线上的每一点在旋转轨迹上所形成的n个点的坐标,可设旋转步长为t=2π/n,旋转变换矩阵为:The specific cutting process of the step 2.2.2 is as follows: After the horizontal cutting is completed, three-dimensional rotation is performed on the obtained points, and the interpolation point coordinates are calculated for the rotation trajectory of each point, and the number of interpolation points is controlled by the vertical cutting density. The higher the longitudinal cutting density, the smoother the cross-section of the generated three-dimensional graphics, but it will also lead to an increase in the amount of data. The coordinate point array x[1, j], y[1, j], z[1, j] on the curve can be obtained by the horizontal cutting operation, and the vertical cutting is set to rotate 360° around the x-axis, in order to find the curve The coordinates of n points formed by each point on the rotation trajectory, the rotation step size can be set to t=2π/n, and the rotation transformation matrix is:

TT == 11 00 00 00 coscos tt -- sinsin tt 00 sinsin tt coscos tt

设曲线上的点为(x,y,z),则旋转后的坐标为:Let the point on the curve be (x, y, z), then the coordinates after rotation are:

[x* y* z*]=[x y z]*T[x * y * z * ]=[x y z]*T

x * = x y * = y cos t + z sin t z * = - y sin t + z cos t Right now x * = x the y * = the y cos t + z sin t z * = - the y sin t + z cos t

所述的步骤3的具体步骤如下:计算法向矢量,所需条件为三个不共线的点的坐标值,它们的排列顺序决定了法向矢量的方向,在右手空间坐标系中,设已知点A、B、C、的坐标值分别为(xA,yA,zA),(xB,yB,zB),(xC,yC,zC),计算三点构成的平面的法向矢量,其算法如下:The specific steps of described step 3 are as follows: calculate the normal vector, the required condition is the coordinate values of three non-collinear points, and their order of arrangement determines the direction of the normal vector, in the right-hand space coordinate system, set The coordinates of points A, B, and C are known as (x A , y A , z A ), (x B , y B , z B ), (x C , y C , z C ), and calculate the three points The normal vector of the formed plane, the algorithm is as follows:

首先求出矢量

Figure BDA0000455268860000063
Figure BDA0000455268860000064
利用空间解析几何的方法,平面法矢量的空间描述为 i j k x AC y AC z AC x BC y BC z BC First find the vector
Figure BDA0000455268860000063
and
Figure BDA0000455268860000064
Using the method of spatial analytic geometry, the space description of the plane normal vector is i j k x AC the y AC z AC x BC the y BC z BC

其中 x AC = x A - x C , y AC = y A - y C , z AC = z A - z C x BC = x B - x C , y BC = y B - y C , z BC = z B - z C in x AC = x A - x C , the y AC = the y A - the y C , z AC = z A - z C x BC = x B - x C , the y BC = the y B - the y C , z BC = z B - z C

将平面法矢量空间描述的矩阵形式展开,可以得到其数学表达式为:(yACzBC-zACyBC)i+(zACxBC-zBCxAC)j+(xACyBC-xBCyAC)k。Expanding the matrix form described by the plane normal vector space, the mathematical expression can be obtained: (y AC z BC -z AC y BC )i+(z AC x BC -z BC x AC )j+(x AC y BC -x BC y AC )k.

如图4所示,本发明利用OpenGL功能函数对所读取的图形文件主要实现了以下几种功能:视窗初始化,图形绘制功能,坐标变换功能,光照与材质设置,图像与纹理操作功能,线框图、面模型、体模型处理等功能。从而通过物体材质和光源的设置,可以较准确地模拟真实世界的光照效果,达到三维实体计算机真实感显示的目的。通过增加雾化效果及纹理贴图,能够实现实体的一些特殊效果显示。As shown in Figure 4, the present invention utilizes the OpenGL function function to mainly realize the following several functions to the graphics file read: window initialization, graphics drawing function, coordinate transformation function, illumination and material setting, image and texture operation function, line Block diagram, surface model, volume model processing and other functions. Therefore, through the setting of the object material and the light source, the lighting effect of the real world can be simulated more accurately, and the purpose of realistic display of the three-dimensional entity computer can be achieved. By adding atomization effects and texture maps, some special effects of entities can be displayed.

Claims (5)

1.基于二维DXF文件格式的零件三维真实感显示方法,其特征在于:具体步骤如下:1. The three-dimensional realistic display method of parts based on the two-dimensional DXF file format is characterized in that: the specific steps are as follows: 步骤1:读取DXF文件格式中母线和轴线的数据;Step 1: Read the busbar and axis data in the DXF file format; 步骤2:利用步骤1中读取的数据构造旋转曲面;Step 2: Use the data read in step 1 to construct a surface of revolution; 步骤2.1:利用圆弧切割算法计算出圆弧的圆心坐标:Step 2.1: Use the arc cutting algorithm to calculate the center coordinates of the arc: 步骤2.2:利用旋转成形算法计算旋转曲面的坐标:Step 2.2: Calculate the coordinates of the surface of revolution using the rotational forming algorithm: 步骤2.2.1:对已知曲线进行横向切割:Step 2.2.1: Transversally cut the known curve: 步骤2.2.2:对横向切割所得的点进行纵向切割:Step 2.2.2: Carry out vertical cutting on the points obtained by horizontal cutting: 步骤3:利用法向矢量算法的进行光照效果处理;Step 3: Use the normal vector algorithm to perform lighting effect processing; 步骤4:利用OpenGL功能函数对三维实体进行显示。Step 4: Use the OpenGL function to display the three-dimensional entity. 2.根据权利要求1所述的基于二维DXF文件格式的零件三维真实感显示方法,其特征在于:所述的步骤1中,用AutoCAD所提供的多义线来描述母线,同时通过设置线型来识别轴线,在实体节中,LINE和LWPOLYLINE中分别存有轴线和母线的信息,在读取数据过程中,可以根据组码0和组码6的值来搜索线型为中心线的轴线,然后按照文件格式依次读取轴线的起始点坐标;对于多义线,首先根据子类标记值搜索作为母线的多义线,然后按照文件格式依次读取多义线所有顶点坐标值。2. The three-dimensional realistic display method for parts based on the two-dimensional DXF file format according to claim 1, characterized in that: in the described step 1, the polyline provided by AutoCAD is used to describe the busbar, and simultaneously by setting the line In the entity section, LINE and LWPOLYLINE respectively store axis and busbar information. In the process of reading data, you can search for the axis whose line type is the center line according to the values of group code 0 and group code 6. , and then read the coordinates of the starting point of the axis in sequence according to the file format; for polylines, first search for the polyline as a bus according to the subclass tag value, and then read all the vertex coordinates of the polyline in sequence according to the file format. 3.根据权利要求1所述的基于二维DXF文件格式的零件三维真实感显示方法,其特征在于:所述的步骤2.1的计算出圆弧的圆心坐标(xo,yo)的具体过程如下:3. the three-dimensional realistic display method of parts based on the two-dimensional DXF file format according to claim 1, is characterized in that: the specific process of calculating the center of circle coordinates (xo, yo) of the arc in the described step 2.1 is as follows: l = ( c - a ) 2 + ( d - b ) 2 2 make l = ( c - a ) 2 + ( d - b ) 2 2 由拱度的定义可知
Figure FDA0000455268850000012
所以h=l*bow
From the definition of camber we know
Figure FDA0000455268850000012
So h=l*bow
由图中三角关系可得:r2-l2=(r-h)2 From the triangle relationship in the figure, it can be obtained: r 2 -l 2 = (rh) 2 即圆弧半径 r = h 2 + l 2 2 × h the radius of the arc r = h 2 + l 2 2 × h ω = arctan ( d - b c - a ) make ω = arctan ( d - b c - a ) 则弧线圆心坐标为:Then the coordinates of the center of the arc are: xoxo == aa ++ cc 22 -- (( rr -- hh )) ×× sinsin ωω yothe yo == bb ++ dd 22 ++ (( rr -- hh )) ×× coscos ωω 式中:设(a,b)为起点坐标,(c,d)为终点坐标,l为(a,b)与(c,d)构成的弦的长度,bow为拱度,h为弦高,ω为l对应的圆心角。In the formula: let (a, b) be the coordinates of the starting point, (c, d) the coordinates of the end point, l is the length of the chord formed by (a, b) and (c, d), bow is the camber, h is the chord height , ω is the central angle corresponding to l.
4.根据权利要求1所述的基于二维DXF文件格式的零件三维真实感显示方法,其特征在于:所述的步骤2.2.1具体切割过程如下:在母线上逐段均匀地提取若干个点,并把它们的坐标存入三个二维数组x[1,j],y[1,j],z[1,j]。4. The three-dimensional realistic display method for parts based on two-dimensional DXF file format according to claim 1, characterized in that: the specific cutting process of the described step 2.2.1 is as follows: uniformly extract several points segment by segment on the bus , and store their coordinates into three two-dimensional arrays x[1, j], y[1, j], z[1, j]. 5.根据权利要求1所述的基于二维DXF文件格式的零件三维真实感显示方法,其特征在于:所述的步骤2.2.2具体切割过程如下:在横向切割完成以后,对所得的点进行三维旋转,并对每一个点的旋转轨迹进行插值点坐标计算:由横向切割操作可以得到曲线上的坐标点数组x[1,j],y[1,j],z[1,j],设纵向切割为绕x轴作360°的旋转,为了求出曲线上的每一点在旋转轨迹上所形成的n个点的坐标,可设旋转步长为t=2π/n,旋转变换矩阵为:5. The three-dimensional realistic display method for parts based on the two-dimensional DXF file format according to claim 1, characterized in that: the specific cutting process of the step 2.2.2 is as follows: after the horizontal cutting is completed, the obtained points are Three-dimensional rotation, and interpolation point coordinate calculation for the rotation trajectory of each point: the coordinate point array x[1, j], y[1, j], z[1, j] on the curve can be obtained by the horizontal cutting operation, Assuming that the longitudinal cutting is a 360° rotation around the x-axis, in order to obtain the coordinates of n points formed by each point on the curve on the rotation trajectory, the rotation step size can be set to t=2π/n, and the rotation transformation matrix is : TT == 11 00 00 00 coscos tt -- sinsin tt 00 sinsin tt coscos tt 设曲线上的点为(x,y,z),则旋转后的坐标为:Let the point on the curve be (x, y, z), then the coordinates after rotation are: [x* y* z*]=[x y z]*T[x * y * z * ]=[x y z]*T x * = x y * = y cos t + z sin t z * = - y sin t + z cos t Right now x * = x the y * = the y cos t + z sin t z * = - the y sin t + z cos t 5、根据权利要求1所述的基于二维DXF文件格式的零件三维真实感显示方法,其特征在于:所述的步骤3的具体步骤如下:计算法向矢量,所需条件为三个不共线的点的坐标值,它们的排列顺序决定了法向矢量的方向,在右手空间坐标系中,设已知点A、B、C、的坐标值分别为(xA,yA,zA),(xB,yB,zB),(xC,yC,zC),计算三点构成的平面的法向矢量,其算法如下:5. The three-dimensional realistic display method for parts based on two-dimensional DXF file format according to claim 1, characterized in that: the specific steps of step 3 are as follows: to calculate the normal vector, the required conditions are three different The coordinate values of the points on the line, their arrangement order determines the direction of the normal vector, in the right-hand space coordinate system, the coordinate values of the known points A, B, C, are respectively (x A , y A , z A ), (x B , y B , z B ), (x C , y C , z C ), calculate the normal vector of the plane composed of three points, the algorithm is as follows: 首先求出矢量
Figure FDA0000455268850000024
利用空间解析几何的方法,平面法矢量的空间描述为 i j k x AC y AC z AC x BC y BC z BC
First find the vector and
Figure FDA0000455268850000024
Using the method of spatial analytic geometry, the space description of the plane normal vector is i j k x AC the y AC z AC x BC the y BC z BC
其中 x AC = x A - x C , y AC = y A - y C , z AC = z A - z C x BC = x B - x C , y BC = y B - y C , z BC = z B - z C in x AC = x A - x C , the y AC = the y A - the y C , z AC = z A - z C x BC = x B - x C , the y BC = the y B - the y C , z BC = z B - z C 将平面法矢量空间描述的矩阵形式展开,可以得到其数学表达式为:(yACzBC-zACyBC)i+(zACxBC-zBCxAC)j+(xACyBC-xBCyAC)k。Expanding the matrix form described by the plane normal vector space, the mathematical expression can be obtained: (y AC z BC -z AC y BC )i+(z AC x BC -z BC x AC )j+(x AC y BC -x BC y AC )k.
CN201410013304.1A 2014-01-10 2014-01-10 Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts Pending CN103761376A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410013304.1A CN103761376A (en) 2014-01-10 2014-01-10 Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410013304.1A CN103761376A (en) 2014-01-10 2014-01-10 Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts

Publications (1)

Publication Number Publication Date
CN103761376A true CN103761376A (en) 2014-04-30

Family

ID=50528612

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410013304.1A Pending CN103761376A (en) 2014-01-10 2014-01-10 Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts

Country Status (1)

Country Link
CN (1) CN103761376A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927425A (en) * 2014-05-06 2014-07-16 上海索广电子有限公司 Method for automatically identifying operation points through DXF files
CN104239400A (en) * 2014-07-16 2014-12-24 沈阳航空航天大学 Method for converting DXF (Drawing Exchange File) file format into STL (STereoLithography) file format of primitive solid
CN106157238A (en) * 2015-05-13 2016-11-23 富士施乐株式会社 Expanded view generates system and launches drawing generating method
CN106249698A (en) * 2016-09-26 2016-12-21 武汉益模科技股份有限公司 Intelligent programming for wire cutting method and system based on three-dimensional graphics design platform
CN106294928A (en) * 2016-07-25 2017-01-04 上海柏楚电子科技有限公司 A kind of method identifying the surface of revolution expressed with rational B-spline surface form
CN108732990A (en) * 2018-04-24 2018-11-02 华侨大学 A kind of three-dimensional circle and elliptical angularly approach method
CN113111458A (en) * 2021-04-13 2021-07-13 合肥工业大学 DXF-based sheet metal part automatic identification and positioning method
CN114676484A (en) * 2022-04-01 2022-06-28 无锡海纳智能科技有限公司 Generation method of three-dimensional structure of photovoltaic power station, storage medium and electronic equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102663160A (en) * 2012-03-16 2012-09-12 苏州芯禾电子科技有限公司 Method for constructing three-dimensional physical circuit design model

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102663160A (en) * 2012-03-16 2012-09-12 苏州芯禾电子科技有限公司 Method for constructing three-dimensional physical circuit design model

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
张滢等: "STL、DXF等通用文件格式图形的真实感显示", 《小型微型计算机系统》 *
张滢等: "基于回转体CAD/CAPP结构的图形文件OpenGL处理技术研究", 《航空精密制造技术》 *
翟晓庆: "二维工程图的智能理解与三维重建研究", 《中国优秀博硕士学位论文全文数据库 (硕士) 工程科技Ⅱ辑》 *

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103927425A (en) * 2014-05-06 2014-07-16 上海索广电子有限公司 Method for automatically identifying operation points through DXF files
CN103927425B (en) * 2014-05-06 2017-04-19 上海索广电子有限公司 Method for automatically identifying operation points through DXF files
CN104239400A (en) * 2014-07-16 2014-12-24 沈阳航空航天大学 Method for converting DXF (Drawing Exchange File) file format into STL (STereoLithography) file format of primitive solid
CN106157238A (en) * 2015-05-13 2016-11-23 富士施乐株式会社 Expanded view generates system and launches drawing generating method
CN106294928A (en) * 2016-07-25 2017-01-04 上海柏楚电子科技有限公司 A kind of method identifying the surface of revolution expressed with rational B-spline surface form
CN106249698A (en) * 2016-09-26 2016-12-21 武汉益模科技股份有限公司 Intelligent programming for wire cutting method and system based on three-dimensional graphics design platform
CN106249698B (en) * 2016-09-26 2019-02-05 武汉益模科技股份有限公司 Intelligent programming for wire cutting method and system based on three-dimensional graphics design platform
CN108732990A (en) * 2018-04-24 2018-11-02 华侨大学 A kind of three-dimensional circle and elliptical angularly approach method
CN108732990B (en) * 2018-04-24 2020-10-09 华侨大学 Equiangular approximation method for three-dimensional circle and ellipse
CN113111458A (en) * 2021-04-13 2021-07-13 合肥工业大学 DXF-based sheet metal part automatic identification and positioning method
CN113111458B (en) * 2021-04-13 2022-10-21 合肥工业大学 DXF-based sheet metal part automatic identification and positioning method
CN114676484A (en) * 2022-04-01 2022-06-28 无锡海纳智能科技有限公司 Generation method of three-dimensional structure of photovoltaic power station, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN103761376A (en) Two-dimensional DXF (drawing exchange file) format based three-dimensional realistic display method of parts
Sullivan et al. High accuracy NC milling simulation using composite adaptively sampled distance fields
US20120221300A1 (en) Method, computer system and computer program product for machining simulation and for visually presenting such simulation
Dietrich et al. Edge transformations for improving mesh quality of marching cubes
CN103839292B (en) Method for sampling contour surface and generating high-quality triangular mesh
CN103077546B (en) The three-dimensional perspective transform method of X-Y scheme
CN110489778A (en) Pattern dividing method, laser ablation control system towards laser ablation processing
CN107564087A (en) A kind of Three-D linear symbol rendering intent based on screen
CN106991215A (en) A kind of high-precision graphical electromagnetic scattering computational methods based on GPU
Athanasiadis et al. Feature-based 3D morphing based on geometrically constrained spherical parameterization
CN103578140B (en) A kind of fast automatic generation method of mine three-dimensional roadway based on DXF
CN105574903B (en) A kind of geometric error modeling synthetic method and system accelerated based on GPU
JP2001034654A (en) Swept capacity model
CN101609565A (en) Three-dimensional solid Boolean operation method based on L-Rep model
CN103065358B (en) Organ geometry reconstruction method based on image volume element operation
CN105279788A (en) Method for generating object space swept volume
JP2020533685A (en) QUADOR: Rotating quadric beam for grid
Garcia et al. Interactive applications for sketch-based editable polycube map
Aubry et al. An entropy satisfying boundary layer surface mesh generation
CN105957141A (en) Symmetric structure-based three-dimensional flower modeling method
CN103440684B (en) A kind of method that humorous for ball lighting is applied to iso-surface patch
Fu et al. An algorithm for finding intersection between ball B-spline curves
CN102663822A (en) Molecule surface mesh generation method based on subdivision method
CN104143204A (en) A Moving Least Squares 2D Character Deformation Method Considering Topology
Ramírez et al. A method for obtaining the tesseract by unraveling the 4D hypercube

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20140430

RJ01 Rejection of invention patent application after publication