Graph processing method and device, computer equipment and storage medium
By obtaining the point list of figures and directly performing target calculation processing, the problem of loss of arc segment information in the prior art is solved, and the efficiency and effect of figure processing are improved.
Patent Information
- Application Number
- CN202311199396.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-03-18
AI Technical Summary
When performing Boolean operations, existing graphics processing methods convert arc segments into straight line segments, resulting in information loss, low computing efficiency, large amount of data stored, and poor graphics processing effect.
By obtaining the point list of the figure, including inflection point position information and the convexity information of the starting point of the arc segment, the target operation process is performed directly to obtain the target point list of the target graph, and avoid converting the arc into a straight line segment.
The information of the arc segment is retained, the calculation efficiency and storage efficiency of graphics processing are improved, and the graphics processing effect is improved.
Smart Images

Figure CN119648819A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a graphics processing method, apparatus, computer equipment and storage medium. Background Art
[0002] When designing home decoration, in order to obtain home decoration data that meets the requirements, it is necessary to perform Boolean operations on contours with arcs. Most existing graphics processing methods convert arc segments in graphics into several straight line segments when performing Boolean operations, and then use the converted line segments for calculations. This not only leads to the loss of information such as the radius and angle of the arc segments, but also leads to problems such as low calculation efficiency and large amount of stored data, resulting in poor graphics processing effects. Summary of the invention
[0003] The embodiments of the present disclosure at least provide a graphics processing method, apparatus, computer equipment, and storage medium.
[0004] In a first aspect, an embodiment of the present disclosure provides a graphics processing method, including:
[0005] Acquire a first point list of a first graphic representing a first entity object and a second point list of a second graphic representing a second entity object; wherein at least one of the first graphic and the second graphic includes an arc segment; the point list includes position information of each inflection point of the graphic and convexity information of a starting point of the arc segment, and the graphic includes the first graphic and the second graphic;
[0006] Determine a target operation type between the first graphic and the second graphic, and process the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic; wherein the target graphic is used to represent a target object after the first entity object and the second entity object are fused, and the target point list is used to render the target graphic.
[0007] In a possible implementation manner, the processing the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic includes:
[0008] Determine, based on the first point list and the second point list, location information of an intersection of the first figure and the second figure;
[0009] Traversing each edge of the first graph and the second graph, for any edge, taking the edge as the starting edge, and determining the remaining edges constituting the target graph corresponding to the edge according to the edge selection method corresponding to the target operation type; wherein, when the target operation type is an intersection operation, the starting edge is a line segment with the intersection point as an endpoint;
[0010] The target graphics corresponding to each edge are filtered, and a target point list of the filtered target graphics is determined.
[0011] In a possible implementation manner, determining the remaining edges constituting the target graph according to the edge selection method corresponding to the target operation type includes:
[0012] Determine the sideline extension direction; wherein the sideline extension direction is the same as the graphic direction of the graphic where the starting sideline is located;
[0013] If the end point of the starting sideline is not the intersection point, the starting sideline is connected to the next line of the starting sideline in the extension direction of the sideline, and the connected line is used as the starting sideline again;
[0014] If the end point of the starting edge line is the intersection point, a next line of the starting edge line is selected from the intersecting lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type.
[0015] In a possible implementation, screening the target graphs corresponding to the edges includes:
[0016] For a target graph corresponding to any edge, when the target graph is a closed graph and does not contain repeated line segments, the target graph is used as a filtered graph.
[0017] In a possible implementation, the selecting a next line of the starting edge line from the intersection lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type includes:
[0018] Determine a first direction of the starting edge line and a second direction of each intersection line; wherein, when the intersection line is an arc segment, the second direction is a tangent direction of the arc segment, and the second direction of the intersection line is consistent with a graphic direction of the graphic where the intersection line is located;
[0019] Based on the first direction and the second direction and the edge line selection method corresponding to the target operation type, a target direction is determined, and the intersection line in the target direction is used as the next line of the starting edge line.
[0020] In a possible implementation manner, when the intersection line includes multiple arc segments and the tangent directions of the multiple arc segments are the same, the method further includes selecting the next line of the starting edge line from the intersection lines corresponding to the intersection point according to the following method:
[0021] Determining the curvature of the plurality of circular arc segments;
[0022] Based on the first direction, the curvatures of the plurality of arc line segments, and the edge line selection method corresponding to the target operation type, a next line of the starting edge line is determined to be selected from the intersection lines corresponding to the intersection point.
[0023] In a possible implementation manner, the target operation type is a Boolean operation type.
[0024] In a second aspect, an embodiment of the present disclosure further provides a graphics processing device, including:
[0025] a determination module, configured to obtain a first point list of a first graphic representing a first entity object and a second point list of a second graphic representing a second entity object; wherein at least one of the first graphic and the second graphic comprises an arc segment; the point list comprises position information of each inflection point of the graphic and convexity information of a starting point of the arc segment, and the graphic comprises the first graphic and the second graphic;
[0026] A processing module is used to determine a target operation type between the first graphic and the second graphic, and process the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic; wherein the target graphic is used to represent a target object after the first entity object and the second entity object are fused, and the target point list is used to render the target graphic.
[0027] In a possible implementation manner, the processing module, when processing the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic, is used to:
[0028] Determine, based on the first point list and the second point list, location information of an intersection of the first figure and the second figure;
[0029] Traversing each edge of the first graph and the second graph, for any edge, taking the edge as the starting edge, and determining the remaining edges constituting the target graph corresponding to the edge according to the edge selection method corresponding to the target operation type; wherein, when the target operation type is an intersection operation, the starting edge is a line segment with the intersection point as an endpoint;
[0030] The target graphics corresponding to each edge are filtered, and a target point list of the filtered target graphics is determined.
[0031] In a possible implementation manner, the processing module, when determining the remaining edges constituting the target graph according to the edge selection method corresponding to the target operation type, is configured to:
[0032] Determine the sideline extension direction; wherein the sideline extension direction is the same as the graphic direction of the graphic where the starting sideline is located;
[0033] If the end point of the starting sideline is not the intersection point, the starting sideline is connected to the next line of the starting sideline in the extension direction of the sideline, and the connected line is used as the starting sideline again;
[0034] If the end point of the starting edge line is the intersection point, a next line of the starting edge line is selected from the intersecting lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type.
[0035] In a possible implementation manner, the processing module, when screening the target graphics corresponding to each edge, is used to:
[0036] For a target graph corresponding to any edge, when the target graph is a closed graph and does not contain repeated line segments, the target graph is used as a filtered graph.
[0037] In a possible implementation manner, the processing module, when selecting the next line of the starting edge line from the intersection lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type, is configured to:
[0038] Determine a first direction of the starting edge line and a second direction of each intersection line; wherein, when the intersection line is an arc segment, the second direction is a tangent direction of the arc segment, and the second direction of the intersection line is consistent with a graphic direction of the graphic where the intersection line is located;
[0039] Based on the first direction and the second direction and the edge line selection method corresponding to the target operation type, a target direction is determined, and the intersection line in the target direction is used as the next line of the starting edge line.
[0040] In a possible implementation manner, when the intersection line includes multiple arc segments and the tangent directions of the multiple arc segments are the same, the processing module is further configured to select the next line of the starting edge line from the intersection line corresponding to the intersection point according to the following method:
[0041] Determining the curvature of the plurality of circular arc segments;
[0042] Based on the first direction, the curvatures of the plurality of arc line segments, and the edge line selection method corresponding to the target operation type, a next line of the starting edge line is determined to be selected from the intersection lines corresponding to the intersection point.
[0043] In a third aspect, an embodiment of the present disclosure further provides a computer device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0044] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.
[0045] In the graphics processing method, device, computer equipment and storage medium provided by the embodiments of the present disclosure, the arc segments in the graphics can be represented by the position information of the starting point of the arc segments and the convexity information, so that the information of the arc segments can be retained as much as possible; in addition, the first point list of the first graphics representing the first entity object and the second point list of the second graphics representing the second entity object can be processed according to the target operation type corresponding to the determined fusion method to obtain the target point list of the target graphics representing the fused target object. In this way, the graphics with arcs can be directly processed without converting the arcs into straight line segments, thereby improving the efficiency of calculating and storing the graphics files.
[0046] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0048] Figure 1 A flowchart of a graphics processing method provided by an embodiment of the present disclosure is shown;
[0049] Figure 2 A schematic diagram showing a method for calculating convexity information in a graphics processing method provided by an embodiment of the present disclosure is shown;
[0050] Figure 3 A schematic diagram of a convexity calculation method provided by an embodiment of the present disclosure when the inflection point is both the starting point and the end point of the arc is shown;
[0051] Figure 4 A schematic diagram of an edge selection method in a graphics processing method provided by an embodiment of the present disclosure is shown;
[0052] Figure 5 A schematic diagram of a method for selecting an edge line provided by an embodiment of the present disclosure when the directions of the tangent lines of the arcs at the intersection points are the same is shown;
[0053] Figure 6 A schematic diagram for introducing the necessity of traversing each edge of a first graph and a second graph provided by an embodiment of the present disclosure is shown;
[0054] Figure 7 A schematic diagram of a graphics processing device provided by an embodiment of the present disclosure is shown;
[0055] Figure 8 A schematic diagram of the structure of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0057] Research has found that when designing home decoration, in order to obtain home decoration data that meets the requirements, it is necessary to perform Boolean operations on contours with arcs. Most existing graphics processing methods convert arc segments in graphics into several straight line segments when performing Boolean operations, and then use the converted segments for calculations. This not only leads to the loss of information such as the radius and angle of the arc segments, but also leads to problems such as low calculation efficiency and large amount of stored data, resulting in poor graphics processing effects.
[0058] Based on the above research, the present disclosure provides a graphics processing method, device, computer equipment and storage medium. For the arc segments in the graphics, the arc segments can be represented by the position information of the starting point of the arc segments and the convexity information, so that the information of the arc segments can be retained as much as possible; in addition, the first point list of the first graphics used to represent the first entity object and the second point list of the second graphics used to represent the second entity object can be processed according to the target operation type corresponding to the determined fusion method to obtain the target point list of the target graphics used to represent the fused target object. Through this method, the graphics with arcs can be directly processed without converting the arcs into straight line segments, which improves the efficiency of calculating and storing the graphics files.
[0059] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0060] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0061] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0062] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0063] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0064] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0065] To facilitate understanding of the present embodiment, a graphics processing method disclosed in the present embodiment is first introduced in detail. The execution subject of the graphics processing method provided in the present embodiment is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the graphics processing method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0066] See also Figure 1 FIG. 1 is a flowchart of a graphics processing method provided by an embodiment of the present disclosure, wherein the method includes steps 101 to 102, wherein:
[0067] Step 101, obtaining a first point list of a first graphic representing a first entity object and a second point list of a second graphic representing a second entity object, and determining a fusion method between the first entity object and the second entity object; wherein at least one of the first graphic and the second graphic includes an arc segment; the point list includes position information of each inflection point of the graphic and convexity information of the starting point of the arc segment, and the graphic includes the first graphic and the second graphic.
[0068] Step 102: determine a target operation type corresponding to the fusion method, and process the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic; wherein the target graphic is used to represent the target object after the first entity object and the second entity object are fused, and the target point list is used to render the target graphic.
[0069] The following is a detailed description of the above steps.
[0070] For step 101:
[0071] The first graphic and the second graphic may both be closed graphics for representing physical objects. The types of the first physical object represented by the first graphic and the second physical object represented by the second graphic may be the same or different. For example, the first physical object may be a wall, and the second physical object may be a cabinet.
[0072] Here, the first graphic used to represent the first physical object can be understood as that the first graphic has the same shape as the first physical object, and the ratio between the actual size of the first physical object and the displayed size of the first graphic is the same as the ratio between the actual size of the second physical object and the displayed size of the second graphic.
[0073] The point list includes the position information of the inflection point in the figure and the convexity information of the starting point of the arc segment in the figure. The inflection point may refer to a point where the curvature changes, and may include, for example, the intersection of two line segments, the starting point and end point of the arc segment, etc.
[0074] The position information of the inflection point may include the horizontal coordinate and the vertical coordinate of the inflection point; the convexity information is used to describe the curvature of the arc segment; when the convexity is positive, it can indicate that the arc segment is a counterclockwise arc, and when the convexity is negative, it can indicate that the arc segment is a clockwise arc.
[0075] Generally, the convexity information of the end point of the arc segment is 0, and the calculation method of the convexity information of the starting point of the arc segment is as follows:
[0076] by Figure 2 Taking the arc segment (p1, p2) as an example, points p1 and p2 are connected by a straight line segment, and the straight line segment connecting points p1 and p2 is perpendicularly divided into two halves by a straight line passing through the center of the arc. h is the length of the part of the perpendicular bisector of the straight line segment connecting points p1 and p2 close to the arc, L is the length of the part of the straight line segment connecting points p1 and p2 close to point p1, and the convexity of the end point p2 of the arc segment is recorded as 0. Since the arc segment (p1, p2) is a clockwise arc, the convexity c=-tanβ=-h / L is calculated. In addition, according to trigonometric functions, the formula for calculating the arc radius is r=L / sinα, where α is half of the central angle corresponding to the arc segment (p1, p2).
[0077] Therefore, in the above method, an arc can be expressed by two three-dimensional points. The arc from p1 to p2 can be expressed as the starting point p1 (x1, y1, c) and the end point p2 (x2, y2, 0), where c is the convexity of point p1.
[0078] In addition, if an inflection point in the figure serves as both the end point of the first arc and the starting point of the second arc, the convexity of the end point of the second arc is recorded as 0, and the convexities of the starting point and end point of the first arc are calculated respectively by the calculation method mentioned above.
[0079] For example, there are Figure 3 The two semicircular arcs (q1, q2) and (q2, q3) shown in the figure, point q2 is both the end point of arc (q1, q2) and the starting point of arc (q2, q3). When calculating the convexity information, the convexity of the end point q3 of the second arc is recorded as 0. Since the absolute value of the convexity of the semicircular arc is 1, it can be obtained that the convexity of point q2 is 1 and the convexity of point q1 is 0.
[0080] The inflection points included in the point list are arranged in a certain order, for example, in a clockwise order or a counterclockwise order. Specifically, in the first figure and the second figure, any inflection point is only connected to the inflection point located one position before the inflection point and the inflection point located one position after the inflection point in the point list. In addition, the last inflection point in the point list is also connected to the first inflection point in the point list. The line segments connecting the inflection points in the point list form a closed figure.
[0081] Regarding step 102:
[0082] In a possible implementation, when determining the target operation type between the first graphic and the second graphic, a fusion method between the first entity object and the second entity object may be first determined, and a target operation type corresponding to the fusion method may be determined.
[0083] The method for determining the fusion method between the first entity object and the second entity object may, for example, be a fusion method input by a user, or the user may determine the fusion method between the first entity object and the second entity object based on a drawing result during the process of drawing the first graphic and the second graphic.
[0084] For example, if the first entity object is cabinet 1, the second entity object is cabinet 2, and cabinet 1 and cabinet 2 are placed superimposed on each other, then when drawing the first figure and the second figure, the fusion method between the first entity object and the second entity object can be determined as superposition fusion.
[0085] The operation type corresponding to each fusion method is a Boolean operation type. Exemplarily, the operation type may include calculating the intersection, union, and difference of the first figure and the second figure. If the target operation type is different, the method for processing the first point list and the second point list is also different. The specific processing method will be introduced below.
[0086] In one possible implementation, when determining the target operation type corresponding to the fusion method, a correspondence between each fusion method and the operation type can be established in advance. After determining the fusion method between the first entity object and the second entity object, the target operation type corresponding to the fusion method can be determined based on the correspondence.
[0087] Alternatively, in another possible implementation, the target operation type between the first graphic and the second graphic can be set by the user, and during the process of drawing the first graphic and the second graphic, the target operation type between the first graphic and the second graphic can be set at the same time.
[0088] After determining the target operation type, when processing the first point list and the second point list according to the target operation type to obtain the target point list of the target figure, the position information of the intersection of the first figure and the second figure can be first determined based on the first point list and the second point list, and then the target point list can be determined based on the position information of the intersection of the first figure and the second figure.
[0089] Specifically, when determining the location information of the intersection, for example, all the line segments constituting the first figure and the second figure can be drawn separately, and then it is determined whether there are any overlapping points between the line segments, and the overlapping points are taken as the intersection of the first figure and the second figure to obtain the location information of the intersection.
[0090] In addition, if the intersection point is a point on the arc segment, the convexity information of the intersection point is calculated according to the convexity information calculation method mentioned above.
[0091] After determining the position information of the intersection of the first graphic and the second graphic, each edge of the first graphic and the second graphic can be traversed. For any edge, the edge is used as the starting edge, and the remaining edges constituting the target graphic corresponding to the edge are determined according to the edge selection method corresponding to the target operation type; then, the target graphics corresponding to each edge are screened, and a list of target points of the screened target graphics is determined.
[0092] Wherein, when the target operation type is an intersection operation, the starting edge line is a line segment with the intersection point as an endpoint. Specifically, when determining the remaining edge lines constituting the target graph corresponding to the edge line according to the edge line selection method corresponding to the target operation type, the following steps can be referred to:
[0093] Step a1: Determine the direction of edge extension.
[0094] The edgeline extension direction can be understood as the graphic direction of the target graphic, for example, it can include a clockwise direction and a counterclockwise direction. Specifically, the edgeline extension direction can be the same as the graphic direction of the graphic where the starting edgeline is located. Here, the graphic direction can refer to the arrangement direction of each point in the point list corresponding to the graphic.
[0095] Step a2: If the end point of the starting sideline is not the intersection point, the starting sideline is connected to the next line of the starting sideline in the extension direction of the sideline, and the connected line is used as the starting sideline again.
[0096] Here, the intersection point refers to the intersection point of the first figure and the second figure. If the end point of the starting edge line is not the intersection point, the next line of the starting edge line in the extension direction of the edge line is unique, so there is no need to select the edge line, and the starting edge line can be connected to the next line.
[0097] Step a3: If the end point of the starting edge line is the intersection point, based on the edge line selection method corresponding to the target operation type, select the next line of the starting edge line from the intersection lines corresponding to the intersection point.
[0098] If the end point of the starting edge is the intersection point, there are multiple line segments connected to the starting edge, so the next line of the starting edge can be selected based on the edge selection method corresponding to the target operation type.
[0099] Since at the intersection, the edge line can extend in the extension direction of the edge line of the first figure or in the extension direction of the edge line of the second figure, when selecting the next line of the starting edge line, first determine the first direction of the starting edge line and the second direction of each intersecting line, and based on the first direction and the second direction, and the edge line selection method corresponding to the target operation type, determine the target direction, and use the intersecting line in the target direction as the next line of the starting edge line; wherein, when the intersecting line is a circular arc segment, the second direction is the tangent direction of the circular arc segment.
[0100] Specifically, when selecting the edge line, first calculate the outer product of the unit length directed line segment in the first direction and the unit length directed line segment in the second direction respectively, then select the direction whose outer product satisfies the preset condition as the target direction, and use the intersecting line in the target direction as the next line of the starting edge line; wherein the preset condition can be that the outer product of the unit length directed line segment in the first direction and the unit length directed line segment in the second direction is the largest, or that the outer product of the unit length directed line segment in the first direction and the unit length directed line segment in the second direction is the smallest.
[0101] Next, the above edge selection method will be introduced with different target operation types.
[0102] Under different operation types, the graphic directions of the first graphic and the second graphic participating in the operation are different. When the target operation type is to find the difference set, the graphic direction of the first graphic is counterclockwise, and the image direction of the second graphic is opposite to the graphic direction of the first graphic, that is, clockwise; when the target operation type is to find the intersection and union, the graphic direction of the first graphic and the graphic direction of the second graphic are the same, both are counterclockwise.
[0103] When the target operation type is difference set, the outer products of the unit length directed line segments in the first direction and the unit length directed line segments in the second directions can be calculated at the intersection points, and then the intersection line with the largest outer product is selected as the next line of the starting edge line.
[0104] by Figure 4 For example, there are two intersecting figures A and B, where figure A is the first figure and figure B is the second figure. The point list of A is (a0, a1, a2, a3, a4), and (a1, i1) is used as the starting edge line. When the target operation type is to find the difference set, there are two intersecting lines at i1, namely (i1, a2) and (i1, b0), and (i1, b1) does not participate in the edge line selection because it is in the opposite direction of the figure B where it is located. Assume that the position coordinates of a1 are (4,0) and i1 are (4,2). The position coordinates of b0 are The position coordinates are (3,2), and the position coordinates of a2 are (4,3). It can be determined that the unit length directed line segment in the first direction can be expressed as (0,1), and the unit length directed line segments in the second direction can be expressed as (0,1) and (-1,0) respectively. Through calculation, it can be obtained that the outer product in the direction of (i1, b0) is 1, and the outer product in the direction of (i1, a2) is 0. It can be known that the outer product in the direction of (i1, b0) is the largest, so the direction of (i1, b0) is taken as the target direction, and (i1, b0) is selected as the next line of the starting edge line.
[0105] When the target operation type is to find the union, the outer products of the unit length directed line segments in the first direction and the unit length directed line segments in the second directions can be calculated at the intersection points, and then the intersection line with the smallest outer product is selected as the next line of the starting edge line.
[0106] Similarly, Figure 4For example, at i1, when the target operation type is to find the union, there are two intersecting lines at i1, namely (i1, a2) and (i1, b1). Assuming that the position coordinates of b1 are (6, 2), the outer product in the direction of (i1, b1) is calculated to be -1. It can be seen that the outer product in the direction of (i1, b1) is the smallest. Therefore, the direction of (i1, b1) is taken as the target direction, and (i1, b1) is selected as the next line.
[0107] When the target operation type is intersection, the outer products of the initial edge line and the intersection line corresponding to the intersection point may be calculated respectively, and then the intersection line with the largest outer product is selected as the next line of the starting edge line.
[0108] Similarly, Figure 4 For example, if the target calculation type is to calculate the intersection of graph A and graph B, the starting edge can be any one of (i2, b3), (i1, a2), (b0, i1), (a2, i2). Here, when (b0, i1) is selected as the initial edge, there are two intersecting lines at i1, namely (i1, a2) and (i1, b1). It can be seen that the outer product of the direction of (i1, a2) is the largest, so the direction of (i1, a2) is used as the target direction, and (i1, a2) is selected as the next line.
[0109] Here, it should be noted that although when calculating the intersection and the difference, the intersecting line with the largest outer product is selected at the intersection position as the next line of the starting edge line, but because when calculating the difference, the first figure is a counterclockwise figure, and the second figure is a clockwise figure, when calculating the intersection, the first figure and the second figure are both counterclockwise figures. Therefore, even when the same intersection is used to select the next line of the starting edge line, since the directions of the figures are not exactly the same, the intersecting lines involved in the selection of the next line are not exactly the same, and therefore the intersection and the difference can obtain different results.
[0110] In addition, when the intersecting line includes multiple arc segments and the tangent directions of the multiple arc segments are the same, since the tangent directions of the arcs are the same, it is impossible to perform edge selection by calculating the outer product. First, the curvatures of the multiple arc segments are determined, and then based on the first direction, the curvatures of the multiple arc segments and the edge selection method corresponding to the target operation type, the next line of the starting edge line is determined to be selected in the intersecting line corresponding to the intersection point.
[0111] For example, the positions of the figure C with the arc segment a and the figure D with the arc segment b are as follows: Figure 5As shown, since the tangent directions of arc a and arc b are the same, at the intersection, the curvatures of arc segment a and arc segment b need to be calculated respectively to select the edge.
[0112] As mentioned above when introducing the calculation method of convexity information, the arc radius can be calculated from the convexity information. When the radius r is known, the curvature of the arc K = 1 / r can be calculated. Since the radius of a is smaller, it can be known that the curvature of a is greater than that of b, indicating that a has a greater inward trend, and the edge line selection is performed accordingly. For different edge line selection methods, the selection results of the arc segment are also different.
[0113] When the target operation type is to find a difference set, the arc segment a with a larger curvature is selected as the edge line.
[0114] When the target operation type is to find the union, the arc segment b with the smaller curvature is selected as the edge line.
[0115] When the target operation type is to find the intersection, the arc segment a with a larger curvature is selected as the edge line.
[0116] Since the target graph obtained may miss some graphs, specifically, Figure 6 As shown, when finding the difference between image E and image F, if (e1, e2) is selected as the starting edge line, the target image obtained is only (e1, e2, j1, j2), and the part of the figure (e3, e4, j4, j3) is omitted. In order to obtain an accurate target figure, after completing an operation and obtaining a target figure, the remaining line segments on the first figure and the second figure are continuously selected as the starting line segments for edge line selection to obtain multiple target figures; wherein, the remaining line segments, in addition to the original line segments on the first figure and the second figure, also include line segments generated by the intersection of the first figure and the second figure with the intersection point as the starting point or end point.
[0117] After obtaining multiple target graphics, since the starting edge line selected when traversing each edge of the first graphic and the second graphic may not be in the target graphic, resulting in redundant edges in the target graphic, it is necessary to filter the target graphics corresponding to each edge to obtain the correct target graphic and determine the target point list of the filtered target graphic.
[0118] When screening the target graphics, for the target graphics corresponding to any side, if the target graphics is a closed graphics and does not contain repeated line segments, the target graphics is judged to meet the conditions and is used as the screened graphics. If the target graphics does not meet the above conditions, the target graphics is deleted, and finally a target point list of the target graphics is obtained.
[0119] After obtaining the target point list of the target figure, if the target point list contains an intersection point on an arc segment, in order to retain the information of the arc segment, the target point list should also include the convexity information of the intersection point. The calculation method of the convexity information has been introduced above and will not be repeated here.
[0120] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0121] Based on the same inventive concept, a graphics processing device corresponding to the graphics processing method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned graphics processing method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0122] Reference Figure 7 FIG. 1 is a schematic diagram of the architecture of a graphics processing device provided by an embodiment of the present disclosure, wherein the device comprises: a determination module 701 and a processing module 702; wherein:
[0123] A determination module 701 is used to obtain a first point list of a first graphic representing a first entity object and a second point list of a second graphic representing a second entity object; wherein at least one of the first graphic and the second graphic includes an arc segment; the point list includes position information of each inflection point of the graphic and convexity information of a starting point of the arc segment, and the graphic includes the first graphic and the second graphic;
[0124] The processing module 702 is used to determine the target operation type between the first graphic and the second graphic, and process the first point list and the second point list according to the target operation type to obtain a target point list of the target graphic; wherein the target graphic is used to represent the target object after the first entity object and the second entity object are fused, and the target point list is used to render the target graphic.
[0125] In a possible implementation manner, the processing module 702, when processing the first point list and the second point list according to the target operation type to obtain a target point list of a target graph, is configured to:
[0126] Determine, based on the first point list and the second point list, location information of an intersection of the first figure and the second figure;
[0127] Traversing each edge of the first graph and the second graph, for any edge, taking the edge as the starting edge, and determining the remaining edges constituting the target graph corresponding to the edge according to the edge selection method corresponding to the target operation type; wherein, when the target operation type is an intersection operation, the starting edge is a line segment with the intersection point as an endpoint;
[0128] The target graphics corresponding to each edge are filtered, and a target point list of the filtered target graphics is determined.
[0129] In a possible implementation manner, the processing module 702, when determining the remaining edges constituting the target graph according to the edge selection method corresponding to the target operation type, is configured to:
[0130] Determine the sideline extension direction; wherein the sideline extension direction is the same as the graphic direction of the graphic where the starting sideline is located;
[0131] If the end point of the starting sideline is not the intersection point, the starting sideline is connected to the next line of the starting sideline in the extension direction of the sideline, and the connected line is used as the starting sideline again;
[0132] If the end point of the starting edge line is the intersection point, a next line of the starting edge line is selected from the intersecting lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type.
[0133] In a possible implementation, the processing module 702, when screening the target graphics corresponding to each edge, is used to:
[0134] For a target graph corresponding to any edge, when the target graph is a closed graph and does not contain repeated line segments, the target graph is used as a filtered graph.
[0135] In a possible implementation, the processing module 702, when selecting the next line of the starting edge line from the intersection lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type, is configured to:
[0136] Determine a first direction of the starting edge line and a second direction of each intersection line; wherein, when the intersection line is an arc segment, the second direction is a tangent direction of the arc segment, and the second direction of the intersection line is consistent with a graphic direction of the graphic where the intersection line is located;
[0137] Based on the first direction and the second direction and the edge line selection method corresponding to the target operation type, a target direction is determined, and the intersection line in the target direction is used as the next line of the starting edge line.
[0138] In a possible implementation manner, when the intersection line includes multiple arc segments and the tangent directions of the multiple arc segments are the same, the processing module 702 is further configured to select the next line of the starting edge line from the intersection line corresponding to the intersection point according to the following method:
[0139] Determining the curvature of the plurality of circular arc segments;
[0140] Based on the first direction, the curvatures of the plurality of arc line segments, and the edge line selection method corresponding to the target operation type, a next line of the starting edge line is determined to be selected from the intersection lines corresponding to the intersection point.
[0141] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0142] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 8 , which is a schematic diagram of the structure of a computer device 800 provided in an embodiment of the present disclosure. The computer device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc., or various forms of servers, such as independent servers or server clusters. Figure 8 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0143] like Figure 8 As shown, the computer device 800 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only storage device (ROM) 802 or a program loaded from a storage device 805 to a random access storage device (RAM) 803. In the RAM 803, various programs and data required for the operation of the computer device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0144] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 808 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 809. The communication devices 809 may allow the computer device 800 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The computer device 800 is shown with various devices, but it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have instead.
[0145] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the graphics processing method. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0146] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the graphics processing method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0147] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the graphics processing method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0148] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0149] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, 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 communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, each functional unit in each embodiment of the present disclosure 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.
[0152] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0153] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A graphics processing method, characterized in that: include: Acquire a first point list of a first graphic representing a first entity object and a second point list of a second graphic representing a second entity object; wherein at least one of the first graphic and the second graphic includes an arc segment; the point list includes position information of each inflection point of the graphic and convexity information of a starting point of the arc segment, and the graphic includes the first graphic and the second graphic; Determine a target operation type between the first graphic and the second graphic, and process the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic; wherein the target graphic is used to represent a target object after the first entity object and the second entity object are fused, and the target point list is used to render the target graphic.
2. The method according to claim 1, characterized in that The step of processing the first point list and the second point list according to the target operation type to obtain a target point list of a target graph includes: Determine, based on the first point list and the second point list, location information of an intersection of the first figure and the second figure; Traversing each edge of the first graph and the second graph, for any edge, taking the edge as the starting edge, and determining the remaining edges constituting the target graph corresponding to the edge according to the edge selection method corresponding to the target operation type; wherein, when the target operation type is an intersection operation, the starting edge is a line segment with the intersection point as an endpoint; The target graphics corresponding to each edge are filtered, and a target point list of the filtered target graphics is determined.
3. The method according to claim 2, characterized in that The step of determining the remaining edges constituting the target graph according to the edge selection method corresponding to the target operation type includes: Determine the sideline extension direction; wherein the sideline extension direction is the same as the graphic direction of the graphic where the starting sideline is located; If the end point of the starting sideline is not the intersection point, the starting sideline is connected to the next line of the starting sideline in the extension direction of the sideline, and the connected line is used as the starting sideline again; If the end point of the starting edge line is the intersection point, a next line of the starting edge line is selected from the intersecting lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type.
4. The method according to claim 2, characterized in that: Filter the target graphics corresponding to each edge, including: For a target graph corresponding to any edge, when the target graph is a closed graph and does not contain repeated line segments, the target graph is used as a filtered graph.
5. The method according to claim 3, characterized in that: The selecting a next line of the starting edge line from the intersection lines corresponding to the intersection point based on the edge line selection method corresponding to the target operation type includes: Determine a first direction of the starting edge line and a second direction of each intersection line; wherein, when the intersection line is an arc segment, the second direction is a tangent direction of the arc segment, and the second direction of the intersection line is consistent with a graphic direction of the graphic where the intersection line is located; Based on the first direction and the second direction and the edge line selection method corresponding to the target operation type, a target direction is determined, and the intersection line in the target direction is used as the next line of the starting edge line.
6. The method according to claim 5, characterized in that In the case where the intersection line includes a plurality of arc line segments, and the tangent directions of the plurality of arc line segments are the same, the method further includes selecting a next line of the starting edge line from the intersection lines corresponding to the intersection point according to the following method: Determining the curvature of the plurality of circular arc segments; Based on the first direction, the curvatures of the plurality of arc line segments, and the edge line selection method corresponding to the target operation type, a next line of the starting edge line is determined to be selected from the intersection lines corresponding to the intersection point.
7. The method according to any one of claims 1 to 6, characterized in that: The target operation type is a Boolean operation type.
8. A graphics processing device, characterized in that: include: a determination module, configured to obtain a first point list of a first graphic representing a first entity object and a second point list of a second graphic representing a second entity object; wherein at least one of the first graphic and the second graphic comprises an arc segment; the point list comprises position information of each inflection point of the graphic and convexity information of a starting point of the arc segment, and the graphic comprises the first graphic and the second graphic; A processing module is used to determine a target operation type between the first graphic and the second graphic, and process the first point list and the second point list according to the target operation type to obtain a target point list of a target graphic; wherein the target graphic is used to represent a target object after the first entity object and the second entity object are fused, and the target point list is used to render the target graphic.
9. A computer device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the graphics processing method according to any one of claims 1 to 7 are performed.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the graphics processing method according to any one of claims 1 to 7 are executed.