A large-scale contour hierarchy reconstruction method and storage medium

By dividing the canvas into grid cells and performing local Boolean operations within each grid, classifying and querying global parent nodes, the problem of high computational complexity and difficulty in ensuring the correctness of hierarchical relationships in large-scale contour processing is solved, and efficient global multi-level tree reconstruction is achieved.

CN123160699APending Publication Date: 2026-11-24GOVION TECHNOLOGY (SUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611665595.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-27
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing technologies suffer from high computational complexity and difficulty in ensuring the correctness of global hierarchical relationships in large-scale contour processing. Especially when there are hundreds of thousands or even millions of contours, existing solutions are unable to meet the requirements of real-time processing and there is a risk of inconsistent results.

Method used

The canvas is divided into multiple grid cells. A local Boolean union operation is performed within each grid cell. Contour nodes are classified as cross-grid, grid root, and grid sub-contour. The global parent node is determined by a global skeleton multi-level tree and querying the nearest edge, generating a complete global multi-level tree.

Benefits of technology

It reduces the computational cost of a single operation, decouples cross-mesh contours from internal contours, preserves global hierarchical relationships, and improves the efficiency and accuracy of large-scale contour processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123160699A_ABST
    Figure CN123160699A_ABST
Patent Text Reader

Abstract

This application discloses a method and storage medium for large-scale contour hierarchical structure reconstruction. The method includes: dividing a canvas containing an input contour set into multiple grid cells; generating a local multi-level tree corresponding to each grid cell; classifying contour nodes in each local multi-level tree into cross-grid contours, intra-grid root contours, and intra-grid sub-contours; performing a Boolean union operation on the cross-grid contours in each grid cell to generate a global skeleton multi-level tree; determining the global parent node for each intra-grid root contour; assigning the global node corresponding to the local parent node of each intra-grid sub-contour as its global parent node; and assembling the global skeleton multi-level tree, the intra-grid root contours, and the intra-grid sub-contours into a global multi-level tree based on the global parent node relationships of each contour node. The solution of this application improves the processing efficiency of large-scale contours while ensuring the correctness of the global hierarchical relationship.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application generally relates to the field of data processing technology. More specifically, this application relates to a method for large-scale contour hierarchy reconstruction and a computer-readable storage medium. Background Technology

[0002] In fields such as printed circuit board manufacturing, computer-aided design and manufacturing systems, and vector graphics processing, it is often necessary to perform Boolean operations on a large number of closed contours to determine the nesting, intersection, and containment relationships between contours, ultimately constructing a multi-level tree that accurately reflects the hierarchical nesting structure from outer contours to holes to islands. With the ever-increasing number of contours, improving processing efficiency while ensuring the correctness of hierarchical relationships has become a pressing technical problem in this field.

[0003] Existing technologies primarily employ global Boolean merging or spatial divide-and-conquer schemes. The global Boolean merging scheme directly inputs all contours into the scanline engine to perform a global Boolean union operation, outputting a complete multi-level tree. While accurate and algorithmically mature, when the number of contours reaches hundreds of thousands or even millions, the computational complexity of global sorting and scanning becomes high, leading to a sharp increase in time and memory overhead, making it difficult to meet the demands of large-scale real-time processing. The spatial divide-and-conquer scheme reduces the computational load per operation by dividing the canvas into several grids and performing local Boolean merging independently within each grid. However, this scheme faces the fundamental challenge of correctly merging the various local multi-level trees into a global multi-level tree. Some contours span multiple grids and are processed repeatedly in the local merging of different grids, posing a risk of inconsistent results. Contours located only within a single grid may have their correct global parent node located in another grid; simple local merging cannot establish such cross-grid hierarchical connections. Directly concatenating the local results would destroy the nested semantics of the multi-level tree, causing the filling rules to fail. Therefore, existing technologies face a difficult trade-off between efficient processing of large-scale contours and the correctness of global hierarchical relationships.

[0004] In view of this, there is an urgent need to provide a solution for large-scale contour hierarchy reconstruction, so as to improve the processing efficiency of large-scale contours while ensuring the correctness of global hierarchical relationships. Summary of the Invention

[0005] In order to at least address one or more of the technical problems mentioned above, this application proposes a scheme for large-scale contour hierarchy reconstruction in several aspects.

[0006] In a first aspect, this application provides a method for large-scale contour hierarchy reconstruction, comprising: Divide the canvas containing the set of input contours into multiple grid cells; For each grid cell, collect the contours that intersect with that grid cell and perform a Boolean union operation on the collected contours to generate a local multi-level tree corresponding to that grid cell. Based on whether the bounding box of the contour is completely located inside the corresponding grid cell and the hierarchical relationship of the contour in the local multi-level tree, the contour nodes in each local multi-level tree are classified into cross-grid contours, grid-intra-root contours, and grid-intra-sub-contours. After aggregating the cross-grid contours in each grid cell, a Boolean union operation is performed to generate a global skeleton multi-level tree. For each root contour within a grid, a query point is extracted from that root contour. In the global skeleton multi-level tree, the contour edge with the closest horizontal distance to the query point is queried along the horizontal direction. Based on the query result, the global parent node of the root contour within the grid is determined. For each sub-contour within a grid, the parent-child chain of its local multi-level tree is propagated from top to bottom, with the global node corresponding to its local parent node as its global parent node. Based on the global parent node relationship of each contour node, the global skeleton multi-level tree, the root contours in each grid and the sub-contours in each grid are assembled into a global multi-level tree.

[0007] In some embodiments, dividing the canvas containing the set of input contours into multiple grid cells includes: The size of the grid cell is determined based on the total number and distribution density of the input contours, so that the proportion of the number of cross-grid contours to the total number of input contours is lower than a preset proportion threshold.

[0008] In some embodiments, the contour nodes in each local multi-level tree are classified into cross-mesh contours, in-mesh root contours, and in-mesh sub-contours, including: Contour nodes whose bounding boxes are not completely located inside the corresponding mesh cells are classified as cross-mesh contours; Contour nodes whose bounding boxes are completely located inside the corresponding mesh cells and are root nodes in the local multi-level tree or whose parent nodes are cross-mesh contours are classified as the in-mesh root contours. Contour nodes whose bounding boxes are completely located inside the corresponding mesh cells and do not belong to the root contour within the mesh are classified as the sub-contours within the mesh.

[0009] In some embodiments, after generating the global skeleton multi-level tree, the method further includes: A depth-first traversal is performed on the global skeleton multi-level tree, and the global depth of each contour node is recorded, with the global depth increasing layer by layer from the root node as 0.

[0010] In some embodiments, determining the global parent node of the root contour within the grid based on the query results includes: When a contour edge is found, the contour to which the contour edge belongs is determined as the adjacent contour. Based on the parity comparison between the depth of the root contour in the local multi-level tree and the depth of the adjacent contour in the global skeleton multi-level tree, the global parent node of the root contour in the mesh is determined. When no contour edge is found, the root contour within the grid is determined as the root node of the global multi-level tree.

[0011] In some embodiments, the global parent node of the root profile within the mesh is determined based on a parity comparison between the depth of the root profile within the mesh in the local multi-level tree and the depth of the adjacent profile in the global skeleton multi-level tree, including: If the parity of the depth of the root contour within the mesh in the local multi-level tree is the same as the parity of the depth of the adjacent contour in the global skeleton multi-level tree, then the global parent node of the root contour within the mesh is determined as the parent node of the adjacent contour. If the parity of the two is different, then the global parent node of the root contour within the mesh is determined as the adjacent contour.

[0012] In some embodiments, extracting query points from the root contour within the grid includes: Extract the leftmost point of the root contour within the grid as the query point; When multiple vertices have the same minimum x-coordinate, select the vertex whose y-coordinate is the median as the query point.

[0013] In some embodiments, querying the contour edge with the nearest horizontal distance to the query point along the horizontal direction in the global skeleton multi-level tree includes: Extract the valley vertices of each contour in the global skeleton multi-level tree and arrange them in ascending order of their ordinates. The valley vertices are the vertices on the contour whose ordinates are local minima. The scan line is advanced along the increasing direction of the vertical coordinate, and an active edge list and a dynamic expiration pile are maintained. The active edge list records the contour edges that intersect with the current scan line and is arranged in ascending order according to the horizontal coordinate of each contour edge at the current scan line. The dynamic expiration pile records the vertical coordinate of the upper endpoint of each contour edge in the current active edge list. As the scan line advances to the ordinate of the query point, a binary search is used in the list of active edges to determine the contour edge that is horizontally closest to the query point.

[0014] In some embodiments, each active edge in the active edge list records the following information: the lower and upper endpoints of the edge segment, the reciprocal of the slope of the edge segment, the association information of the upper endpoint of the edge segment in the contour vertex chain, and the travel direction identifier along the contour vertex chain; and Advance the scan line along the increasing direction of the vertical axis and maintain the list of active edges, including: When the scan line advances to the ordinate of the valley bottom vertex, the descending edge and the ascending edge are extracted from the valley bottom vertex along the predecessor and successor directions of the contour vertex chain, respectively. After skipping the continuous horizontal segments, the extracted non-horizontal edges are inserted into the active edge list, where horizontal edges are not included in the active edge list. Arrange the query points in ascending order of their ordinates to form a query point sequence, and arrange the valley vertices in ascending order of their ordinates to form a valley vertex sequence. In each round, take the smaller ordinate of the current query point sequence and the current valley vertex sequence as the target ordinate, and alternately process the valley vertex edge addition event and the query point query event. Before processing the event corresponding to the target ordinate, pop out contour edges whose upper endpoint ordinate is less than the target ordinate in batches through a dynamic expiration heap. For the popped contour edges, skip the subsequent non-horizontal segments whose upper endpoint ordinate is still less than the target ordinate continuously along its travel direction in the contour vertex chain until a valid segment with an upper endpoint ordinate not less than the target ordinate is found or the contour edge is removed from the active edge list.

[0015] In a second aspect, this application provides a computer-readable storage medium storing program instructions for large-scale contour hierarchy reconstruction, which, when executed by a processor, implement the large-scale contour hierarchy reconstruction method described above.

[0016] Using the above-described scheme for large-scale contour hierarchy reconstruction, this embodiment divides the canvas into multiple grid cells and performs local Boolean union operations independently within each grid cell, decomposing the global large-scale Boolean merging into multiple local small-scale operations. This reduces the computational load of a single operation, and the local operations of each grid cell are independent of each other, facilitating parallel execution. By classifying contour nodes into cross-grid contours, in-grid root contours, and in-grid sub-contours, decoupling cross-grid contours from internal contours is achieved, facilitating differentiated processing. By aggregating cross-grid contours and performing a global Boolean union operation to generate a global skeleton multi-level tree, the hierarchical relationship of cross-grid contours in the global scope is preserved, and the cross-grid... The number of grid contours is usually much smaller than the total number of contours, and the computational cost of global merging is controllable. By querying the contour edge with the horizontal distance to the root contour in the grid in the global skeleton multi-level tree and determining its global parent node based on the query result, a global hierarchical connection between internal contours and cross-grid contours is established with low computational cost, avoiding global reordering of all contours. By making the sub-contours in the grid diffuse from top to bottom along the parent-child chain of the local multi-level tree to determine the global parent node, the internal hierarchical relationship determined during local merging is reused, without the need for additional geometric queries. Finally, a complete global multi-level tree is obtained through global assembly, which improves the processing efficiency of large-scale contours while ensuring the correctness of the global hierarchical relationship. Attached Figure Description

[0017] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, and the same or corresponding reference numerals denote the same or corresponding parts, wherein: Figure 1 An exemplary flowchart of a large-scale contour hierarchy reconstruction method according to an embodiment of this application is shown; Figure 2 A schematic diagram showing the intersection of the grid division and the contour is shown; Figure 3 A schematic diagram of a local multi-level tree and a three-level classification is shown; Figure 4 A schematic diagram of nearest edge query and parity determination is shown; Figure 5 A schematic diagram of global multi-level tree assembly is shown; Figure 6 An exemplary flowchart of the query for the nearest contour edge operation according to an embodiment of this application is shown; Figure 7 An exemplary structural block diagram of a large-scale contour hierarchy reconstruction apparatus according to an embodiment of this application is shown; Figure 8 An exemplary structural block diagram of an electronic device according to an embodiment of this application is shown. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0019] It should be understood that the terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0020] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0021] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0022] The specific embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0023] Figure 1 An exemplary flowchart of a large-scale contour hierarchy reconstruction method 100 according to an embodiment of this application is shown. It is understood that the method 100 can run on general-purpose computing devices, including but not limited to servers, workstations, personal computers, embedded processors, etc. At the software level, the method can be integrated into printed circuit board computer-aided manufacturing software, computer-aided design and manufacturing systems, vector graphics processors, or electronic design automation tools.

