Dxf-based complex sheet profile topology reconstruction method

By acquiring data from laser cutting nesting diagrams in DXF format, using spanning tree and cotree search for the minimum independent closed loop, removing borders and process lines, and calculating contour inclusion relationships, accurate parsing and part identification of complex laser cutting nesting diagrams are achieved, improving production efficiency and reducing labor costs.

CN116090126BActive Publication Date: 2026-03-27NORTHWESTERN POLYTECHNICAL UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-06
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies cannot effectively analyze complex laser cutting nesting diagrams, especially in accurately removing process parameters and identifying complex contours containing common edges, resulting in low laser cutting production efficiency and high labor costs.

Method used

By acquiring data from the laser cutting nesting diagram in DXF format, using the spanning tree and cotree search for the minimum independent closed loop, removing borders, lead-in lines and lead-out lines, calculating the contour inclusion relationship, and performing topology reconstruction to identify all parts.

Benefits of technology

It achieves accurate analysis of complex laser cutting nesting diagrams, identifies and extracts all parts, solves the problem that existing technologies cannot handle complex nesting diagrams, improves production efficiency and reduces labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116090126B_ABST
    Figure CN116090126B_ABST
Patent Text Reader

Abstract

The application discloses a complex sheet profile topology reconstruction method based on DXF, which firstly reads data information from a laser cutting layout sheet in DXF format, pre-processes the data through the degree characteristics of vertices, and can remove process parameters such as a frame, a lead-in line and a lead-out line. A spanning tree and a cotree are constructed, and on this basis, a minimum independent closed ring is searched, a closed profile in the layout sheet is extracted, and the profile includes a profile with a common edge. The containing relationship among all profiles and the profile depth are calculated, topology reconstruction is performed from the outside to the inside to construct a connectable profile group, the relationship between parts and parts is processed, and all parts contained in the layout sheet can be identified. For the complex laser cutting layout sheet in the DXF format, the method can accurately identify all parts contained in the layout sheet, and solves the problem that the prior art cannot parse such a complex layout sheet.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of laser cutting, and particularly relates to a DXF-based complex sheet profile topology reconstruction method. BACKGROUND

[0002] Laser cutting is a processing method for realizing plate cutting by using high energy density of focused laser beams, and has outstanding advantages such as high quality, high efficiency, high precision, energy saving and environmental protection, and has great market demand in many manufacturing fields such as aerospace, rail transit and automobile. The cutting machine on the current common laser cutting production line can realize automatic cutting, but the feeding and discharging in the production process still mostly adopt manual operation mode, the production efficiency is restricted, the normal capacity of the laser cutting machine is affected, and a large number of workers need to be arranged for each laser cutting machine, which consumes a large amount of labor cost. Based on the efficiency and cost of most enterprises, the feeding and discharging process of laser cutting begins to change to automation and intelligence, and obtaining the data of parts from the DXF format laser cutting layout drawing becomes the key, however, the laser cutting layout drawing generated by the CAD / CAM suite software contains process parameters such as frame, lead-in line and lead-out line, and there may be a nesting relationship between parts and parts, and the profile edges of some parts may also coincide if the common edge cutting mode is adopted.

[0003] The patent "Wu Yanming, Gao Xiong, Wu Zhejian, etc. A DXF-based sheet metal part automatic recognition and positioning method, CN113111458A[P]. 2021-07-13." relates to a DXF-based sheet metal part automatic recognition and positioning method, which can recognize and position irregular sheet metal parts on a metal plate. The patent "Cai Man, Han Houkuan, Zhou Quanqing. Method for automatic recognition of lead lines of DXF graphics based on numerical control machining system, CN106354096A[P]. 2017-01-25." relates to a method for automatic recognition of lead lines of DXF graphics based on a numerical control machining system, which judges whether there are lead-in lines and lead-out lines by sorting the graphics after the lead lines are merged with the original graphics, and identifying the length and distance of the first line and the final line after sorting.

[0004] Therefore, the DXF recognition method involved in the above method can recognize simple graphics and lead lines contained in the file, but cannot effectively remove the process parameters, and cannot accurately extract the closed profile, especially the profile containing common edges, and is not suitable for analyzing complex laser cutting layout drawings. SUMMARY

[0005] The purpose of the present application is to overcome the shortcomings of the prior art, and to provide a DXF-based complex sheet profile topology reconstruction method to solve the problem that it is difficult to accurately analyze complex laser cutting layout drawings in the prior art.

[0006] To achieve the above object, the present application adopts the following technical scheme to realize it: characterized in that it comprises the following steps:

[0007] Step 1, obtaining the layout data from the laser cutting layout in DXF format, storing the graphic element information in the layout data into the contour array and the adjacency list;

[0008] Step 2, judging whether the laser cutting layout has a rectangular frame according to the graphic element information, if so, removing the frame; at the same time, removing the leading line and the outgoing line by judging the degree of the vertex in the adjacency list;

[0009] Step 3, based on the adjacency list, finding the connected components and respectively establishing the generating tree and the corresponding residual tree, searching all the minimum independent closed rings through the generating tree and the residual tree, and storing all the minimum independent closed rings in the contour array;

