A method for solving the contour of a closed unordered line segment group based on Boolean operations
By generating feature rectangles for disordered line segment groups and performing Boolean union operations, the problem of high time complexity of the disordered line segment group contour solution algorithm in the prior art is solved, and a more efficient solution process and lower computational complexity are achieved.
Patent Information
- Application Number
- CN202210049789.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2042-01-17
AI Technical Summary
The existing disordered line segment group contour solution algorithm has high time complexity and is difficult to efficiently process a large number of disordered line segments, resulting in slow solution speed and high computational complexity.
Using a Boolean operation method, a closed polygon outline is obtained by generating feature rectangles for unordered line segment groups and performing Boolean union operations.
While ensuring accuracy, it significantly improves the solution speed and reduces the calculation complexity, and reduces the algorithm time complexity to O(n), greatly improving the slice efficiency.
Smart Images

Figure CN114399598B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of computer-aided geometric design, and in particular to a method for solving the contour of a closed disordered line segment group based on Boolean operations. Background Art
[0002] The application of solving the polygonal contour of the end-to-end connected unordered line segment group in the plane is widely used in computer-aided geometric design, such as the slicing algorithm of 3D printing, the connection algorithm in laser nesting, etc. The most widely used geometric model format in industrial geometric algorithms is the STL format, that is, the discrete triangular patch model. The STL model simulates an approximate three-dimensional solid model by using a large number of irregular spatial triangulated patches. Therefore, in the process of geometric calculation, the model contour is often surrounded by a large number of disordered tiny line segments. If you want to obtain a usable directed closed contour curve, you need a related algorithm to process the enclosable unordered line segment group.
[0003] In the existing literature, there are three contour solving algorithms. The first one is an algorithm based on the topological information of the triangle face. First, the focus coordinates j1 and j2 of a target triangle face that intersects with the tangent plane are obtained, and then the next triangle face linked to it is found and the intersection is calculated again. This process is repeated and finally connected in sequence according to the focus order. The second one is an algorithm based on the geometric features of the model. By defining the "potential" and "energy" of the triangle face, the "level" and "class" are divided. This algorithm is applicable to limited occasions. The third one is an algorithm based on the geometric continuity of the model. Its core is to use the continuity of the STL model. The principle is similar to the first algorithm, but the disadvantage is that it is more difficult to process.
[0004] In summary, the above three slicing algorithms are difficult to solve and take a long time to solve. As the number of line segments increases, the time complexity of the above algorithms is close to O(n 2 ). Summary of the invention
[0005] The present invention provides a method for solving polygonal contours of a closed disordered line segment group based on Boolean operations. The method solves the polygonal contours of a group of disordered closed line segments in a plane, achieving better global efficiency while ensuring accuracy.
[0006] The purpose of the present invention is achieved through the following technical solutions:
[0007] A method for solving the contour of a closed unordered line segment group based on Boolean operations, the method specifically comprises the following steps:
[0008] S1: Input a group of scattered and disordered line segments in the plane;
[0009] S2: Draw the normal vector of each line segment at its two endpoints. The two normal vectors are in opposite directions and are in the same plane as the line segment.
[0010] S3: Translate each line segment by a small distance Δ in both directions along the normal vector, and construct a characteristic rectangle of the line segment with the two translated line segments as the length of the rectangle and twice the value of Δ as the width of the rectangle.
[0011] S4: Perform a Boolean union operation on the rectangles generated by all line segments.
[0012] S5: Select the inner contour or outer contour of the union as the contour of the closable unordered line segment group for filling.
[0013] Furthermore, the translation distance Δ of the line segment should be small enough to ensure that there is an intersection between adjacent characteristic rectangles.
[0014] Furthermore, after executing S4, select the offset contour obtained by offsetting the inner contour of the union outward by Δ or select the offset contour obtained by offsetting the outer contour of the union inward by Δ as the contour of the closable unordered line segment group for filling.
[0015] The beneficial effects of the present invention are as follows:
[0016] Compared with the traditional unordered scattered line segment connection algorithm, the method for solving the polygon contour of the closable unordered line segment group based on Boolean operations can obtain a directed closed polygon contour by generating several rectangles, avoiding the complex calculation of sorting the line segment group. It has the following advantages:
[0017] (1) There is no need to establish the topological link information of the unordered scattered line segment group;
[0018] (2) The solution speed is faster. This method avoids sorting the line segment group, reduces the calculation amount, and effectively improves the slicing efficiency.
[0019] (3) The time complexity of the algorithm is O(n), while the time complexity of the traditional algorithm that sorts the line segment group is O(n 2 ), and the complexity is greatly reduced.
[0020] (4) The method of the present invention can be used to solve the slicing contour after three-dimensional printing slicing, and has important applications in practical problems such as solving the connection path in laser nesting. Description of the Drawings
[0021] Figure 1 is the flow chart of the method for solving the contour of the closable unordered line segment group based on Boolean operations of the present invention;
[0022] Figure 2 is the schematic diagram of the three-dimensional slicing process of the STL model; among them, the left figure is the STL mesh model, the middle figure is the intersection of the cutting plane and the STL model; the right figure is the unordered line segment group obtained by slicing;
[0023] Figure 3 Schematic diagram for generating characteristic rectangles of line segment groups; among them, the upper right figure is a partial enlarged view of the disordered line segment group, the middle right figure is the normal vectors of each line segment; the lower right figure is the characteristic rectangles of each line segment produced.
[0024] Figure 4 Boolean union contour of the characteristic rectangles of the target line segment group; among them, the left figure is the characteristic rectangles of each line segment, the middle figure is the result after taking the union of the characteristic rectangles, and the right figure is the inner contour and outer contour of the generated target line segment group.
[0025] Figure 5 Target polygon connection contour of the line segment group
[0026] Figure 6 Schematic diagram of the application of the connected polygon of the line segment group in the subsequent slicing process. Specific implementation manner
[0027] The present invention will be described in detail below according to the accompanying drawings and preferred embodiments. The purpose and effect of the present invention will become more clear. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0028] The implementation steps of the present invention are as follows Figure 1 shown, including the following steps:
[0029] S1: Input a scattered and disordered line segment group in a plane, denoted as Vector <segment>{Seg 1 、Seg 2 、…、Seg n};
[0030] The set of scattered and disordered line segments belongs to the same plane, and the set of line segments can be connected end to end to form a closed polygon.
[0031] S2: At the two endpoints of each line segment, construct the normal vectors of the line segment, and the two normal vectors have opposite directions and are in the same plane as the line segment; denoted as {n 1 , n 2 , …, n k};
[0032] S3: Translate each line segment along the two directions of the normal vector by a small distance Δ respectively, and construct the characteristic rectangle of the line segment with the two translated line segments as the length of the rectangle and twice the value of Δ as the width of the rectangle;
[0033] To ensure the accuracy of the generated contour, the translation distance Δ of the line segment should be small enough, and at the same time, it is necessary to ensure that there is an intersection between the rectangles.
[0034] S4: Perform a Boolean union operation on the rectangles generated by all line segments;
[0035] S5: Select the inner contour or the outer contour of the union as the contour of the set of closable disordered line segments.
[0036] Since the translation distance Δ is small enough, the inner and outer contours of the rectangle union are not much different, and the required target contour can be selected according to the actual situation.
[0037] Delete the redundant parts of the target contour, and finally obtain a directed closed contour line. It is necessary to ensure that there are no redundant points and repeated intersection line segments in the obtained contour, and there are no problems of loop self-intersection and intersection in the finally generated closed contour.
[0038] This embodiment takes the three-dimensional slice of the three-dimensional printing STL model as a specific engineering application scenario. When performing an intersection operation between a plane and the STL model to obtain a set of closable disordered line segments, in order to generate the filling path of the processing area of this layer, it is necessary to convert the inner and outer contours from a set of line segments into polygons, as Figure 2 shown. The method for solving the contour of the set of closable disordered line segments based on Boolean operations in this embodiment includes the following steps:
[0039] (1) After the plane intersects with the STL model, obtain a contour model with a set of disordered line segments as the data structure, and its data structure can be expressed as: Vector <segment>{Seg 1 、Seg 2 、…、Seg n}, where the adjacent elements Seg i and Seg i+1 are not necessarily adjacent line segments in space. If a brute-force traversal algorithm is used, the space complexity of finding a polygon contour with head and tail connected is O(n 2 ).
[0040] (2) Construct the normal vectors of each line segment, denoted as {n 1 , n 2 , …, n k}, and this normal vector should be in the same plane as the line segment group. The line segment group Vector <segment>The normal vectors coplanar with the line segment group can be generated segment by segment. Each line segment can generate two normal vectors in opposite directions, as Figure 3 shown.
[0041] (3) Translate each line segment along the two directions of the normal vector by a small distance Δ respectively. Use the two translated line segments as the length of the rectangle and twice the value of Δ as the width of the rectangle to construct the characteristic rectangle of the line segment. The translation distance Δ of the line segment should be small enough to ensure the accuracy of the required contour, and at the same time, ensure that there is an intersection between the rectangles. The characteristic rectangle is as Figure 3 shown.
[0042] (4) Perform a Boolean union operation on the rectangle group generated by the line segment group to obtain the inner contour and outer contour of the target selected segment characteristic rectangle, as Figure 4 shown.
[0043] (5) Select the inner contour or outer contour of this union as the target polygon contour. Since the translation distance Δ is small enough, the inner and outer contours of the rectangle union are not very different, and the required target contour can be selected according to the actual situation.
[0044] (6) Delete the redundant parts outside the target contour, and ensure that there are no redundant points, repeated intersection line segments, and no problems of loop self-intersection and intersection in the finally generated closed contour. The final directed contour line is as Figure 5 shown. When the translation distance Δ meets the accuracy requirements, the polymorphic outer contour can be used as the filling area for 3D printing of the STL model. The filling path can be an annular offset path (as Figure 6 shown), or a zigzag path.
[0045] Those of ordinary skill in the art can understand that the above are only preferred examples of the invention and are not used to limit the invention. Although the invention has been described in detail with reference to the foregoing examples, for those skilled in the art, they can still modify the technical solutions recorded in the foregoing examples, or perform equivalent replacements for some of the technical features. Any modifications, equivalent replacements, etc. made within the spirit and principle of the invention shall be included within the protection scope of the invention.< / segment> < / segment> < / segment>
Claims
1. A method for solving the contour of a group of closable and disordered line segments based on Boolean operations, characterized in that, the application scenario of this method is the three-dimensional slicing of a three-dimensional printing STL model. When a plane intersects with the STL model, a group of closable and disordered line segments is obtained. In order to generate the filling path of the processing area of the layer where the closable and disordered line segments are located, the inner and outer contours need to be converted from the group of closable and disordered line segments obtained above into polygons. The method for solving the contour of a group of closable and disordered line segments based on Boolean operations specifically includes the following steps: S1: After the plane intersects with the STL model, a contour model with a disordered line segment group as the data structure is obtained; S2: Generate the normal vectors of each line segment, denoted as {n 1 , n 2 , …, n k}, and the normal vector should be in the same plane as the unordered line segment group; the unordered line segment group Vector generated by slicing <segment>Generate normal vectors coplanar with the disordered line segment group segment by segment, and generate two normal vectors in opposite directions for each line segment;< / segment> S3: Translate each line segment in two directions along the normal vector by a small distance , and use the two translated line segments as the length of the rectangle and twice the value as the width of the rectangle to construct the characteristic rectangle of the line segment; The distance by which the line segment is translated should be small enough to ensure the accuracy of the required contour, and at the same time ensure that there is an intersection between adjacent characteristic rectangles; S4: Perform a Boolean union operation on the characteristic rectangles generated by all line segments to obtain the inner contour and outer contour of the target line segment characteristic rectangle; S5: Select the inner contour or outer contour of the union as the target polygon contour, delete the redundant parts outside the target polygon contour, ensure that there are no redundant points, repeated intersection line segments, and no problems of loop self-intersection and intersection in the finally generated closed contour, and the finally obtained directed contour line is used as the contour of the group of closable and disordered line segments for filling.
Citation Information
Patent Citations
Three-dimensional printing variable-filling method based on contour features
CN109094013A
Hashtable-based scattered line segment quick connecting method
CN110356008A