[0024] like Figure 1 As shown, in step S101, the canvas containing the input contour set is divided into multiple grid cells.

[0025] Specifically, firstly, the union of the bounding boxes of all input contours is obtained, and the canvas extent is calculated. Then, the size of the grid cells is determined based on the total number and distribution density of the input contours, ensuring that the proportion of cross-grid contours to the total number of input contours is below a preset proportion threshold. In this embodiment, the contours in the input contour set can be closed contours, such as polygonal contours. The preset proportion threshold can be, for example, 5% to 10%, or it can be set based on at least one of the total number of contours, distribution density, and processing resources.

[0026] As an example, assume the canvas ranges in the horizontal direction as follows: The range in the vertical axis direction is Based on the total number and distribution density of the input contours, the canvas is evenly divided into... List A rectangular grid cell in a row, denoted as ,in , Based on this, the first The bounding box of each grid cell has a range in the horizontal direction of... The range in the vertical axis direction is ,in , .

[0027] The principle for selecting mesh cell size is to ensure that, after local merging, the proportion of contours identified as crossing mesh boundaries is below a certain percentage, such as 5% to 10%. This proportion reflects the degree to which contours cross mesh boundaries: a lower proportion indicates that most contours fall entirely within a single mesh, allowing for direct local merging to obtain the correct local hierarchy, requiring only subsequent global merging for a small number of contours crossing mesh boundaries; a higher proportion means that a large number of contours cross mesh boundaries, significantly increasing the computational cost of global merging. Therefore, the selection of mesh cell size should strike a balance between high efficiency in local merging and controllable computational cost in global merging.