[0010] Step 4, judging the containing relationship of all the contours in the contour array through the method of whether the point is in the polygon or not, calculating the depth of all the contours; according to the containing relationship of the contours, carrying out the topological reconstruction from outside to inside until all the contours are reconstructed, and the topological reconstruction ends.

[0011] Further improvement of the present application is that:

[0012] Preferably, in step 1, the process of storing the graphic element information in the layout data into the contour array and the adjacency list is:

[0013] Step 1.1, establishing the contour array to store the contour of the cutting plate and establishing the adjacency list to store the graph;

[0014] Step 1.2, reading a group code and the corresponding group value from the DXF file, if the group value is ENTITIES, then reading another group code and the corresponding group value, executing step 1.3; if the group value is EOF, it means that the file end has been reached, executing step 1.7; otherwise, repeating the step;

[0015] Step 1.3, if the group value is a circle, executing step 1.4; if the group value is a straight line, executing step 1.5; if the group value is an arc line, executing step 1.6; if the group value is ENDSEC, executing step 1.7;

[0016] Step 1.4, reading the data of a circle, converting the circle into a closed polygon set, storing the polygon set into the contour array, and then reading another group code and the corresponding group value, executing step 1.3;

[0017] Step 1.5, reading the data of a straight line, storing the straight line in the form of a line segment into the adjacency list, and then reading another group code and the corresponding group value, executing step 1.3;

[0018] Step 1.6, reading data of an arc, converting the arc into several line segments, storing the line segments into the adjacency list in turn, then reading a group code and corresponding group value, and executing step 1.3;

[0019] Step 1.7, reading the end of the flow, and closing the DXF file.

[0020] Preferably, in step 2, the process of judging whether the vertices of the corners can form a rectangle is as follows: Figure Four

[0021] (1) creating a boundary array to store boundary points, searching all vertices in the graph, and storing the four vertices of the left lower corner, the left upper corner, the right upper corner and the right lower corner into the boundary array in turn.

[0022] (2) judging whether the four boundary points are the four vertices of a rectangle;

[0023] (3) judging whether the four boundary points are connected at the head and tail to form a rectangle;

[0024] (4) if all conditions of step (2) and step (3) are met, the four vertices form the edge frame of the plate, traversing the boundary array, deleting the adjacent edges of each vertex, and setting the degree of the vertex to 0.

[0025] Preferably, in step (2), whether the four boundary points are the four vertices of a rectangle is judged by comparing the coordinate values of the four vertices.

[0026] Preferably, in step (3), whether the four boundary points can form a rectangle after being connected at the head and tail is judged by judging whether there is an adjacent edge between the four vertices.

[0027] Preferably, in step 2, the specific process of removing the lead-in line and the lead-out line is as follows:

[0028] (1) creating a queue to store the lead-in line and the lead-out line;

[0029] (2) traversing all vertices in the adjacency list, and inserting the vertices with a degree of 1 into the queue;

[0030] (3) if the queue is not empty, dequeuing the head element, deleting the edge to which the head element belongs, reducing the degree of the other end point of the edge by 1, and inserting the other end point into the queue if the degree of the other end point is also 1;

[0031] (4) if the queue is empty, the algorithm flow ends, otherwise, step (3) is executed.

[0032] Preferably, the specific process of step 3 is as follows:

[0033] (1) creating a visit array and a contour array;

[0034] ​(2) Create sets vertex, branch and cotree to store vertices, branches and cotrees respectively; create a queue Q and traverse the visit array, select a vertex that has not been visited and insert it into the queue Q, mark the vertex as visited;

[0035] (3) If the queue Q is not empty, take a vertex from it and add it to the vertex set, then traverse all the adjacent points of the vertex, insert the vertices that have not been visited into the queue Q and mark the vertices as visited, and add the corresponding adjacent edges into the branch set, repeat the step until the queue Q is empty;

[0036] (4) Traverse the vertex set, if there is an edge between two vertices and the edge is not in the branch set, the edge is a cotree, add the edge into the cotree set;

[0037] (5) If the cotree is not empty, for each edge in the cotree, find the shortest path between the endpoints u and v, and the shortest path plus the corresponding edge forms a closed loop;

[0038] (6) Compare the closed loops obtained in step (5) and select the smallest closed loop to add to the contour number array, add the corresponding cotree to the branch set, and delete the corresponding cotree from the cotree set, if the cotree is empty, execute step (7), otherwise execute step (5);

[0039] (7) If all vertices have been visited, the algorithm flow ends, otherwise execute step (2).

[0040] Preferably, in step (5), the shortest path between the two endpoints of the cotree is found by Dijkstra's algorithm.

[0041] Preferably, the specific process of judging the inclusion relationship of the contour is as follows:

[0042] (1) Judge the inclusion relationship between all contours;

[0043] (2) Calculate the depth of the contour in turn, and record the maximum depth as maxDepth;

[0044] (3) Topological reconstruction from outside to inside, first assign the initial search depth i as 0;

[0045] (4) Start from a contour with depth i and not searched, search all contours contained in the contour and with depth i+1, save the contour and the sub-contour as a connectable contour group, mark all contours in the connectable contour group as visited, repeat step (4) until all contours with depth i are searched;

[0046] (5) Let i = i + 2, if i < maxDepth, then execute step (4), otherwise the algorithm flow ends.

[0047] Preferably, in step (1), the specific process of judging the containing relationship between the contours is as follows:

[0048] If the contour A is contained in the contour B, all points on the contour A are inside the contour B; a ray is sent from any end point to infinity, the number of intersection points of the ray and the polygon is calculated, if the number of intersection points is even, it indicates that the point is outside the polygon, otherwise the point is inside the polygon.

[0049] Compared with the prior art, the present application has the following beneficial effects:

[0050] The present application discloses a complex sheet contour topology reconstruction method based on DXF, which firstly reads data information from a DXF format laser cutting layout drawing, pre-processes the data through the degree characteristics of the vertex, and can remove process parameters such as the frame, lead-in line and lead-out line. A spanning tree and a residual tree are constructed, and on this basis, a minimum independent closed ring is searched, and a closed contour in the layout drawing is extracted, including contours with common edges. The containing relationship between all contours and the contour depth are calculated, and topology reconstruction is performed from the outside to the inside to construct a connectable contour group, the relationship between parts and parts is processed, and all parts contained in the layout drawing can be identified. For a DXF format complex laser cutting layout drawing, the method can accurately identify all parts contained in the layout drawing, and solves the problem that such a complex layout drawing cannot be parsed in the prior art. BRIEF DESCRIPTION OF DRAWINGS

[0051] Figure 1 For a complex laser cutting layout drawing;

[0052] Figure 2 For a flowchart of reading a DXF file;

[0053] Figure 3 For a flowchart of removing the frame;

[0054] Figure 4 For a flowchart of removing the lead-in line;

[0055] Figure 5 For a flowchart of searching for a minimum independent closed ring;

[0056] Figure 6 For a schematic diagram of the relationship between a point and a polygon;

[0057] Figure 7 For a schematic diagram of the contour containing relationship;

[0058] Figure 8 For a schematic diagram of the hierarchy of the connectable contour group;

[0059] Figure 9 To construct the flowchart of the connectable contour group;

[0060] Figure 10 To show the program running result. DETAILED DESCRIPTION

[0061] The application will be further described below in conjunction with the drawings:

[0062] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application; the terms "first", "second", "third" are only for the purpose of description, and cannot be understood as indicating or implying relative importance; in addition, unless otherwise explicitly specified and limited, the terms "mounting", "connecting", "connecting" should be understood broadly, for example, it can be fixed connection, or detachable connection; it can be directly connected, or indirectly connected through an intermediate medium; it can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0063] The application discloses a DXF-based complex sheet contour topology reconstruction method, aiming at solving the problem that complex laser cutting layout diagrams cannot be accurately parsed in the prior art.

[0064] To achieve the above purpose, the application adopts the following technical scheme: A DXF-based complex sheet contour topology reconstruction method, characterized by comprising the following steps:

[0065] Step 1, open the DXF format laser cutting layout diagram, and read the data information contained therein. This step includes:

[0066] ①Establish a contour array polygons to store the contour of the sheet to be cut, establish an adjacency list adjacencyList to store the graph, and open the DXF file. The contour is composed of straight lines, arc lines and circles by default.

[0067] ②Read a group code and the corresponding group value from the DXF file. If the group value is ENTITIES, read another group code and the corresponding group value, and execute step ③; if the group value is EOF, it means that the file end has been reached, and step ⑦ is executed; otherwise, repeat the step.

[0068] If the group value is CIRCLE, step 4 is executed; if the group value is LINE, step 5 is executed; if the group value is ARC, step 6 is executed; if the group value is ENDSEC, step 7 is executed.

[0069] Step 4, read the data of a circle and convert the circle into a closed polygon set and store the closed polygon set into the contour array polygons, then read a group code and a corresponding group value, and execute step 3.

[0070] Step 5, read the data of a straight line and store the straight line in the form of a line segment into the adjacency list adjacencyList, then read a group code and a corresponding group value, and execute step 3.

[0071] Step 6, read the data of an arc and convert the arc into a plurality of line segments and store the line segments into the adjacency list adjacencyList in sequence, then read a group code and a corresponding group value, and execute step 3.

[0072] Step 7, read the end of the flow and close the DXF file.

[0073] Step 2, pre-process the data to remove the plate frame, lead-in line and lead-out line and other process information, so as to eliminate the interference on the subsequent extraction of the closed contour.

[0074] Step 2.1, removal of the plate frame, the plate frame represents the outer boundary of the plate, all two-dimensional parts should be within the frame, and the frame cannot be identified as a part, the raw materials involved in laser cutting are all rectangular thin plates, therefore it is necessary to judge whether the four boundary vertices can be connected end to end to form a rectangle. This step includes:

[0075] Step 1, create a boundary array boundary to store the boundary points, search all vertices in the adjacency list adjacencyList, and store the four vertices of the left lower corner, the left upper corner, the right upper corner and the right lower corner into the boundary array in sequence.

[0076] Step 2, judge whether the four boundary points are the four vertices of a rectangle: the four vertices of a rectangle should satisfy the following conditions: in the X direction, the X coordinates of boundary[0] and boundary[1] should be equal, and the X coordinates of boundary[2] and boundary[3] should be equal; in the Y direction, the Y coordinates of boundary[0] and boundary[3] should be equal, and the Y coordinates of boundary[1] and boundary[2] should be equal.

