Method for determining minimum closed area and electronic equipment
By generating a straight line passing through the target point and determining the edge closest to the target point, the problem of drawing software determining the smallest closed area during the graphics drawing process is solved, achieving fast and accurate results and improving drawing efficiency.
Patent Information
- Application Number
- CN202510126519.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-27
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2045-01-27
AI Technical Summary
Drawing software needs to determine the minimum enclosed area containing target points during the drawing process, but prior art is difficult to achieve this requirement quickly and accurately, especially when the graphics contain complex higher order curves.
By generating a straight line passing through the target point and intersecting points with each edge of the drawing area in the target extension direction, the edge closest to the target point is determined, thereby determining the smallest closed area containing the target point.
This method reduces the computational complexity and calculation amount, realizes the rapid and accurate determination of the minimum closed area, improves the drawing efficiency, and avoids the inaccuracy of area comparison.
Smart Images

Figure CN119559293A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of drawing technology, and in particular relates to a method for determining a minimum closed area and an electronic device. Background Art
[0002] As the functions of drawing software continue to improve, most users tend to use drawing software to draw graphics. Among them, Computer Aided Design (CAD) is one of the commonly used drawing tools.
[0003] In the related art, drawing software needs to display the minimum closed area containing the target point, such as the cursor position, the mouse hovering position, etc., in combination with the lines drawn by the user, so as to assist the user to better draw graphics and improve drawing efficiency. In other words, during the process of drawing graphics, there is a need to determine the minimum closed area containing the target point. Summary of the invention
[0004] The embodiments of the present application provide a method for determining a minimum closed area, an electronic device, and a computer-readable storage medium, aiming to solve the problem in the related art that drawing software needs to determine the minimum closed area containing a target point during the graphics drawing process.
[0005] In a first aspect, an embodiment of the present application provides a method for determining a minimum closed area, the method comprising: in response to a target point acting on a drawing area, generating a straight line passing through the target point, wherein the drawing area includes one or more edges; determining the intersection of the straight line with each edge in the drawing area in the target extension direction, determining the edge corresponding to the target intersection as the target edge, the target intersection being the intersection closest to the target point among the determined intersections, wherein the target extension direction is any extension direction of the straight line; based on the target edge, determining the minimum closed area containing the target point.
[0006] In a second aspect, an embodiment of the present application provides a device for determining a minimum enclosed area, the device comprising: A data response unit, for generating a straight line passing through the target point in response to a target point acting on a drawing area, wherein the drawing area includes one or more edges; A target determination unit is used to determine the intersection of the straight line with each edge in the drawing area in the target extension direction, and determine the edge corresponding to the target intersection as the target edge, wherein the target intersection is the intersection closest to the target point among the determined intersections, wherein the target extension direction is any extension direction of the straight line; The area determination unit is used to determine the minimum closed area containing the target point according to the target edge.
[0007] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the steps of the above-mentioned method for determining a minimum enclosed area when executing the computer program.
[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned methods for determining a minimum enclosed area.
[0009] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes any of the above-mentioned methods for determining a minimum enclosed area.
[0010] Compared with the related art, the embodiments of the present application have the following beneficial effects: by using auxiliary straight lines to determine the minimum closed area containing the target point, the computational complexity is low and the amount of computation is small, so the minimum closed area can be determined quickly, that is, the data processing efficiency can be improved. In addition, since it is difficult to accurately determine the area of the closed area formed by the edges in the figure, and since there is no need to determine and compare the area of the closed area formed by the edges in the figure in the process of determining the minimum closed area containing the target point, the present application can ensure the accuracy of the determined minimum closed area while ensuring a small amount of computation, that is, the present application can quickly and accurately determine the minimum closed area containing the target point, which helps to improve drawing efficiency.
[0011] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0013] Figure 1 is a flowchart of a method for determining a minimum enclosed area provided in an embodiment of the present application; Figure 2 It is a schematic diagram of a straight line passing through a target point provided in an embodiment of the present application; Figure 3 This is a schematic diagram of two straight lines passing through a target point provided in an embodiment of the present application; Figure 4is a schematic diagram of determining a target edge based on an auxiliary line provided in an embodiment of the present application; Figure 5 is a schematic diagram of an invalid edge in a drawing area provided by an embodiment of the present application; Figure 6 is a schematic diagram of a plurality of closed areas including target edges provided in an embodiment of the present application; Figure 7 is a schematic diagram of a process for determining a minimum closed area containing a target point provided in an embodiment of the present application; Figure 8 is a schematic diagram of a closed area that does not contain a target point provided in an embodiment of the present application; Fig. 9 is a schematic diagram of a plurality of third closed areas provided in an embodiment of the present application; Fig.10 is a schematic diagram of a drawing area provided in an embodiment of the present application; Fig.11 is a schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application; Fig.12 is another schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application; Fig.13 is a flowchart of another method for determining a minimum enclosed area provided in an embodiment of the present application; Fig.14 is a structural schematic diagram of a device for determining a minimum enclosed area provided in an embodiment of the present application; Fig.15 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0014] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0015] The following are some concepts that may be involved in the embodiments of the present application: (1) Multiple: Unless otherwise specified, in the embodiments of the present application, multiple refers to two or more.
[0016] (2) Computer Aided Design (CAD): In the embodiments of the present application, CAD is drawing software, which can also be called a drawing tool. In practice, CAD software can usually be used to draw CAD sketches.
[0017] (3) CAD sketch: In the embodiments of the present application, a CAD sketch is a preliminary design drawing drawn using CAD software in the field of engineering design, and is used to express and present design intent in product design, engineering drawing and other work.
[0018] CAD sketching is relatively free. It can help designers quickly visualize the design ideas in their minds and promote communication and understanding among team members. In addition, the powerful editing functions of CAD software, such as move, rotate, scale, stretch, trim and other commands, can be used to easily modify CAD sketches, greatly improving design efficiency. Furthermore, many CAD software support further modeling and detailed design based on CAD sketches. For example, in 3D modeling, sketches can be used as the basic outline for operations such as stretching, rotating, scanning, etc., which facilitates the generation of complex 3D models.
[0019] CAD sketches differ from images in several ways: First, the difference in drawing accuracy: The drawing of CAD sketches needs to be based on accurate coordinate systems and geometric constraints. Taking the drawing of mechanical parts sketches in CAD software as an example, the coordinates of the line endpoints can be accurately set, and the size constraints and geometric constraints can be used to ensure that the size of each part of the drawing is accurate and the position relationship is fixed. The software itself has strong precision control capabilities and can achieve high-precision drawing through functions such as polar tracking and object snapping.
[0020] Images are generally composed of pixels, and their accuracy depends on the resolution. For example, common JPEG and PNG images will appear pixelated and have blurred edges after being enlarged. Even vector graphics can be infinitely enlarged without distortion in theory, but in the actual processing and conversion process, their accuracy is not absolutely accurate due to the limitations of software algorithms and processing capabilities. For example, when you draw a straight line in image processing software, it may seem straight, but you may find slight jagged edges after enlarging it.
[0021] Second, the difference in data structure: CAD sketches build data structures based on geometric elements. For example, a straight line is defined by the coordinates of the start and end points, and a circle is defined by the coordinates of the center and the radius. Complex graphics are composed of multiple basic graphic elements through Boolean operations and constraint relationships. Although the storage formats of sketches drawn by different CAD software are different, they are essentially records of geometric elements and their relationships.
[0022] Images are constructed with pixels as the basis of data structure. Each pixel records information such as color and brightness. The amount of data is large and it is difficult to edit a single object. For example, moving an object in a bitmap photo requires complex clipping and compositing operations.
[0023] Third, graphic editing: The editing of CAD sketches mainly relies on special CAD editing commands, such as move, rotate, scale, stretch, trim, etc., which can directly operate graphic elements and accurately modify the position, size, and shape. For example, to change the side length of a rectangle, you can modify the size parameters or stretch the operation. The editing process is based on geometric relationships and constraints, which can maintain the accuracy and consistency of the graphics.
[0024] Image editing is often done by modifying pixels with the help of drawing tools, such as brushes, erasers, selection tools, etc. For example, when retouching a photo, you can use the Clone Stamp tool to copy pixels to cover up blemishes.
[0025] As the functions of drawing software continue to improve, most users tend to use drawing software to draw graphics. Among them, Computer Aided Design (CAD) is one of the commonly used drawing tools.
[0026] In the related art, in order to improve drawing efficiency, drawing software needs to display the minimum closed area containing the target point in combination with the lines drawn by the user. The target point can be the cursor position, the mouse hovering position, etc. In other words, in the related art, there is a need to determine the minimum closed area containing the target point during the graphics drawing process of the drawing software.
[0027] In order to solve the above technical problems, a possible approach is to use a connected domain algorithm in the image field to determine one or more closed areas containing the target point, and then determine the minimum closed area containing the target point by comparing the area sizes of each closed area.
[0028] However, since the graphics drawn by the drawing software change in real time with the user's drawing operation, and the drawn graphics (or sketches) often contain various complex high-order curves, this approach may have the following two problems: First, complex high-order curves are usually drawn by spline curves and other methods. Although the mathematical description of these curves is accurate, there may be a loss of precision when they are converted into discrete data that can be processed by computers. For example, when spline curves are displayed and stored, they may only be an approximation of their true shape. This means that the boundaries of closed areas determined based on these curves may not be accurate, making the results of area comparison unreliable.
[0029] Secondly, complex high-order curves will bring a large number of data points, which not only increases the size of the graphics file, but also greatly increases the amount of computation required for area calculation. When comparing the areas of multiple closed areas, the computational efficiency will become very low. If the graphics are still changing in real time, the computational efficiency will be very low. Moreover, as the amount of data increases, the possibility of error accumulation in the calculation process will also increase, further affecting the accuracy of the area comparison results.
[0030] In view of the above technical problems existing in the related art, the embodiment of the present application provides a method for determining the minimum closed area, adding one or more auxiliary straight lines (or simply auxiliary lines) passing through the target point, and determining the edge (or line) adjacent to the target point by analyzing the distance between the target point and the first intersection point, so as to analyze and obtain the minimum closed area containing the target point. Among them, the first intersection point is the intersection point of the auxiliary line and each edge in the figure. By determining the minimum closed area containing the target point through the auxiliary line, the calculation complexity and amount of calculation are low, and the minimum closed area can be determined quickly, that is, the data processing efficiency can be improved. In addition, since it is difficult to accurately determine the area of the closed area formed by each edge in the figure in the related art, and since the present application does not need to compare the area of the closed area formed by each edge in the figure in the process of determining the minimum closed area containing the target point, the present application can ensure the accuracy of the determined minimum closed area while ensuring the amount of calculation is small.
[0031] Combine the following Figure 1 The method for determining the minimum enclosed area provided in the embodiment of the present application is further described. Figure 1 As shown, the method for determining the minimum closed area may include the following steps 101 to 103 .
[0032] Step 101 : The electronic device generates a straight line passing through a target point in response to a target point acting on a drawing area.
[0033] The drawing area includes one or more edges. It can be understood that each edge in the drawing area has two endpoints. Each edge of the drawing area can be a straight line segment or a curve segment.
[0034] The target point may be a point of a preset type in the drawing area. For example, the target point may be a point where a mouse is hovering, and the preset type may be a first type indicating a point where the mouse is hovering. The target point may also be a point where a cursor is located, and the preset type may be a second type indicating a cursor point. It is understandable that the embodiment of the present application does not specifically limit the type of the target point.
[0035] Here, the electronic device can detect the target point acting on the drawing area and determine the position of the target point in the drawing area by using the method disclosed in the related art. For example, when the target point is the mouse hovering position point, the electronic device can detect the target point acting on the drawing area and its position coordinates by using the scheme for detecting the mouse hovering position disclosed in the related art.
[0036] When the electronic device detects the target point acting on the drawing area, based on the position coordinates of the target point, a straight line passing through the target point can be generated in the drawing area. It can be understood that the electronic device can adopt the solution of generating a straight line passing through a certain point disclosed in the related art to generate a straight line passing through the target point.
[0037] Optionally, in step 101, a straight line may be generated.
[0038] Optionally, in step 101, multiple straight lines may be generated, and the angles between each two adjacent rays are equal among the multiple rays formed by the intersection of the multiple straight lines. In this case, the edge near the target point can be detected more accurately, thereby quickly and accurately determining the minimum closed area containing the target point.
[0039] Optionally, in step 101, a first straight line and a second straight line passing through the target point may be generated, the first straight line being parallel to the horizontal coordinate axis of the drawing area, and the second straight line being parallel to the vertical coordinate axis of the drawing area. On the one hand, by using the horizontal coordinate axis and the vertical coordinate axis of the drawing area as references to generate straight lines, it is possible to ensure that the straight line passing through the target point is generated quickly and accurately. In addition, since the first straight line is parallel to the horizontal coordinate axis of the drawing area, and the second straight line is parallel to the vertical coordinate axis of the drawing area, the vertical coordinates of the intersections of the first straight line and each edge can be the same, and the horizontal coordinates of the intersections of the second straight line and each edge can be the same, which helps to reduce the amount of calculation, thereby further improving drawing efficiency.
[0040] Combine the following Figures 2 to 3 Describe the situation of a straight line passing through the target point. Among them, Figure 2 A schematic diagram of a straight line passing through a target point is provided for an embodiment of the present application. Figure 3 The embodiment of the present application provides a schematic diagram of two straight lines passing through the target point.
[0041] like Figure 2 As shown, the drawing area may have three edges, namely edge 1, edge 2 and edge 3. Among them, edge 1, edge 2 and edge 3 form a triangle. The target point is point P. When there is a straight line passing through the target point, the straight line may intersect with two of edge 1, edge 2 and edge 3, for example, intersect with edge 1 and edge 2.
[0042] like Figure 3As shown, the drawing area may have three sides, namely side 1, side 2 and side 3. Among them, side 1, side 2 and side 3 form a triangle. The target point is point P. When there are two straight lines passing through the target point and the two straight lines are perpendicular to each other, the two straight lines may intersect with three sides of side 1, side 2 and side 3.
[0043] It can be understood that, generally speaking, the more straight lines passing through the target point, the more edges intersecting the straight lines in the drawing area.
[0044] Step 102: The electronic device determines the intersection points of the straight line with each edge in the drawing area in the target extension direction, and determines the edge corresponding to the target intersection point as the target edge.
[0045] The target intersection point is the intersection point closest to the target point among the determined intersection points, and the target extension direction is any extension direction of the straight line.
[0046] Here, for each extension direction of each straight line (or auxiliary line), the electronic device can determine the intersection of the straight line with each edge in the extension direction, thereby determining the edge closer to the target point in the extension direction (that is, the target edge). In this way, the adjacent edges of the target point in each direction can be determined, which helps to quickly determine the minimum closed area containing the target point.
[0047] Combine the following Figure 4 The process of determining the target edge is described. Figure 4 A schematic diagram of determining a target edge based on auxiliary lines provided in an embodiment of the present application.
[0048] like Figure 4 As shown, the drawing area may have 5 edges, namely edge 1, edge 2, edge 3, edge 4 and edge 5, the target point is point P, and there are two straight lines passing through point P, wherein the horizontal straight line is parallel to the horizontal coordinate axis, and the vertical straight line is parallel to the vertical coordinate axis. Among them, the horizontal straight line extends to the left and intersects with edge 1, and the intersection point is A. The horizontal straight line extends to the right and intersects with edge 2 and edge 5, and the intersection point with edge 2 is B, and the intersection point with edge 5 is C. The vertical straight line extends upward and intersects with edge 1, and the intersection point is D. The vertical straight line extends downward and intersects with edge 3, and the intersection point is E.
[0049] Figure 4In the figure, the horizontal line has only one intersection point A with each edge in the direction of leftward extension. In this case, point A is the target intersection point and edge 1 is the target edge. The horizontal line has two intersection points with each edge in the direction of rightward extension, namely point B and point C. Since point B is closer to point P, point B is the target intersection point and edge 2 is the target edge. The vertical line has only one intersection point D with each edge in the direction of upward extension. In this case, point D is the target intersection point and edge 1 is the target edge. The vertical line has only one intersection point E with each edge in the direction of downward extension. In this case, point E is the target intersection point and edge 3 is the target edge. Combined with Figure 4 , we can determine that there are three target edges, namely edge 1, edge 2 and edge 3.
[0050] Considering that there may be some invalid edges in the drawing area, for example, one of the two endpoints of an edge is not connected to any edge, then this edge can be called an invalid edge.
[0051] Therefore, in some embodiments, before the above step 101, the electronic device may further perform the following operation: if the two ends of the first edge are respectively connected to other edges, the first edge is determined to be a valid edge. In this case, the above step 102 may be replaced by: the electronic device determines the intersection of the straight line with each valid edge in the drawing area in the target extension direction. The first edge is any one of the multiple edges, and the other edges are the edges other than the first edge.
[0052] In the embodiment of the present application, determining the minimum closed area containing the target point based on the valid edges can avoid the interference caused by invalid edges, reduce the amount of calculation, and help improve the efficiency of determining the minimum closed area, thereby improving the drawing efficiency.
[0053] Optionally, before the above step 101, the electronic device may further perform the following operation: if any end of the first edge is not connected to other edges, determine that the first edge is an invalid edge.
[0054] In some optional embodiments, the electronic device may delete invalid edges among the multiple edges before step 101. The invalid edges are edges other than valid edges.
[0055] Further references Figure 5 , Figure 5 This is a schematic diagram of an invalid edge in a drawing area provided by an embodiment of the present application. Figure 5 As shown, the drawing area can have 5 edges, namely edge 1, edge 2, edge 3, edge 4 and edge 5. Among them, edge 1, edge 2 and edge 3 form a triangle, the two ends of edge 4 are not connected to any edge (that is, they are suspended), one end of edge 5 is connected to other edges, and the other end is not connected to any edge. The target point is point P. Figure 5 In the example, edge 1, edge 2, and edge 3 are valid edges, and edge 4 and edge 5 are invalid edges.
[0056] In some optional implementations of the embodiments of the present application, in the above step 102, if the straight line has no intersection with the edges in the drawing area in the target extension direction, the electronic device can output a second prompt information. The second prompt information indicates that there is no minimum closed area containing the target point. It can be understood that if the auxiliary line passing through the target point does not have an intersection with the edge in any extension direction, then it means that there is no closed area containing the target point in the drawing area.
[0057] It can be understood that if there is a closed area containing the target point in the drawing area, then each auxiliary line has an intersection and edges corresponding to the intersection in both extension directions. In this case, there are multiple target edges obtained in step 102.
[0058] Step 103: The electronic device determines the minimum closed area including the target point according to the target edge.
[0059] Optionally, after obtaining the target edge, the electronic device can determine the minimum closed area containing the target point in the following manner: starting from a certain target edge, searching for the next edge connected to the target edge and the next next edge connected to the next edge in a preset order, for example, in a counterclockwise order or a clockwise order, until finally returning to the target edge, so as to obtain a closed area formed by the edges. Afterwards, the closed area can be determined as the minimum closed area containing the target point.
[0060] In the embodiment of the present application, the minimum closed area including the target point is determined by an auxiliary straight line, and the computational complexity is low and the amount of computation is small, so the minimum closed area can be determined quickly, that is, the data processing efficiency can be improved. In addition, since it is difficult to accurately determine the area of the closed area formed by each edge in the figure, and since there is no need to determine and compare the area of the closed area formed by each edge in the figure in the process of determining the minimum closed area including the target point, the present application can ensure the accuracy of the determined minimum closed area while ensuring a small amount of computation, that is, the present application can quickly and accurately determine the minimum closed area including the target point, which helps to improve the drawing efficiency.
[0061] Considering that there are often multiple closed areas containing target points in the drawing area. Figure 6 , the drawing area can have 13 edges, namely edge 1 to edge 13, and the target point is point P. Figure 6 It can be found that the target edges are edge 1, edge 2, edge 3 and edge 12. Taking any target edge, such as edge 1, as the starting edge, three closed areas containing point P can be found, which are Figure 6 The enclosed area shown in the upper right, Figure 6 The enclosed area shown in the middle on the right, Figure 6 The enclosed area is shown in the lower right. Figure 6 A schematic diagram of a plurality of closed areas containing target edges provided in an embodiment of the present application.
[0062] Therefore, in some optional implementations of the embodiments of the present application, in the above step 103, the electronic device determines the minimum closed area containing the target point according to the target edge, which may include the following steps 701 to 703. Figure 7 A schematic diagram of the process of determining the minimum closed area containing a target point provided in an embodiment of the present application.
[0063] Step 701: The electronic device uses a first target edge as a starting edge and determines N first closed areas including the first target edge.
[0064] The first closed area is a closed area including the target edge.
[0065] The endpoints of every two adjacent edges in the first closed area are connected, the first target edge is any one of the multiple target edges, and N is an integer greater than or equal to 0.
[0066] Here, the electronic device can take a certain target edge (that is, the first target edge) as the starting edge, and search for the next edge connected to the target edge and the next-to-next edge connected to the next edge in a preset order, for example, in a counterclockwise order or a clockwise order, until finally returning to the target edge. In this way, a closed area containing the target edge (referred to as the first closed area) can be obtained.
[0067] In practice, it is possible to determine multiple first closed regions containing the first target edge, for example, combining Figure 6 , we can get the three first closed regions including edge 1 (that is, the first target edge).
[0068] Optionally, if there is no first closed area including the first target edge, first prompt information is output, and the first prompt information indicates that there is no minimum closed area including the target point. In this case, there is no minimum closed area in the drawing area.
[0069] Step 702: The electronic device selects M second closed areas including the target point from the N first closed areas.
[0070] Wherein, M is an integer greater than or equal to 0, and M is less than or equal to N.
[0071] The second closed area is a closed area including the target point among the multiple first closed areas.
[0072] Among them, the electronic device can determine whether the closed area formed by multiple edges contains the target point through the solution disclosed in the relevant technology, which will not be elaborated here.
[0073] Here, it is considered that there may be a closed area that does not contain the target point among the N first closed areas obtained in step 701. Selecting a closed area (or second closed area) containing the target point from the N first closed areas, and then screening the minimum closed area containing the target point from a number of second closed areas, can reduce the amount of calculation and further improve the efficiency of determining the minimum closed area.
[0074] Combine the following Figure 8 The following describes the situation where there are multiple closed areas containing target edges, but there are closed areas that do not contain the target point. Figure 8 A schematic diagram of a closed area that does not contain a target point provided in an embodiment of the present application. It should be noted that: Figure 8 In the example, the starting edge is represented by a bold line. It can be understood that the embodiment of the present application does not specifically limit how to represent the starting edge.
[0075] like Figure 8 As shown, Figure 8 The left figure starts with edge 1, and can traverse to two closed areas including edge 1, which are Figure 8 The enclosed area shown in the upper right and Figure 8 The enclosed area is shown at the lower right. Figure 8 The closed area shown in the upper right corner does not contain the target point P, but Figure 8 The closed area shown in the lower right corner contains the target point P. That is, Figure 8 In this case, two first closed areas can be obtained, N=2, and one second closed area can be selected from these two first closed areas, M=1.
[0076] Optionally, if in step 702, it is determined that there is only one second closed area, then the electronic device may directly determine the second closed area as the minimum closed area.
[0077] Step 703: The electronic device determines a minimum closed area from the M second closed areas according to the number of target edges included in each second closed area.
[0078] Here, if it is determined in step 702 that there are multiple second closed areas, the electronic device can select one of the second closed areas as the minimum closed area based on the number of target edges contained in each second closed area. For example, the second closed area containing the largest number of target edges can be selected as the minimum closed area. Figure 4 For example, Figure 4Two second closed areas can be obtained, one of which is a closed area formed by edge 1, edge 2 and edge 3, referred to as area 1, and the other is a closed area formed by edge 1, edge 3, edge 5 and edge 4, referred to as area 2. Figure 4 In combination with the auxiliary lines, it can be found that the target edges are edge 1, edge 2, and edge 3. In this case, region 1 contains 3 target edges, and region 2 contains 2 target edges. Region 1 contains the most target edges, and region 1 can be determined as the minimum closed region. It can be understood that the minimum closed region mentioned in the embodiment of the present application is the minimum closed region that contains the target point.
[0079] Considering that among the multiple second closed areas obtained in step 702, there may be one or more second closed areas containing the largest number of target edges.
[0080] Combine the following Fig. 9 The following describes the situation where there are multiple second closed areas (referred to as third closed areas) that contain the largest number of target edges. Fig. 9 A schematic diagram of a plurality of third closed areas provided in an embodiment of the present application. It should be noted that: Fig. 9 In order to distinguish the target edge from other edges, the target edge may be represented by a bold line, and edges other than the target edge (referred to as other edges) may be represented by a non-bold line. It is understandable that the embodiments of the present application do not specifically limit how to distinguish the target edge from other edges.
[0081] like Fig. 9 As shown in (a) of the figure, there are four auxiliary lines passing through the target point P. From the intersection of these four auxiliary lines and the edges, we can find that the target edges are edge 1, edge 2, edge 3, edge 4, edge 5 and edge 6. Fig. 9 (b) and Fig. 9 In (c), we can find that two closed regions can be obtained, one of which is the region formed by edge 1, edge 2, edge 3, edge 4, edge 5, edge 6 and edge 7, referred to as the third region (see Fig. 9 The other closed region is the region formed by edge 1, edge 2, edge 3, edge 4, edge 5, edge 6, edge 8 and edge 9, referred to as the fourth region (see Fig. 9 (c) in the figure. Fig. 9 In the example, the third region and the fourth region both contain all current target edges, that is, the third region and the fourth region are the regions with the largest number of target edges (referred to as the third closed region).
[0082] Therefore, in some embodiments, the above step 703 can be replaced by the following operation: if there is one third closed area, the third closed area is determined as the minimum closed area. The third closed area is the second closed area with the largest number of target edges among the M second closed areas. Figure 4 , the closed area formed by edge 1, edge 2 and edge 3 can be determined as the minimum closed area.
[0083] In other embodiments, the above step 703 may be replaced by the following steps 1 to 4.
[0084] Step 1: If there are multiple third closed areas and the number of straight lines passing through the target point is greater than a first preset value, the electronic device determines the overlapping edges and multiple local contours according to the overlap between the multiple third closed areas.
[0085] Each local contour corresponds to a third closed area, and the local contour is composed of non-coincident edges.
[0086] Among them, the first preset value is a pre-set value, and the first preset value is an integer greater than 1. For example, the first preset value may be 10. The embodiment of the present application does not limit the value of the first preset value.
[0087] It can be understood that, generally speaking, the more auxiliary lines that pass through the target point, the more edges that intersect with the auxiliary lines in the drawing area. The target edges determined in step 102 can almost cover every edge in the minimum closed area, that is, the minimum closed area can be determined quickly and accurately.
[0088] Considering that the target point may be located in a relatively biased position, even if auxiliary lines are added, it is impossible to obtain all the target edges that can cover the minimum closed area. Fig. 9 In (a), since the position of the target point P is relatively biased, the auxiliary line intersecting with edge 7, edge 8 or edge 9 will first intersect with edge 1, resulting in that under the method of determining the target edge described in the above step 102, edge 7, edge 8 and edge 9 cannot be determined as the target edge.
[0089] In step 1, the electronic device can combine the edges included in each third closed area to determine the overlapping edges and the local contour. The overlapping edges are the overlapping edges of each area, or the same edges. The non-overlapping edges are the non-overlapping edges of each area, or different edges. Fig. 9 As an example, (a) in FIG. 1 is used, the overlapping edges are edges 1 to 6. One of the local contours is edge 7, and the other local contour is the contour formed by edges 8 and 9.
[0090] Optionally, in the above step 1, if there are multiple third closed areas and the number of straight lines passing through the target point is less than or equal to the first preset value, the electronic device can add straight lines passing through the target point. It should be noted that adding auxiliary lines in certain circumstances helps to obtain more target edges.
[0091] Step 2: The electronic device determines the first coincident edge initially connected to the plurality of local contours and the starting points of the plurality of local contours according to the connection sequence of the edges in any third closed area.
[0092] The connection sequence includes a clockwise sequence or a counterclockwise sequence.
[0093] Combine the following Fig.10 Describe the connection sequence. Fig.10 A schematic diagram of a drawing area provided for an embodiment of the present application. Fig.10 The drawing area shown is Fig. 9 The plot area shown in (a) is the same as Fig.10 As shown, the direction indicated by the dotted arrow is clockwise, and the connection order is clockwise. In this case, the connection order of the coincident edges in the third closed area is: edge 1-edge 2-edge 3-edge 4-edge 5-edge 6. Connect to the local contour from edge 6, and connect to the local contour from point A. At this time, edge 6 is the first coincident edge, and point A is the starting point of multiple local contours. Fig.10 In the figure, there are two local contours, namely the contour formed by edge 7 (referred to as contour 1) and the contour formed by edges 8 and 9 (referred to as contour 2).
[0094] Step 3: The electronic device determines the selection order of each local contour in sequence in the reverse direction of the connection order based on the first overlapping edge and the starting point.
[0095] The selection order of the local contours can indicate the probability that the third closed area corresponding to the local contour is the minimum closed area. The earlier the selection order of the local contours, the greater the probability that the third closed area formed by the local contours is the minimum closed area, or the earlier the selection order of the third closed area formed by the local contours.
[0096] Combine the following Fig.11 Explain the selection order. Fig.11 A schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application. Fig.11 The drawing area shown is Fig.10 The plotting area shown is the same. Fig.11As shown, the dotted arrow indicates the connection order, and the direction of the connection order is clockwise. The dotted arrow indicates the direction of determining the selection order of each local contour, and the direction of determining the selection order of each local contour is counterclockwise. Fig.11 , the selection order of contour 1 formed by edge 7 is earlier, and the selection order of contour 2 formed by edges 8 and 9 is later than the selection order of contour 1. For example, the selection order of contour 1 can be determined as the first sequence number value, and the selection order of contour 2 can be determined as the second sequence number value. Among them, the first sequence number value indicates the first selection order, and the second sequence number value indicates the second first selection order.
[0097] In some optional implementations of the embodiments of the present application, the above step three can be replaced by: taking the starting point as the center and the first overlapping edge as the starting edge, and drawing a first curve in a first direction. The first direction is the opposite direction of the connection order. The first curve can be a circle. Afterwards, the electronic device can determine the selection order of each local contour according to the intersection order of the first curve and each local contour, for example, it can be determined. Combined Fig.11 , if the first curve is Fig.11 From the dotted line in the figure, we can see that the selection order of contour 1 formed by edge 7 is earlier, and the selection order of contour 2 formed by edges 8 and 9 is later than that of contour 1.
[0098] Step 4: The electronic device selects the third closed area with the highest order among the multiple third closed areas and determines it as the smallest closed area.
[0099] Here, combined Fig.11 The electronic device can determine the third closed area corresponding to the contour 1 with the front selection order as the minimum closed area, that is, the area formed by edge 1, edge 2, edge 3, edge 4, edge 5, edge 6 and edge 7 as the minimum closed area.
[0100] Fig.11 The following describes the situation where the connection sequence is in a clockwise direction. Fig.12 The case where the connection sequence is in the counterclockwise direction is further described. Fig.12 Another schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application.
[0101] like Fig.12 As shown, the dotted arrow indicates the connection order, and the direction of the connection order is counterclockwise. The dotted arrow indicates the direction of determining the selection order of each local contour. In this case, the direction of determining the selection order of each local contour is clockwise. In this case, edge 1 is the first overlapping edge, and point B is the starting point of multiple local contours. Fig.12, the selection order of contour 1 formed by edge 7 is earlier, and the selection order of contour 2 formed by edges 8 and 9 is later than the selection order of contour 1. For example, the selection order of contour 1 can be determined as the first sequence number value, and the selection order of contour 2 can be determined as the second sequence number value. Among them, the first sequence number value indicates the first selection order, and the second sequence number value indicates the second first selection order.
[0102] Combination Fig.11 and Fig.12 It can be found that when the connection order is different, the ranking values of the local contours determined based on step 3 are the same, that is, the minimum closed areas determined are the same.
[0103] Optionally, after step 103, the electronic device may further perform the following operations: highlighting the minimum enclosed area. As an example, each edge of the minimum enclosed area may be bolded. As another example, the entire minimum enclosed area may be highlighted. It is understandable that the embodiments of the present application do not specifically limit how to highlight the minimum enclosed area.
[0104] It should be noted that highlighting the minimum closed area containing the target point can enable the user to more intuitively find the minimum closed area, so as to draw the graphics with the assistance of the minimum closed area. In other words, the solution provided by the embodiment of the present application helps to improve the drawing efficiency.
[0105] It is understandable that after the above step 103, all the straight lines (or auxiliary lines) passing through the target point can be cleared, so as to avoid affecting the efficiency of the user's drawing of the graphics due to the addition of unnecessary lines.
[0106] Combine the following Fig.13 The method for determining the minimum enclosed area provided in the embodiment of the present application is further described. Fig.13 As shown, the method for determining the minimum enclosed area may include the following steps: Step 1301: The electronic device obtains all edges in the two-dimensional sketch.
[0107] The two-dimensional sketch is Figures 2 to 5 , Figure 6 , Figures 8 to 12 The drawing area in which any drawing is presented. Optionally, the 2D sketch can be a CAD sketch.
[0108] Here, the electronic device can obtain the coordinate data of all the edges and their endpoints in the two-dimensional sketch, and set a unique ID for each edge, such as edge 1, edge 2, and so on.
[0109] Step 1302 , the electronic device pre-processes all edges in the two-dimensional sketch, removes isolated or dangling invalid edges, and adds the remaining valid edges to set 1 .
[0110] Here, the edges in set 1 are the aforementioned valid edges.
[0111] It should be pointed out that removing invalid edges can avoid interference from invalid edges, which helps to improve data processing speed while ensuring the accuracy of the minimum closed area.
[0112] Step 1303: The electronic device draws two auxiliary straight lines in the horizontal and vertical directions for the given point.
[0113] The auxiliary straight line can also be called an auxiliary line. The given point is the aforementioned target point.
[0114] Step 1304: the electronic device finds the intersection points of the newly created auxiliary straight line and all the edges in set 1.
[0115] Here, the electronic device can calculate the intersections of the two auxiliary lines and all the edges in set 1, and classify them according to the extension direction of the auxiliary lines. For example, [dirction1 of line1, <intersection 1, intersection 2>], [dirction2 of line1, <intersection 3, intersection 4>]. Where line1 is an auxiliary line, dirction1 is one extension direction of the auxiliary line, and dirction2 is another extension direction of the auxiliary line.
[0116] Step 1305, the electronic device determines whether each auxiliary straight line has an intersection in both directions. If not, it outputs the result: there is no minimum closed area surrounding the given point; if so, it proceeds to the next step.
[0117] Step 1306 , the electronic device calculates the distance between the intersection point in each direction and the given point, compares the intersection point with the smallest distance in each direction, and then adds the edge where the point is located to set 2 .
[0118] Here, the electronic device can calculate the distance between the intersection of the auxiliary straight line in each extension direction and the given point, and then find the intersection with the smallest distance in the extension direction by comparing the distance values corresponding to each intersection, so as to find the edge where the intersection is located, and the edge found is the nearest edge in the extension direction. Similarly, the electronic device can find the nearest edge of each auxiliary line in each extension direction. Finally, the ID of the nearest edge in each extension direction can be added to set 2.
[0119] Among them, the edges in set 2 are the aforementioned target edges.
[0120] Step 1307: The electronic device determines whether the candidate closed area set 3 is empty.
[0121] Here, if step 1306 is executed for the first time, the candidate closed area set 3 is empty, and steps 13071 and 13072 are executed; if set 3 is not empty, step 1308 is executed.
[0122] Step 13071: the electronic device selects an edge from set 2, traverses to find all closed paths containing the edge, and adds it to set 3 as a candidate closed area.
[0123] Here, the closed area found in step 13071 is the aforementioned first closed area, that is, the closed area including the target edge.
[0124] Step 13072: The electronic device determines the enclosing relationship between each candidate closed area and the given point, and removes the candidate closed areas that do not contain the given point.
[0125] Here, the closed area after screening in step 13072 is the aforementioned second closed area, that is, the closed area including the target point.
[0126] Step 1308 : The electronic device counts the number of edges in set 2 that each candidate closed area in set 3 contains.
[0127] Step 1309: The electronic device determines whether there is a candidate closed area that contains the largest and unique number of edges in set 2.
[0128] If so, output: the candidate closed region with the largest and unique number of edges in set 2; if not, proceed to the next step.
[0129] Here, the closed area with the largest number of edges in the set 2 is the third closed area. There may be one or more third closed areas. If there is only one third closed area, the third closed area is directly used as the minimum closed area. If there are more than one third closed area, the minimum closed area is further screened by executing step 1310.
[0130] Step 1310: The electronic device determines whether the number of auxiliary straight lines currently drawn is greater than a preset critical value.
[0131] The pre-set critical value is the same as the first pre-set value mentioned above.
[0132] Here, if the number of auxiliary straight lines currently drawn is greater than a preset critical value (for example, 360), and the number of auxiliary straight lines currently drawn exceeds the critical value but the minimum closed area has not been solved, it means that the position of the given point deviates too far from the center of the minimum closed area, resulting in the edges contained in some local contours of the minimum closed area being unable to intersect with the auxiliary straight lines, and it is necessary to execute steps 13101 and 13102. On the contrary, if the number of auxiliary straight lines currently drawn is less than or equal to the preset critical value, execute step 13103.
[0133] Step 13101, the electronic device counts all candidate closed areas with the largest number of edges in set 2, compares them, counts the same edges and adds them to set 4 as the same contour, and finds out the local contours composed of different edges.
[0134] Combination Figures 9 to 12 , the same contours in set 4 are the contours formed by the coincident edges, that is, the contours formed by edges 1 to 6. In this case, there are two local contours, namely contour 1 formed by edge 7 and contour 2 formed by edges 8 and 9.
[0135] Step 13102, the electronic device uses a circle sorting algorithm for the starting vertex of each local contour to find each nearest edge and add it to set 5. End of process output: a closed area consisting of all edges in set 4 and all nearest edges in set 5 obtained by circle sorting.
[0136] The circular sorting of each local contour is as follows: the previous edge connected to the local contour is taken as the adjacent edge (or the first coincident edge), and the endpoint connected to the local contour is taken as the adjacent point (or the starting point). Based on the adjacent edge, all edges starting from the adjacent point are circularly sorted according to the first sorting direction, wherein the first sorting direction is the opposite direction of the aforementioned connection order.
[0137] Combination Fig.11 and Fig.12 , we can find that the nearest edge is edge 7. That is, edge 7 can be added to set 5. The edges in set 4 are edges 1 to 6. In this case, the edges in set 4 and the edges in set 5 can jointly form a minimum closed area.
[0138] In step 13103 , the electronic device draws the same number of new auxiliary straight lines in the direction of the angle bisectors of all the current auxiliary straight lines, and then continues to execute step 1304 .
[0139] Corresponding to the method for determining the minimum enclosed area in the above embodiment, Fig.14 The structure block diagram of the device for determining the minimum enclosed area provided by the embodiment of the present application is shown. For the convenience of explanation, only the part related to the embodiment of the present application is shown. Fig.14The minimum closed area determination device may include a data response unit 1401 , a target determination unit 1402 , and an area determination unit 1403 .
[0140] The data response unit 1401 is used to generate a straight line passing through the target point in response to a target point acting on a drawing area, wherein the drawing area includes one or more edges.
[0141] The target determination unit 1402 is used to determine the intersection of the straight line with each edge in the drawing area in the target extension direction, and determine the edge corresponding to the target intersection as the target edge. The target intersection is the intersection closest to the target point among the determined intersections, wherein the target extension direction is any extension direction of the straight line.
[0142] The area determination unit 1403 is used to determine the minimum closed area including the target point according to the target edge.
[0143] In some embodiments, the device may further include a first determination unit (not shown in the figure), which is used to determine that the first edge is a valid edge if the two ends of the first edge are respectively connected to other edges. The first edge is any one of the multiple edges, and the other edges are the edges of the multiple edges except the first edge.
[0144] In this case, the target determination unit 1402 determines the intersection points of the straight line with each edge in the drawing area in the target extension direction, including: determining the intersection points of the straight line with each valid edge in the drawing area in the target extension direction.
[0145] In some embodiments, the data response unit 1401 generates a straight line passing through the target point, including: generating a first straight line and a second straight line passing through the target point, the first straight line is parallel to the horizontal coordinate axis of the drawing area, and the second straight line is parallel to the vertical coordinate axis of the drawing area.
[0146] In some embodiments, there are multiple target edges. The region determination unit 1403 includes a first module, a second module, and a third module (not shown in the figure).
[0147] A first module is used to determine N first closed areas containing the first target edge with the first target edge as the starting edge, where the endpoints of every two adjacent edges in the first closed area are connected, the first target edge is any edge among the multiple target edges, and N is an integer greater than or equal to 0; The second module is used to select M second closed areas containing the target point from the N first closed areas, where M is an integer greater than or equal to 0 and M is less than or equal to N; The third module is used to determine the minimum closed area from the M second closed areas according to the number of target edges contained in each second closed area.
[0148] In some embodiments, the third module is specifically used to: if there is one third closed area, determine the third closed area as the minimum closed area, wherein the third closed area is the second closed area with the largest number of target edges among the M second closed areas.
[0149] In some embodiments, the third module is specifically used for: if there are multiple third closed areas, and the number of straight lines passing through the target point is greater than a first preset value, the overlapping edges and multiple local contours are determined according to the overlap between the multiple third closed areas, wherein each local contour corresponds to a third closed area, and the local contours are composed of non-overlapping edges. According to the connection order of each edge in any third closed area, the first overlapping edge that starts to connect to the multiple local contours and the starting point of the multiple local contours are determined, and the connection order includes a clockwise order or a counterclockwise order. Based on the first overlapping edge and the starting point, the selection order of each local contour is determined in turn in the opposite direction of the connection order. The third closed area with the highest selection order among the multiple third closed areas is determined as the smallest closed area.
[0150] In some embodiments, the device further includes a straight line adding unit (not shown in the figure) for adding a straight line passing through the target point if there are multiple third closed areas and the number of straight lines passing through the target point is less than or equal to a first preset value.
[0151] In some embodiments, the device further comprises a first prompt unit (not shown in the figure). The first prompt unit is used to output first prompt information if there is no first closed area containing the first target edge, the first prompt information indicating that there is no minimum closed area containing the target point.
[0152] In some embodiments, the device further includes a second prompt unit (not shown in the figure). The second prompt unit is used to output second prompt information if the straight line has no intersection with each edge in the drawing area in the target extension direction, and the second prompt information indicates that there is no minimum closed area containing the target point.
[0153] The device provided in this embodiment determines the minimum closed area containing the target point through an auxiliary straight line, and has low computational complexity and small amount of calculation, and can quickly determine the minimum closed area, that is, it can improve data processing efficiency. In addition, since it is difficult to accurately determine the area of the closed area formed by each edge in the figure, and since there is no need to determine and compare the area of the closed area formed by each edge in the figure in the process of determining the minimum closed area containing the target point, the present application can ensure the accuracy of the determined minimum closed area while ensuring a small amount of calculation, that is, the present application can quickly and accurately determine the minimum closed area containing the target point, which helps to improve drawing efficiency.
[0154] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0155] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0156] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0157] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0158] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0159] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish descriptions and should not be understood as indicating or implying relative importance. It should also be understood that although the terms "first", "second", etc. are used in the text to describe various elements in some embodiments of the present application, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element.
[0160] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0161] In addition, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0162] The method for determining the minimum enclosed area provided in the embodiment of the present application can be applied to electronic devices, and the electronic devices can be devices such as terminals or servers. The terminal can be a tablet computer, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), etc. The server can be a network server, a cloud server, etc. This embodiment of the present application does not limit this.
[0163] In order to better understand the embodiments of the present application, Fig.15 The structure of the electronic device according to the embodiment of the present application is introduced.
[0164] Fig.15 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Fig.15 As shown, the electronic device 1500 of this embodiment includes: at least one processor 1501 ( Fig.15Only one processor is shown in the figure), a memory 1502, and a computer program 1503 stored in the memory 1502 and executable on at least one processor 1501, such as a minimum enclosed area determination program. When the processor 1501 executes the computer program 1503, the steps in any of the above-mentioned method embodiments are implemented. When the processor 1501 executes the computer program 1503, the steps in the above-mentioned minimum enclosed area determination method embodiments are implemented. When the processor 1501 executes the computer program 1503, the functions of each module / unit in the above-mentioned device embodiments are implemented, such as Fig.14 The functions of the data response unit 1401, the target determination unit 1402 and the area determination unit 1403 are shown.
[0165] Exemplarily, the computer program 1503 may be divided into one or more modules / units, one or more modules / units are stored in the memory 1502, and are executed by the processor 1501 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 1503 in the electronic device 1500. For example, the computer program 1503 may be divided into a data response unit 1401, a target determination unit 1402, and an area determination unit 1403. The specific functions of each unit have been described in the above embodiments and will not be repeated here.
[0166] The electronic device 1500 may include, but is not limited to, a processor 1501 and a memory 1502. Those skilled in the art will appreciate that Fig.15 It is only an example of electronic device 1500 and does not constitute a limitation of electronic device 1500. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0167] The processor 1501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0168] The memory 1502 may be an internal storage unit of the electronic device 1500, such as a hard disk or memory of the electronic device 1500. The memory 1502 may also be an external storage device of the electronic device 1500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 1500. Further, the memory 1502 may also include both an internal storage unit of the electronic device 1500 and an external storage device. The memory 1502 is used to store computer programs and other programs and data required by the electronic device. The memory 1502 may also be used to temporarily store data that has been output or is to be output.
[0169] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0170] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0171] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software 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 be beyond the scope of this application.
[0172] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as 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 interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0173] 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.
[0174] 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.
[0175] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Among them, the computer-readable storage medium can be non-volatile or volatile. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in computer-readable storage media can be appropriately increased or decreased according to the requirements of legislation and patent practices in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practices, computer-readable storage media do not include electrical carrier signals and telecommunication signals.
[0176] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method for determining a minimum enclosed area, characterized in that: The method comprises: In response to a target point acting on a drawing area, generating a straight line passing through the target point, wherein the drawing area includes one or more edges; Determine the intersection of the straight line and each edge in the drawing area in the target extension direction, determine the edge corresponding to the target intersection as the target edge, the target intersection is the intersection closest to the target point among the determined intersections, wherein the target extension direction is any extension direction of the straight line; A minimum closed area including the target point is determined according to the target edge.
2. The method for determining the minimum enclosed area according to claim 1, characterized in that: Before generating a straight line passing through the target point, the method further includes: if two ends of a first edge are respectively connected to other edges, determining the first edge as a valid edge, wherein the first edge is any one of the multiple edges, and the other edges are edges of the multiple edges other than the first edge; The determining of the intersection points of the straight line with each edge in the drawing area in the target extension direction includes: determining the intersection points of the straight line with each valid edge in the drawing area in the target extension direction.
3. The method for determining the minimum enclosed area according to claim 1, characterized in that: The generating a straight line passing through the target point comprises: A first straight line and a second straight line passing through the target point are generated, wherein the first straight line is parallel to the horizontal coordinate axis of the drawing area, and the second straight line is parallel to the vertical coordinate axis of the drawing area.
4. The method for determining the minimum enclosed area according to claim 1, characterized in that: There are multiple target edges; determining the minimum closed area containing the target point according to the target edges includes: Taking a first target edge as a starting edge, determining N first closed areas including the first target edge, where endpoints of every two adjacent edges in the first closed areas are connected, the first target edge is any edge among the multiple target edges, and N is an integer greater than or equal to 0; From the N first closed areas, select M second closed areas that contain the target point, where M is an integer greater than or equal to 0; The minimum closed area is determined from the M second closed areas according to the number of target edges included in each second closed area.
5. The method for determining the minimum enclosed area according to claim 4, characterized in that: The determining the minimum closed area from the M second closed areas according to the number of target edges included in each second closed area includes: If there is one third closed area, the third closed area is determined as the minimum closed area, wherein the third closed area is the closed area with the largest number of target edges among the M second closed areas.
6. The method for determining the minimum enclosed area according to claim 4, characterized in that: The determining the minimum closed area from the M second closed areas according to the number of target edges included in each second closed area includes: If there are multiple third closed areas, and the number of straight lines passing through the target point is greater than a first preset value, determining overlapping edges and multiple local contours according to the overlap between the multiple third closed areas, wherein each local contour corresponds to a third closed area, and the local contour is composed of non-overlapping edges; Determine, according to a connection sequence of the edges in any of the third closed areas, a first coincident edge initially connected to the plurality of local contours and a starting point of the plurality of local contours, wherein the connection sequence includes a clockwise sequence or a counterclockwise sequence; Taking the first coincident edge and the starting point as references, determining the selection order of each local contour in turn in the reverse direction of the connection order, wherein the selection order of the local contours is consistent with the selection order of the third closed area corresponding to the local contours; A third closed area with the highest order among the multiple third closed areas is selected and determined as the minimum closed area.
7. The method for determining the minimum enclosed area according to claim 6, characterized in that: The method comprises: If there are multiple third closed areas and the number of straight lines passing through the target point is less than or equal to a first preset value, add straight lines passing through the target point.
8. The method for determining the minimum enclosed area according to claim 4, characterized in that: The method further comprises: If the first closed area including the first target edge does not exist, first prompt information is output, where the first prompt information indicates that there is no minimum closed area including the target point.
9. The method for determining the minimum enclosed area according to any one of claims 1 to 8, characterized in that: The method further comprises: If the straight line has no intersection with any edge in the drawing area in the target extension direction, a second prompt information is output, where the second prompt information indicates that there is no minimum closed area containing the target point.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for determining the minimum enclosed area according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Closed area searching method and device and electronic equipment
CN111986289A
Closed area identification method and device, electronic equipment and storage medium
CN116189221A
Method and device for updating closed area in drawing, electronic equipment and storage medium
CN116259066A
Minimum closed region identification method, apparatus and device, and computer readable medium
CN116311338A
Minimum closed area determination method and device, terminal equipment and readable storage medium
CN116958319A