[0028] Figure 2 A schematic diagram illustrating the intersection of mesh division and contour is shown. For example... Figure 2 As shown, the canvas is evenly divided into Each grid cell, with the central grid This is an example window illustrating the spatial distribution and intersection relationships of the three types of contours.

[0029] The cross-grid outline is represented by a red dashed line R, which includes a large circle R1, a horizontal rectangle R2, and a small square R3 inside the horizontal rectangle. All three cross the central grid boundary and extend to the adjacent grid. The grid-internal root outline is represented by a green solid line G, which includes a rectangle G1 and a small circle G2. Both of their bounding boxes are completely inside the central grid. Rectangle G1 is inside the large circle R1, and small circle G2 is outside the large circle R1. The grid-internal sub-outline is represented by a blue solid line B, which includes a triangle B1 and a rhombus B2. These are completely inside rectangle G1 and small circle G2 of the grid-internal root outline, respectively, reflecting the parent-child nesting relationship in the local multi-level tree.

[0030] In step S102, for each grid cell, the contours that intersect with the grid cell are collected, and a Boolean union operation is performed on the collected contours to generate a local multi-level tree corresponding to the grid cell.

[0031] Here, "non-empty intersection with grid cells" means that the closed region enclosed by the contour and the rectangular region enclosed by the grid cells have overlapping areas, not that the contour boundary line and the grid boundary line have geometric intersection points. For contours whose bounding boxes are completely inside the grid cells, the non-empty intersection with the grid cells is obvious; for contours whose bounding boxes cross the grid boundaries, further precise geometric intersection judgment is required to confirm that there is indeed an overlapping area between the contour region and the grid cell region.

[0032] Based on this, when collecting contours that do not intersect with grid cells, the following two-step allocation strategy can be adopted.

[0033] The first step is to iterate through each contour. Calculate its bounding box The bounding box determines the range of the grid index it covers. Let the bounding box of a certain contour have a range in the horizontal direction of... The range in the vertical axis direction is Then the grid column index range covered by this contour is from arrive The range of grid row indices covered is from arrive .in, This indicates rounding down. If the upper or right boundary of the bounding box happens to fall on the grid boundary, it can be assigned to an adjacent grid according to preset rules, as long as the subsequent intersection judgment is correct.

[0034] The second step involves examining each grid cell within the coverage area. If the bounding box of the contour is completely contained within that grid cell, then the contour belongs exclusively to that grid, and it is directly added to the contour list of that grid. If the bounding box of the contour overlaps with but does not completely contain the grid cell, then the intersection of the contour and the grid cell is further checked. This includes tests such as line segment and rectangle clipping or point within a rectangle. Only after confirming that the intersection is not empty is the contour added to the contour list of that grid. This two-step strategy filters out most cases that do not require computation with inexpensive bounding box testing, and only performs more expensive geometric intersection checks when necessary.

[0035] For each non-empty mesh cell, a Boolean union operation engine is invoked, taking the outline list of that mesh cell as input, performing a union operation, and outputting a local multi-level tree. This Boolean union operation engine can be a scanline Boolean operation engine. The local multi-level tree can also be called a local PolyTree. The purpose of local merging is to eliminate self-intersections and mutual intersections of outlines within the same mesh, obtaining a topologically clean local multi-level tree. The correctness of the global nesting relationship is not guaranteed by local merging, but is reconstructed by subsequent steps S104 to S107.

[0036] In practice, the local merging operations of each grid cell are independent and can be executed in parallel in a multi-threaded or multi-process environment. This parallel execution can be implemented on a multi-core CPU or GPU, and no complex global synchronization is required between grid cells.

[0037] In step S103, based on whether the bounding box of the contour is completely located inside the corresponding grid cell and the hierarchical relationship of the contour in the local multi-level tree, the contour nodes in each local multi-level tree are classified into cross-grid contours (which can be represented by cEx), in-grid root contours (which can be represented by cRoot), and in-grid sub-contours (which can be represented by cChild).

[0038] Specifically, contour nodes whose bounding boxes are not completely located inside the corresponding grid cells are classified as cross-grid contours; contour nodes whose bounding boxes are completely located inside the corresponding grid cells and are root nodes in the local multi-level tree or whose parent node is a cross-grid contour are classified as intra-grid root contours; and contour nodes whose bounding boxes are completely located inside the corresponding grid cells and do not belong to intra-grid root contours are classified as intra-grid sub-contours.

[0039] During classification, a depth-first traversal is performed on the local multi-level tree of each grid cell. A classification label is assigned to each contour node based on its spatial location and local hierarchical relationship, and its local depth and local parent node are recorded. The local depth increases layer by layer from the root node (0). For nodes classified as root contours within the grid, their leftmost point is recorded as the query point and added to the global set of root contours within the grid.

[0040] Figure 3 A schematic diagram of a local multi-level tree and a three-level classification is shown. Figure 2 Central grid Taking [example] as an example, we demonstrate its multi-level tree structure and three-level classification results after local Boolean union. The large circle R1 across the grid outline is the local multi-level tree root node with a local depth of 0; the horizontal bar R2 across the grid outline is an independent local root node with a local depth of 0; the small square R3 across the grid outline is completely inside the horizontal bar R2 with a local depth of 1. The rectangle G1 within the grid root outline is completely inside the grid and contained within the large circle R1, with a local depth of 1; the small circle G2 within the grid root outline is completely inside the grid, independent of the large circle R1, with a local depth of 0. The triangle B1 within the grid sub-outline is completely inside the grid and contained within the rectangle G1, with a local depth of 2; the rhombus B2 within the grid sub-outline is completely inside the grid and contained within the small circle G2, with a local depth of 1.

[0041] In step S104, the cross-grid contours in each grid cell are aggregated and a Boolean union operation is performed to generate a global skeleton multi-level tree.