[0077] ③Judge whether the four boundary points are connected to form a rectangle: in the degree of the vertex, the degree of the four vertices in boundary must be 2, and the four vertices in boundary must be connected by edges.

[0078] ④If the four vertices in boundary satisfy all the conditions in ② and ③, these boundary points form the edge frame of the plate, and the boundary array needs to be traversed. For each vertex in it, delete all its adjacent edges, and set the degree of the vertex to 0. If four vertices satisfying the above conditions cannot be found, it means that the layout drawing has no edge frame.

[0079] Step 2.2, removal of lead-in and lead-out lines. In the laser cutting process, perforation is usually performed, and the perforated hole is usually larger than the cut slit. If the perforation is directly performed on the contour of the part, the original contour will be damaged, so the perforation must be performed far away from the contour of the part, and then connected to the contour track through a line, which is called lead-in line. After the laser cutting is completed, in order to make the part be cut down completely, and ensure the integrity and regularity of the part contour, a line needs to be continued to cut outside the part contour, which is called lead-out line. The lead-in line and the lead-out line are essentially composed of one or more line segments, of which the line segment farthest from the part contour path must not be closed, i.e. the degree of one end point of the line segment is 1. In the process of topological reconstruction, the lead-in line and the lead-out line will affect the extraction of the closed contour, so they need to be removed. This step includes:

[0080] ①Create a queue leads to store the lead-in and lead-out lines;

[0081] ②Traverse all vertices in the adjacency list adjacencyList, search for vertices with degree 1, these vertices are the starting point of the lead-in line or the end point of the lead-out line, insert them into the queue leads in turn;

[0082] ③If the queue leads is not empty, dequeue the head element, first delete the edge where it is located, and then reduce the degree of the other end point of the edge by 1. At this time, if the degree of the other end point is also 1, it means that the other end point is still not on the part contour, i.e. it is still one end of the lead-in line or the lead-out line, and it is inserted into the queue leads;

[0083] ④If the queue leads is empty, the algorithm flow ends; otherwise, step ③ is executed.

[0084] Step 3, build spanning tree and cotree to search all the minimum independent closed loops in the graph. Among them, the spanning tree is the minimal connected subgraph of the connected graph containing all the vertices in the graph, and the spanning tree is not unique. Different spanning trees can be obtained by traversing from different vertices. The cotree is a set composed of the remaining edges of the connected graph except the branches contained in the spanning tree, and each edge is a cotree branch. The closed loop is a closed contour composed of several line segments connected end to end, and the minimum independent closed loop meets the following three conditions: all closed loops are linearly independent; The number of edges contained is the least; If the number of edges is the same, the closed loop with the shortest length should be selected. This step includes:

[0085] ① Create a visit array to mark whether the vertices in the adjacency list adjacencyList are visited, and store the contours in the contour array polygons;

[0086] ② Create sets vertex, branch and cotree to store vertices, branches and cotree branches respectively, create a queue Q, traverse the visit array, select an unvisited vertex and insert it into the queue Q, and mark the point as visited;

[0087] ③ If the queue Q is not empty, take out a vertex from it, first add the vertex to the vertex set, then traverse all the adjacent points of the vertex, insert the unvisited vertices into the queue Q and mark the vertices as visited, and add the corresponding adjacent edges to the branch set. Repeat this step until the queue Q is empty;

[0088] ④ Traverse the vertex set, if there is an edge between two vertices and the edge is not in the branch set, then the edge is a cotree branch, add it to the cotree set;

[0089] ⑤ If the cotree is not empty, for each edge in the cotree, find the shortest path from u to v in branch using Dijkstra algorithm, and the shortest path plus the corresponding edge (u, v) gets a closed loop;

[0090] ⑥ Compare the closed loops obtained in step 5, select the one with the smallest perimeter as the current closed loop, add it to the contour array polygons, add its corresponding cotree branch to the branch set and delete it from the cotree set. If the cotree set is empty, execute step ⑦, otherwise execute step ⑤;

[0091] ⑦ If all vertices have been visited, the algorithm flow ends, otherwise execute step ②.

[0092] Through step 3, the remaining contours in the laser cutting layout diagram except circles are obtained, and all the contours are stored in the storage array.

[0093] Step 4, calculate the inclusion relationship between contours and the depth of the contours, and build the connectable contour group. The inclusion relationship between contours can be determined by whether a point is inside a polygon. The contours are divided into outer contours and inner contours, wherein the outer contour refers to the outermost contour or the contour whose number of contained contours is even; the inner contour refers to the contour whose number of contained contours is odd. The parent contour refers to the contour containing a certain contour, and the child contour refers to the contour contained by a certain contour. The depth of the contour is equal to the number of parent contours containing the contour, which represents the relative depth of the contour in all contours. The connectable contour group refers to a contour group consisting of an outer contour and the inner contour contained by the outer contour, which is the target part to be extracted. This step includes:

[0094] ①Calculate the inclusion relationship between all contours;

[0095] ②Calculate the depth of the contour in turn, and record the maximum depth as maxDepth;

[0096] ③From outside to inside, topological reconstruction is performed, and the initial search depth i is assigned as 0;

[0097] ④Starting from a contour with a depth of i and not searched, search all contours contained in the contour and with a depth of i+1, save the contour and the child contours as a connectable contour group, and mark all contours in the connectable contour group as visited. Repeat the step until all contours with a depth of i are searched;

