Three-dimensional visible edge generation method, system, computer and readable storage medium
By calculating the MVP transformation matrix and frustum cropping technology, the problem of high processing cost of large 3D models is solved, and the efficient generation of 3D visible edge images is achieved to meet user needs.
Patent Information
- Application Number
- CN202111280006.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-11-01
AI Technical Summary
The existing technology has high processing costs for large three-dimensional models and cannot meet the needs of most users.
By calculating the MVP transformation matrix and obtaining the three-dimensional model of the primitives, initialization processing is performed. The primitives that are not within the visual frustum are removed by frustum cropping, and the wireframes of primitives that exist within the visual frustum are extracted and blocked according to the preset algorithm. lines and repair broken edges to generate three-dimensional visible edges.
It achieves efficient processing of large-scale 3D models, accurately generates 3D visible edge images, reduces processing costs, meets the needs of most users, and is conducive to wide-scale promotion and use.
Smart Images

Figure CN113902887B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a three-dimensional visible edge generation method, system, computer and readable storage medium. Background Art
[0002] With the advancement of science and the rapid development of productivity, people have been able to design and manufacture a variety of components and equipment, which have been applied in people's daily lives, greatly facilitating people's lives.
[0003] Among them, before the above-mentioned components and equipment are produced, it is necessary to first construct the corresponding three-dimensional model, and then generate the corresponding two-dimensional drawings through the three-dimensional model for specific production and manufacturing. Among them, the three-dimensional visible edge generation method, namely hidden line removal, is one of the important steps in converting the three-dimensional model into a two-dimensional drawing. It is an algorithm for eliminating invisible edges from the three-dimensional scene represented by the wireframe model. In three-dimensional CAD engineering applications, the three-dimensional visible edge generation method is often used to automatically generate two-dimensional drawings that can be used to guide production and assembly based on the three-dimensional model, that is, two-dimensional drawing.
[0004] However, the existing technology has a high processing cost for large three-dimensional models, which makes it impossible to meet the usage needs of most users, and is not conducive to large-scale promotion and use. Summary of the invention
[0005] Based on this, the purpose of the present invention is to provide a three-dimensional visible edge generation method, system, computer and readable storage medium to solve the problem that the existing technology has high processing costs for large three-dimensional models and cannot meet the needs of most users.
[0006] A first aspect of the present invention provides a method for generating a three-dimensional visible edge, the method comprising:
[0007] Calculating the MVP transformation matrix and obtaining the primitive three-dimensional model to initialize the primitive data set of the primitive three-dimensional model;
[0008] Remove primitives that are not in the view cone by frustum clipping, and extract primitive wireframes corresponding to primitives that exist in the view cone, wherein the primitive wireframes include sharp edges and contour edges, wherein the sharp edges are boundary edges of the primitive three-dimensional model, and the contour edges are the edges presented on the outermost side of the surface of the primitive three-dimensional model observed along a viewport direction;
[0009] The blocked lines in the primitive wireframe are hidden according to a preset algorithm, and the broken edges of the primitive wireframe are repaired to generate three-dimensional visible edges.
[0010] The beneficial effects of the present invention are as follows: the present application first calculates the required MVP transformation matrix and obtains the primitive three-dimensional model, and initializes the primitive three-dimensional model to define each primitive data set, then removes the primitives that are not in the view cone by frustum clipping, and extracts the primitive wireframes corresponding to the primitives that exist in the view cone, and finally hides the obscured lines in the primitive wireframe according to a preset algorithm, and repairs the broken edges of the primitive wireframe, so as to generate a three-dimensional visible edge. The three-dimensional visible edge generation method provided by the present application can process large-scale three-dimensional models, and can accurately generate corresponding three-dimensional visible edges and their images. At the same time, the processing efficiency is high, so that the processing cost of large-scale three-dimensional models can be greatly reduced, and the use needs of most users can be effectively met, which is conducive to large-scale promotion and use.
[0011] A second aspect of the present invention provides a three-dimensional visible edge generation system, the system comprising:
[0012] An initialization module, used for calculating the MVP transformation matrix and obtaining a primitive three-dimensional model, so as to initialize a primitive data set of the primitive three-dimensional model;
[0013] A processing module, used for removing primitives not in the view cone by frustum clipping, and extracting primitive wireframes corresponding to primitives existing in the view cone, wherein the primitive wireframes include sharp edges and contour edges, wherein the sharp edges are boundary edges of the primitive three-dimensional model, and the contour edges are edges presented at the outermost sides of the curved surface observed along a viewport direction of the primitive three-dimensional model;
[0014] The generating module is used to hide the obstructed lines in the primitive wireframe according to a preset algorithm and to repair the broken edges of the primitive wireframe to generate three-dimensional visible edges.
[0015] A third aspect of the present invention provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-described three-dimensional visible edge generation method when executing the computer program.
[0016] A fourth aspect of the present invention provides a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the three-dimensional visible edge generation method as described above.
[0017] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A flowchart of a method for generating three-dimensional visible edges provided by a first embodiment of the present invention;
[0019] Figure 2 A flowchart of a method for generating three-dimensional visible edges provided in a second embodiment of the present invention;
[0020] Figure 3 This is a structural block diagram of a 3D visible edge generation system provided in the third embodiment of the present invention.
[0021] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0022] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0023] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be a central element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be a central element at the same time. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0025] See also Figure 1 , shown is a three-dimensional visible edge generation method provided by the first embodiment of the present invention. It should be noted that the method is mainly used to process large-scene three-dimensional model calculations, such as scenes for drawing full-station models in the fields of three-dimensional architecture, three-dimensional electricity, etc., and the processing efficiency of the method is high, thereby being able to significantly reduce the processing cost of large-scale three-dimensional models.
[0026] Specifically, the method for generating a 3D visible edge provided in this embodiment includes the following steps:
[0027] Step S10, calculating the MVP transformation matrix and obtaining the primitive three-dimensional model to initialize the primitive data set of the primitive three-dimensional model;
[0028] Specifically, in this embodiment, it should be noted that the MVP transformation matrix can be used for subsequent projection calculation of points on the three-dimensional model on the two-dimensional viewport plane, and reverse calculation of points on the three-dimensional model based on the projection points on the two-dimensional viewport plane. The MVP transformation matrix consists of three parts: model transformation matrix M, viewport transformation matrix V and projection transformation matrix P. Among them, the MVP transformation matrix is: MVP = M*V*P.
[0029] In addition, in this step, a primitive three-dimensional model is also obtained. The primitive three-dimensional model is composed of a large number of primitives. In this embodiment, the primitive three-dimensional model can be created by the user through CA software or obtained by importing external data.
[0030] Furthermore, after the primitive three-dimensional model is obtained, the primitive data set of the primitive three-dimensional model will be initialized. Specifically, this embodiment will define the above primitive to include 8 items of data information, namely: a topological face set, a triangle piece set, a two-dimensional viewport projection area, a wireframe edge set, a self-hiding result edge set, a mutual hiding result edge set, a broken edge repair result edge set and a two-dimensional visible edge set.
[0031] Step S20, removing primitives that are not within the view frustum by frustum clipping, and extracting primitive wireframes corresponding to primitives that exist within the view frustum, wherein the primitive wireframes include sharp edges and contour edges, wherein the sharp edges are boundary edges of the primitive three-dimensional model, and the contour edges are edges presented on the outermost side of the surface of the primitive three-dimensional model observed along a viewport direction;
[0032] Furthermore, in this embodiment, the obtained three-dimensional model of the primitive will be processed with three-dimensional visible edges. Specifically, in this embodiment, the primitives that are not within the view cone will be removed by frustum clipping, wherein the view cone is common knowledge to those skilled in the art, that is, the line of sight radiates from the human eye in an abstract cone shape, which is called the view cone.
[0033] Furthermore, the present embodiment further extracts the primitive wireframe corresponding to the primitive existing in the above-mentioned viewing cone, wherein the primitive wireframe includes sharp edges and contour edges, and the above-mentioned sharp edges are boundary edges of the primitive three-dimensional model, and the above-mentioned contour edges are the edges presented at the outermost sides of the surface of the primitive three-dimensional model observed along a viewport direction.
[0034] Step S30, hiding the blocked lines in the primitive wireframe according to a preset algorithm, and repairing the broken edges of the primitive wireframe to generate three-dimensional visible edges.
[0035] Finally, in this step, the obstructed lines in the primitive wireframe obtained in step S20 are hidden according to a preset hidden algorithm, and at the same time, the broken edges in the primitive wireframe are repaired by a preset program, so that a complete three-dimensional visible edge can be generated. At the same time, the processing efficiency is high, which can greatly reduce the processing cost of large three-dimensional models.
[0036] When in use, firstly, the required MVP transformation matrix is calculated and the primitive three-dimensional model is obtained, and the primitive three-dimensional model is initialized to define each primitive data set, and then the primitives that are not in the cone are removed by cone clipping, and the primitive wireframes corresponding to the primitives that exist in the cone are extracted, and finally, the obscured lines in the primitive wireframe are hidden according to the preset algorithm, and the broken edges of the primitive wireframe are repaired, so that a three-dimensional visible edge can be generated. The three-dimensional visible edge generation method provided in the present application can process large-scale three-dimensional models, and can accurately generate corresponding three-dimensional visible edge images. At the same time, the processing efficiency is high, so that the processing cost of large-scale three-dimensional models can be greatly reduced, and the use needs of most users can be effectively met, which is conducive to large-scale promotion and use.
[0037] It should be noted that the above implementation process is only to illustrate the feasibility of the present application, but this does not mean that the three-dimensional visible edge generation method of the present application has only the above-mentioned single implementation process. On the contrary, as long as the three-dimensional visible edge generation method of the present application can be implemented, it can be included in the feasible implementation plan of the present application.
[0038] In summary, the three-dimensional visible edge generation method in the above-mentioned embodiment of the present invention can process large-scale three-dimensional models and can accurately generate corresponding three-dimensional visible edge images. At the same time, the processing efficiency is high, which can greatly reduce the processing cost of large-scale three-dimensional models, can effectively meet the usage needs of most users, and is conducive to large-scale promotion and use.
[0039] See also Figure 2 , which is a three-dimensional visible edge generation method provided by the second embodiment of the present invention, and the three-dimensional visible edge generation method specifically comprises the following steps:
[0040] Step S11, calculating the MVP transformation matrix and obtaining the primitive three-dimensional model to initialize the primitive data set of the primitive three-dimensional model;
[0041] In this embodiment, it should be noted that the above MVP transformation matrix includes a model transformation matrix M, a viewport transformation matrix V and a projection transformation matrix P;
[0042] The MVP transformation matrix is: MVP = M*V*P, and the MVP transformation matrix is calculated as follows:
[0043] Wherein, the model transformation matrix M is:
[0044] ;
[0045] Among them, (n x , n y , n z ) is the viewport normal vector coordinate, (u x ,u y ,u z ) is the viewport upward vector coordinate, (v x , v y , v z ) is the viewport right direction vector coordinate, T=[t x , t y , t z ] is the translation component of the model transformation matrix M, and the translation component T is calculated by the following formula:
[0046] ;
[0047] Among them, (e x , e y , e z ) is the viewpoint coordinate;
[0048] The viewport transformation matrix V is:
[0049] ;
[0050] Among them, W is the width of the viewport plane, H is the height of the viewport plane, and D is the depth of the viewing cone;
[0051] The projection transformation matrix P is:
[0052] ;
[0053] Among them, w is the width of the viewport pixel map, and h is the height of the viewport pixel map, so that the above MVP transformation matrix can be calculated.
[0054] In this embodiment, after the above initialization process, the above primitive is defined as containing 8 data information, namely: topological face set, triangle piece set, 2D viewport projection area, wireframe edge set, self-hiding result edge set, mutual hiding result edge set, broken edge repair result edge set and 2D visible edge set. Among them, the topological face set and triangle piece set are known information of the primitive topology; the 2D viewport projection area is calculated in the frustum clipping; the wireframe edge set is calculated in the wireframe extraction; the self-hiding result edge set is calculated in the self-hiding; the mutual hiding result edge set is calculated in the mutual hiding; the broken edge repair result edge set is calculated in the broken edge repair; and the 2D visible edge set is calculated in the visible edge generation.
[0055] In this embodiment, it is assumed that the three-dimensional scene is composed of N primitives, and the primitive data set is , let Si be the i-th element in the element data set S, and i=1, 2, ..., N, then
[0056] ;
[0057] Among them, F i is the topological face set of the i-th primitive, T i is the triangle set of the i-th primitive, R i is the two-dimensional viewport projection area of the i-th primitive, WE i is the wireframe edge set of the i-th primitive, SE i is the self-hidden result edge set of the i-th primitive, HE i is the mutual hidden edge set of the i-th primitive, RE i is the edge set of the broken edge repair result of the i-th primitive, VE i is the visible edge set of the ith primitive, i=1, 2, ..., N, where N is a natural number, so as to complete the initialization processing of the primitive data set of the above primitive three-dimensional model.
[0058] Step S21, obtaining a cropping mark of each of the graphic elements; when the cropping mark is true, the graphic element is removed, otherwise the graphic element is retained;
[0059] The cropping marks are:
[0060] ;
[0061] Among them, R is the viewport pixel map area, , (u, v) is any pixel in the viewport pixel map area, w is the viewport pixel map width, h is the viewport pixel map height; Ri is the two-dimensional projection area of the i-th primitive on the viewport plane, , (u, v) is any pixel in the viewport pixel map area, X minThe minimum horizontal coordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane is rounded, X max Y is the maximum horizontal coordinate of the projection point of the 8 vertices of the i-th primitive bounding box on the viewport plane. min Y is the minimum ordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane. max Round the maximum ordinate coordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane.
[0062] Step S31, extracting the primitive wireframe to obtain a primitive wireframe edge set corresponding to the primitive wireframe; and performing contour edge calculation according to the primitive wireframe edge set;
[0063] The primitive wireframe edge set WEi is:
[0064] ;
[0065] in, is the sharp edge set of the i-th primitive, which is composed of the topological surface set F of the i-th primitive i The mid-plane type face is generated by directly extracting the boundary edges; is the contour edge set of the i-th primitive, which is composed of the topological face set F of the i-th primitive i It is calculated from the surface type of the face and the viewport normal vector N, where the viewport normal vector N is a known frustum parameter.
[0066] Specifically, in this step, it specifically includes the calculation of the contour edge of the spherical surface, the calculation of the contour edge of the cylindrical surface, and the calculation of the contour edge of the irregular surface.
[0067] Among them, the spherical surface contour edge is calculated as:
[0068] The contour edge of the sphere for:
[0069] ;
[0070] in, is the circle equation, which is determined by the center, radius and axis vector; O is the center of the spherical surface, which is also the center of the circular contour edge; r is the radius of the spherical surface, which is also the radius of the circular contour edge; N is the viewport normal vector, which is also the axis vector of the circular contour edge.
[0071] The cylindrical surface contour edge is calculated as:
[0072] Silhouette edge of a cylindrical face for:
[0073]
[0074] in, is the equation of the straight line segment, which is determined by the starting point and the end point; the four vertices P0-P3 of the two straight line segment contour edges of the cylindrical surface are:
[0075]
[0076] Among them, O is the center of the bottom circle of the cylinder, h is the height of the cylinder, N is the normal vector of the viewport plane, y is the axis direction of the cylinder, which is a known topological parameter of the cylindrical surface, and x is the starting sweep angle direction of the cylinder bottom circle, which is obtained by the cross product of N and y.
[0077] Irregular surface contour edge calculation:
[0078] Surfaces that are not of the above two regular types are recorded as irregular surfaces. The ContapContour algorithm in the open source geometry kernel OCC is used to calculate the contour edge of irregular surfaces.
[0079] Step S41, hiding the obstructed lines in the primitive wireframe according to a preset algorithm, and repairing the broken edges of the primitive wireframe to generate three-dimensional visible edges;
[0080] In this step, it should be noted that the above-mentioned preset algorithm includes self-hiding calculation and mutual hiding calculation. Specifically, self-hiding means removing the part of the primitive wireframe edge that is blocked by the model itself; mutual hiding means removing the part of the primitive wireframe edge that is blocked by other primitives. Among them, the above-mentioned self-hiding calculation includes spherical primitive self-hiding, cylindrical primitive self-hiding, convex polyhedron primitive self-hiding and irregular primitive self-hiding.
[0081] Among them, the self-hiding of the ball element is:
[0082] Assuming that the i-th primitive is a spherical primitive, its self-hidden edge SE i for:
[0083]
[0084] Where type is the topological type of the i-th element, and is a known attribute of the element. i The wireframe edge set of the sphere primitive.
[0085] The cylindrical primitive is self-hidden as follows:
[0086] Assuming that the i-th primitive is a cylindrical primitive, according to the different positional relationships between the viewport normal vector N and the cylinder axis direction, the self-hiding calculation of the cylindrical primitive is divided into two cases:
[0087] Case 1: The viewport direction N is perpendicular to the cylinder axis direction y;
[0088] The result edge SE of the cylindrical primitive self-hiding corresponding to case 1 i for:
[0089] ;
[0090] Wherein, type is the topological type of the i-th primitive, which is a known attribute of the primitive; Arc is the equation of an arc, determined by five parameters: the center, radius, axis vector, starting point, and ending point; Line is the equation of a line, determined by the starting point and the ending point; O is the center of the bottom circular surface of the cylinder, r is the radius of the cylinder, y is the cylinder axis direction vector, which are known cylinder topological parameters, is the center of the top circular surface of the cylinder, and P0 - P3 are the four endpoints of the side contour line of the cylinder, calculated from the above step S31.
[0091] Case 2: The viewport direction N is not perpendicular to the cylinder axis direction y;
[0092] The self - hidden result edge SE of the cylinder primitive corresponding to Case 2 i is:
[0093] ;
[0094] Wherein, type is the topological type of the i-th primitive, which is a known attribute of the primitive; Circle is the equation of a circle, determined by three parameters: the center, radius, and axis vector; Arc is the equation of an arc, determined by five parameters: the center, radius, axis vector, starting point, and ending point; Line is the equation of a line, determined by the starting point and the ending point; O is the center of the bottom circular surface of the cylinder, r is the radius of the cylinder, y is the cylinder axis direction vector, which are known cylinder topological parameters, is the center of the top circular surface of the cylinder, and P0 - P3 are the four endpoints of the side contour line of the cylinder, calculated from the above step S31.
[0095] The self - hidden result of the convex polyhedron primitive is:
[0096] Assume that the i-th primitive is a convex polyhedron primitive, then its self - hidden result edge SE i is:
[0097] The visible edges of the convex polyhedron are composed of all the edges corresponding to the front faces. Therefore, there is:
[0098] ;
[0099] Wherein, type is the topological type of the i-th primitive, which is a known attribute of the primitive; E j is the j-th self - hidden result edge, 0 < j < k, and k is a natural number, , representing all the edges corresponding to the front faces in the wireframe edges, WE i is the wireframe edge set of the i-th primitive, E.F.Nor represents the normal vector of the face where the current wireframe edge is located, which are known primitive topological parameters, and N is the viewport normal vector.
[0100] The self - hidden result of the irregular primitive is:
[0101] The primitives that are not of the above three regular types are recorded as irregular primitives. The self-hiding calculation of irregular primitives is performed simultaneously with mutual hiding in the subsequent mesh hiding.
[0102] In this embodiment, it should be noted that the step of hiding the blocked lines in the primitive wireframe according to the preset algorithm includes the self-hiding and mutual hiding, wherein the mutual hiding includes the following steps:
[0103] Dividing the two-dimensional viewport pixel map into a plurality of grid units, and collecting the image metadata in each of the grid units to obtain a grid data set;
[0104] The visible edges of each of the grid units are calculated to hide the obstructed lines in the primitive wireframe.
[0105] Specifically, the specific operation steps of the above mutual elimination are:
[0106] This embodiment proposes a new mutual hiding method based on Z-Buffer and divide-and-conquer strategy, which divides the two-dimensional viewport pixel map into m*n grid units, and reduces the number of mutual hiding pairs of primitives by limiting the grid area, thereby reducing the algorithm calculation overhead. In addition, the hiding calculation of each grid is independent of each other, and is accelerated by parallel computing technology. When the visible edge results of the primitives in the grid are output, there may be thread conflicts. At this time, the threads are synchronized through mutex locks. In addition, the mutual hiding method proposed in this embodiment will continue to consider the occlusion of the primitive itself on the basis of self-hiding when removing invisible edges, thereby solving the self-hiding problem of irregular primitives.
[0107] The mutual cancellation calculation is performed in two steps:
[0108] 1. Grid division
[0109] Divide the two-dimensional viewport pixel map into m*n grid units, collect the metadata in each grid, and obtain the grid data set G as:
[0110] ;
[0111] Among them, G j is the data of the jth grid, j=1,2,...,m*n, m is the number of horizontal splits of the pixel map, n is the number of vertical splits of the pixel map, m and n are both natural numbers greater than 1, the default value of m is 80, and the default value of n is 60, both of which can be adjusted according to the actual scenario;
[0112] definition , where r is the row number of the jth grid in the entire grid distribution and c is the column number of the jth grid in the entire grid distribution, GRj is the two-dimensional pixel area of the j-th grid, GS j is the primitive data set in the jth grid.
[0113] The two-dimensional pixel region GR of the j-th grid j for:
[0114]
[0115] Among them, u and v are GR j , r is the row number of the j-th grid in the entire grid distribution, c is the column number of the j-th grid in the entire grid distribution, m is the number of horizontal splits of the pixel map, n is the number of vertical splits of the pixel map, w is the viewport pixel map width, and h is the viewport pixel map height.
[0116] The two-dimensional pixel area GS of the j-th grid j for:
[0117]
[0118] Where S k is the primitive with projection in the jth grid, that is, the kth primitive in the primitive data set of the jth grid, k is a natural number, k≤N, N is the number of primitives in the whole scene; S is the primitive data set of the current 3D scene; S k .R k .u min For the element S k The minimum pixel value in the u direction of the projection area, S k .R k .u max For the element S k The maximum value of the u-axis pixel in the projection area; S k .R k .v min For the element S k The minimum value of the v-axis pixel in the projection area, S k .R k .v max For the element S k The maximum value of the v-axis pixel in the projection area; GR j .u min is the minimum value of pixels in the pixel map area u of the jth grid; GR j .u max is the maximum value of the pixel in the pixel map area u of the jth grid; GR j .v min is the minimum value of pixels in the pixel map area v of the jth grid; GR j .v max It is the maximum value of the pixels in the v direction of the pixel map area of the j-th grid.
[0119] 2. Grid visible edge calculation
[0120] In this embodiment, it should be noted that the above step of calculating the visible edges of each of the grid units to hide the obscured lines in the primitive wireframe includes the following specific steps:
[0121] Performing method processing on the grid area corresponding to each of the grid units, and calculating the grid pixel map corresponding to each of the grid units;
[0122] Eliminating completely invisible primitives in the grid unit according to the depth value of the grid pixel map, and performing edge splitting processing on each of the grid units;
[0123] Visibility determination is performed according to the visibility facts after the edge splitting, and according to the result of the visibility determination, the visible edges are added to the corresponding primitive muted edge set according to the numbers of the corresponding primitives.
[0124] Specifically, this embodiment proposes a new method for calculating visible edges of a mesh based on edge splitting. The method is designed based on the following fact: in a wireframe diagram of a three-dimensional scene, the edges can be split into multiple segments according to the intersection points between the edges. At this time, all disconnected edges in the scene are either completely visible or completely invisible.
[0125] According to the above facts, if Figure 3 As shown in Figure 2, the mesh visible edge calculation method is divided into six steps:
[0126] 1) Zoom in on the grid area
[0127] It is known that the two-dimensional pixel area of the jth grid is GR j In order to improve the accuracy of the hidden layer removal algorithm based on the Z-Buffer pixel map and reduce the complexity of the splitting algorithm based on edge intersection within a single pixel, the grid area GR j Zoom in. Note the grid area GR j The pixel area after K times magnification is SGR j ,have:
[0128]
[0129] in, is the grid area GR j The lower left corner of Grid area GR j , K is the magnification factor, which is a natural number greater than 1. The default value is 20 and can be adjusted according to the application scenario.
[0130] 2) Calculate the grid pixel map
[0131] Let the grid pixel map of the jth grid be GM j ,but
[0132]
[0133] Among them, P rc is the pixel data of the rth row and cth column in the grid pixel map GMj of the jth grid, where 1≤r≤u, 1≤c≤v, u and v are the grid pixel map GM of the jth grid. j The maximum number of rows and columns.
[0134] definition , dDepth is the minimum depth value of the current pixel, nShapeId is the primitive number corresponding to the minimum depth value of the current pixel, and TriIds is the set of triangle numbers of all primitives projected in the current pixel.
[0135] The grid pixel map GM of the jth grid j The calculation method is as follows:
[0136] Extract the primitive dataset GS of the jth grid j The list of triangles for each primitive in , denoted by S i For GS j The i-th primitive in the graph has a triangle list T i , obtained from the primitive topological data;
[0137] Triangle MVP Transformation
[0138] Remember Tri k T i The kth triangle of , where k is a natural number greater than 0. Definition , where nTriId is the triangle number, P0, P1, P2 are the three vertices of the triangle, then the triangle Tri after MVP transformation k for:
[0139]
[0140] in, , , , MVP is the 3D-2D transformation matrix.
[0141] Calculate Tri k The bounding box of
[0142]
[0143] Among them, u min 、v minTake the minimum horizontal and vertical pixel coordinates of the three projection points P0, P1, and P2, u max 、v max Take the maximum horizontal and vertical pixel coordinates of the three projection points P0, P1, and P2.
[0144] Update pixel map GM j
[0145] Traversal For each pixel in the image, let the pixel at position (r,c) be V rc According to the triangle centroid algorithm, we can get:
[0146] ;
[0147] Among them, P0, P1, and P2 are triangle pieces T i The three vertices of are projected points after MVP transformation. w1 and w2 are the centroid weight coefficients, which are obtained by Cramer's law. w1 = D1 / D, w2 = D2 / D, where D, D1, and D2 are calculated as follows:
[0148] ;
[0149] Among them, V rc for The pixel point at the inner position (r,c), P0, P1, P2 are triangle pieces T i The projection points of the three vertices after MVP transformation.
[0150] If w1≥0, w2≥0, w1+w2≤1, then the pixel V rc In the projected triangle Tri k Inside, the triangle piece Tri k In pixel P rc The projection depth D rc for:
[0151]
[0152] in, is a triangle Tri k The projection depth of the first vertex P0 on the pixel map, is a triangle Tri k The projection depth of the second vertex P1 on the pixel map, is a triangle Tri k The projection depth of the third vertex P2 on the pixel map.
[0153] If D rc ≤P rc .dDepth, then update the pixel map, that is, P rc.dDepth =D rc , P rc .nShapeId =S i .nShapeId, the triangle Tri k The unique number is added to P rc .TriIds list, where S i .nShapeId is the unique number of the element Si.
[0154] Repeat steps (2), (3), (4) to complete the calculation of all triangles of the primitive Si and update the pixel map GM j ;
[0155] Repeat steps (1)(2)(3)(4)(5) to complete the primitive dataset GS of the jth grid. j Calculate all primitives in and update the pixel map GM j .
[0156] 3) Eliminate completely invisible primitives
[0157] The grid pixel map GM of the jth grid is known j A pixel in , where P rc .nShapeId is the number of the primitive with the smallest projected depth value on its pixel. According to the depth test principle, in the pixel map GM j The primitives whose primitive numbers do not appear in are invisible primitives. Based on this criterion, the primitive dataset GS of the jth grid is removed. j The middle part is completely invisible to reduce subsequent calculation overhead.
[0158] 4) Edge Splitting
[0159] Usually, the distribution of edges in a wireframe graph within a single grid is often complex. Directly splitting edges by pairing edges to find intersections will result in a large algorithm computational overhead and fail to meet the performance requirements of actual applications. To address this problem, the present invention proposes a new fast edge splitting method based on pixel graphs, which optimizes the wireframe edge intersection calculation through simple pixel chain intersection and a series of line segment intersection detections (bounding box intersection, parallelism, and intersection point on line segment), and quickly obtains the splitting points of three-dimensional wireframe edges.
[0160] As described below, the above edge splitting method is divided into the following 6 steps:
[0161] S1: Curve edge sampling
[0162] There are two types of edges in the mesh wireframe view: straight edges and curved edges (circles, ellipses, B-splines, etc.). To simplify the intersection of curved edges, they are sampled as straight line strings for subsequent intersection calculations. After edge sampling, all edges in the mesh wireframe view are converted to straight line segments, thus converting edge intersection into straight line segment intersection.
[0163] S2: Calculate edge pixel chain
[0164] After all straight line segments in the grid wireframe view are transformed by MVP, a straight line segment pixel chain can be obtained, and the intersection of the straight line segments can be further simplified by using the edge pixel chain intersection.
[0165] Set straight line segment , then after MVP transformation, the projection edge in the pixel map is:
[0166]
[0167] in, , , P0 and P1 are the starting point and end point of the straight line segment, and MVP is the 3D-2D transformation matrix.
[0168] Let the pixel chain corresponding to the straight line segment L be LP, then:
[0169]
[0170] in, PLX k For the k-th pixel of LP, define , where u and v are pixel positions, and nEdgeId is the unique number of the straight line segment corresponding to the current pixel chain.
[0171] When calculating the pixel chain corresponding to the straight line segment L as LP, if there is a pixel that is not within the current grid range, its corresponding pixel segment is removed to avoid the conflict of hidden results when mutual hidden is performed by grid because a certain primitive spans multiple grids.
[0172] S3: Calculate edge pixel map
[0173] Let the jth grid G j The edge pixel map is GEM j , then:
[0174]
[0175] Among them, P rc is the edge pixel map GEM of the jth grid j The pixel data of the rth row and cth column in , where 1≤r≤u, 1≤c≤v, u, v are the edge pixel map GEM of the jth grid j The maximum number of rows and columns.
[0176] definition , where TriIds is a unique set of numbers of straight line segments projected within the current pixel.
[0177] The edge pixel map filling method is: traverse each pixel in all edge pixel chains, and add its straight line segment unique number to the edge pixel map GEM according to the pixel coordinates j The corresponding pixel’s TriIds can be used.
[0178] S4: Edge intersection and edge splitting
[0179] Traverse the edge pixel map GEM of the j-th grid j , for any pixel P rc If the number of edges in the unique number set TriIds of the straight line segments is greater than 1, there is an edge intersection; then the straight line segments are paired and intersected according to their unique numbers, and the corresponding wireframe edges are divided into two according to the intersection points of the straight line segments.
[0180] Suppose two straight line segments are: , , the method to intersect two straight line segments and split the wireframe edge is as follows:
[0181] Perform MVP transformation on two straight line segments to obtain the corresponding projection edge , ;
[0182] calculate , The 2D viewport bounding box , ;
[0183]
[0184] in, Represents the projection endpoint The horizontal pixel coordinates of Represents the projection endpoint The vertical pixel coordinates of Same reason.
[0185] According to the intersection of bounding boxes, determine whether the line segments intersect. If they do, continue the calculation, otherwise exit;
[0186] Determine the straight line segment , Are they parallel? Let the parallel mark be m, then:
[0187]
[0188] If m is not equal to 0, the two straight line segments are not parallel, and the calculation continues; otherwise, exit;
[0189] Simultaneous Linear , The parametric equation of the two projection lines gives the coordinates of the intersection point:
[0190]
[0191] in, Represents the projection endpoint The horizontal pixel coordinates of Represents the projection endpoint The vertical pixel coordinates of Similarly, m is the parallel coefficient.
[0192] Determine whether the intersection point is within the line segment, and record the determination marks as follows: and ,but:
[0193]
[0194] if , if the intersection point is within the range of the two line segments, continue the calculation; otherwise, exit.
[0195] Remember two projected line segments , The depth values of the intersection points corresponding to different line segments are z1 and z2 respectively, then
[0196]
[0197] in, For the projected line segment Starting point The projection depth value, For the projected line segment The end point The projection depth value, , is the relative projection line segment of the intersection point The interpolation coefficients for the start and end points of
[0198]
[0199] Similarly, we can get z2. Then, we can get the line segment , The coordinates of the intersection points are , .
[0200] Intersection point , By performing the inverse MVP transformation, the wireframe edge splitting points corresponding to the three-dimensional straight line segments L1 and L2 are obtained as follows:
[0201]
[0202] A is the split point of the three-dimensional wireframe edge corresponding to line segment L1, B is the split point of the three-dimensional wireframe edge corresponding to L2, and MVP -1 Represents the inverse of the MVP matrix.
[0203] 5) Visibility determination
[0204] The wireframe edge set of the split primitives in the jth grid is GSE j , according to the split edge visibility fact: GSE j The edges in are either completely visible or completely invisible. Therefore, GSE j Any side of e i The middle point P c Visibility V(P c ) That is, e i Visibility V(e i ), that is:
[0205]
[0206] Among them, V is the visibility criterion, V(P c ) is calculated as follows:
[0207] P c Perform MVP transformation to get the projection point , then P c In the grid pixel map GM j The corresponding pixel in is , Represents the projection point The horizontal pixel coordinates of Represents the projection point The vertical pixel coordinates of
[0208] Known The unique number list TriIds of all primitive triangles is stored in P c The visibility of P is whether there is a triangle in TriIds that blocks P c .
[0209] Set triangle , then P c Relative to Tri k The visibility is calculated as follows:
[0210] Triangle k Performing MVP transformation, we can get:
[0211]
[0212] in, , , , MPV is the 3D-2D transformation matrix, P0, P1, P2 are the three vertices of the triangle;
[0213] According to the triangle centroid algorithm formula, we can get:
[0214]
[0215] Among them, w1 and w2 are the weight coefficients of the center of gravity, which are obtained by solving Cramer's law, w1 = D1 / D, w2 = D2 / D, where D, D1, and D2 can be obtained by the above formula;
[0216] if If not satisfied, then P c visible;
[0217] if If satisfied, calculate P c Corresponding to the triangle Tri k The projection depth of the upper point is denoted by D c ,
[0218]
[0219] in, is a triangle Tri k The projection depth of the first vertex P0 on the pixel map, is a triangle Tri k The projection depth of the second vertex P1 on the pixel map, is a triangle Tri k The projection depth of the third vertex P2 on the pixel map;
[0220] if , then P c Invisible; on the contrary P c visible.
[0221] 6) Data Synchronization
[0222] According to the visibility judgment result, the visible edges in GSEj are added to the hidden edge set HEi of the corresponding primitive Si according to the unique number of the primitive to which they belong.
[0223] In order to avoid the thread conflict problem caused by multiple grids performing data synchronization on the HEi set of a primitive at the same time, the present invention adopts a mutex lock to ensure the thread safety of data synchronization.
[0224] In this embodiment, broken edge repair is performed. Specifically, since the hidden edge calculation adopts a divide-and-conquer strategy, the wireframe edge of the entire 3D scene is split into m*n grids. When the edge is split, the grid boundary will interrupt the edge to eliminate the mutual influence of the grid hidden edge calculation and realize parallel calculation. However, this operation will split the wireframe edge excessively, and the final 3D visible edge result will have multiple segments.
[0225] To solve the above problems, the present invention designs a broken edge repair mechanism: for the same edge, after splitting into multiple segments, each segment edge keeps the same edge handle, and the edge segments are distinguished by parameter intervals. i The hidden edge set HE i The edges in are classified according to the edge handles. In the edge sequence of the same edge handle, if there are continuous parameter regions, the broken edges are repaired by merging the parameter intervals.
[0226] The calculation of repairing broken edges of each primitive is independent of each other, so parallel computing technology is used to accelerate it.
[0227] In this embodiment, it should be noted that after the steps of hiding the blocked lines in the primitive wireframe according to the preset algorithm and repairing the broken edges of the primitive wireframe to generate three-dimensional visible edges, the method further includes:
[0228] Step S51, converting the three-dimensional visible edge into a corresponding two-dimensional visible edge through the MVP transformation matrix; and exporting the two-dimensional visible edge to an engineering drawing.
[0229] Specifically, any primitive S i The hidden edge set HE i The edges in the figure are three-dimensional visible edges, while the output in the engineering application DWG drawings are two-dimensional edges on the projection plane. Therefore, the three-dimensional visible edges are finally transformed into two-dimensional visible edges according to the MVP transformation matrix, which is recorded as VE i . Three-dimensional visible edges are divided into: straight edges and curved edges.
[0230] The projection calculation method of a straight line edge is: project its two endpoints, and connect the projection points to get the projected straight line edge;
[0231] The projection calculation method of the curve edge is as follows: perform isoparametric sampling on the curve edge, project the sampling points, obtain the projection point set, and then fit the projection curve edge with a two-dimensional non-uniform rational B-spline curve.
[0232] The calculation of generating the two-dimensional visible edge of each primitive is independent of each other, so parallel computing technology is used to accelerate it.
[0233] Finally, through the ODA File Converter component, it can be exported to a two-dimensional visible edge drawing DWG.
[0234] It should be pointed out that the implementation principle and some technical effects of the method provided in the second embodiment of the present invention are the same as those of the first embodiment. For the sake of brief description, for matters not mentioned in this embodiment, reference may be made to the corresponding contents in the first embodiment.
[0235] In summary, the three-dimensional visible edge generation method in the above-mentioned embodiment of the present invention can process large-scale three-dimensional models and can accurately generate corresponding three-dimensional visible edge images. At the same time, the processing efficiency is high, which can greatly reduce the processing cost of large-scale three-dimensional models, can effectively meet the usage needs of most users, and is conducive to large-scale promotion and use.
[0236] See also Figure 3 , which is a three-dimensional visible edge generation system provided by a third embodiment of the present invention, and includes:
[0237] An initialization module 12 is used to calculate the MVP transformation matrix and obtain a primitive three-dimensional model to initialize a primitive data set of the primitive three-dimensional model;
[0238] A processing module 22 is used to remove primitives that are not in the view cone by frustum clipping, and extract primitive wireframes corresponding to primitives that exist in the view cone, wherein the primitive wireframes include sharp edges and contour edges, wherein the sharp edges are boundary edges of the primitive three-dimensional model, and the contour edges are edges presented on the outermost side of the surface of the primitive three-dimensional model observed along a viewport direction;
[0239] The generating module 32 is used to hide the blocked lines in the primitive wireframe according to a preset algorithm and repair the broken edges of the primitive wireframe to generate three-dimensional visible edges.
[0240] Wherein, in the above-mentioned three-dimensional visible edge generation system, the MVP transformation matrix includes a model transformation matrix M, a viewport transformation matrix V and a projection transformation matrix P;
[0241] Wherein, the MVP transformation matrix is: MVP=M*V*P;
[0242] Wherein, the model transformation matrix M is:
[0243] ;
[0244] Among them, (n x , n y , n z ) is the viewport normal vector coordinate, (u x ,u y ,u z ) is the viewport upward vector coordinate, (v x , v y, v z ) is the viewport right direction vector coordinate, T=[t x , t y , t z ] is the translation component of the model transformation matrix M, and the translation component T is calculated by the following formula:
[0245] ;
[0246] The viewport transformation matrix V is:
[0247] ;
[0248] Among them, W is the width of the viewport plane, H is the height of the viewport plane, and D is the depth of the viewing cone;
[0249] The projection transformation matrix P is:
[0250] ;
[0251] Among them, w is the width of the viewport pixel map, and h is the height of the viewport pixel map.
[0252] In the above three-dimensional visible edge generation system, the processing module 22 is specifically used for:
[0253] Obtaining the cropping mark of each of the primitives;
[0254] When the clipping mark is true, the primitive is removed, otherwise the primitive is retained. The clipping mark is:
[0255] ;
[0256] Among them, R is the viewport pixel map area, , (u, v) is any pixel in the viewport pixel map area, w is the viewport pixel map width, h is the viewport pixel map height; Ri is the two-dimensional projection area of the i-th primitive on the viewport plane, , (u, v) is any pixel in the viewport pixel map area, X min The minimum horizontal coordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane is rounded, X max Y is the maximum horizontal coordinate of the projection point of the 8 vertices of the i-th primitive bounding box on the viewport plane. min Y is the minimum ordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane. max Round the maximum ordinate coordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane.
[0257] In the above three-dimensional visible edge generation system, the processing module 22 is further specifically used for:
[0258] Extracting the primitive wireframe to obtain a primitive wireframe edge set corresponding to the primitive wireframe;
[0259] The contour edge is calculated according to the primitive wireframe edge set, and the primitive wireframe edge set WEi is:
[0260] ;
[0261] in, is the sharp edge set of the i-th primitive, which is composed of the topological surface set F of the i-th primitive i The mid-plane type face is generated by directly extracting the boundary edges; is the contour edge set of the i-th primitive, which is composed of the topological face set F of the i-th primitive i It is calculated from the surface type of the face and the viewport normal vector N, where the viewport normal vector N is a known frustum parameter.
[0262] The processing module 22 is further used to: divide the two-dimensional viewport pixel map into a plurality of grid units, and collect the image metadata in each of the grid units to obtain a grid data set;
[0263] The visible edges of each of the grid units are calculated to hide the obstructed lines in the primitive wireframe.
[0264] The processing module 22 is further used to: perform method processing on the grid area corresponding to each of the grid units, and calculate the grid pixel map corresponding to each of the grid units;
[0265] Eliminating completely invisible primitives in the grid unit according to the depth value of the grid pixel map, and performing edge splitting processing on each of the grid units;
[0266] Visibility determination is performed according to the visibility facts after the edge splitting, and according to the result of the visibility determination, the visible edges are added to the corresponding primitive muted edge set according to the numbers of the corresponding primitives.
[0267] In the above three-dimensional visible edge generation system, the three-dimensional visible edge generation system further includes a conversion module 42, and the conversion module 42 is specifically used for:
[0268] Converting the three-dimensional visible edge into a corresponding two-dimensional visible edge by using the MVP transformation matrix;
[0269] The two-dimensional visible edges are exported to an engineering drawing.
[0270] A fourth embodiment of the present invention provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the three-dimensional visible edge generation method provided in the first embodiment or the second embodiment described above is implemented.
[0271] A fifth embodiment of the present invention provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for generating three-dimensional visible edges provided in the first embodiment or the second embodiment is implemented.
[0272] In summary, the three-dimensional visible edge generation method, system, computer and readable storage medium in the above embodiments of the present invention can process large-scale three-dimensional models and accurately generate corresponding three-dimensional visible edge images. At the same time, the processing efficiency is high, which can greatly reduce the processing cost of large three-dimensional models, effectively meet the usage needs of most users, and is conducive to large-scale promotion and use.
[0273] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0274] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0275] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0276] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0277] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0278] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for generating three-dimensional visible edges, characterized in that: The method comprises: Calculating the MVP transformation matrix and obtaining the primitive three-dimensional model to initialize the primitive data set of the primitive three-dimensional model; Remove primitives that are not in the view cone by frustum clipping, and extract primitive wireframes corresponding to primitives that exist in the view cone, wherein the primitive wireframes include sharp edges and contour edges, wherein the sharp edges are boundary edges of the primitive three-dimensional model, and the contour edges are the edges presented on the outermost side of the surface of the primitive three-dimensional model observed along a viewport direction; Hiding the obstructed lines in the primitive wireframe according to a preset algorithm, and repairing the broken edges of the primitive wireframe to generate three-dimensional visible edges; The MVP transformation matrix includes a model transformation matrix M, a viewport transformation matrix V and a projection transformation matrix P; Wherein, the MVP transformation matrix is: MVP=M*V*P; Wherein, the model transformation matrix M is: ; Among them, (n x , n y , n z ) is the viewport normal vector coordinate, (u x ,u y ,u z ) is the viewport upward vector coordinate, (v x , v y , v z ) is the viewport right direction vector coordinate, T=[t x , t y , t z ] is the translation component of the model transformation matrix M, and the translation component T is calculated by the following formula: ; Among them, (e x , e y , e z ) is the viewpoint coordinate; The viewport transformation matrix V is: ; Among them, W is the width of the viewport plane, H is the height of the viewport plane, and D is the depth of the viewing cone; The projection transformation matrix P is: ; Among them, w is the width of the viewport pixel map, and h is the height of the viewport pixel map; The step of removing the primitives that are not within the view frustum by clipping the view frustum comprises: Obtaining the cropping mark of each of the primitives; When the clipping mark is true, the primitive is removed, otherwise the primitive is retained. The clipping mark is: ; Among them, R is the viewport pixel map area, , (u, v) is any pixel in the viewport pixel map area, w is the viewport pixel map width, h is the viewport pixel map height; Ri is the two-dimensional projection area of the i-th primitive on the viewport plane, , where (u, v) is any pixel in the viewport pixel map area, X min The minimum horizontal coordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane is rounded, X max Y is the maximum horizontal coordinate of the projection point of the 8 vertices of the i-th primitive bounding box on the viewport plane. min Y is the minimum ordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane. max Round the maximum ordinate coordinate of the projection point of the eight vertices of the i-th primitive bounding box on the viewport plane.
2. The method for generating three-dimensional visible edges according to claim 1, characterized in that: The step of extracting the primitive wireframe corresponding to the primitive existing in the viewing cone comprises: Extracting the primitive wireframe to obtain a primitive wireframe edge set corresponding to the primitive wireframe; The contour edge is calculated according to the primitive wireframe edge set, and the primitive wireframe edge set WEi is: ; in, is the sharp edge set of the i-th primitive, which is composed of the topological surface set F of the i-th primitive i The mid-plane type face is generated by directly extracting the boundary edges; is the contour edge set of the i-th primitive, which is composed of the topological face set F of the i-th primitive i It is calculated from the surface type of the face and the viewport normal vector N, where the viewport normal vector N is a known frustum parameter.
3. The method for generating three-dimensional visible edges according to claim 1, characterized in that: The step of hiding the obscured lines in the primitive wireframe according to a preset algorithm comprises: Dividing the two-dimensional viewport pixel map into a plurality of grid units, and collecting the image metadata in each of the grid units to obtain a grid data set; The visible edges of each of the grid units are calculated to hide the obstructed lines in the primitive wireframe.
4. The method for generating three-dimensional visible edges according to claim 3, characterized in that: The step of calculating the visible edges of each of the grid units to hide the obscured lines in the primitive wireframe includes: Performing method processing on the grid area corresponding to each of the grid units, and calculating the grid pixel map corresponding to each of the grid units; Eliminating completely invisible primitives in the grid unit according to the depth value of the grid pixel map, and performing edge splitting processing on each of the grid units; Visibility determination is performed according to the visibility facts after the edge splitting, and according to the result of the visibility determination, the visible edges are added to the corresponding primitive muted edge set according to the numbers of the corresponding primitives.
5. The method for generating three-dimensional visible edges according to claim 1, characterized in that: After the step of hiding the obstructed lines in the primitive wireframe according to a preset algorithm and repairing the broken edges of the primitive wireframe to generate three-dimensional visible edges, the method includes: Converting the three-dimensional visible edge into a corresponding two-dimensional visible edge by using the MVP transformation matrix; The two-dimensional visible edges are exported to an engineering drawing.
6. A three-dimensional visible edge generation system, the system adopts the three-dimensional visible edge generation method according to claim 1, characterized in that: The system comprises: An initialization module, used to calculate the MVP transformation matrix and obtain a primitive three-dimensional model, so as to initialize a primitive data set of the primitive three-dimensional model; A processing module, used for removing primitives not in the view cone by frustum clipping, and extracting primitive wireframes corresponding to primitives existing in the view cone, wherein the primitive wireframes include sharp edges and contour edges, wherein the sharp edges are boundary edges of the primitive three-dimensional model, and the contour edges are edges presented at the outermost sides of the curved surface observed along a viewport direction of the primitive three-dimensional model; The generating module is used to hide the obstructed lines in the primitive wireframe according to a preset algorithm and to repair the broken edges of the primitive wireframe to generate three-dimensional visible edges.
7. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the three-dimensional visible edge generation method according to any one of claims 1 to 5 is implemented.
8. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the three-dimensional visible edge generation method as claimed in any one of claims 1 to 5 is implemented.