[0042] Specifically, contours classified as cross-mesh contours in all grid cells are collected into a global set, Sex. Since the same cross-mesh contour may be included by multiple grid cells simultaneously, duplicate contours may exist in this global set. Duplicate contours do not affect the correctness of the Boolean union operation, i.e. Therefore, deduplication is unnecessary. The Boolean union operation engine is invoked, taking all cross-mesh contours as input, to perform a union operation and output a global skeleton multi-level tree. This global skeleton multi-level tree consists only of cross-mesh contours, preserving the correct nesting relationships of all cross-mesh contours globally. Since the number of cross-mesh contours is usually much smaller than the total number of contours, the computational cost of this global merging is manageable.

[0043] Furthermore, after generating the global skeleton multi-level tree, a depth-first traversal can be performed on the global skeleton multi-level tree to record the global depth for each contour node, with the global depth increasing level by level from the root node as 0. This global depth value will be directly used in the subsequent parity determination.

[0044] In step S105, for each root contour within a grid, a query point is extracted from the root contour within the grid. The contour edge with the horizontal distance to the query point is queried in the global skeleton multi-level tree along the horizontal direction. The global parent node of the root contour within the grid is determined based on the query result.

[0045] As one implementation method, extracting the query point from the root contour within the grid can be achieved by performing the following operation: extracting the leftmost point of the root contour within the grid as the query point. The formula for this implementation method is as follows: For each root contour within the grid... Extract its leftmost point : ,in, Represents vertices The x-coordinate. Additionally or optionally, when multiple vertices have the same minimum x-coordinate, the vertex whose y-coordinate is the median is selected as the query point.

[0046] Furthermore, when a contour edge is found, the contour to which the contour edge belongs is determined as the adjacent contour, and the global parent node of the root contour in the mesh is determined based on the parity comparison between the depth of the root contour in the local multi-level tree and the depth of the adjacent contour in the global skeleton multi-level tree; when no contour edge is found, the root contour in the mesh is determined as the root node of the global multi-level tree.

[0047] In practice, the global parent node of the root profile within the mesh is determined by comparing the parity of its depth in the local multi-level tree with that of the adjacent profile in the global skeleton multi-level tree. This can be further refined as follows: if the parity of the depth of the root profile within the mesh in the local multi-level tree is the same as that of the adjacent profile in the global skeleton multi-level tree, then the global parent node of the root profile within the mesh is determined as the parent node of the adjacent profile; if the parity of the two is different, then the global parent node of the root profile within the mesh is determined as the adjacent profile.

[0048] Figure 4 A schematic diagram illustrating nearest-edge query and parity determination is shown. In this application, the contour nodes in the multi-level tree can include entity region contour nodes and hole contour nodes; wherein, a hole contour node refers to the internal boundary contour surrounded by entity region contours in the Boolean union result, and its depth in the multi-level tree is odd, while the entity region contour node has an even depth in the multi-level tree. For ease of description, the contour node representing a hole in the global skeleton multi-level tree is referred to as a hole, and the contour node representing the outer boundary of an entity region in the global skeleton multi-level tree is referred to as an outer contour. The above naming is only for ease of description and does not constitute an additional limitation on the contour node type.

[0049] like Figure 4 As shown, the leftmost points P1 and P2 of two root contours cR1 and cR2 within a mesh are displayed. Querying left from query point P1, the nearest edge belongs to hole H1 in the global skeleton, with a depth of 1 (odd). The depth of the root contour within the mesh is also 1 (odd). Since the local parity is the same as the global parity, they are determined to be siblings, sharing the same global parent node. Querying left from query point P2, the nearest edge belongs to outer contour O1 in the global skeleton, with a depth of 0 (even). The depth of the root contour within the mesh is also 1 (odd). Since the local parity is different from the global parity, they are determined to be parent-child, meaning the root contour within the mesh is a child node of the outer contour O1, and the outer contour O1 is the global parent node of the root contour within the mesh.

[0050] The correctness of the above parity determination can be demonstrated based on the mathematical properties of multi-level trees. In a multi-level tree, the depth difference between parent and child nodes is always 1, so their parity must be different; sibling nodes share the same parent node, so the depth difference is 0 or even, and their parity must be the same. Therefore, parity can be used as a necessary and sufficient condition to distinguish between parent and child and sibling nodes. For the root contour within the grid and its adjacent contour, if their parity is the same, it is impossible for them to be in a parent-child relationship according to the above properties. Combined with the nearest edge query, which guarantees that they are directly adjacent, it can be determined that they are siblings and share the same global parent node; if their parity is different, they are in a parent-child relationship. Since the bounding box of the root contour within the grid is completely inside the grid cell, while the adjacent contour comes from the cross-grid contour and extends outside the grid cell, the root contour within the grid cannot contain the adjacent contour. Therefore, the adjacent contour must contain the root contour within the grid, that is, the adjacent contour is the parent and the root contour within the grid is the child.

[0051] In step S106, for each sub-contour within a grid, the parent-child chain of its local multi-level tree is spread from top to bottom, with the global node corresponding to its local parent node becoming its global parent node.

[0052] The parent node of a sub-contour within a mesh in the local multi-level tree can only be the root contour within the mesh or another sub-contour within the mesh, and its internal hierarchical relationship is completely determined during local merging. Therefore, for each root contour within a mesh, its sub-contour subtree within the mesh in the local multi-level tree is directly mounted to the corresponding position in the global multi-level tree. The sub-contour within the mesh migrates along with its local parent node, without requiring additional geometric queries or hierarchical calculations.

[0053] In step S107, based on the global parent node relationship of each contour node, the global skeleton multi-level tree, the root contours in each grid and the sub-contours in each grid are assembled into a global multi-level tree.

[0054] It should be noted that during the assembly process, for each root contour within a mesh, if its global parent node is empty, it is set as the root node of the global multi-level tree; otherwise, it is attached to the determined global parent node. The final output global multi-level tree is the complete global contour hierarchy structure, accurately reflecting the nested hierarchy relationship of all contours.

[0055] Figure 5 A schematic diagram of global multi-level tree assembly is shown. For example... Figure 5 As shown, a complete global multi-level tree is formed by attaching the global skeleton multi-level tree, the root contour within the mesh, and the sub-contours within the mesh according to the determined parent-child relationship.

[0056] Figure 5In the diagram, cEx1 to cEx3 are cross-mesh contour nodes, cRoot1 to cRoot4 are in-mesh root contour nodes, and cChild1 to cChild7 are in-mesh sub-contour nodes. Figure 5 The root node represents the top-level node of the global multi-level tree, under which are cEx1, cEx2, and cRoot1, with a global depth of 0. cEx1's child nodes include cEx3, with a global depth of 1. cEx3's child nodes include cRoot3 and cRoot4, with a global depth of 2. cRoot3's child nodes include cChild6, with a global depth of 3. cRoot4's child nodes include cChild7, with a global depth of 3. cEx2's child nodes include cRoot2, with a global depth of 1. cRoot2's child nodes include cChild2 and cChild3, with a global depth of 2. cRoot1's child nodes include cChild1 and cChild5, with a global depth of 1. cChild1's child nodes include cChild4, with a global depth of 2.

