Polygon filling method, system and device based on global subdivision grid multi-level combination and medium
By adopting a multi-level combination method based on global mesh, the accuracy and efficiency problems of polygon rasterization and filling on a global scale are solved, achieving efficient and accurate polygon filling, which is suitable for large-scale parallel computing in global multi-scale spatial analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE 28TH RES INST OF CHINA ELECTRONICS TECH GROUP CORP
- Filing Date
- 2026-04-23
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies struggle to efficiently and accurately rasterize and fill arbitrary polygons on a global scale. In particular, they cannot effectively address the issues of data uniformity and computational efficiency in large-scale parallel computing environments. Furthermore, traditional methods suffer from accuracy loss and cross-scale computational difficulties when dealing with boundaries.
A multi-level combination method based on global mesh is adopted. By determining the vertices and area of the bounding rectangle of the polygon, the mesh set is retrieved using mesh coding rules, and the geometric relationship of the mesh is determined by the ray method to assign filling values. This optimizes the number and accuracy of the mesh and enables parallel computation on a mesh-by-mesh basis.
It improves the accuracy and computational efficiency of polygon filling, ensures seamlessness and geometric correctness of filling results, and is suitable for large-scale parallel computing in global multi-scale spatial analysis.
Smart Images

Figure CN122089864A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of computer graphics and geographic information processing, and relates to a polygon filling method, system, device and medium based on a multi-level combination of global subdivided grids. Specifically, it relates to a method, system, device and medium for efficiently and accurately rasterizing and filling arbitrary polygons within a globally unified grid reference framework. Background Technology
[0002] In computer graphics, polygon rasterization and filling are the core operations of vector data rasterization. Traditional polygon filling methods (such as scanline filling algorithms) are highly efficient, but when processing global-scale, multi-resolution data, they suffer from difficulties in integrating with geospatial reference frames and complex cross-boundary processing.
[0003] On the other hand, to unify the organization and management of spatial data on a global scale, the Discrete Global Grid System (DGGS) emerged. DGGS uses specific mathematical methods to uniformly discretize the continuous surface of the Earth into a seamless, non-overlapping, multi-resolution grid hierarchy, and uses unique codes for grid cells instead of traditional geographic coordinates for data operations. For example, GeoSOT (Geographic Coordinate Subdividing Grid with One Dimension Integral Coding on 2n-Tree) is a classic global latitude and longitude subdivision grid model. It expands the Earth's surface space three times and then performs a rigorous recursive quadtree subdivision, forming a 32-level multi-layer grid system with global coverage and centimeter-level precision. Each cell in this grid has a globally unique code, exhibiting hierarchy and aggregation, making it ideal for indexing, retrieving, and parallel computing of large-scale spatial data.
[0004] Currently, common raster filling techniques (such as polygon extraction tools in GIS software) are mostly based on regular pixel arrays, determining the ownership of a pixel by whether its center point is located inside a polygon. This method is simple and efficient, but suffers from "all or nothing" accuracy loss when dealing with boundaries, and it is difficult to deeply integrate with the hierarchical and coded characteristics of global grids to achieve cross-scale computation. Furthermore, when polygon boundaries coincide with grid cell boundaries, ambiguity and gaps can easily arise.
[0005] Therefore, existing technologies lack a scheme that can fully utilize the mathematical rigor, hierarchy, and coding advantages of global meshes to achieve high-precision, clear-boundary grid-by-grid rasterization filling of arbitrary polygons. Especially in large-scale parallel computing environments, it is unable to effectively solve the problems of data uniformity and computational efficiency in global multi-scale spatial analysis. Summary of the Invention
[0006] Purpose of the invention: The purpose of this invention is to provide a polygon filling method, system, device, and medium based on a multi-level combination of global meshes, in order to solve one or more problems existing in the prior art.
[0007] Technical solution: The present invention provides a polygon filling method based on a multi-level combination of globally partitioned meshes, comprising:
[0008] S1: Based on the vertex set of the input polygon Determine the vertices and area of the bounding rectangle of the polygon;
[0009] S2: Based on the vertex coordinates of the outer rectangle and the mesh encoding rules, retrieve and determine the mesh set under the selected mesh subdivision level. And initialize the grid fill value;
[0010] S3: Set a threshold based on the area of the outer rectangle. Compare grid sets Medium grid side length With threshold The numerical value is optimized based on the number of grid cells to be processed, and the grid set is optimized accordingly. Update to grid set ;like Then, according to the grid encoding rules, the grid is traversed upwards, and grids with side lengths greater than the threshold are selected. The smallest level of the grid is used to obtain the grid set. At this time, the grid set With grid sets A collection of meshes at different levels under the same subdivision grid; if ,but ;
[0011] S4: Computational Grid Set The set of center points to vertices of any grid The minimum distance between all vertices in the grid is calculated based on the minimum distance and the grid set. The grid is divided into boundary grids or non-boundary grids, and fill values are assigned accordingly. When the grid is divided into non-boundary grids, proceed to step S5; when the grid is divided into boundary grids, proceed to step S6.
[0012] S5: Determine the mesh set using the ray casting method The number of corner points located inside the polygon among the four corner points of the non-boundary mesh is used to further classify the non-boundary mesh into internal meshes, external meshes, or boundary meshes of the polygon based on the number of corner points, and fill values are assigned accordingly; when the non-boundary mesh is classified as a boundary mesh of the polygon, proceed to step S6;
[0013] S6: Determine the mesh set using the ray casting method The corresponding grids of the middle boundary Whether the center point of the hierarchical sub-mesh is located inside the polygon, for each Hierarchical sub-mesh fill values are assigned; mesh set The fill value of the middle boundary grid depends on each The fill value of the hierarchical subgrid is determined;
[0014] S7: For mesh sets After performing steps S4 to S6 on all grids, the polygon's internal grid is colored and filled according to the grid fill value.
[0015] Furthermore, in step S1, the vertices and area of the bounding rectangle of the polygon are determined based on the coordinates of each vertex of the polygon. The minimum and maximum values of the coordinates and The minimum and maximum values of the coordinates are determined.
[0016] Further, step S2 includes: assuming the set of meshes that intersect with the outer rectangle at the current mesh level. ,in , for grid set The Middle One grid, For grid sets Number of grid cells; For grid Grid encoding; For grid The set of coordinates of the four corner points; For grid The fill value is initially set to 0.
[0017] Further, step S3 includes: assuming a grid set ,in , for grid set The Middle One grid, For grid sets Number of grid cells; For grid Grid encoding; For grid The set of coordinates of the four corner points; For grid The fill value;
[0018] If grid The side length is ,but , grid Includes indivual Hierarchical subgrid ,in For grid The Middle indivual Hierarchical subgrids.
[0019] Further, step S4 includes: calculating the mesh. center point To the vertex set The distances to each vertex in the set are used to obtain the distance set. , This represents the number of vertices in the polygon. Represents a grid center point To the polygon Distance between vertices; grid center point According to the grid The coordinates of the four corner points are determined;
[0020] Traverse the distance set The minimum value is denoted as Apply the following formula to the grid. Fill value Assignment:
[0021]
[0022] when At that time, the grid For boundary grids; when At that time, the grid It is a non-boundary mesh.
[0023] Further, step S5 includes: if the mesh Fill value If the value is 0, then the mesh is determined using the ray casting method. Determine whether the four corner points are located inside the polygon, and count the number of corner points that are inside the polygon. Denote this as... Apply the following formula to the grid. Fill value Assignment:
[0024]
[0025] like If it is 1, then the grid For the internal mesh of a polygon, the mesh is... Corresponding sub-mesh set All grid fill values are set to 1; if If it is 0, then the grid For the outer mesh of the polygon, the mesh is... The fill value of all grids in the corresponding sub-grid set is set to 0; if Then the grid The boundary grid of the polygon.
[0026] Further, step S6 includes: targeting the mesh Fill value When the value is 0.5, the mesh will be... Split into corresponding indivual Hierarchical subgrid Perform sub-mesh fill value judgment: for any Hierarchical subgrid Determined by X-ray method Is the center point located inside the polygon? If the center point is located inside the polygon, then its corresponding fill value is... ,otherwise ;
[0027] Computational grid Fill value :
[0028] .
[0029] Based on the same inventive concept, the present invention provides a polygon filling system based on a multi-level combination of globally partitioned grids, comprising:
[0030] An outsourced rectangle calculation module is used to calculate the rectangle based on the vertex set of the input polygon. Determine the vertices and area of the bounding rectangle of the polygon;
[0031] The mesh retrieval module is used to retrieve and determine the set of meshes under the selected mesh level based on the vertex coordinates of the outer rectangle and the mesh encoding rules. And initialize the grid fill value;
[0032] The mesh optimization module is used to set a threshold based on the area of the outer rectangle. Compare grid sets Medium grid side length With threshold The numerical value is optimized based on the number of grid cells to be processed, and the grid set is optimized accordingly. Update to grid set ;like Then, according to the grid encoding rules, the grid is traversed upwards, and grids with side lengths greater than the threshold are selected. The smallest level of the grid is used to obtain the grid set. At this time, the grid set With grid sets A collection of meshes at different levels under the same subdivision grid; if ,but ;
[0033] The mesh coarse division module is used to calculate the mesh set. The set of center points to vertices of any grid The minimum distance between all vertices in the grid is calculated based on the minimum distance and the grid set. The grid edge length is set, and the grid is divided into boundary grids or non-boundary grids and a fill value is assigned. When the grid is divided into non-boundary grids, the non-boundary grid subdivision module is entered; when the grid is divided into boundary grids, the boundary grid processing module is entered.
[0034] The non-boundary mesh subdivision module is used to determine the mesh set based on the ray method. The number of corner points located inside the polygon among the four corner points of the non-boundary mesh is used to further classify the non-boundary mesh into internal, external, or boundary meshes of the polygon based on the number of corner points, and fill values are assigned accordingly; when the non-boundary mesh is classified as a boundary mesh of the polygon, it enters the boundary mesh processing module.
[0035] The boundary mesh processing module is used to determine the mesh set using the ray casting method. The corresponding grids of the middle boundary Whether the center point of the hierarchical sub-mesh is located inside the polygon, for each Hierarchical sub-mesh fill values are assigned; mesh set The fill value of the middle boundary grid depends on each The fill value of the hierarchical subgrid is determined;
[0036] The loop module is used to repeatedly execute the mesh coarsening module, the non-boundary mesh subdivision module, and the boundary mesh processing module until the mesh set is obtained. All grids in the process undergo data processing in the coarse meshing module, non-boundary mesh subdivision module, and boundary mesh processing module.
[0037] The fill module is used to perform coloring and filling of the internal mesh of polygons based on the mesh fill value.
[0038] Based on the same inventive concept, the present invention provides a polygon filling device based on a multi-level combination of global subdivision grids, comprising a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the polygon filling device implements the steps of the polygon filling method.
[0039] Based on the same inventive concept, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the polygon filling method.
[0040] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages:
[0041] This invention maps polygons onto a standardized global mesh. Leveraging the advantage of rapid indexing between different mesh levels based on encoding rules, it employs a coarse-to-fine approach. First, it reduces the number of meshes to be calculated to the hundreds based on the size of the polygon's outer rectangle. Then, it further analyzes the distance and position of the mesh center points to obtain the geometric relationship between all meshes and the polygons, completing the assignment of fill values. Simultaneously, this invention optimizes the handling of complex cases such as mesh fill judgment in polygon boundary regions, ensuring seamlessness and geometric correctness of the fill results. Furthermore, the high-precision, grid-by-grid parallel computation method is particularly suitable for GPU parallel acceleration technology, improving computational efficiency. This invention is a filling technique for meshes and is applicable to current mainstream meshes (such as GeoSOT). Attached Figure Description
[0042] Figure 1 This is a flowchart of a polygon filling method based on a multi-level combination of a globally partitioned mesh, provided by an embodiment of the present invention.
[0043] Figure 2 This is a schematic diagram of the mesh differentiation process in an embodiment of the present invention, wherein (a) is a schematic diagram of the differentiation between boundary meshes and non-boundary meshes, (b) is a schematic diagram of differentiating non-boundary meshes into internal meshes, external meshes, or boundary meshes of polygons, and (c) is a schematic diagram of further differentiating boundary meshes into internal meshes or external meshes of polygons. Detailed Implementation
[0044] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. Those skilled in the art will understand that the objectives and advantages achievable with the present invention are not limited to those specifically described above, and that the above and other objectives achievable by the present invention will become clearer from the following detailed description.
[0045] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application, design, and conditions of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0046] In this invention, the term "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0047] Example 1: As Figure 1 As shown, Example 1 provides a polygon filling method based on a multi-level combination of global meshes, including the following steps:
[0048] S1: Based on the vertex set of the input polygon Determine the vertices and area of the bounding rectangle of the polygon.
[0049] The vertices and area of the bounding rectangle of the polygon are determined by the coordinates of each vertex of the polygon. The minimum and maximum values of the coordinates and The minimum and maximum values of the coordinates are determined. Specifically, assume the input polygon has a set of vertices. = ,in This represents the number of vertices in the polygon. For vertex set The Middle There are vertices, and their coordinates are... To facilitate subsequent data processing, the vertex set can be... Divided into and Two sets, where , Traverse each section separately. and , obtain minimum value Maximum value , minimum value Maximum value The coordinates of the four vertices of the bounding rectangle of the polygon are... , , as well as Area of the outer rectangle .
[0050] S2: Based on the vertex coordinates of the outer rectangle and the mesh encoding rules, retrieve and determine the mesh set under the selected mesh subdivision level. And initialize the grid fill value.
[0051] Based on the grid coding rules, retrieve the set of grids that intersect with the outer rectangle at the current grid level. ,in , for grid set The Middle One grid, For grid sets Number of grid cells; For grid Grid encoding; For grid The set of coordinates of the four corner points; For grid The fill value is initially set to 0.
[0052] S3: Set a threshold based on the area of the outer rectangle. Compare grid sets Medium grid side length With threshold The numerical value is optimized based on the number of grid cells to be processed, and the grid set is optimized accordingly. Update to grid set ;like Then, according to the grid encoding rules, the grid is traversed upwards, and grids with side lengths greater than the threshold are selected. The smallest level of the grid is used to obtain the grid set. At this time, the grid set With grid sets A collection of meshes at different levels under the same subdivision grid; if ,but .
[0053] grid collection Update to grid set The goal is to reduce the number of grid cells to be computed and improve the grid set. Each grid in the middle Computational efficiency. Setting a threshold. The purpose is to evaluate the grid set. Number of grid cells. This embodiment sets a threshold. The denominator 100 can also be set to other values as needed.
[0054] like This describes the grid set. With a small number of grids, the grid set can be directly used. It is itself a grid collection , used for subsequent calculations.
[0055] like Then use a grid set. The higher-level mesh set This is used for subsequent calculations. Assume a mesh set. ,in , for grid set The Middle One grid, For grid sets Number of grid cells; For grid Grid encoding; For grid The set of coordinates of the four corner points; For grid The fill value.
[0056] If grid The side length is ,but , grid Includes indivual Hierarchical subgrid ,in For grid The Middle indivual Hierarchical subgrids.
[0057] S4: Computational Grid Set The set of center points to vertices of any grid The minimum distance between all vertices in the grid is calculated based on the minimum distance and the grid set. The grid is divided into boundary grids or non-boundary grids, and a fill value is assigned. When the grid is divided into non-boundary grids, proceed to step S5; when the grid is divided into boundary grids, proceed to step S6.
[0058] Computational grid center point To the vertex set The distances to each vertex in the set are used to obtain the distance set. , Represents a grid center point To the polygon Distance between vertices; grid center point According to the grid The coordinates of the four corner points are determined.
[0059] Traverse the distance set The minimum value is denoted as Apply the following formula to the grid. Fill value Assignment:
[0060]
[0061] when When, it indicates a grid. Distance to vertex set A grid can be considered as having one or more vertices that are close together. Located near the polygon boundary, it forms the boundary mesh; when When, it indicates a grid. Distance to vertex set In this case, all vertices are relatively far apart, and the grid can be considered as a whole. Far from the polygon, it is a non-boundary mesh.
[0062] S5: Determine the mesh set using the ray casting method The number of corner points located inside the polygon among the four corner points of the non-boundary mesh is used to further classify the non-boundary mesh into internal meshes, external meshes, or boundary meshes of the polygon based on the number of corner points, and fill values are assigned accordingly; when the non-boundary mesh is classified as a boundary mesh of the polygon, proceed to step S6.
[0063] If grid Fill value If the value is 0, then the mesh is determined using the ray casting method. Determine whether the four corner points are located inside the polygon, and count the number of corner points that are inside the polygon. Denote this as... Apply the following formula to the grid. Fill value Assignment:
[0064]
[0065] like If it is 1, then the grid For the internal mesh of a polygon, the mesh is... Corresponding sub-mesh set Set all grid fill values to 1.
[0066] like If it is 0, then the grid For the outer mesh of the polygon, the mesh is... Set the fill value of all grids in the corresponding subgrid set to 0.
[0067] like Then the grid Part of it is located inside the polygon, forming the boundary grid of the polygon.
[0068] S6: Determine the mesh set using the ray casting method The corresponding grids of the middle boundary Whether the center point of the hierarchical sub-mesh is located inside the polygon, for each Hierarchical sub-mesh fill values are assigned; mesh set The fill value of the middle boundary grid depends on each The fill value of the hierarchical subgrid is determined.
[0069] For grid Fill value When the value is 0.5, the mesh will be... Split into corresponding indivual Hierarchical subgrid Perform sub-mesh fill value judgment: for any Hierarchical subgrid Determined by X-ray method Is the center point located inside the polygon? If the center point is located inside the polygon, then its corresponding fill value is... ,otherwise .
[0070] Computational grid Fill value :
[0071] .
[0072] S7: For mesh sets After performing steps S4 to S6 on all grids, the polygon's internal grid is colored and filled according to the grid fill value.
[0073] Figure 2 The grid differentiation process is shown, in which Figure 2 (a) is based on the minimum distance from the grid center point to each vertex and the grid set. The middle grid side length is used to filter out boundary grids and non-boundary grids, where yellow grids are boundary grids and white grids are non-boundary grids. Figure 2 (b) further distinguishes each non-boundary grid into internal grids, external grids, or boundary grids, and represents them in green, black, and yellow, respectively. Figure 2 (c) in the middle is for further... Figure 2 In (b), each yellow grid (i.e., the boundary grid) is subdivided into... The result of hierarchical meshing, center point determination, and fill value calculation is shown. Mesh inside the polygon is represented in green, and mesh outside the polygon is represented in black.
[0074] Example 2: Example 2 provides a polygon filling system based on a multi-level combination of global meshes, including an outer rectangle calculation module, a mesh retrieval module, a mesh optimization module, a mesh coarse division module, a non-boundary mesh subdivision module, a boundary mesh processing module, a loop module, and a filling module.
[0075] The outer rectangle calculation module is used to calculate the value of the input polygon's vertex set. Determine the vertices and area of the bounding rectangle of the polygon.
[0076] The mesh retrieval module is used to retrieve and determine the set of meshes under the selected mesh level based on the vertex coordinates of the outer rectangle and the mesh encoding rules. And initialize the grid fill value.
[0077] The mesh optimization module is used to set a threshold based on the area of the outer rectangle. Compare grid sets Medium grid side length With threshold The numerical value is optimized based on the number of grid cells to be processed, and the grid set is optimized accordingly. Update to grid set ;like Then, according to the grid encoding rules, the grid is traversed upwards, and grids with side lengths greater than the threshold are selected. The smallest level of the grid is used to obtain the grid set. At this time, the grid set With grid sets A collection of meshes at different levels under the same subdivision grid; if ,but .
[0078] The mesh coarseness module is used to calculate the mesh set. The set of center points to vertices of any grid The minimum distance between all vertices in the grid is calculated based on the minimum distance and the grid set. The grid edge length is set, and the grid is divided into boundary grids or non-boundary grids and a fill value is assigned. When the grid is divided into non-boundary grids, the non-boundary grid subdivision module is entered; when the grid is divided into boundary grids, the boundary grid processing module is entered.
[0079] The non-boundary mesh subdivision module is used to determine the mesh set based on the ray method. The number of corner points located inside the polygon among the four corner points of the non-boundary mesh is used to further classify the non-boundary mesh into internal, external, or boundary meshes of the polygon based on the number of corner points, and fill values are assigned accordingly; when the non-boundary mesh is classified as a boundary mesh of the polygon, it enters the boundary mesh processing module.
[0080] The boundary mesh processing module is used to determine the mesh set using the ray casting method. The corresponding grids of the middle boundary Whether the center point of the hierarchical sub-mesh is located inside the polygon, for each Hierarchical sub-mesh fill values are assigned; mesh set The fill value of the middle boundary grid depends on each The fill value of the hierarchical subgrid is determined.
[0081] The loop module is used to repeatedly execute the mesh coarsening module, the non-boundary mesh subdivision module, and the boundary mesh processing module until the mesh set is completed. All grids in the process undergo data processing in the coarse meshing module, non-boundary mesh subdivision module, and boundary mesh processing module.
[0082] The fill module is used to color and fill the internal mesh of a polygon based on the mesh fill value.
[0083] Example 3: Example 3 provides a polygon filling device based on a multi-level combination of global meshes, including a processor and a memory. The memory stores computer instructions, and the processor executes the computer instructions stored in the memory. When the computer instructions are executed by the processor, the polygon filling device implements the steps of the polygon filling method described in Example 1 and achieves the same technical effect.
[0084] The memory may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the memory may be used to read and write non-removable, non-volatile magnetic media (commonly referred to as a "hard disk drive"). A program / utility having a set (at least one) of program modules may be stored in, for example, memory. Such program modules include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules typically perform the functions and / or methods described in the embodiments of the present invention.
[0085] The processor executes various functional applications and data processing by running programs stored in memory, such as implementing the polygon filling method provided in Embodiment 1 of the present invention.
[0086] Example 4: Example 4 provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the polygon filling method as described in Example 1 and achieves the same technical effect.
[0087] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0088] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0089] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0090] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0091] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the above-described method operations, but can also perform related operations in the methods provided in any embodiment of the present invention.
[0092] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A polygon filling method based on a multi-level combination of globally partitioned meshes, characterized in that, include: S1: Based on the vertex set of the input polygon Determine the vertices and area of the bounding rectangle of the polygon; S2: Based on the vertex coordinates of the outer rectangle and the mesh encoding rules, retrieve and determine the mesh set under the selected mesh subdivision level. And initialize the grid fill value; S3: Set a threshold based on the area of the outer rectangle. Compare grid sets Medium grid side length With threshold The numerical value is optimized based on the number of grid cells to be processed, and the grid set is optimized accordingly. Update to grid set ;like Then, according to the grid encoding rules, the grid is traversed upwards, and grids with side lengths greater than the threshold are selected. The smallest level of the grid is used to obtain the grid set. At this time, the grid set With grid sets A collection of meshes at different levels under the same subdivision grid; if ,but ; S4: Computational Grid Set The set of center points to vertices of any grid The minimum distance between all vertices in the grid is calculated based on the minimum distance and the grid set. The grid is divided into boundary grids or non-boundary grids, and fill values are assigned accordingly. When the grid is divided into non-boundary grids, proceed to step S5; when the grid is divided into boundary grids, proceed to step S6. S5: Determine the mesh set using the ray casting method The number of corner points located inside the polygon among the four corner points of the non-boundary mesh is used to further classify the non-boundary mesh into internal meshes, external meshes, or boundary meshes of the polygon based on the number of corner points, and fill values are assigned accordingly; when the non-boundary mesh is classified as a boundary mesh of the polygon, proceed to step S6; S6: Determine the mesh set using the ray casting method The corresponding grids of the middle boundary Whether the center point of the hierarchical sub-mesh is located inside the polygon, for each Hierarchical sub-mesh fill values are assigned; mesh set The fill value of the middle boundary grid depends on each The fill value of the hierarchical subgrid is determined; S7: For mesh sets After performing steps S4 to S6 on all grids, the polygon's internal grid is colored and filled according to the grid fill value.
2. The polygon filling method based on multi-level combination of global meshes according to claim 1, characterized in that, In step S1, the vertices and area of the bounding rectangle of the polygon are determined based on the coordinates of each vertex of the polygon. The minimum and maximum values of the coordinates and The minimum and maximum values of the coordinates are determined.
3. The polygon filling method based on multi-level combination of global meshes according to claim 1, characterized in that, Step S2 includes: assuming the set of meshes that intersect with the outer rectangle at the current mesh level. ,in , for grid set The Middle One grid, For grid sets Number of grid cells; For grid Grid encoding; For grid The set of coordinates of the four corner points; For grid The initial value for filling is 0.
4. The polygon filling method based on multi-level combination of global mesh as described in claim 3, characterized in that, Step S3 includes: assuming a grid set ,in , for grid set The Middle One grid, For grid sets Number of grid cells; For grid Grid encoding; For grid The set of coordinates of the four corner points; For grid The fill value; If grid The side length is ,but , grid Includes indivual Hierarchical subgrid ,in For grid The Middle indivual Hierarchical subgrids.
5. The polygon filling method based on multi-level combination of global meshes according to claim 4, characterized in that, Step S4 includes: calculating the mesh center point To the vertex set The distances to each vertex in the set are used to obtain the distance set. , This represents the number of vertices in the polygon. Represents a grid center point To the polygon Distance between vertices; grid center point According to the grid The coordinates of the four corner points are determined; Traverse the distance set The minimum value is denoted as Apply the following formula to the grid. Fill value Assignment: when At that time, the grid For boundary grids; when At that time, the grid It is a non-boundary mesh.
6. The polygon filling method based on multi-level combination of global mesh as described in claim 5, characterized in that, Step S5 includes: if the mesh Fill value If the value is 0, then the mesh is determined using the ray casting method. Determine whether the four corner points are located inside the polygon, and count the number of corner points that are inside the polygon. Denote this as... Apply the following formula to the grid. Fill value Assignment: like If it is 1, then the grid For the internal mesh of a polygon, the mesh is... Corresponding sub-mesh set All grid fill values are set to 1; if If it is 0, then the grid For the outer mesh of the polygon, the mesh is... The fill value of all grids in the corresponding sub-grid set is set to 0; if Then the grid The boundary grid of the polygon.
7. The polygon filling method based on multi-level combination of global meshes according to claim 6, characterized in that, Step S6 includes: targeting the mesh Fill value When the value is 0.5, the mesh will be... Split into corresponding indivual Hierarchical subgrid Perform sub-mesh fill value judgment: for any Hierarchical subgrid Determined by X-ray method Is the center point located inside the polygon? If the center point is located inside the polygon, then its corresponding fill value is... ,otherwise ; Computational grid Fill value : 。 8. A polygon filling system based on a multi-level combination of globally partitioned grids, characterized in that, include: An outsourced rectangle calculation module is used to calculate the rectangle based on the vertex set of the input polygon. Determine the vertices and area of the bounding rectangle of the polygon; The mesh retrieval module is used to retrieve and determine the set of meshes under the selected mesh level based on the vertex coordinates of the outer rectangle and the mesh encoding rules. And initialize the grid fill value; The mesh optimization module is used to set a threshold based on the area of the outer rectangle. Compare grid sets Medium grid side length With threshold The numerical value is optimized based on the number of grid cells to be processed, and the grid set is optimized accordingly. Update to grid set ;like Then, according to the grid encoding rules, the grid is traversed upwards, and grids with side lengths greater than the threshold are selected. The smallest level of the grid is used to obtain the grid set. At this time, the grid set With grid sets A collection of meshes at different levels under the same subdivision grid; if ,but ; The mesh coarse division module is used to calculate the mesh set. The set of center points to vertices of any grid The minimum distance between all vertices in the grid is calculated based on the minimum distance and the grid set. The grid edge length is set, and the grid is divided into boundary grids or non-boundary grids and a fill value is assigned. When the grid is divided into non-boundary grids, the non-boundary grid subdivision module is entered. When a grid is divided into boundary grids, the process enters the boundary grid processing module; The non-boundary mesh subdivision module is used to determine the mesh set based on the ray method. The number of corner points located inside the polygon among the four corner points of the non-boundary mesh is used to further classify the non-boundary mesh into internal, external, or boundary meshes of the polygon based on the number of corner points, and fill values are assigned accordingly; when the non-boundary mesh is classified as a boundary mesh of the polygon, it enters the boundary mesh processing module. The boundary mesh processing module is used to determine the mesh set using the ray casting method. The corresponding grids of the middle boundary Whether the center point of the hierarchical sub-mesh is located inside the polygon, for each Hierarchical sub-mesh fill values are assigned; mesh set The fill value of the middle boundary grid depends on each The fill value of the hierarchical subgrid is determined; The loop module is used to repeatedly execute the mesh coarsening module, the non-boundary mesh subdivision module, and the boundary mesh processing module until the mesh set is obtained. All grids in the process undergo data processing in the coarse meshing module, non-boundary mesh subdivision module, and boundary mesh processing module. The fill module is used to perform coloring and filling of the internal mesh of polygons based on the mesh fill value.
9. A polygon filling device based on a multi-level combination of globally partitioned grids, characterized in that, The device includes a processor and a memory, the memory storing computer instructions, and the processor executing the computer instructions stored in the memory. When the computer instructions are executed by the processor, the polygon filling device implements the steps of the polygon filling method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the polygon filling method as described in any one of claims 1 to 7.