[0098] ⑤Let i=i+2, if i<maxDepth, execute step ④, otherwise the algorithm flow ends.

[0099] The specific drawings and examples are further described below.

[0100] Example

[0101] Step 1, open the laser cutting layout in DXF format, and read the data information contained therein.

[0102] DXF is a file format for AutoCAD and other software for CAD data exchange, is a kind of marked data representation of all information contained. Its essence is composed of several groups, each group occupies two rows, the first line is the code of the group, the second line is the group value, the combination of the two represents the meaning and value of a data. The structure of the file is quite complex, a complete DXF file consists of seven sections (SECTION), each section starts with a line of group code 0 and a line of string SECTION, followed by a line of group code 2 and a line of string indicating the section name, the end of the section is started by a line of group code 0 and a line of string indicating the end of the section ENDSEC. In practical application, as long as the entity section (ENTITIES) is obtained, the section records the name, coordinate, line type and other meta information of each entity. Refer to the attached Figure 1 , the laser cutting discharge process only considers using arc (ARC), straight line (LINE), circle (CIRCLE) three simple meta, so only need to process these three meta in the reading process. Refer to the attached Figure 2 , the specific process of this step is as follows:

[0103] ①Establish the contour array polygons to store the contour, establish the adjacency list adjacencyList to store the graph, open the DXF file.

[0104] ②Read a group code and the corresponding group value from the DXF file, if the group value is ENTITIES, read another group code and the corresponding group value, execute step ③; if the group value is EOF, it means that the end of the file has been reached, execute step ⑦; otherwise, repeat this step.

[0105] ③If the group value is CIRCLE, the read meta is a circle, execute step ④; if the group value is LINE, the read meta is a straight line, execute step ⑤; if the group value is ARC, the read meta is an arc, execute step ⑥; if the group value is ENDSEC, it means that the end of the ENTITIES section has been read, execute step ⑦.

[0106] ④Read the group code and the corresponding group value from the DXF file in turn, until the group code is 0, execute step ③; in this process, the group codes 10 and 20 correspond to the X and Y coordinates of the center point, and the group code 40 corresponds to the radius, convert the circle to a closed polygon set and store it directly to the contour array polygons.

[0107] ⑤Read the group code and the corresponding group value from the DXF file in turn, until the group code is 0, execute step ③; in this process, the group codes 10 and 20 correspond to the X and Y coordinates of the starting point, and the group codes 11 and 21 correspond to the X and Y coordinates of the ending point, store the straight line in the form of line segment to the adjacency list adjacencyList.

[0108] ⑥Read the group code and corresponding group value from the DXF file in turn until the group code is 0, and execute step ③; in this process, the group code is 10 and 20, and the corresponding group value is the X coordinate and Y coordinate of the center point, respectively, the group code is 40, and the corresponding group value is the radius, the group code is 50 and 51, and the corresponding group value is the start angle and end angle, respectively, and the arc is converted into a plurality of line segments and stored in the adjacency list adjacencyList in turn.

[0109] ⑦Read the flow ends, and close the DXF file.

[0110] Step 2, pre-process the data, remove the plate frame, lead-in line and lead-out line and other process information, so as to eliminate the interference on the subsequent extraction of closed contour;

[0111] Step 2.1, removal of plate frame, the plate frame represents the outer boundary of the plate, all two-dimensional parts should be within the frame, and the frame cannot be identified as a part, the raw materials involved in laser cutting are all rectangular thin plates, so it is necessary to judge whether the four boundary vertices can be connected end to end to form a rectangle. Referring to the attached Figure 3 , the specific process of this step is as follows:

[0112] ①Create a boundary array boundary to store the boundary points, search all vertices in the adjacency list adjacencyList, and store the four vertices of the left lower corner, the left upper corner, the right upper corner and the right lower corner in the boundary array in turn.

[0113] ②Judge whether the four boundary points are the four vertices of a rectangle: the four vertices of a rectangle must satisfy the following conditions: in the X direction, the X coordinates of boundary[0] and boundary[1] are equal, and the X coordinates of boundary[2] and boundary[3] are equal; in the Y direction, the Y coordinates of boundary[0] and boundary[3] are equal, and the Y coordinates of boundary[1] and boundary[2] are equal.

[0114] ③Judge whether the four boundary points are connected end to end to form a rectangle: in the degree of the vertex, the degrees of the four vertices in the boundary are all 2, and at the same time, there are adjacent edges between boundary[0] and boundary[1], boundary[1] and boundary[2], boundary[2] and boundary[3], and boundary[3] and boundary[0].

[0115] (4) If the four vertices in boundary satisfy all the conditions in (2) and (3), these boundary points form the edge of the plate, and the boundary array needs to be traversed. For each vertex in it, delete all its adjacent edges, and set the degree of the vertex to 0.

[0116] Step 2.2, the removal of lead-in and lead-out lines. In the process of laser cutting, perforation is generally carried out, and the perforated hole is usually larger than the cut slit. If the perforation is directly carried out on the contour of the part, the original contour will be damaged, so the perforation must be carried out far away from the contour of the part, and then connected to the contour track through a line, which is called the lead-in line. After the laser cutting is completed, in order to make the part be cut down completely, and ensure the integrity and regularity of the part contour, a line of continuous cutting outside the part contour is needed, which is the lead-out line. The lead-in line and the lead-out line are essentially composed of one or more line segments, of which the line segment farthest from the part contour path must not be closed, i.e. one end of the line segment has a degree of 1. In the process of topological reconstruction, the lead-in line and the lead-out line will affect the extraction of the closed contour, so they need to be removed. Referring to the attached Figure 4 , the specific process of this step is as follows.