[0057] Figure 5 Nodes are categorized and colored according to their outlines: red for cross-mesh outlines, green for root outlines within the mesh, and blue for sub-outlines within the mesh. The numbers labeled on each node represent its global depth, indicating its level depth within the global multi-level tree. It's worth noting that some nodes also have local depths labeled. The depth values ​​of these nodes change during the process of being attached from the local multi-level tree to the global multi-level tree; that is, the local depth and global depth are inconsistent.

[0058] For example, the root contour cRoot4 within the mesh is the root node in the local multi-level tree with a local depth of 0, but it is attached to the cross-mesh contour cEx3 in the global tree with a global depth of 2; the child contour cChild7 within the mesh is a child node of the root contour cRoot4 within the mesh in the local multi-level tree with a local depth of 1, but its global depth is 3 after being globally attached.

[0059] The above combination Figure 1This application describes a method for large-scale contour hierarchy reconstruction. This method divides the canvas into multiple grid cells and performs local Boolean union operations independently within each grid cell, decomposing the global large-scale Boolean merging into multiple small-scale local operations, reducing the computational cost of a single operation. Furthermore, the local operations of each grid cell are independent, facilitating parallel execution. By classifying contour nodes into cross-grid contours, intra-grid root contours, and intra-grid sub-contours, the method decouples cross-grid contours from internal contours, facilitating differentiated processing. By performing a global Boolean union operation on the aggregated cross-grid contours to generate a global skeleton multi-level tree, the method preserves the hierarchical relationship of cross-grid contours globally. Since the number of cross-grid contours is typically much smaller than the total number of contours, the computational cost of global merging is controllable. Through a multi-level global skeleton... The algorithm queries the contour edge with the horizontal distance to the root contour within the mesh in the hierarchical tree and determines its global parent node based on the query result. This establishes a global hierarchical connection between internal contours and cross-mesh contours with low computational cost, avoiding global reordering of all contours. By making the sub-contours within the mesh diffuse from top to bottom along the parent-child chains of the local multi-level tree to determine the global parent node, the algorithm reuses the internal hierarchical relationship determined during local merging, eliminating the need for additional geometric queries. In addition, the nearest edge query directly reuses the active edge list structure of the scanline engine, eliminating the need to build additional global spatial indexes such as R-trees and kd-trees, thus avoiding the structural overhead and maintenance costs of additional spatial indexes. Finally, a complete global multi-level tree is obtained through global assembly, which improves the processing efficiency of large-scale contours while ensuring the correctness of global hierarchical relationships.

[0060] It should be noted that the above-mentioned multi-level tree can also be called a PolyTree, which is used to represent the nesting, intersection, and containment relationships between contours, especially the hierarchical nesting structure of outer contour—hole—island—hole. The global parent node mentioned above refers to the parent node of the contour node in the final output global multi-level tree; the local parent node refers to the parent node of the contour node in the local multi-level tree of the corresponding mesh cell.

[0061] The embodiments of this application also consider the handling of the following boundary degradation cases.

[0062] Degeneracy Case 1: No results found for the root contour query within the mesh. If the query point of a root contour within a mesh cannot find any contour edge in the global skeleton multi-level tree, it means that the root contour within the mesh is not inside any cross-mesh contour. In this case, the root contour within the mesh is set as the root node of the global multi-level tree.

[0063] Degeneracy Case Two: No cross-mesh contours exist within a certain mesh cell. All contours in this mesh cell are either intra-mesh root contours or intra-mesh sub-contours. These contours are entirely within the mesh cell and do not interact with other mesh cells. Its local multi-level tree is the correct global subtree: the intra-mesh root contour cannot find adjacent contours in step S105 and will be set as the global root node. Its intra-mesh sub-contours are then spread and attached through step S106 to form an independent global subtree.

[0064] In the third degenerate scenario, cross-mesh contours disappear after global merging. Some cross-mesh contours may be completely inside another cross-mesh contour. After the global Boolean union operation, they no longer exist as independent nodes; this is normal behavior of Boolean operations. In this case, the adjacent contour of the root contour child node within the local mesh corresponding to the merged cross-mesh contour will be the larger contour that merged it, as queried in step S105. The parity determination, based on the final hierarchical structure after merging, remains correct.

[0065] Next, combine Figure 6 The specific implementation of querying the contour edge with the lowest horizontal distance to the query point along the horizontal direction in the global skeleton multi-level tree at step S105 above is described by way of example. Figure 6 An exemplary flowchart of the query for the nearest contour edge operation 600 according to an embodiment of this application is shown. It will be understood that the following is combined with... Figure 6 The description is a specific implementation of the operation of querying the nearest contour edge in the aforementioned step S105. Therefore, in conjunction with the above... Figure 1 The described characteristics can be similarly applied here.

[0066] like Figure 6 As shown, in step S601, the valley vertices of each contour in the global skeleton multi-level tree are extracted and arranged in ascending order of their ordinates. A valley vertex is a vertex on the contour whose ordinate is a local minimum. Here, a valley vertex can also be called a Local Minimum.

[0067] Closed contours naturally exhibit a wave-like shape along the vertical axis. Vertices on the contour whose vertical coordinates are local minima are called valley vertices. Each valley vertex is precisely the starting point of two non-horizontal edges: a descending edge extending along the preceding direction of that vertex in the contour vertex chain, and an ascending edge extending along the succeeding direction of that vertex. Horizontal edges are not involved in valley determination. In the preprocessing stage, the contour vertices are traversed to construct a circular doubly linked list. Valleys and peaks are identified by the state transitions of the ascending and descending trends of the vertex's vertical coordinate. All valley vertices are stored in the valley list and sorted in ascending order of their vertical coordinates. Since the number of valley vertices is usually much smaller than the total number of edges, the sorting overhead is low.

[0068] In step S602, the scan line is advanced along the increasing direction of the vertical coordinate, and an active edge list and a dynamic expiration stack are maintained. The active edge list records the contour edges that intersect with the current scan line and is arranged in ascending order according to the horizontal coordinate of each contour edge at the current scan line. The dynamic expiration stack records the vertical coordinate of the upper endpoint of each contour edge in the current active edge list.

