Method and electronic device for determining minimum enclosed area
By generating straight lines passing through target points and determining intersection edges, the problem of high computational complexity and low efficiency in determining the minimum closed area in the drawing software is solved, and fast and accurate minimum closed area determination is achieved, improving drawing efficiency.
Patent Information
- Application Number
- CN202510126519.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-27
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-01-27
AI Technical Summary
It is difficult for drawing software to quickly and accurately determine the minimum closed area containing target points during the graphics drawing process. The existing methods have high computational complexity and high calculation amount, resulting in inefficient drawing.
By generating a straight line passing through the target point, determine the intersection point between the straight line and the edge of the drawing area, select the edge corresponding to the intersection closest to the target point as the target edge, and then determine the minimum closed area containing the target point to avoid area comparison calculation.
It realizes the rapid and accurate determination of the minimum closed area, reduces the computational complexity and calculation amount, and improves the drawing efficiency.
Smart Images

Figure CN119559293B_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 enclosed 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 related technologies, drawing software needs to display the minimum enclosed area containing the target point, such as the cursor position or the mouse hover position, based on the line drawn by the user, to assist the user in drawing graphics and improve drawing efficiency. In other words, during the drawing process, drawing software needs to determine the minimum enclosed 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 related technologies 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: 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; 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; and determining the minimum closed area containing the target point based on the target edge.
[0006] In a second aspect, an embodiment of the present application provides a device for determining a minimum enclosed area, the device comprising:
[0007] a data response unit for generating a straight line passing through a target point in response to a target point acting on a drawing area, wherein the drawing area includes one or more edges;
[0008] a target determination unit, configured to determine the intersection of the straight line and each edge in the drawing area in a 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;
[0009] The region determination unit is used to determine the minimum closed region containing the target point based on the target edge.
[0010] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the processor implements the steps of any of the above-mentioned methods for determining a minimum enclosed area.
[0011] 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 the minimum enclosed area.
[0012] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute any of the above-mentioned methods for determining a minimum enclosed area.
[0013] Compared with the related art, the embodiments of the present application have the following advantages: 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 quickly determined, which means that 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 areas of the closed areas 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. In other words, the present application can quickly and accurately determine the minimum closed area containing the target point, which helps to improve drawing efficiency.
[0014] 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
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. 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 any creative work.
[0016] Figure 1 1 is a flow chart of a method for determining a minimum enclosed area provided in an embodiment of the present application;
[0017] Figure 2 This is a schematic diagram of an embodiment of the present application in which there is a straight line passing through a target point;
[0018] Figure 3 This is a schematic diagram of two straight lines passing through a target point provided in an embodiment of the present application;
[0019] Figure 4 This is a schematic diagram of determining a target edge based on auxiliary lines provided in an embodiment of the present application;
[0020] Figure 5 is a schematic diagram of an invalid edge in a drawing area provided by an embodiment of the present application;
[0021] Figure 6 is a schematic diagram of a plurality of closed areas containing target edges provided by an embodiment of the present application;
[0022] Figure 7 This is a schematic diagram of the process of determining the minimum closed area containing a target point provided by an embodiment of the present application;
[0023] Figure 8 This is a schematic diagram of a closed area that does not contain a target point provided in an embodiment of the present application;
[0024] Figure 9 This is a schematic diagram of a plurality of third closed areas provided in an embodiment of the present application;
[0025] Figure 10 is a schematic diagram of a drawing area provided in an embodiment of the present application;
[0026] Figure 11 is a schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application;
[0027] Figure 12 is another schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application;
[0028] Figure 13 1 is a flow chart of another method for determining a minimum enclosed area provided in an embodiment of the present application;
[0029] Figure 14 1 is a schematic structural diagram of a device for determining a minimum enclosed area provided in an embodiment of the present application;
[0030] Figure 15 It is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0031] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may 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 avoid obscuring the description of the present application with unnecessary detail.
[0032] The following describes some concepts that may be involved in the embodiments of this application:
[0033] (1) Multiple: Unless otherwise specified, in the embodiments of this application, multiple refers to two or more.
[0034] (2) Computer Aided Design (CAD): In the embodiments of this application, CAD refers to drawing software, which can also be called a drawing tool. In practice, CAD software can usually be used to draw CAD sketches.
[0035] (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.
[0036] CAD sketching offers relative freedom. It helps designers quickly visualize their design concepts, facilitating communication and understanding among team members. Furthermore, CAD software's powerful editing features, such as move, rotate, scale, stretch, and trim commands, allow for easy modification of CAD sketches, significantly improving design efficiency. Furthermore, many CAD software programs support further modeling and refinement based on CAD sketches. For example, in 3D modeling, sketches can serve as the basis for operations like stretching, rotating, and scanning, facilitating the creation of complex 3D models.
[0037] CAD sketches differ from images in several ways:
[0038] First, the difference in drawing accuracy:
[0039] CAD sketches require precise coordinate systems and geometric constraints. For example, when sketching a mechanical part in CAD software, line endpoint coordinates can be precisely set, and dimensional and geometric constraints can be used to ensure the precise dimensions and positional relationships of each part of the drawing. The software itself offers strong precision control, enabling high-precision drawing through features like polar tracking and object snapping.
[0040] Images are generally composed of pixels, and their accuracy depends on resolution. For example, common JPEG and PNG images will appear pixelated and have blurred edges when enlarged. Even vector graphics, while theoretically infinitely scalable without distortion, are not always absolutely accurate in actual processing and conversion due to limitations in software algorithms and processing power. For example, a line drawn in image processing software may appear perfectly straight, but upon enlargement, subtle jagged edges may appear.
[0041] Second, the difference in data structure:
[0042] CAD sketches are constructed using geometric elements as their data structure. For example, a line is defined by its start and end coordinates, while a circle is defined by its center coordinates and radius. Complex shapes are constructed by combining multiple basic elements through Boolean operations and constraints. Sketches created using different CAD software may have different storage formats, but they are all essentially records of geometric elements and their relationships.
[0043] Images are constructed with pixel-based data structures, where each pixel records information such as color and brightness. The amount of data is large and editing individual objects is difficult. For example, moving an object in a bitmap photo requires complex clipping and compositing operations.
[0044] Third, graphic editing:
[0045] CAD sketch editing relies primarily on specialized CAD editing commands, such as move, rotate, scale, stretch, and trim. These commands allow you to directly manipulate graphic elements and precisely modify their position, size, and shape. For example, changing the side length of a rectangle can be done by modifying the dimensional parameters or stretching. The editing process is based on geometric relationships and constraints, ensuring accuracy and consistency.
[0046] Image editing is often done by modifying pixels using drawing tools such as brushes, erasers, and selection tools. For example, when retouching an image, you might use the Clone Stamp tool to copy pixels and cover up blemishes.
[0047] 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.
[0048] In the related art, to improve drawing efficiency, drawing software needs to combine the lines already drawn by the user and display the minimum enclosed area that contains the target point. The target point can be the cursor position, the mouse hover position, etc. In other words, in the related art, drawing software has a need to determine the minimum enclosed area that contains the target point during the graphics drawing process.
[0049] In order to solve the above technical problems, one possible approach is to use the 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.
[0050] However, since the graphics drawn by drawing software change in real time with the user's drawing operations, and the drawn graphics (or sketches) often contain various complex high-order curves, this approach may have the following two problems:
[0051] First, complex, high-order curves are often drawn using methods like spline curves. While the mathematical descriptions of these curves are precise, they can lose precision when converted into discrete data that computers can process. For example, spline curves, when displayed and stored, may only approximate their true shape. This can lead to inaccurate boundaries for enclosed areas determined using these curves, making area comparisons unreliable.
[0052] Secondly, complex, high-order curves generate a large number of data points, which not only increases the size of the graphics file but also significantly increases the computational effort required for area calculations. When comparing the areas of multiple closed regions, computational efficiency can be very low, especially if the graphics are changing in real time. Furthermore, as the amount of data increases, the likelihood of error accumulation during the calculation process also increases, further impacting the accuracy of the area comparison results.
[0053] In view of the above-mentioned technical problems existing in the related art, an embodiment of the present application provides a method for determining a minimum closed area, which adds one or more auxiliary straight lines (or simply auxiliary lines) passing through the target point, and determines the edge (or called a line) adjacent to the target point by analyzing the distance between the target point and the first intersection point, thereby analyzing and obtaining 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 graphic. Determining the minimum closed area containing the target point through the auxiliary line 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 graphic 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 graphic during 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.
[0054] The following combination 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 enclosed area may include the following steps 101 to 103 .
[0055] In 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.
[0056] The drawing area includes one or more edges. It is understood that each edge in the drawing area has two endpoints. Each edge in the drawing area can be a straight line segment or a curved line segment.
[0057] The target point can be a point of a preset type in the drawing area. For example, the target point can be a point where a mouse is hovering, in which case the preset type can be a first type indicating the point where the mouse is hovering. The target point can also be a point where a cursor is located, in which case the preset type can be a second type indicating the cursor point. It is understood that the embodiments of the present application do not specifically limit the type of target point.
[0058] Here, the electronic device can use methods disclosed in related art to detect a target point acting on the drawing area and determine the target point's position within the drawing area. For example, when the target point is a mouse hovering location, the electronic device can use methods disclosed in related art for detecting a mouse hovering location to detect the target point acting on the drawing area and its position coordinates.
[0059] When the electronic device detects a target point acting on the drawing area, it can generate a straight line passing through the target point in the drawing area based on the position coordinates of the target point. It is understood that the electronic device can use a solution disclosed in related art for generating a straight line passing through a certain point to generate a straight line passing through the target point.
[0060] Optionally, in step 101 , a straight line may be generated.
[0061] Optionally, in step 101, multiple straight lines may be generated, and the angles between each two adjacent rays formed by the intersection of the multiple straight lines are equal. In this case, the edges adjacent to the target point can be detected more accurately, thereby quickly and accurately determining the minimum enclosed area containing the target point.
[0062] Optionally, in step 101, a first straight line and a second straight line may be generated that pass through the target point, with the first straight line being parallel to the horizontal axis of the drawing area, and the second straight line being parallel to the vertical axis of the drawing area. Generating straight lines based on the horizontal and vertical axes of the drawing area ensures that straight lines passing through the target point are generated quickly and accurately. Furthermore, because the first straight line is parallel to the horizontal axis of the drawing area, and the second straight line is parallel to the vertical axis of the drawing area, the vertical coordinates of the intersections of the first straight line with each edge are identical, and the horizontal coordinates of the intersections of the second straight line with each edge are identical, helping to reduce computational complexity and further improving drawing efficiency.
[0063] The following combination Figures 2 to 3 Describe the situation of a straight line passing through the target point. Figure 2 A schematic diagram of a straight line passing through a target point is provided in 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.
[0064] like Figure 2As shown, the drawing area can have three edges: edge 1, edge 2, and edge 3. Edges 1, 2, and 3 form a triangle. The target point is point P. If there is a straight line passing through the target point, the straight line can intersect with two of edge 1, edge 2, and edge 3, for example, edge 1 and edge 2.
[0065] like Figure 3 As shown, the drawing area may have three sides: side 1, side 2, and side 3. Sides 1, 2, and 3 form a triangle. The target point is point P. If there are two perpendicular lines passing through the target point, these two lines may intersect with three of side 1, side 2, and side 3.
[0066] It can be understood that, generally speaking, the more straight lines passing through the target point, the more edges intersecting with the straight lines in the drawing area.
[0067] In step 102 , the electronic device determines the intersection of the straight line in the target extension direction with each edge in the drawing area, and determines the edge corresponding to the target intersection as the target edge.
[0068] 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.
[0069] 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 that extension direction, thereby determining the edge closest to the target point in that extension direction (i.e., 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 enclosed area containing the target point.
[0070] The following combination 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.
[0071] like Figure 4 As shown, the drawing area can have five sides: side 1, side 2, side 3, side 4, and side 5. The target point is point P. There are two lines passing through point P, one of which is parallel to the horizontal coordinate axis and the other is parallel to the vertical coordinate axis. The horizontal line extends leftward and intersects side 1 at point A. The horizontal line extends rightward and intersects side 2 and side 5 at point B and point C. The vertical line extends upward and intersects side 1 at point D. The vertical line extends downward and intersects side 3 at point E.
[0072] Figure 4In the leftward extension direction, the horizontal straight line has only one intersection point A with each edge. In this case, point A is the target intersection point, and edge 1 is the target edge. In the rightward extension direction, the horizontal straight line has two intersection points with each edge, 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. In the upward extension direction, the vertical straight line has only one intersection point D with each edge. In this case, point D is the target intersection point, and edge 1 is the target edge. In the downward extension direction, the vertical straight line has only one intersection point E with each edge. In this case, point E is the target intersection point, and edge 3 is the target edge. Combined Figure 4 , we can determine that there are three target edges, namely edge 1, edge 2 and edge 3.
[0073] 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.
[0074] Therefore, in some embodiments, before step 101, the electronic device may further perform the following operation: if the first edge is connected to other edges at both ends, the electronic device determines that the first edge is a valid edge. In this case, 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.
[0075] In the embodiment of the present application, determining the minimum closed area containing the target point based on valid edges can avoid interference caused by invalid edges, reduce the amount of calculation, and help improve the efficiency of determining the minimum closed area, thereby improving drawing efficiency.
[0076] Optionally, before 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.
[0077] In some optional embodiments, the electronic device may delete invalid edges from the plurality of edges before step 101. Invalid edges are edges other than valid edges.
[0078] 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 five edges: edge 1, edge 2, edge 3, edge 4, and edge 5. Edges 1, 2, and 3 form a triangle. Edge 4 has two ends that are not connected to any edge (i.e., they are dangling). Edge 5 has one end connected to another edge, but the other end is not connected to any edge. The target point is point P. Figure 5 In the example, edges 1, 2, and 3 are valid edges, while edges 4 and 5 are invalid edges.
[0079] In some optional implementations of the embodiments of the present application, in step 102, if the straight line does not intersect any edge in the drawing area in the target extension direction, the electronic device may output a second prompt. The second prompt indicates that there is no minimum enclosed area containing the target point. It will be appreciated that if the auxiliary line passing through the target point does not intersect any edge in any extension direction, then it indicates that there is no enclosed area in the drawing area containing the target point.
[0080] It is understandable 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.
[0081] Step 103: The electronic device determines the minimum closed area containing the target point based on the target edge.
[0082] Optionally, after obtaining the target edge, the electronic device may determine the minimum enclosed area containing the target point by starting with a target edge and searching for the next edge connected to the target edge and the next next edge connected to the next edge in a predetermined order, such as counterclockwise or clockwise, until finally returning to the target edge. In this way, a closed area formed by the edges may be obtained. This closed area may then be determined as the minimum enclosed area containing the target point.
[0083] In the embodiment of the present application, the minimum closed area containing the target point is determined by using auxiliary straight lines, which 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. In other words, the present application can quickly and accurately determine the minimum closed area containing the target point, which helps to improve drawing efficiency.
[0084] 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 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.
[0085] 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 based on 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.
[0086] In 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.
[0087] The first closed area is a closed area including the target edge.
[0088] 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.
[0089] 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 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.
[0090] 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).
[0091] Optionally, if there is no first closed area containing the first target edge, a first prompt message is output, the first prompt message indicating that there is no minimum closed area containing the target point. In this case, there is no minimum closed area in the drawing area.
[0092] In step 702 , the electronic device selects M second closed areas containing the target point from the N first closed areas.
[0093] Wherein, M is an integer greater than or equal to 0, and M is less than or equal to N.
[0094] The second closed area is a closed area among the multiple first closed areas that includes the target point.
[0095] 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 described in detail here.
[0096] Here, considering that some of the N first closed areas obtained in step 701 may not contain the target point, selecting a closed area containing the target point (or referred to as a second closed area) from the N first closed areas, and then screening the minimum closed area containing the target point from the plurality of second closed areas, can reduce the computational complexity and further improve the efficiency of determining the minimum closed area.
[0097] The following combination Figure 8 This paper 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 This is a schematic diagram of a closed area that does not contain a target point provided in the embodiment of the present application. It should be noted that Figure 8 In the example, a bold line is used to represent the starting edge. It is understandable that the embodiment of the present application does not specifically limit how to represent the starting edge.
[0098] like Figure 8 As shown, Figure 8 The left graph takes edge 1 as the starting edge and can traverse to two closed areas containing edge 1, which are Figure 8 The enclosed area shown in the upper right and Figure 8 The enclosed area is shown in the lower right. Figure 8 The closed area shown in the upper right corner does not contain the target point P, and 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.
[0099] 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.
[0100] Step 703: The electronic device determines a minimum closed area from the M second closed areas according to the number of target edges contained in each second closed area.
[0101] Here, if in step 702, it is determined 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 with 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 Combining the auxiliary lines, we can see that the target edges are edge 1, edge 2, and edge 3. In this case, region 1 contains three target edges, while region 2 contains two target edges. Region 1 contains the most target edges, so region 1 can be determined as the minimum enclosed area. It is understood that the minimum enclosed area mentioned in this embodiment of the application is the minimum enclosed area that contains the target point.
[0102] 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.
[0103] The following combination Figure 9 This paper describes the situation where there are multiple second closed areas (referred to as third closed areas) that contain the largest number of target edges. Figure 9 This is a schematic diagram of a plurality of third closed areas provided in an embodiment of the present application. It should be noted that: Figure 9 In order to distinguish the target edge from other edges, the target edge can be represented by a bold line, and edges other than the target edge (hereinafter referred to as other edges) can be represented by a non-bold line. It is understood that the embodiments of the present application do not specifically limit how to distinguish the target edge from other edges.
[0104] like Figure 9 As shown in (a), 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. Figure 9 (b) and Figure 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 Figure 9 (b) in Figure 1). 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 Figure 9 (c) in the figure). Figure 9 In the example, the third and fourth regions both contain all current target edges. That is, the third and fourth regions are the regions with the largest number of target edges (referred to as the third closed region).
[0105] 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.
[0106] In other embodiments, the above step 703 may be replaced by the following steps 1 to 4.
[0107] 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 overlapping edges and multiple local contours based on the overlap between the multiple third closed areas.
[0108] Each local contour corresponds to a third closed area, and the local contour is composed of non-coincident edges.
[0109] 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 can be 10. The embodiment of the present application does not limit the value of the first preset value.
[0110] 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 edge determined in step 102 can almost cover every edge in the minimum closed area, which means that the minimum closed area can be determined quickly and accurately.
[0111] 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. Figure 9 In (a), since the target point P is relatively offset, the auxiliary line that intersects with edge 7, edge 8, or edge 9 will first intersect with edge 1. As a result, under the method of determining the target edge described in step 102 above, edges 7, 8, and 9 cannot be determined as the target edge.
[0112] In step 1, the electronic device can combine the edges contained 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. Figure 9 As an example, (a) in FIG. 5A shows that 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.
[0113] Optionally, in step 1 above, 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, the electronic device may add straight lines passing through the target point. It should be noted that, in certain circumstances, adding auxiliary lines may help obtain more target edges.
[0114] In 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.
[0115] The connection order includes a clockwise order or a counterclockwise order.
[0116] The following combination Figure 10 Explain the connection sequence. Among them, Figure 10 A schematic diagram of a drawing area provided in an embodiment of the present application. Figure 10 The drawing area shown is the same as Figure 9 The plotting area shown in (a) is the same as Figure 10 As shown, the dashed arrow indicates a clockwise direction, so the connection order is clockwise. In this case, the connection order of the coincident edges in the third closed region is: edge 1 - edge 2 - edge 3 - edge 4 - edge 5 - edge 6. Starting from edge 6, the connection is made to the local contour, and from point A to the local contour. In this case, edge 6 is the first coincident edge, and point A is the starting point of multiple local contours. Figure 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).
[0117] In 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 coincident edge and the starting point.
[0118] The order in which the local contours are selected can indicate the probability that the third enclosed area corresponding to the local contour is the minimum enclosed area. The earlier the local contour is selected, the greater the probability that the third enclosed area formed by the local contour is the minimum enclosed area, or in other words, the earlier the third enclosed area formed by the local contour is selected.
[0119] The following combination Figure 11 Explain the selection order. Figure 11 A schematic diagram of the order of determining the selection of local contours provided in an embodiment of the present application. Figure 11 The drawing area shown is the same as Figure 10 The plotting area shown is the same. Figure 11As shown, the dotted arrows indicate the connection order, and the direction of the connection order is clockwise. The dotted arrows indicate 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. Figure 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.
[0120] 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 the first curve in the 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 Figure 11 , if the first curve is Figure 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.
[0121] In 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.
[0122] Here, combined Figure 11 The electronic device can determine the third closed area corresponding to the contour 1 with the earliest 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.
[0123] Figure 11 The following describes the situation where the connection sequence is in a clockwise direction. Figure 12 The case where the connection sequence is in the counterclockwise direction is further described. Figure 12 Another schematic diagram of determining the selection order of each local contour provided in an embodiment of the present application.
[0124] like Figure 12 As shown, the dotted arrows indicate the connection order, and the direction of the connection order is counterclockwise. The dotted arrows indicate the direction of determining the selection order of each local contour, and 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. Figure 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.
[0125] Combine Figure 11 and Figure 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.
[0126] Optionally, after step 103, the electronic device may further perform the following operation: 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 understood that the embodiments of the present application do not specifically limit how to highlight the minimum enclosed area.
[0127] It should be noted that highlighting the minimum enclosed area containing the target point allows the user to more intuitively find the minimum enclosed area, thereby assisting in drawing graphics with the aid of the minimum enclosed area. In other words, the solution provided by the embodiment of the present application helps to improve drawing efficiency.
[0128] It is understandable that after the above step 103, all straight lines (or auxiliary lines) passing through the target point can be cleared to avoid affecting the efficiency of the user's drawing due to the addition of unnecessary lines.
[0129] The following combination Figure 13 The method for determining the minimum enclosed area provided in the embodiment of the present application is further described. Figure 13 As shown, the method for determining the minimum enclosed area may include the following steps:
[0130] Step 1301: The electronic device obtains all edges in the two-dimensional sketch.
[0131] Among them, 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.
[0132] Here, the electronic device can obtain the coordinate data of all 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.
[0133] In 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 .
[0134] Here, the edges in set 1 are the aforementioned valid edges.
[0135] 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.
[0136] In step 1303, the electronic device draws two auxiliary lines in the horizontal and vertical directions for the given point.
[0137] The auxiliary straight line can also be called an auxiliary line. The given point is the aforementioned target point.
[0138] In step 1304 , the electronic device calculates the intersection points of the newly created auxiliary straight line and all the edges in set 1 .
[0139] Here, the electronic device can calculate the intersection points of the two auxiliary lines and all edges in set 1 and statistically classify them according to the extension direction of the auxiliary lines. For example, [dirction1 of line1, <intersection1, intersection2>], [dirction2 of line1, <intersection3, intersection4>]. Where line1 is an auxiliary line, dirction1 is one extension direction of the auxiliary line, and dirction2 is the other extension direction of the auxiliary line.
[0140] In step 1305, the electronic device determines whether each auxiliary straight line has an intersection in both directions. If not, the electronic device outputs the result: there is no minimum closed area surrounding the given point; if so, proceeds to the next step.
[0141] In 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 .
[0142] Here, the electronic device can calculate the distance between the intersection points of the auxiliary lines in each extension direction and the given point. Then, by comparing the distance values corresponding to the intersection points, it finds the intersection point with the smallest distance in that extension direction, thereby finding the edge where the intersection point is located. The found edge is the closest edge in that extension direction. Similarly, the electronic device can find the closest edge of each auxiliary line in each extension direction. Finally, the ID of the closest edge in each extension direction can be added to Set 2.
[0143] Among them, the edges in set 2 are the aforementioned target edges.
[0144] Step 1307: The electronic device determines whether the candidate closed area set 3 is empty.
[0145] 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.
[0146] In step 13071, the electronic device selects an edge from set 2, traverses to find all closed paths containing the edge, and adds the path to set 3 as a candidate closed area.
[0147] Here, the closed area found in step 13071 is the aforementioned first closed area, that is, the closed area containing the target edge.
[0148] In 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.
[0149] Here, the closed area filtered in step 13072 is the aforementioned second closed area, that is, the closed area including the target point.
[0150] In step 1308 , the electronic device counts the number of edges in set 2 included in each candidate closed region in set 3 .
[0151] In 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 .
[0152] 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.
[0153] Here, the closed region containing the largest number of edges in set 2 is the aforementioned third closed region. There may be one or more third closed regions. If there is only one third closed region, then that third closed region is directly used as the minimum closed region. If there are multiple third closed regions, then step 1310 is performed to further select the minimum closed region.
[0154] In step 1310 , the electronic device determines whether the number of auxiliary straight lines currently drawn is greater than a preset threshold.
[0155] The pre-set critical value has the same concept as the first pre-set value mentioned above.
[0156] Here, if the number of auxiliary lines currently drawn is greater than a preset threshold (e.g., 360), and the minimum enclosed region has not yet been solved despite the number of auxiliary lines currently drawn exceeding the threshold, it indicates that the given point is too far from the center of the minimum enclosed region, resulting in the edges of some local contours of the minimum enclosed region not intersecting with the auxiliary lines. Therefore, steps 13101 and 13102 need to be executed. Conversely, if the number of auxiliary lines currently drawn is less than or equal to the preset threshold, step 13103 is executed.
[0157] In 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 local contours composed of different edges.
[0158] Combine Figures 9 to 12 , the same contours in set 4 are the contours formed by coincident edges, that is, the contours formed by edges 1 to 6. In this case, there are two local contours, contour 1 formed by edge 7 and contour 2 formed by edges 8 and 9.
[0159] In step 13102, the electronic device uses a circle sorting algorithm on the starting vertex of each local contour to find each nearest edge and add it to set 5. The process ends and outputs: a closed area consisting of all edges in set 4 and all nearest edges in set 5 obtained by circle sorting.
[0160] Circular sorting of each local contour is performed by taking the previous edge connected to the local contour as the adjacent edge (or the first overlapping edge) and the endpoint connected to the local contour as the adjacent point (or the starting point). Based on the adjacent edge, all edges starting from this adjacent point are circularly sorted according to the first sorting direction, which is the opposite direction of the aforementioned connection order.
[0161] Combine Figure 11 and Figure 12 , we can find that the nearest edge is edge 7. That is, we can add edge 7 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 together form a minimum closed region.
[0162] 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 proceeds to step 1304 .
[0163] Corresponding to the method for determining the minimum enclosed area in the above embodiment, Figure 14 The structural block diagram of the device for determining the minimum enclosed area provided by the embodiment of the present application is shown. For the sake of convenience, only the part related to the embodiment of the present application is shown. Figure 14The minimum enclosed area determination device may include a data response unit 1401 , a target determination unit 1402 , and an area determination unit 1403 .
[0164] The data response unit 1401 is configured to generate a straight line passing through a target point in response to a target point acting on a drawing area, wherein the drawing area includes one or more edges.
[0165] The target determination unit 1402 is used to determine the intersection of the straight line and 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.
[0166] The region determining unit 1403 is configured to determine the minimum closed region containing the target point based on the target edge.
[0167] In some embodiments, the apparatus may further include a first determining unit (not shown in the figure), configured to determine that the first edge is a valid edge if both ends of the first edge are connected to other edges. The first edge is any one of the multiple edges, and the other edges are edges other than the first edge.
[0168] In this case, the target determining unit 1402 determines the intersections of the straight line with each edge in the drawing area in the target extension direction, including: determining the intersections of the straight line with each valid edge in the drawing area in the target extension direction.
[0169] 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.
[0170] 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).
[0171] A first module is configured to determine N first closed regions containing a first target edge, with the first target edge as a starting edge, where endpoints of every two adjacent edges in the first closed regions are connected, the first target edge being any edge among the multiple target edges, and N being an integer greater than or equal to 0;
[0172] The second module is configured 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;
[0173] The third module is configured to determine a minimum closed area from the M second closed areas according to the number of target edges contained in each second closed area.
[0174] In some embodiments, the third module is specifically configured 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 containing the largest number of target edges among the M second closed areas.
[0175] 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 contour is 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. With the first overlapping edge and the starting point as the reference, 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.
[0176] In some embodiments, the device further includes a line adding unit (not shown in the figure) configured to add a line passing through the target point if there are multiple third closed areas and the number of lines passing through the target point is less than or equal to a first preset value.
[0177] In some embodiments, the device further includes a first prompt unit (not shown in the figure). The first prompt unit is configured to output a first prompt message if there is no first closed area containing the first target edge, the first prompt message indicating that there is no minimum closed area containing the target point.
[0178] In some embodiments, the device further includes a second prompt unit (not shown in the figure). The second prompt unit is configured to output a second prompt message if the straight line has no intersection with any edge in the drawing area in the target extension direction, the second prompt message indicating that there is no minimum closed area containing the target point.
[0179] The device provided in this embodiment uses auxiliary straight lines to determine the minimum enclosed area containing the target point. This has low computational complexity and a small amount of computation, and can quickly determine the minimum enclosed area, thereby improving data processing efficiency. Furthermore, since it is difficult to accurately determine the area of the enclosed area formed by the edges of a graphic, and since there is no need to determine and compare the areas of the enclosed areas formed by the edges of the graphic when determining the minimum enclosed area containing the target point, the present application can ensure the accuracy of the determined minimum enclosed area while ensuring a small amount of computation. In other words, the present application can quickly and accurately determine the minimum enclosed area containing the target point, thereby helping to improve drawing efficiency.
[0180] 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 this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0181] 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 this application.
[0182] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0183] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0184] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" 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 "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0185] In addition, in the description of this application and the appended claims, the terms "first," "second," "third," etc. are used only to distinguish and describe, 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.
[0186] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0187] In addition, those skilled in the art will clearly understand that for the sake of convenience and brevity 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 distributed and 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 in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0188] The method for determining the minimum enclosed area provided in the embodiments of the present application can be applied to electronic devices, which can be terminals or servers. The terminals can be tablet computers, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), etc. The servers can be network servers, cloud servers, etc. This embodiment of the present application does not limit this.
[0189] In order to better understand the embodiments of the present application, Figure 15 The structure of the electronic device according to the embodiment of the present application is introduced.
[0190] Figure 15 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. Figure 15 As shown, the electronic device 1500 of this embodiment includes: at least one processor 1501 ( Figure 15Only one processor is shown in the figure), memory 1502, and a computer program 1503 stored in memory 1502 and executable by at least one processor 1501, such as a minimum enclosed area determination program. When processor 1501 executes computer program 1503, steps in any of the above-described method embodiments are implemented. When processor 1501 executes computer program 1503, steps in the above-described minimum enclosed area determination method embodiments are implemented. When processor 1501 executes computer program 1503, functions of modules / units in the above-described device embodiments are implemented, such as Figure 14 The functions of the data response unit 1401, the target determination unit 1402 and the area determination unit 1403 are shown.
[0191] Exemplarily, the computer program 1503 may be divided into one or more modules / units, one or more of which are stored in the memory 1502 and 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 performing specific functions, which 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.
[0192] 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 Figure 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.
[0193] The processor 1501 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), 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.
[0194] Memory 1502 can be an internal storage unit of electronic device 1500, such as a hard drive or memory of electronic device 1500. Memory 1502 can also be an external storage device of electronic device 1500, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on electronic device 1500. Furthermore, memory 1502 can include both an internal storage unit of electronic device 1500 and an external storage device. Memory 1502 is used to store computer programs and other programs and data required by the electronic device. Memory 1502 can also be used to temporarily store data that has been output or is about to be output.
[0195] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and 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 into one processing unit, or each unit can exist physically alone, 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. 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, and will not be repeated here.
[0196] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0197] Those skilled 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 beyond the scope of this application.
[0198] In the embodiments provided in this 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 merely a logical function division. In actual implementation, there may be other division methods, 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.
[0199] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0200] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0201] If the integrated module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be either non-volatile or volatile. Based on this understanding, the present application can implement all or part of the process steps in the above-mentioned method embodiments by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. Computer-readable storage media can include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. 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 telecommunications signals.
[0202] 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, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection 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 and extending in two directions, wherein the drawing area includes one or more edges; Determine the intersection of the straight line and each edge in the drawing area in a target extension direction, and determine the edge corresponding to the target intersection as a 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; Determine, based on the target edge, a minimum closed area containing the target point; There are multiple target edges; and determining the minimum closed area containing the target point based on the target edges includes: Taking a first target edge as a starting edge, determine N first closed regions that include the first target edge, where the endpoints of every two adjacent edges in the first closed regions 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; Selecting 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; According to the number of target edges contained in each second closed area, the minimum closed area is determined from the M second closed areas, including: 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; 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, according to the overlap between the multiple third closed areas, overlapping edges and multiple local contours are determined, wherein each local contour corresponds to a third closed area, and the local contour is composed of non-overlapping edges; according to each edge in any of the third closed areas The connection order of the edges is to determine the first overlapping edge connected to the multiple local contours and the starting point of the multiple local contours, 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, wherein the selection order of the local contours is consistent with the selection order of the third closed area corresponding to the local contours; the third closed area with the highest selection order among the multiple third closed areas is determined as the minimum closed area; 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 straight lines passing through the target point are increased.
2. The method for determining the minimum enclosed area according to claim 1, wherein: Before generating the 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, wherein: The generating of a straight line passing through the target point includes: 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, wherein: 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.
5. The method for determining the minimum enclosed area according to any one of claims 1 to 4, 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 message is output, where the second prompt message indicates that there is no minimum closed area containing the target point.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for determining the minimum enclosed area according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Closed area searching method and device and electronic equipment
CN111986289A