[0117] (1) Create a queue leads to store the lead-in line and the lead-out line;

[0118] (2) Traverse all vertices in the adjacency list adjacencyList, search for vertices with a degree of 1, which are the starting points of the lead-in line or the ending points of the lead-out line, and insert them into the queue leads in turn;

[0119] (3) If the queue leads is not empty, dequeue the head element, first delete the edge where it is located, and then reduce the degree of the other end point of the edge by 1. At this time, if the degree of the other end point is also 1, it means that the other end point is still not on the part contour, i.e. it is still one end of the lead-in line or the lead-out line, so it is inserted into the queue leads;

[0120] (4) If the queue leads is empty, the algorithm flow ends; otherwise, step (3) is executed.

[0121] Step 3, construct the spanning tree and the residual tree to search for all the smallest independent closed loops in the graph, and add them to the contour array polygons.

[0122] Spanning tree and spanning forest: a spanning subgraph T of a graph G is called a spanning tree of G if T is a tree; if T is a forest, it is called a spanning forest of G. In a connected graph, the spanning tree is the smallest connected subgraph of the graph that contains all the vertices of the graph. Usually, there is not a unique spanning tree, and different spanning trees can be obtained by traversing from different vertices. A non-connected graph can be divided into multiple connected components, and the spanning trees of these connected components constitute the spanning forest of the non-connected graph.

[0123] The cotree of T is G[E(G)-E(T)]. .

[0124] A closed loop is a closed contour formed by connecting the ends of several line segments, and a minimum independent closed loop satisfies the following three conditions: all closed loops are linearly independent; the number of edges contained is the least; if the number of edges is the same, the closed loop with the shortest length should be selected. In a spanning tree, there are several cotree branches. For one of the cotree branches, there can be several paths from the start point to the end point, and all of them can form a closed loop with the cotree branch. A minimum closed loop needs to be selected from all the paths to form a minimum closed loop. The shortest path from one point to another point in the graph belongs to the single-source shortest path problem, and a suitable algorithm can be selected from Dijkstra algorithm, Bellman-Ford algorithm and SPFA algorithm to solve the problem. The Dijkstra algorithm is used to calculate the shortest path between the two end points of the cotree branch. Each cotree branch in the cotree corresponds to a minimum closed loop, and the order of their addition has a direct impact on the result. A secondary comparison of the set of minimum independent closed loops is needed to select the cotree branch corresponding to the minimum closed loop.

[0125] The common edge condition in the laser cutting layout is relatively complex. The non-connected graph is first decomposed into multiple connected components, and the connected contours form a connected component. However, not all contours in the layout are connected, so there can be several connected components. For each connected component, a spanning tree and a cotree are constructed, and a search is performed based on this to find all closed contours. Then, for each connected component, a spanning tree and a cotree are constructed, and finally, the minimum independent closed loop is found in turn. Referring to the attached drawings, the specific process of this step is as follows: Figure 5

[0126] ① Create a visit array to mark whether the vertices in the adjacency list adjacencyList have been visited, and create a contour array polygons to store the contours;

[0127] ② Create sets vertex, branch and cotree to store vertices, tree branches and cotree branches respectively, create a queue Q, traverse the visit array, select an unvisited vertex and insert it into the queue Q, and mark it as visited;

[0128] ​③If the queue Q is not empty, take a vertex from it, first add the vertex to the vertex set, then traverse all the adjacent points of the vertex, insert the unvisited vertex into the queue Q and mark the vertex as visited, while adding the corresponding adjacent edge to the branch set, repeat the step until the queue Q is empty;

[0129] ④Traverse the vertex set, if there is an edge between two vertices and the edge is not in the branch set, then the edge is the cotree, add it to the cotree set;

[0130] ⑤If the cotree is not empty, for each edge in the cotree, find the shortest path from u to v in the branch by Dijkstra algorithm, the shortest path plus the corresponding edge (u, v) gets the closed loop;

[0131] ⑥Compare the closed loops obtained in step ⑤, select the one with the smallest perimeter as the current closed loop, add it to the polygon array polygons, add its corresponding cotree to the branch set and delete it from the cotree set, if the cotree is empty, execute step ⑦, otherwise execute step ⑤;

[0132] ⑦If all vertices are visited, the algorithm flow ends, otherwise execute step ②.

[0133] Step 4, calculate the inclusion relationship between the contours and the depth of the contours, and construct the connectable contour group.

[0134] Through the above steps, all the contours in the DXF format laser cutting layout drawing can be obtained, then the inclusion relationship between all the contours can be calculated, which can be judged by whether the point is in the polygon or not, if contour A is contained in contour B, then all the points on contour A are inside contour B. From a certain endpoint, a ray is sent to infinity, the number of intersection points of the ray and the polygon is calculated, if the number of intersection points is even, it means that the point is outside the polygon, otherwise the point is inside the polygon, the relationship between the point and the polygon can be judged by the following flow:

[0135] ①Build a safety rectangle: refer to Fig. 1 Figure 6 (a), traverse all the vertices of the polygon, count the maximum and minimum x, y values, thus the coordinates of the four vertices of the safety rectangle are constructed, all the points outside the safety rectangle can be directly judged as not inside the polygon.

[0136] ②Safety area of line segment: refer to Fig. 2 Figure 6(b), for line segment AB, the upper of L1, the lower of L2 and the right of line segment AC (assuming the ray is horizontal right) are all safe areas, that is, when the point is in these areas, it will never intersect with line segment AB, so it can be determined whether it is in the safe area first, if not, then continue to calculate whether there is an intersection, if in the safe area, it can be immediately concluded that there is no intersection.

[0137] ③When the point to be determined is neither in the safe rectangle nor in the safe area of the line segment, it is necessary to traverse all the edges of the polygon and sequentially determine whether there is an intersection with the ray. There are some special cases in the calculation, please refer to the attached Figure 6 (c), at this time, the upper vertex and the lower vertex of the line segment must be distinguished, only when the ray passes through the upper vertex of the line segment, it is considered to have an intersection; when the ray passes through the lower vertex of the line segment, the ray and the line segment have no intersection.

[0138] The contours are divided into outer contours and inner contours, where the outer contour refers to the outermost contour or the contour whose number of contained contours is even; the inner contour refers to the contour whose number of contained contours is odd. The parent contour refers to the contour containing a certain contour, and the child contour refers to the contour contained by a certain contour. The depth of the contour is equal to the number of parent contours containing the contour, representing the relative depth of the contour in all contours. The connectable contour group refers to a contour group composed of a certain outer contour and the next layer of inner contours contained by it, which is the target part to be extracted.

[0139] Refer to the attached Figure 7 , there are 7 contours in the laser cutting layout, among which C1 is the outermost contour without any parent contour, with a depth of 0, belonging to the outer contour; the parent contours of C2, C3, C8 and C9 are all C1, with a depth of 1, belonging to the inner contour; the parent contours of C4 and C5 are C1 and C2, with a depth of 2, belonging to the outer contour; the parent contours of C6 and C7 are C4, C2 and C1, and C5, C3 and C1, with a depth of 3, belonging to the inner contour.

[0140] Refer to the attached Figure 8 , the inclusion relationship among all contours can be represented by a hierarchical structure, where the connectable contour group refers to a contour group composed of a certain outer contour and the next layer of inner contours contained by it, therefore, C1, C2, C3, C8 and C9 constitute a connectable contour group, C4 and C6 constitute a connectable contour group, and C5 and C7 constitute a connectable contour group, representing three independent parts respectively.

[0141] Refer to the attached Figure 9 , the specific process of this step is as follows:

[0142] ① Calculate the inclusion relationship among all contours;

[0143] ②Calculate the depth of the contour in turn, and record the maximum depth as maxDepth;

[0144] ③From outside to inside, assign the initial search depth i as 0;

[0145] ④From a contour with depth i and not searched, search all contours with depth i+1 contained in the contour, save the contour and the sub-contours as a group of connectable contours, mark all contours in the group of connectable contours as visited, repeat the step until all contours with depth i are searched;

[0146] ⑤Let i=i+2, if i<maxDepth, execute step ④, otherwise the algorithm flow ends.

[0147] The method is verified by using C# to write a program, refer to the attached Figure 10 For a complex DXF format laser cutting layout, the method can read the DXF file, remove the process parameters, find the closed contour and build the group of connectable contours, and finally accurately identify all parts in the drawing, which has great significance for actual industrial manufacturing needs.

[0148] The above only describes the preferred embodiments of the present application and is not intended to limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for topological reconstruction of complex thin plate contours based on DXF, characterized in that, Includes the following steps: Step 1: Obtain the layout data from the laser cutting layout diagram in DXF format, and store the graphic element information in the layout data into the contour array and the adjacency list; Step 2: Determine whether there is a rectangular border in the laser cutting layout based on the element information. If so, remove the border. At the same time, remove the lead-in and lead-out lines by judging the degree of the vertices in the adjacency list. Step 3: Based on the adjacency list, find the connected components and build the spanning tree and corresponding cotree respectively. Search for all the minimum independent closed loops through the spanning tree and cotree, and store all the minimum independent closed loops in the contour array. The specific process of step 3 is as follows: (1) Create a visit array and a contour array; (2) Create sets vertex, branch and cotree to store vertices, branches and cotrees respectively; create queue Q, traverse the visit array, select unvisited vertices and insert them into queue Q, and mark the point as visited; (3) If queue Q is not empty, take out a vertex from it and add it to the vertex set. Then, traverse all the adjacent vertices of the vertex, insert the unvisited vertex into queue Q and mark the vertex as visited. At the same time, add the corresponding adjacent edge to the branch set. Repeat this step until queue Q is empty. (4) Traverse the vertex set. If there is an edge between two vertices and the edge is not in the branch set, then the edge is a cotree and add the edge to the cotree set. (5) If cotree is not an empty set, for each edge in cotree, find the shortest path between u and v, and add the corresponding edge to the shortest path to obtain a closed loop. (6) Compare the closed loops obtained in step (5), select the smallest closed loop and add it to the outline number array, add the corresponding branch of the smallest closed loop to the branch set, and delete the corresponding branch from the cotree set. If the cotree is an empty set, execute step (7); otherwise, execute step (5). (7) If all vertices have been visited, the algorithm process ends; otherwise, proceed to step (2). Step 4: Determine the containment relationship of all contours in the contour array by checking whether a point is inside a polygon, and calculate the depth of all contours; based on the containment relationship of the contours, perform topological reconstruction from the outside to the inside until all contours are reconstructed, and the topological reconstruction ends.