[0069] The scanline algorithm is a classic paradigm in computational geometry, applicable to various scenarios such as line segment intersection detection, point-within-polygon determination, and nearest-neighbor pair solving. Based on the classic scanline idea, this application addresses the horizontal nearest neighbor query requirements for large-scale contour edges by employing the following three optimization operations at the implementation level: Optimization operation one: valley vertex-driven edge addition replaces global edge event sorting; Optimization operation two: utilizing the order invariance of the active edge list to eliminate the overhead of rearranging along the vertical axis; Optimization operation three: employing a dynamic expiration heap and alternating event advancement for localized edge removal management. The following sections explain each of these three optimizations.

[0070] Optimization Operation 1: Add edges driven by valley vertices, replacing global edge event sorting.

[0071] As the scan line advances along the increasing ordinate direction, the contour edges that intersect with the current scan line are called active edges. The Active Edge List (AEL) maintains an ordered list of all active edges at the current scan line, sorted in ascending order of their x-coordinates at the current scan line. The Dynamic Expiration Heap (DEH) is a min-heap structure that only maintains the ordinate of the upper endpoint of each active edge in the current active edge list. As the scan line advances, edges are popped sequentially, starting with those whose upper endpoint ordinate is less than the current scan line's ordinate, thus achieving localized edge removal management.

[0072] In practical applications, each active edge in the active edge list can record the following information: the lower and upper endpoints of the edge segment, the reciprocal of the slope of the edge segment, the association information of the upper endpoint of the edge segment in the contour vertex chain, and the travel direction identifier along the contour vertex chain. The lower endpoint is the endpoint with the smaller ordinate, and the upper endpoint is the endpoint with the larger ordinate; the reciprocal of the slope is used to calculate the x-coordinate of the edge at the scan line based on the current scan line's ordinate interpolation; the association information of the upper endpoint in the contour vertex chain is used to ensure that the edge continues along the contour direction to the next non-horizontal segment after reaching the peak; the travel direction identifier indicates the travel direction along the contour vertex chain, i.e., along the direction of the successor vertex or along the direction of the predecessor vertex.

[0073] In the first optimization operation, when the scan line advances to the vertical coordinate of the valley bottom vertex, the descending edge and the ascending edge are extracted from the valley bottom vertex along the predecessor and successor directions of the contour vertex chain, respectively. After skipping the continuous horizontal segments, the extracted non-horizontal edges are inserted into the active edge list, where horizontal edges are not included in the active edge list.

[0074] This operation leverages the structural characteristics of valley vertices, extracting only the valley vertices as trigger points for edge events, replacing the classic scanline implementation's approach of globally sorting all edge events. The classic scanline implementation typically requires globally sorting all 2E edge events (addition and removal events), resulting in a preprocessing complexity of O(n log n). ,in This represents the total number of edges. This application only extracts D valley vertices as edge event trigger points; the sorting cost is... Down to ,in Typically much smaller than the total number of sides. As the scan line advances from top to bottom, reaching the ordinate of a valley triggers the addition of an edge. A descending and ascending edge is pulled from that valley in one go, skipped over horizontal segments, and then inserted into the active edge list. Horizontal edges are naturally skipped in the main loop; if adjacent vertices have the same ordinate, no state change is triggered, they are not added to the valley list, and are not inserted into the active edge list. During edge construction, when traversing the contour vertices along a specified direction, consecutive horizontal vertices are automatically skipped until the first vertex with a different ordinate is encountered, at which point the non-horizontal segment is extracted. This ensures that edges entering the active edge list are always non-horizontal edges.

[0075] Optimization operation 2: Utilize the invariance of the order of the active edge list to eliminate the overhead of rearrangement along the vertical axis.

[0076] Since the contours in the global skeleton multi-level tree have undergone Boolean union operations and therefore do not intersect, the relative left-right order of any two simultaneously active contour edges in the active edge list remains constant within the range of their shared active ordinate. In the classic scanline implementation, the relative left-right order of active edges may change each time the scanline advances to a new edge event. Therefore, each time an edge event is processed, it is usually necessary to re-sort all active edges in the active edge list globally according to the x-coordinate at the current ordinate, resulting in a time complexity of O(log n). ,in Size of the active edge list.

[0077] The order invariance theorem of this application is proved as follows: Assume that at the ordinate y1, the first edge e1 is to the left of the second edge e2, i.e., x1(y1) is less than x2(y1). At another ordinate y2, the first edge e1 is to the right of the second edge e2, i.e., x1(y2) is greater than x2(y2). Then, by continuity, there must exist an intermediate ordinate y0 such that the x-coordinates of the two edges are equal, x1(y0) equals x2(y0), i.e., the two lines intersect, which does not contradict the fact that they have already been merged. Based on this theorem, the edges in the active edge list do not need to be rearranged when the scan line moves along the ordinate direction; their positions are only adjusted when edges are inserted or removed. This allows the query engine to avoid the overhead of repeated global rearrangement when processing a large number of edge events. A single query only needs to perform a binary search within the active edge list. Complete within the specified time.

[0078] Optimization Operation 3: Adopt dynamic expiration heap and alternating event advancement, and manage localized edge removal.

[0079] This optimization operation employs a dynamic expiration heap to locally manage the lifecycle of edges and unifies valley edge addition events and query events into an alternating scanline loop. During the initialization phase, the leftmost points of all root contours within the mesh are sorted in ascending order of their ordinates to form a query point sequence. Simultaneously, the valley vertices of all contours in the global skeleton are sorted in ascending order of their ordinates to form a valley vertex sequence. The scanline advances along the increasing direction of the ordinate, and in each round, the target ordinate of the next pending event is taken as the smaller value between the ordinate of the current query point and the ordinate of the current valley vertex.

[0080] Before processing the event corresponding to the target ordinate, pop out contour edges whose upper endpoint ordinate is less than the target ordinate in batches through a dynamic expiration heap. For the popped contour edges, skip the subsequent non-horizontal segments whose upper endpoint ordinate is still less than the target ordinate continuously along its travel direction in the contour vertex chain until a valid segment with an upper endpoint ordinate not less than the target ordinate is found or the contour edge is removed from the active edge list.

[0081] Specifically, after the target ordinate is determined, the top element of the dynamic expiration heap is checked and processed first, and all edges whose upper endpoint ordinates are less than the target ordinate are popped in a loop. For each popped edge, the subsequent non-horizontal continuation segment is searched along its travel direction in the contour vertex chain; if the upper endpoint ordinate of the continuation segment is still less than the target ordinate, the segment is skipped and the next segment is searched until a valid segment with an upper endpoint ordinate not less than the target ordinate is found. The valid segment is then updated with the new endpoint information of the edge and pushed back into the dynamic expiration heap; if the contour peak has been traversed and there are no subsequent non-horizontal segments, the edge is removed from the list of active edges. This continuous skipping mechanism avoids pushing consecutively expired intermediate segments back into the dynamic expiration heap and popping them one by one, and merges multiple expired edges within the same event window into a single processing, significantly reducing the runtime overhead in event-intensive scenarios. When adding edges to the valley floor, if the target ordinate is equal to the ordinate of the current valley floor vertex, then pull out descending and ascending edges from that valley floor vertex, skip the horizontal segments, extract the non-horizontal segments and insert them into the active edge list, and push the ordinate of the upper endpoint of each newly inserted edge into the dynamic expiration heap.

