Polygon processing method and device, equipment and storage medium
By obtaining the vertices of the polygon and determining its corresponding scanning lines, the polygons are divided into sub-polygons, which solves the problem of low rendering efficiency of complex polygons and achieves rapid rendering.
Patent Information
- Application Number
- CN202510331160.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-03-20
AI Technical Summary
In the prior art, when the polygon renders complex or there are many vertices, the scanning line filling method and the polygon decomposition method lead to low rendering efficiency.
By obtaining each vertex of the polygon, determining the scan line corresponding to each vertex, dividing the polygon into multiple sub-polygons, thereby improving rendering efficiency.
By dividing the polygon into subpolygons with larger areas, polygon filling can be quickly performed to improve rendering efficiency.
Smart Images

Figure CN119850783A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a polygon processing method, device, equipment and storage medium, and relates to the technical field of computer technology. Background Art
[0002] In the field of computer technology, in order to render polygons, it is usually necessary to fill the polygons. When filling the polygons, a scan line filling method or a polygon decomposition method is generally used.
[0003] In the related art, when the polygon is very complex or has a large number of vertices, the scan line filling method needs to calculate the intersection of each scan line and the polygon edge, which significantly increases the amount of calculation and leads to low polygon rendering efficiency. When the polygon decomposition method is used, when the decomposed triangle is large and has more pixels, the rendering speed of the polygon is reduced. In this way, there is a technical problem of low rendering efficiency in the related art. Summary of the invention
[0004] The present invention provides a polygon processing method, device, equipment and storage medium to at least solve the technical problem of low rendering efficiency in the related art. The technical solution of the present application is as follows: According to a first aspect of an embodiment of the present application, a polygon processing method is provided, including: obtaining each vertex of the polygon to be processed; determining the scan line corresponding to each vertex to obtain multiple scan lines; two adjacent scan lines among the multiple scan lines are parallel; the scan line corresponding to each vertex passes through each vertex; and dividing the polygon to be processed into multiple sub-polygons according to the multiple scan lines.
[0005] In a possible implementation, the polygon to be processed is divided into multiple sub-polygons according to multiple scan lines, including: for the first scan line, the intersection of the first scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons; for the second scan line, the intersection of the second scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the second scan line is a scan line adjacent to the first scan line.
[0006] In a possible implementation, when the first sub-polygon has three vertices, the first sub-polygon is a triangle.
[0007] In a possible implementation manner, when the first sub-polygon has four vertices, the first sub-polygon is a trapezoid or a rectangle.
[0008] In a possible implementation, the method further includes: for the third scan line, when the intersection of the third scan line and the polygon to be processed is the vertex of the polygon to be processed, removing the active edge where the intersection of the third scan line and the polygon to be processed is located; the third scan line is any one of a plurality of scan lines; when the intersection of the third scan line and the polygon to be processed is not the vertex of the polygon to be processed, determining the intersection as the endpoint of the active edge.
[0009] According to the second aspect of an embodiment of the present application, a polygon processing device is provided, the device comprising: an acquisition unit, a determination unit and a processing unit; the acquisition unit is used to acquire each vertex of the polygon to be processed; the determination unit is used to determine the scan line corresponding to each vertex to obtain multiple scan lines; two adjacent scan lines among the multiple scan lines are parallel; the scan line corresponding to each vertex passes through each vertex; the processing unit is used to divide the polygon to be processed into multiple sub-polygons according to the multiple scan lines.
[0010] In a possible implementation, in the above-mentioned polygon processing device, the processing unit is specifically used to: for the first scan line, determine the intersection of the first scan line and the polygon to be processed as the vertex of the first sub-polygon; the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons; for the second scan line, determine the intersection of the second scan line and the polygon to be processed as the vertex of the first sub-polygon; the second scan line is a scan line adjacent to the first scan line.
[0011] In a possible implementation, in the polygon processing device, when the first sub-polygon has three vertices, the first sub-polygon is a triangle.
[0012] In a possible implementation, in the polygon processing device, when the first sub-polygon has four vertices, the first sub-polygon is a trapezoid or a rectangle.
[0013] In a possible embodiment, in the above-mentioned polygon processing device, the above-mentioned processing unit is also used for: for the third scan line, when the intersection of the third scan line and the polygon to be processed is the vertex of the polygon to be processed, removing the active edge where the intersection of the third scan line and the polygon to be processed is located; when the intersection of the third scan line and the polygon to be processed is not the vertex of the polygon to be processed, determining the intersection as the endpoint of the active edge; the third scan line is any one of the multiple scan lines.
[0014] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to execute instructions to implement the method of the above-mentioned first aspect and any possible implementation manner thereof.
[0015] According to the fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method in the above-mentioned first aspect and any possible implementation method thereof.
[0016] According to a fifth aspect of an embodiment of the present application, a computer program product is provided. The computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method of the first aspect and any possible implementation manner thereof.
[0017] The technical solution of the first aspect provided by the embodiments of the present application brings at least the following beneficial effects: The technical solution provided by the embodiment of the present application first obtains each vertex of the polygon to be processed; then determines the scan line corresponding to each vertex to obtain multiple scan lines. Then, according to the multiple scan lines, the polygon to be processed is divided into multiple sub-polygons. In this way, the polygon to be processed can be divided into multiple sub-polygons with larger areas according to the multiple scan lines, and the polygon can be filled quickly.
[0018] It should be noted that the technical effects brought about by any implementation method in the second to fifth aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here.
[0019] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.
[0021] Figure 1 is a flowchart of a polygon processing method according to an exemplary embodiment; Figure 2 is a schematic diagram of a polygon processing method according to an exemplary embodiment; Figure 3 is a schematic diagram of another polygon processing method according to an exemplary embodiment; Figure 4 is a flowchart of another polygon processing method according to an exemplary embodiment; Figure 5 is a schematic diagram of another polygon processing method according to an exemplary embodiment; Figure 6is a schematic diagram of another polygon processing method according to an exemplary embodiment; Figure 7 is a schematic diagram of another polygon processing method according to an exemplary embodiment; Figure 8 is a schematic diagram of another polygon processing method according to an exemplary embodiment; Fig. 9 is a schematic diagram of another polygon processing method according to an exemplary embodiment; Fig.10 is a block diagram of a polygon processing device according to an exemplary embodiment; Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0022] In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples. The following examples are used to illustrate the present invention but are not used to limit the scope of the present invention.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0024] Before introducing the polygon processing method provided by the present application in detail, a brief introduction to the application scenarios involved in the present application is first given.
[0025] In the field of computer technology, in order to render polygons, it is usually necessary to fill the polygons. When filling polygons, a scan line filling method or a polygon decomposition method is generally used. Common polygon decomposition methods include Delaunay triangulation, ear cutting method, etc.
[0026] In the related art, when the polygon is very complex or has a large number of vertices, the scan line filling method needs to calculate the intersection of each scan line and the polygon edge, which significantly increases the amount of calculation and leads to low polygon rendering efficiency. When the polygon decomposition method is used, when the decomposed triangle is large and has more pixels, the rendering speed of the polygon is reduced. In this way, there is a technical problem of low rendering efficiency in the related art.
[0027] Figure 1 1 is a flowchart of a polygon processing method according to an exemplary embodiment. The method can be applied to an electronic device or a polygon processing device connected to or located inside the electronic device. The method is described below by taking the method applied to the electronic device as an example. Figure 1 As shown, the polygon processing method includes the following steps: S101: The electronic device obtains each vertex of a polygon to be processed.
[0028] The vertices of the polygon to be processed are the inflection points of the polygon to be processed.
[0029] As a possible implementation method, the electronic device traverses the inner hole of the outer contour of the polygon to be processed to obtain the coordinates of each vertex of the polygon to be processed.
[0030] S102: The electronic device determines a scan line corresponding to each vertex to obtain a plurality of scan lines.
[0031] Among the multiple scan lines, two adjacent scan lines are parallel; and the scan line corresponding to each vertex passes through each vertex.
[0032] As a possible implementation, the electronic device determines a scan line that is parallel to the Y axis in the coordinate system and passes through a vertex as the scan line corresponding to the vertex. Further, the electronic device determines multiple scan lines.
[0033] As another possible implementation, the electronic device determines a scan line that is parallel to the X-axis in the coordinate system and passes through a vertex as the scan line corresponding to the vertex. Further, the electronic device determines multiple scan lines.
[0034] As another possible implementation, the electronic device determines a scan line that is not parallel to the X-axis and the Y-axis in the coordinate system and passes through the vertex as the scan line corresponding to the vertex. Further, the electronic device determines multiple scan lines.
[0035] In actual application, the electronic device can traverse the inner control of the outer contour to be processed once to obtain the scan line of the X coordinates of all vertices of the polygon to be processed, and the edge link list-link list of the polygon to be processed. The edge link list-link list of the polygon to be processed is a link list composed of multiple edge link lists. The sorting direction of the edge link list-link list can be to sort the edge link list from left to right according to the direction of the scan line.
[0036] like Figure 2 As shown, when the scan line is parallel to the Y axis, for the edge list EL1 on the same scan line, the edges can be sorted from bottom to top according to the Y coordinates of the edges on the scan line. Thus, the edges in the edge list EL1 are sorted as e1, e2.
[0037] like Figure 3 As shown in the figure, when the scan line is parallel to the Y axis, for the edge list EL2 on the same scan line, when multiple edges have the same Y coordinate on the scan line, they can be sorted from small to large according to the slope of each edge. Since the Y coordinates of edge e2 and edge e3 are the same, the order of the edges in edge list EL2 is e1, e2, e3.
[0038] S103: The electronic device divides the polygon to be processed into multiple sub-polygons according to multiple scan lines.
[0039] As a possible implementation manner, first, for the first scan line, the electronic device determines the intersection point between the first scan line and the polygon to be processed as the vertex of the first sub-polygon.
[0040] Secondly, for the second scan line, the electronic device determines the intersection point between the second scan line and the polygon to be processed as the vertex of the first sub-polygon.
[0041] It should be noted that the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons.
[0042] The second scan line is a scan line adjacent to the first scan line.
[0043] It can be understood that the technical solution provided in the embodiment of the present application first obtains each vertex of the polygon to be processed; then determines the scan line corresponding to each vertex to obtain multiple scan lines. Then, according to the multiple scan lines, the polygon to be processed is divided into multiple sub-polygons. In this way, the polygon to be processed can be divided into multiple sub-polygons with larger areas according to the multiple scan lines, and the polygon can be filled quickly.
[0044] In some embodiments, in order to be able to divide the polygon to be processed into multiple sub-polygons, in the polygon processing method provided in the embodiment of the present application, for example Figure 4 As shown, the above S103 specifically includes the following steps: S201: The electronic device determines, for a first scan line, intersection points between the first scan line and a polygon to be processed as vertices of a first sub-polygon.
[0045] The first scan line is any one of the multiple scan lines; and the first sub-polygon is any one of the multiple sub-polygons.
[0046] In actual application, the electronic device determines an active edge list from the edge list-list of the polygon to be processed. Figure 5 As shown, the intersection points of the first scan line and the polygon to be processed are intersection point A and intersection point B. Further, the electronic device determines both intersection point A and intersection point B as vertices of the first sub-polygon.
[0047] S202: The electronic device determines, for the second scan line, intersection points between the second scan line and the polygon to be processed as vertices of the first sub-polygon.
[0048] The second scan line is a scan line adjacent to the first scan line.
[0049] In actual application, Figure 6 As shown, the first scan line moves to the right and becomes the second scan line. The intersections of the second scan line and the polygon to be processed are intersection points C and D. As can be seen from the above, intersection point C is the vertex of the polygon to be processed, and intersection point D is the intersection point of the active edge e2 and the second scan line.
[0050] The vertices of the first sub-polygon are intersection point A, intersection point B, intersection point C, and intersection point D.
[0051] It should be noted that when the first sub-polygon has four vertices, the first sub-polygon is a trapezoid or a rectangle, and the polygon can be quickly filled. Of course, the rectangle can be understood as a special trapezoid, and the geometric characteristics of the rectangle make rasterization simpler.
[0052] When the first sub-polygon has three vertices, the first sub-polygon is a triangle. The triangle can be understood as a degenerate trapezoid. The two vertices of the first sub-polygon on a scan line coincide with each other. Compared with a general arbitrary triangle, it also has the properties of a trapezoid and can be quickly rasterized.
[0053] It can be understood that the technical solution provided in the embodiment of the present application is that for the first scan line, the intersection of the first scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons; and for the second scan line, the intersection of the second scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the second scan line is a scan line adjacent to the first scan line. In this way, a sub-polygon can be determined from the polygon to be processed through any two adjacent scan lines, and then, through all the scan lines, the polygon to be processed can be decomposed into multiple sub-polygons.
[0054] In some embodiments, the polygon processing method provided by the embodiments of the present application further includes: For the third scan line, when the intersection point between the third scan line and the polygon to be processed is a vertex of the polygon to be processed, the active edge where the intersection point between the third scan line and the polygon to be processed is located is removed.
[0055] It should be noted that the third scan line is any one of the multiple scan lines.
[0056] The active edge is the edge where the third scan line intersects the polygon to be processed.
[0057] When the intersection point between the third scanning line and the to-be-processed polygon is not a vertex of the to-be-processed polygon, the intersection point is determined as an endpoint of the active edge.
[0058] It should be noted that the endpoint of the above-mentioned active edge is the starting point of the updated active edge.
[0059] It is understandable that when the intersection of the third scan line and the polygon to be processed is not the vertex of the polygon to be processed, the intersection is determined as the starting point of the active edge. In this way, the active edge can be updated so that a new trapezoid or rectangle is formed according to the updated active edge.
[0060] like Figure 7 As shown, in actual application, when the polygon to be processed is a rectangle and the scan line is parallel to the Y axis, the decomposed polygon to be processed is still a rectangle.
[0061] like Figure 8 As shown, in actual application, when the polygon to be processed is a triangle and the scan line is parallel to the Y axis, the decomposed polygon to be processed is two triangles.
[0062] In other cases, for example, the polygon to be processed is a right triangle placed vertically, and it is still a right triangle after decomposition.
[0063] like Fig. 9As shown, in actual application, when the polygon to be processed is an irregular polygon and the scanning line is parallel to the Y axis, the decomposed polygon to be processed is a plurality of triangles and a plurality of trapezoids.
[0064] In actual application, the method decomposes any irregular polygon to be processed to obtain one or more of a plurality of triangles, a plurality of trapezoids, and a plurality of rectangles.
[0065] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to realize the above functions, the polygon processing device or electronic device includes hardware structures and / or software modules corresponding to executing each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0066] The embodiment of the present application can exemplarily divide the polygon processing device or electronic device into functional modules according to the above method. For example, the polygon processing device or electronic device can include functional modules corresponding to the functional divisions, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0067] For example, an embodiment of the present application also provides a polygon processing device.
[0068] In some embodiments, Fig.10 FIG. 3 is a block diagram of a polygon processing device 300 according to an exemplary embodiment. Fig.10 The polygon processing device 300 includes an acquisition unit 301, a determination unit 302 and a processing unit 303.
[0069] The acquisition unit 301 is used to acquire each vertex of the polygon to be processed.
[0070] The determination unit 302 is used to determine the scan line corresponding to each vertex to obtain a plurality of scan lines; two adjacent scan lines in the plurality of scan lines are parallel; and the scan line corresponding to each vertex passes through each vertex.
[0071] The processing unit 303 is used to divide the polygon to be processed into multiple sub-polygons according to multiple scan lines.
[0072] Optional, such as Fig.10 As shown, the processing unit 303 provided in the embodiment of the present application is specifically used for: For the first scan line, the intersection point between the first scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons.
[0073] For the second scan line, the intersection point between the second scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the second scan line is a scan line adjacent to the first scan line.
[0074] Optionally, when the first sub-polygon has three vertices, the first sub-polygon is a triangle.
[0075] Optionally, when the first sub-polygon has four vertices, the first sub-polygon is a trapezoid or a rectangle.
[0076] Optionally, the processing unit 303 is further configured to: For the third scan line, when the intersection point between the third scan line and the polygon to be processed is a vertex of the polygon to be processed, the active edge where the intersection point between the third scan line and the polygon to be processed is located is removed; When the intersection point between the third scanning line and the to-be-processed polygon is not a vertex of the to-be-processed polygon, the intersection point is determined as an endpoint of the active edge.
[0077] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0078] Fig.11 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Fig.11 As shown, the electronic device 400 includes but is not limited to: a processor 401 and a memory 402 .
[0079] The memory 402 is used to store executable instructions of the processor 401. It can be understood that the processor 401 is configured to execute instructions to implement the polygon processing method in the above embodiment.
[0080] It should be noted that those skilled in the art can understand that Fig.11 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include Fig.11 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.
[0081] The processor 401 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 401 may include one or more processing units. Optionally, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0082] The memory 402 may be used to store software programs and various data. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one functional module (such as a determination unit, a processing unit, etc.), etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0083] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 402 including instructions, and the above instructions can be executed by a processor 401 of an electronic device 400 to implement the polygon processing method in the above embodiment.
[0084] In actual implementation, Fig.10 The functions of the acquisition unit 301, the determination unit 302 and the processing unit 303 in Fig.11 The processor 401 in the embodiment calls the computer program stored in the memory 402. The specific execution process can refer to the description of the polygon processing method in the above embodiment, which will not be repeated here.
[0085] Optionally, the computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0086] In an exemplary embodiment, the present application also provides a computer program product including one or more instructions, and the one or more instructions can be executed by the processor 401 of the electronic device to complete the polygon processing method in the above embodiment.
[0087] It should be noted that when the instructions in the above-mentioned computer-readable storage medium or one or more instructions in the computer program product are executed by the processor of the electronic device, the various processes of the above-mentioned polygon processing method embodiment are implemented, and the same technical effect as the above-mentioned polygon processing method can be achieved. To avoid repetition, they will not be repeated here.
[0088] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0089] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0090] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0091] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0092] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the full classification part or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute the full classification part or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD and other media that can store program code.
[0093] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A polygon processing method, characterized in that: The method comprises: Get each vertex of the polygon to be processed; Determine a scan line corresponding to each vertex to obtain a plurality of scan lines; two adjacent scan lines in the plurality of scan lines are parallel; and the scan line corresponding to each vertex passes through each vertex; According to the multiple scan lines, the polygon to be processed is divided into multiple sub-polygons.
2. The method according to claim 1, characterized in that The step of dividing the polygon to be processed into a plurality of sub-polygons according to the plurality of scan lines comprises: For a first scan line, an intersection point between the first scan line and the polygon to be processed is determined as a vertex of a first sub-polygon; the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons; For the second scan line, the intersection point between the second scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the second scan line is a scan line adjacent to the first scan line.
3. The method according to claim 2, characterized in that include: When the first sub-polygon has three vertices, the first sub-polygon is a triangle.
4. The method according to claim 2, characterized in that: include: When the first sub-polygon has four vertices, the first sub-polygon is a trapezoid or a rectangle.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: For a third scan line, when an intersection point between the third scan line and the polygon to be processed is a vertex of the polygon to be processed, removing an active edge where the intersection point between the third scan line and the polygon to be processed is located; the third scan line is any one of the multiple scan lines; When the intersection point between the third scan line and the to-be-processed polygon is not a vertex of the to-be-processed polygon, the intersection point is determined as an endpoint of the active edge.
6. A polygon processing device, characterized in that: The device comprises: an acquisition unit, a determination unit and a processing unit; The acquisition unit is used to acquire each vertex of the polygon to be processed; The determining unit is used to determine the scan line corresponding to each vertex to obtain a plurality of scan lines; two adjacent scan lines in the plurality of scan lines are parallel; and the scan line corresponding to each vertex passes through each vertex; The processing unit is used to divide the polygon to be processed into multiple sub-polygons according to the multiple scan lines.
7. The device according to claim 6, characterized in that The processing unit is specifically used for: For a first scan line, an intersection point between the first scan line and the polygon to be processed is determined as a vertex of a first sub-polygon; the first scan line is any one of the multiple scan lines; the first sub-polygon is any one of the multiple sub-polygons; For the second scan line, the intersection point between the second scan line and the polygon to be processed is determined as the vertex of the first sub-polygon; the second scan line is a scan line adjacent to the first scan line.
8. The device according to claim 7, characterized in that When the first sub-polygon has three vertices, the first sub-polygon is a triangle.
9. The device according to claim 7, characterized in that When the first sub-polygon has four vertices, the first sub-polygon is a trapezoid or a rectangle.
10. The device according to any one of claims 6 to 9, characterized in that: The processing unit is also used for: For the third scan line, when the intersection point between the third scan line and the polygon to be processed is a vertex of the polygon to be processed, removing the active edge where the intersection point between the third scan line and the polygon to be processed is located; The third scan line is any one of the plurality of scan lines; When the intersection point between the third scan line and the to-be-processed polygon is not a vertex of the to-be-processed polygon, the intersection point is determined as an endpoint of the active edge.
11. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method as claimed in any one of claims 1 to 5.
12. A computer-readable storage medium, characterized in that: When the computer-executable instructions stored in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is capable of performing the method as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Triangularization method of polygon in computer image processing and system using the same
CN103164864A
Image processing method and device
CN105513008A
Polygonal land parcel segmentation method and device, storage medium and electronic equipment
CN109934384A
Excavation and filling amount calculation method and device
CN114219922A
Large-scale graph simplification method for polygon with arcs
CN118133759A
Cited By
Polygon trapezoidal segmentation method and device based on double scanning lines, medium, terminal and program product
CN121353299A