2. The method for reconstructing the topology of complex thin plates based on DXF according to claim 1, characterized in that, In step 1, the process of storing the graphic element information in the layout data into the contour array and the adjacency list is as follows: Step 1.1: Create a contour array to store the contours of the sheet metal to be cut, and create an adjacency list to store the graph. Step 1.2: Read a group code and its corresponding group value from the DXF file. If the group value is ENTITIES, read another group code and its corresponding group value and proceed to step 1.

3. If the group value is EOF, it means the end of the file has been reached, and proceed to step 1.

7. Otherwise, repeat this step. Step 1.3: If the group value is a circle, proceed to step 1.4; if the group value is a line, proceed to step 1.5; if the group value is an arc, proceed to step 1.6; if the group value is ENDSEC, proceed to step 1.

7. Step 1.4: Read the data of a circle, convert the circle into a closed set of polygons, store the set of polygons in the contour array, then read a group code and the corresponding group value, and execute step 1.3; Step 1.5: Read the data of a straight line, store the straight line in the adjacency list as a line segment, then read a group key and the corresponding group value, and execute step 1.3; Step 1.6: Read the data of an arc, convert the arc into several line segments, store the line segments in the adjacency list in sequence, then read a group key and the corresponding group value, and execute step 1.3; Step 1.7: The reading process ends; close the DXF file.

3. The method for topological reconstruction of complex thin plate contours based on DXF according to claim 1, characterized in that, In step 2, the process of determining whether the four corner vertices of the laser cutting layout can form a rectangle is as follows: (1) Create a boundary array to store boundary points. Search all vertices in the graph and store the four vertices at the bottom left, top left, top right, and bottom right in sequence into the boundary array. (2) Determine whether the four boundary points are the four vertices of a rectangle; (3) Determine whether the four boundary points are connected end to end to form a rectangle; (4) If all the conditions of steps (2) and (3) are met at the same time, the four vertices form the board border. Traverse the boundary array, delete the adjacent edges of each vertex, and set the degree of the vertex to 0.

4. The method for reconstructing the topology of complex thin plates based on DXF according to claim 3, characterized in that, In step (2), the coordinate values ​​of the four vertices are compared to determine whether the four boundary points are rectangles.

5. The method for reconstructing the topology of complex thin plates based on DXF according to claim 3, characterized in that, In step (3), it is determined whether a rectangle can be formed by connecting the four boundary points end to end by judging whether there are adjacent edges between the four vertices.

6. The method for reconstructing the topology of complex thin plates based on DXF according to claim 1, characterized in that, In step 2, the specific process of removing the lead-in and lead-out wires is as follows: (1) Create queue storage input and output lines; (2) Traverse all vertices in the adjacency list and insert vertices with a degree of 1 into the queue; (3) If the queue is not empty, dequeue the head element, delete the edge to which the head element belongs, and decrement the degree of the other endpoint of the edge by 1. If the degree of the other endpoint is also 1, insert the other endpoint into the queue. (4) If the queue is empty, the algorithm process ends; otherwise, step (3) is executed.

7. A method for reconstructing the topology of complex thin plates based on DXF according to claim 6, characterized in that, In step (5), the shortest path between the two endpoints of the remaining branch is found using Dijkstra's algorithm.

8. The method for reconstructing the topology of complex thin plates based on DXF according to claim 1, characterized in that, The specific process for determining the containment relationship of contours is as follows: (1) Determine the containment relationship between all contours; (2) Calculate the depth of the contours sequentially, and record the maximum depth as maxDepth; (3) Perform topology reconstruction from the outside to the inside, first setting the initial search depth i to 0; (4) Starting from a contour with depth i that has not been searched, search for all contours contained within the contour with depth i+1, save the contour and its sub-contours as a group of connectable contours, mark all contours in the group of connectable contours as visited, and repeat step (4) until all contours with depth i have been searched. (5) Let i = i + 2. If i < maxDepth, then execute step (4); otherwise, the algorithm process ends.

9. A method for reconstructing the topology of complex thin plates based on DXF according to claim 8, characterized in that, In step (1), the specific process of determining the containment relationship between contours is as follows: If contour A is contained within contour B, then all points on contour A are inside contour B; radiate a ray from any endpoint to infinity, and calculate the number of intersections between the ray and the polygon. If the number of intersections is even, then the point is outside the polygon; otherwise, the point is inside the polygon.

Citation Information

Patent Citations

  • Guide line automatic recognition method of DXF (drawing exchange format) graph on basis of digital control processing system

    CN106354096A

  • CAM (computer-aided manufacturing) system of high-power thick-plate numerical control laser cutting machine and method

    CN103389683A

  • Raster vectorization system based on hierarchical boundary-topology search model

    CN103838829A