[0082] In step S603, when the scan line advances to the ordinate of the query point, the contour edge with the closest horizontal distance to the query point is determined by binary search in the list of active edges.

[0083] Specifically, the insertion position of the query point's x-coordinate can be found by binary search in the list of active edges, and the active edges adjacent to the insertion position can be compared. The active edge with the smaller difference between its x-coordinate and the query point's x-coordinate is determined as the closest contour edge.

[0084] During batch queries, the leftmost points of all root contours within the grid are sorted in ascending order by their ordinates, serving as the query point sequence. ,in The query count is [number of query points]. Sort the valley vertices of all contours in the global skeleton multi-level tree in ascending order of their ordinates to form a valley list. ,in This represents the number of vertices at the bottom of the valley. The driving scan line advances along the increasing direction of the vertical coordinate, alternately processing valley edge addition events and query events.

[0085] At this point, the active edge list retains only the valid active edges that intersect the scan line. A binary search is performed in the active edge list to find the edge with the closest horizontal distance to the query point, and the contour to which this edge belongs is recorded. That is, the adjacent contour corresponding to the k-th query point. The time complexity of a single nearest edge query is O(k). ,in This represents the number of cross edges at the current scan line. The total time complexity of batch queries is O(log n). ,in For the number of query points, The number of vertices at the bottom of the valley. This is the maximum size of the active edge list. This represents the total number of segments skipped consecutively. The total number of segments skipped consecutively in a typical scenario. Much smaller than the total number of sides And the number of root contours within the mesh The complexity is typically much smaller than the total number of contours, therefore it is lower than performing a global sort on all edge events. plan.

[0086] The key advantages of the above three optimizations are: traditional scanline implementation requires global sorting and management of all 2E edge events, while this application separates the sorting of valley vertices from the sorting of query points, and the scanline uses... The time is minimized to advance; the dynamic expiration heap only maintains the active edges in the current active edge list, and its size is always equal to the minimum value. When handling expired edges, a continuous skipping mechanism is used to reduce the number of heap operations. The complexity of a single dynamic expired heap operation for adding an edge at a valley or querying an event is O(log n). During continuous skipping, only one heap operation is triggered for multiple expired edges of the same contour chain, which significantly reduces the runtime overhead in event-intensive scenarios.

[0087] In summary, the three optimizations mentioned above all revolve around the core data structures of the scanline architecture: valley vertices, the active edge list, and active edge lifecycle management. Without altering the basic scanning paradigm of the scanline, they reduce preprocessing sorting overhead, eliminate runtime reordering overhead, and localize edge removal management at the implementation level. These three components are independent yet collaborative, enabling the query engine to maintain query efficiency comparable to classic scanline architectures while decomposing the overhead of traditional global edge event sorting into valley vertex sorting and local heap management, thereby further reducing the computational load for queries in large-scale contour scenarios.

[0088] Next, combine Figure 7 This application provides an exemplary description of a large-scale contour hierarchy structure reconstruction apparatus 700. For example... Figure 7 As shown, the large-scale contour hierarchy reconstruction device 700 of this application embodiment may include a partitioning module 701, a first calculation module 702, a classification module 703, a second calculation module 704, a query module 705, a diffusion module 706, and an assembly module 707. This device 700 is used to perform the aforementioned combination... Figure 1 The method for reconstructing large-scale contour hierarchical structures is described, with each module corresponding to a step in the method, working together to complete the reconstruction of large-scale contour hierarchical structures.

[0089] The partitioning module 701 is configured to divide a canvas containing a set of input contours into multiple grid cells; The first operation module 702 is configured to collect contours that intersect with the grid cell for each grid cell, and perform a Boolean union operation on the collected contours to generate a local multi-level tree corresponding to the grid cell. The classification module 703 is configured to classify contour nodes in each local multi-level tree into cross-mesh contours, in-mesh root contours, and in-mesh sub-contours based on whether the contour's bounding box is completely located inside the corresponding mesh cell and the contour's hierarchical relationship in the local multi-level tree. The second operation module 704 is configured to perform a Boolean union operation on the cross-grid contours in each grid cell to generate a global skeleton multi-level tree. The query module 705 is configured to extract a query point from the root contour of each grid, query the contour edge with the horizontal distance to the query point in the global skeleton multi-level tree, and determine the global parent node of the root contour of the grid based on the query result. The diffusion module 706 is configured to diffuse from top to bottom along the parent-child chain of its local multi-level tree for each sub-profile within the mesh, with the global node corresponding to its local parent node as its global parent node. Assembly module 707 is configured to assemble the global skeleton multi-level tree, the root contours within each grid, and the sub-contours within each grid into a global multi-level tree based on the global parent node relationship of each contour node.

[0090] In the embodiments of this application, the above modules can be implemented by a processor executing program instructions stored in memory, or by dedicated hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), etc.), or by a combination of hardware and software. This application does not make any specific limitations on this.

[0091] Next, combine Figure 8 An exemplary description of an electronic device 800 provided in an embodiment of this application is given below. For example... Figure 8 As shown, the electronic device 800 in this application embodiment may include a processor 801, a memory 802, and a communication bus 803.

[0092] In some embodiments, the processor 801 described above may be at least one of an Application-Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field-Programmable Gate Array (FPGA), a CPU, a controller, a microcontroller, and a microprocessor. It is understood that, for different devices, the electronic device used to implement the above processor function may also be other, and this embodiment does not specifically limit it.

[0093] In this embodiment, the communication bus 803 is used to establish communication between the processor 801 and the memory 802; the memory 802 stores program instructions for large-scale contour hierarchy reconstruction; when the processor 801 executes the program instructions stored in the memory 802, it implements the combination of this application. Figure 1 The method described is for large-scale contour hierarchy reconstruction.

[0094] In some embodiments of this application, the electronic device may be a server, computer, workstation, or other computing device with data processing capabilities. The memory 802 may be a high-speed random access memory or a non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device.

[0095] The above combination Figure 8 This paper describes an electronic device for large-scale contour hierarchy reconstruction that can be used to perform the present application. It should be understood that the device structure or architecture described herein is merely exemplary, and the implementation methods and implementation entities of this application are not limited thereto, but can be modified without departing from the spirit of this application.

[0096] Based on the foregoing description in conjunction with the accompanying drawings, those skilled in the art will understand that the embodiments of this application can also be implemented by software programs. Therefore, this application also provides a computer-readable storage medium. This computer-readable storage medium stores program instructions for large-scale contour hierarchy reconstruction, which can be used to implement the embodiments of this application. Figure 1 The method described is for large-scale contour hierarchy reconstruction.

[0097] In some embodiments of this application, the computer-readable storage medium can be any tangible medium capable of storing, encoding, or carrying program instructions, such as, but not limited to, USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks, etc., and other media capable of storing program code. The program instructions can be stored in the form of source code, object code, or intermediate code.

[0098] It is understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or corresponding parts can be referred to each other. For the purpose of brevity, this disclosure will not go into detail.

[0099] It should be noted that although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart can be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0100] While numerous embodiments of this application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will arise for those skilled in the art without departing from the spirit and intent of this application. It should be understood that various alternatives to the embodiments of this application described herein may be employed in the practice of this application. The appended claims are intended to define the scope of protection of this application and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. A method for large-scale contour hierarchy reconstruction, characterized in that, include: Divide the canvas containing the set of input contours into multiple grid cells; For each grid cell, collect the contours that intersect with that grid cell and perform a Boolean union operation on the collected contours to generate a local multi-level tree corresponding to that grid cell; Based on whether the bounding box of the contour is completely located inside the corresponding grid cell and the hierarchical relationship of the contour in the local multi-level tree, the contour nodes in each local multi-level tree are classified into cross-grid contours, grid-intra-root contours, and grid-intra-sub-contours. After aggregating the cross-grid contours in each grid cell, a Boolean union operation is performed to generate a global skeleton multi-level tree. For each root contour within a grid, a query point is extracted from that root contour. In the global skeleton multi-level tree, the contour edge with the closest horizontal distance to the query point is queried along the horizontal direction. Based on the query result, the global parent node of the root contour within the grid is determined. For each sub-contour within a grid, the parent-child chain of its local multi-level tree is propagated from top to bottom, with the global node corresponding to its local parent node as its global parent node. Based on the global parent node relationship of each contour node, the global skeleton multi-level tree, the root contours in each grid and the sub-contours in each grid are assembled into a global multi-level tree.

2. The method according to claim 1, characterized in that, The canvas containing the input contour set is divided into multiple grid cells, including: The size of the grid cell is determined based on the total number and distribution density of the input contours, so that the proportion of the number of cross-grid contours to the total number of input contours is lower than a preset proportion threshold.

3. The method according to claim 1, characterized in that, The contour nodes in each local multi-level tree are classified into cross-mesh contours, intra-mesh root contours, and intra-mesh sub-contours, including: Contour nodes whose bounding boxes are not completely located inside the corresponding mesh cells are classified as cross-mesh contours; Contour nodes whose bounding boxes are completely located inside the corresponding mesh cells and are root nodes in the local multi-level tree or whose parent nodes are cross-mesh contours are classified as the in-mesh root contours. Contour nodes whose bounding boxes are completely located inside the corresponding mesh cells and do not belong to the root contour within the mesh are classified as the sub-contours within the mesh.

4. The method according to claim 1, characterized in that, After generating the global skeleton multi-level tree, the process also includes: A depth-first traversal is performed on the global skeleton multi-level tree, and the global depth of each contour node is recorded, with the global depth increasing layer by layer from the root node as 0.

5. The method according to claim 1, characterized in that, Based on the query results, determine the global parent node of the root profile within the mesh, including: When a contour edge is found, the contour to which the contour edge belongs is determined as the adjacent contour. Based on the parity comparison between the depth of the root contour in the local multi-level tree and the depth of the adjacent contour in the global skeleton multi-level tree, the global parent node of the root contour in the mesh is determined. When no contour edge is found, the root contour within the grid is determined as the root node of the global multi-level tree.

6. The method according to claim 5, characterized in that, Based on the parity comparison between the depth of the root profile within the mesh in the local multi-level tree and the depth of the adjacent profile in the global skeleton multi-level tree, the global parent node of the root profile within the mesh is determined, including: If the parity of the depth of the root contour within the mesh in the local multi-level tree is the same as the parity of the depth of the adjacent contour in the global skeleton multi-level tree, then the global parent node of the root contour within the mesh is determined as the parent node of the adjacent contour. If the parity of the two is different, then the global parent node of the root contour within the mesh is determined as the adjacent contour.

7. The method according to claim 1, characterized in that, Extract query points from the root contour within the grid, including: Extract the leftmost point of the root contour within the grid as the query point; When multiple vertices have the same minimum x-coordinate, select the vertex whose y-coordinate is the median as the query point.

8. The method according to claim 1, characterized in that, In the global skeleton multi-level tree, the horizontal search for the contour edge that is closest to the query point includes: Extract the valley vertices of each contour in the global skeleton multi-level tree and arrange them in ascending order of their ordinates. The valley vertices are the vertices on the contour whose ordinates are local minima. The scan line is advanced along the increasing direction of the vertical coordinate, and an active edge list and a dynamic expiration pile are maintained. The active edge list records the contour edges that intersect with the current scan line and is arranged in ascending order according to the horizontal coordinate of each contour edge at the current scan line. The dynamic expiration pile records the vertical coordinate of the upper endpoint of each contour edge in the current active edge list. As the scan line advances to the ordinate of the query point, a binary search is used in the list of active edges to determine the contour edge that is horizontally closest to the query point.

9. The method according to claim 8, characterized in that, Each active edge in the active edge list records the following information: the lower and upper endpoints of the edge segment, the reciprocal of the slope of the edge segment, the association information of the upper endpoint of the edge segment in the contour vertex chain, and the travel direction identifier along the contour vertex chain. as well as Advance the scan line along the increasing direction of the vertical axis and maintain the list of active edges, including: When the scan line advances to the ordinate of the valley bottom vertex, the descending edge and the ascending edge are extracted from the valley bottom vertex along the predecessor and successor directions of the contour vertex chain, respectively. After skipping the continuous horizontal segments, the extracted non-horizontal edges are inserted into the active edge list, where horizontal edges are not included in the active edge list. Arrange the query points in ascending order of their ordinates to form a query point sequence, and arrange the valley vertices in ascending order of their ordinates to form a valley vertex sequence. In each round, take the smaller ordinate of the current query point sequence and the current valley vertex sequence as the target ordinate, and alternately process the valley vertex edge addition event and the query point query event. Before processing the event corresponding to the target ordinate, pop out contour edges whose upper endpoint ordinate is less than the target ordinate in batches through a dynamic expiration heap. For the popped contour edges, skip the subsequent non-horizontal segments whose upper endpoint ordinate is still less than the target ordinate continuously along its travel direction in the contour vertex chain until a valid segment with an upper endpoint ordinate not less than the target ordinate is found or the contour edge is removed from the active edge list.

10. A computer-readable storage medium storing program instructions for large-scale contour hierarchy reconstruction, which, when executed by a processor, implement the method according to any one of claims 1-9.