Method, device, electronic device and storage medium for updating closed areas in a drawing

By monitoring updated line segments in the drawings and calculating intersection points, the updated closed areas are automatically identified, solving the problem of time-consuming and labor-intensive manual identification in existing technologies and improving identification efficiency.

CN116259066BActive Publication Date: 2026-07-03深圳市万翼数字技术有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
深圳市万翼数字技术有限公司
Filing Date
2022-12-30
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In existing technologies, after adding or deleting lines in drawings, identifying closed areas requires human intervention, which is time-consuming, labor-intensive, and inefficient.

Method used

By monitoring the updated line segments in the drawings, the target line segments that intersect with them are identified, the intersection points are calculated, the second intersection point outside the intersection point is obtained, and the updated closed area is determined based on the intersection points.

Benefits of technology

It automatically identifies updated closed areas without human intervention, improving recognition efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116259066B_ABST
    Figure CN116259066B_ABST
Patent Text Reader

Abstract

The application relates to a method and device for updating a closed area in a drawing, electronic equipment and a storage medium, and belongs to the technical field of computers, wherein the method comprises the following steps: monitoring an update line segment in a drawing, the drawing comprising a line segment set, and the line segment set comprising at least three historical line segments; determining a target line segment in the line segment set intersecting the update line segment; determining a first intersection point of the target line segment and the update line segment; acquiring a second intersection point on the target line segment except the first intersection point; and determining an updated closed area based on the first intersection point and the second intersection point. The application can solve the problem that, in the prior art, after adding a new line or deleting a line, a person needs to participate in identifying a closed area, resulting in time and labor consumption and low identification efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more particularly to a method, apparatus, electronic device, and storage medium for updating closed areas in a drawing. Background Technology

[0002] When developing a CAD graphics platform, it is necessary to identify the smallest non-overlapping closed areas for the lines drawn by the user.

[0003] In related technologies, the identification of closed areas is often done manually by professionals, which is time-consuming, labor-intensive, and extremely inefficient. Even after adding or deleting lines, manual processing by professionals is still required. Therefore, there is an urgent need to invent a method for updating closed areas in drawings. Summary of the Invention

[0004] This application provides a method, apparatus, electronic device, and storage medium for updating closed areas in drawings, in order to solve the problem in the prior art that after adding or deleting lines, human intervention is required to identify closed areas, which leads to time-consuming, labor-intensive, and low-efficiency identification.

[0005] In a first aspect, embodiments of this application provide a method for updating a closed region in a drawing, including:

[0006] Monitor updated line segments in a drawing, the drawing including a set of line segments, the set of line segments including at least three historical line segments;

[0007] Identify the target line segment in the set of line segments that intersects with the updated line segment;

[0008] Determine the first intersection point between the target line segment and the updated line segment;

[0009] Obtain the second intersection point on the target line segment, excluding the first intersection point;

[0010] The updated closed region is determined based on the first intersection point and the second intersection point.

[0011] Optionally, the updated line segments in the monitored drawing include:

[0012] Monitor whether any historical line segments have been deleted or new line segments have been added to the drawing.

[0013] If so, determine whether the deleted historical segment or the newly added segment is the updated segment.

[0014] Optionally, determining the target line segment in the set of line segments that intersects with the updated line segment includes:

[0015] Obtain the two first endpoints of the updated line segment;

[0016] The target line segment intersecting with the set of line segments is determined based on the two first endpoints.

[0017] Optionally, when the updated line segment is a newly added line segment, determining the first intersection point between the target line segment and the updated line segment includes:

[0018] Obtain the two first endpoints of the updated line segment and the two second endpoints of the target line segment;

[0019] The first intersection point is calculated based on the two first endpoints and the two second endpoints.

[0020] Optionally, when the updated line segment is a newly added line segment, determining the updated closed region based on the first intersection point and the second intersection point includes:

[0021] Based on the first intersection point, after determining that the updated line segment intersects with the target line segment, the first sub-line segment is obtained on the updated line segment;

[0022] Based on the first intersection point and the second intersection point, determine the second sub-segment obtained on the target line segment after the updated line segment intersects with the target line segment;

[0023] Using the first sub-segment as the starting segment of the updated closed region, and based on the positional relationship between the second sub-segment and the first sub-segment, other segments of the updated closed region are determined from the second sub-segment.

[0024] Optionally, when the updated line segment is a deleted line segment, determining the updated closed region based on the first intersection point and the second intersection point includes:

[0025] Sort the first intersection points to obtain the sorting result;

[0026] Based on the first intersection point and the second intersection point, determine the sub-segments on the target line segment;

[0027] Starting from the first intersection point in the first position of the sorting result, an initial closed region is determined based on the positional relationship between the sub-segments;

[0028] If the initial closed region is determined according to a specific direction, the initial closed region is determined as the updated closed region;

[0029] If the initial closed region is determined in the opposite direction to a specific direction, roll back each sub-segment of the initial closed region and redetermine the closed region until the determined closed region is in the specific direction.

[0030] Optionally, determining the initial closed region based on the positional relationship between the sub-segments, starting from the first intersection point in the sorting result, includes:

[0031] Determine any first sub-segment that includes the first intersection point;

[0032] Perform the following determination steps: Determine the N+1th sub-segment with the largest projected length on the Nth sub-segment among the candidate sub-segments connected to the M+1th sub-intersection point, wherein the M+1th sub-intersection point is another sub-intersection point on the Nth sub-segment other than the Mth sub-intersection point, and N and M are both positive integers greater than or equal to 1, with the initial values ​​of N and M being 1;

[0033] Determine whether the (M+1)th intersection point of the (N+1)th sub-segment is the first intersection point;

[0034] If not, increment both N and M by 1 and repeat the determination step until the (M+1)th sub-intersection is the first intersection.

[0035] If so, the space enclosed by the first intersection point to the (M+1)th intersection point is determined as the initial closed region.

[0036] Optionally, after determining the updated closed region based on the first intersection point and the second intersection point, the method further includes:

[0037] When the updated line segment is a deleted line segment, the closed region including the deleted line segment will be deleted;

[0038] When the updated line segment is a newly added line segment, the closed area that intersects with the newly added line segment is deleted.

[0039] Secondly, embodiments of this application provide an apparatus for updating a closed area in a drawing, comprising:

[0040] The first acquisition module is used to monitor updated line segments in the drawing, the drawing including a set of line segments, the set of line segments including at least three historical line segments;

[0041] The first determining module is used to determine the target line segment in the set of line segments that intersects with the updated line segment;

[0042] The second determining module is used to determine the first intersection point between the target line segment and the updated line segment;

[0043] The second acquisition module is used to acquire the second intersection point on the target line segment, excluding the first intersection point;

[0044] The third determining module is used to determine the updated closed region obtained after the update based on the first intersection point and the second intersection point.

[0045] Thirdly, embodiments of this application provide an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0046] The memory is used to store computer programs;

[0047] The processor is configured to execute the program stored in the memory to implement the method for updating closed areas in the drawing as described in the first aspect.

[0048] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for updating closed areas in a drawing as described in the first aspect.

[0049] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application monitors updated line segments in a drawing, wherein the drawing includes a set of line segments, and the set of line segments includes at least three historical line segments; determines a target line segment in the set of line segments that intersects with the updated line segment; determines a first intersection point between the target line segment and the updated line segment; obtains a second intersection point on the target line segment other than the first intersection point; and determines the updated closed region based on the first intersection point and the second intersection point. Thus, without human intervention, the updated closed region can be determined by redetermining the first and second intersection points on the updated line segment and the target line segment, thereby improving the efficiency of identifying updated closed regions in the drawing. Attached Figure Description

[0050] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is an application scenario diagram illustrating a method for updating a closed area in a drawing according to an embodiment of this application.

[0053] Figure 2 A flowchart illustrating a method for updating a closed region in a drawing according to an embodiment of this application;

[0054] Figure 3A schematic diagram of a closed region in a method for updating a closed region in a drawing provided in an embodiment of this application;

[0055] Figure 4 A schematic diagram of line segments having the same intersection point in a method for updating a closed area in a drawing provided in another embodiment of this application;

[0056] Figure 5 A schematic diagram illustrating the method for determining other line segments in an updated drawing of a closed region provided in another embodiment of this application;

[0057] Figure 6 A schematic diagram of the closed region in a method for updating a closed region in a drawing provided in another embodiment of this application;

[0058] Figure 7 A structural diagram of the device for the closed area in the updated drawings provided in an embodiment of this application;

[0059] Figure 8 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0060] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0061] According to one embodiment of this application, a method for updating a closed region in a drawing is provided. Optionally, in this embodiment, the above-described method for updating a closed region in a drawing can be applied to, for example... Figure 1 The hardware environment shown consists of terminal 101 and server 102. For example... Figure 1 As shown, server 102 is connected to terminal 101 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 102. The network mentioned above includes, but is not limited to, wide area network, metropolitan area network or local area network. Terminal 101 is not limited to PC, mobile phone, tablet computer, etc.

[0062] The method for updating a closed area in a drawing according to this application embodiment can be executed by server 102, terminal 101, or jointly by server 102 and terminal 101. Specifically, the method for updating a closed area in a drawing according to this application embodiment can also be executed by a client installed on terminal 101.

[0063] Taking the method of updating a closed area in a drawing according to an embodiment of this application as an example, Figure 2 This is a flowchart illustrating an optional method for updating a closed area in a drawing according to an embodiment of this application, as shown below. Figure 2 As shown, the process of this method may include the following steps:

[0064] Step 201: Monitor the updated line segments in the drawing, wherein the drawing includes a set of line segments, and the set of line segments includes at least three historical line segments.

[0065] In some embodiments, the drawings can be two-dimensional drawings such as architectural drawings and construction drawings. In the drawings, corresponding areas are often drawn with different line segments for display.

[0066] In one optional embodiment, monitoring the updated line segments in the drawing includes:

[0067] Monitor whether any historical line segments have been deleted or new line segments have been added to the drawing.

[0068] If so, determine whether the deleted historical segment or the newly added segment is the updated segment.

[0069] In some embodiments, it can be determined whether historical line segments have been deleted or new line segments have been added by monitoring operations on the drawing.

[0070] Step 202: Determine the target line segment in the set of line segments that intersects with the updated line segment.

[0071] In some embodiments, line segments in the drawing may be parallel or intersecting, forming closed regions through their intersections. Therefore, whether two line segments intersect can be determined by calculating their endpoints; if so, the two line segments intersect. Here, the two line segments mentioned above refer to the updated line segments and any line segment in the line segment set.

[0072] In an optional embodiment, determining the target line segment intersecting the updated line segment in the set of line segments includes:

[0073] Obtain the two first endpoints of the updated line segment;

[0074] The target line segment intersecting with the set of line segments is determined based on the two first endpoints.

[0075] In some embodiments, after a line segment is drawn on a drawing, its two endpoints can be obtained using the coordinates on the drawing. Whether two line segments intersect can be determined mathematically, for example, through the cross product of vectors. Specifically, this involves: First, determining whether the projections of the two line segments onto the x-axis and y-axis intersect; if there is no intersection on either axis, they cannot intersect (rapid repulsion experiment); Second, determining whether the two lines cross each other, using the cross product (cross product experiment).

[0076] Step 203: Determine the first intersection point between the target line segment and the updated line segment.

[0077] In an optional embodiment, when the updated line segment is a newly added line segment, determining the first intersection point between the target line segment and the updated line segment includes:

[0078] Obtain the two first endpoints of the updated line segment and the two second endpoints of the target line segment;

[0079] The first intersection point is calculated based on the two first endpoints and the two second endpoints.

[0080] In some embodiments, after identifying two intersecting line segments, their intersection point can be calculated mathematically. For example, the intersection point of the lines containing the two line segments can be calculated using the first endpoint and the second endpoint. Then, it can be determined whether the intersection point lies on the two line segments. If so, the intersection point is taken as the intersection point of the two line segments, i.e., the first intersection point.

[0081] Step 204: Obtain the second intersection point on the target line segment, excluding the first intersection point.

[0082] In some embodiments, the terminal's database stores the original closed regions formed by historical line segments, as well as the intersections between historical line segments. Therefore, the second intersections on the historical line segments can be directly obtained from the database.

[0083] Step 205: Determine the updated closed region based on the first intersection point and the second intersection point.

[0084] In some embodiments, by monitoring updated line segments in a drawing, the drawing including a set of line segments containing at least three historical line segments; identifying a target line segment in the set that intersects with the updated line segment; determining a first intersection point between the target line segment and the updated line segment; obtaining a second intersection point on the target line segment other than the first intersection point; and determining the updated closed region based on the first and second intersection points. Thus, without human intervention, the updated closed region can be determined by redetermining the first and second intersection points on the updated and target line segments, thereby improving the efficiency of identifying updated closed regions in the drawing.

[0085] In an optional embodiment, when the updated line segment is a newly added line segment, determining the updated closed region based on the first intersection point and the second intersection point includes:

[0086] Based on the first intersection point, after determining that the updated line segment intersects with the target line segment, the first sub-line segment is obtained on the updated line segment;

[0087] Based on the first intersection point and the second intersection point, determine the second sub-segment obtained on the target line segment after the updated line segment intersects with the target line segment;

[0088] Using the first sub-segment as the starting segment of the updated closed region, and based on the positional relationship between the second sub-segment and the first sub-segment, other segments of the updated closed region are determined from the second sub-segment.

[0089] In some embodiments, after a new line segment is added, the original closed region may be split into two, or a new closed region may be formed with the historical line segment.

[0090] For example, see Figure 3 In this diagram, A, B, C, and D represent historical line segments, and E represents updated line segments. 1 to 13 represent intersection points in the drawing, where 7 to 10 represent the first intersection point, and 1 to 6 and 11 to 13 represent the second intersection point.

[0091] Specifically, after adding the new line segment, the intersection points 7, 8, 9, and 10 are sorted in ascending order of their x-coordinates, and then constructed sequentially along the new line segment E at points 7, 8, 9, and 10.

[0092] According to the projection method, the next sub-segment of sub-segment 7-8 is 8-2; the next sub-segment of 8-2 is 2-7. The first region 7-8-2 is obtained, and the traversal path is set to visited.

[0093] Similarly, calculate the next sub-segment of sub-segment 8-7, which are 7-1, 1-11, 11-3, 3-8; obtain the second region 8-7-1-11-3, and set the traversal path to visited;

[0094] Similarly, calculate the next sub-segment of sub-segment 8-9, which are 9-4, 4-13, 13-2, 2-8 in sequence; obtain the third region 8-9-4-13-2, and set the traversal path to visited;

[0095] Similarly, calculate the next sub-segment of sub-segment 9-8, which are 8-3 and 3-9 respectively; obtain the fourth region 9-8-3, and set the traversal path to visited;

[0096] Similarly, calculate the next sub-segment of sub-segment 9-10, which are 10-6, 6-4, and 4-9 respectively; obtain the fifth region 9-10-6-4-9, and set the traversal path to visited;

[0097] Similarly, calculate the next sub-segment of sub-segment 10-9, which are 9-3, 3-5, and 5-10 in sequence; obtain the sixth region 10-9-3-5, and set the traversal path to visited.

[0098] Furthermore, the projection method described above can be implemented in the following ways:

[0099] First, obtain the floor plan that needs to be identified.

[0100] Second, identify the line segments in the plan view, as well as the intersections and endpoints between all line segments.

[0101] Third, filter the endpoints to ensure that each position retains only a unique point and save the pointer of that point.

[0102] Fourth, starting from the bottom left corner, traverse the intersection points in order from left to right.

[0103] Fifth, for the first point, such as Figure 4 As shown, a list of line segments originating from the starting point is created. The list is then sorted, and the rightmost line segment is retrieved, meaning all other line segments are to its left. Figure 4 The middle point is line segment 1, and the other endpoint of line segment 1 is the second point.

[0104] Sixth, add the start and end points of line segment 1 to the result list, and set the status of line segment 1 to visited.

[0105] Seventh, starting from the second line segment, the new endpoints are obtained based on the projected length, such as... Figure 5 As shown, in addition to the edge set list added to result, there are a total of 7 edges connected to b. The projection length can be obtained by projecting the unit vector onto the ab ray, and the projection length can be negative.

[0106] 8. Divide the line segments into two categories: the left side of the ray and the right side of the ray; assign the line segments collinear with the ray to the right side of the ray. If there is a line segment on the left side of the ray, compare the projected lengths of the line segments on the left. If there is no line segment on the left, compare the projected lengths of the line segments on the right. The line segment with the smallest projected length is the next line segment, and its status is set to visited.

[0107] ninth, Figure 5The next line segment is coded as 1, and the other endpoint of line segment 1 is the third point. This continues until the next point is the first point. This determines that the above points form a closed region, and the boundary points are stored in the result. If the enclosed region is counter-clockwise, it is saved directly; if it is clockwise, a reverse list is saved, and the counter-clockwise list is set to visited.

[0108] 10. Continue from the first point until the number of edges passing through that point and having the state "invisited" is 1, then move on to the next point. Repeat the search as in step 5 until all closed regions are found.

[0109] Eleventh, store the closed regions obtained using the above method in the form of line segment combinations.

[0110] The method for calculating the projected length can be the projected length itself. for:

[0111]

[0112]

[0113] Where vector a is the vector formed by the Pth line segment, where P is a positive integer greater than 0, and vector b is the vector formed by the line segments connected to the Pth line segment.

[0114] In an alternative embodiment, when the updated line segment is a newly added line segment, the closed region intersecting with the newly added line segment is deleted.

[0115] For example, see Figure 3 Since the newly added line segment E intersects with the original closed areas 1-11-3-2, 2-3-4-13 and 3-5-6-4, the above three areas stored in the drawing are deleted.

[0116] In an optional embodiment, when the updated line segment is a deleted line segment, determining the updated closed region based on the first intersection point and the second intersection point includes:

[0117] Sort the first intersection points to obtain the sorting result;

[0118] Based on the first intersection point and the second intersection point, determine the sub-segments on the target line segment;

[0119] Starting from the first intersection point in the first position of the sorting result, an initial closed region is determined based on the positional relationship between the sub-segments;

[0120] If the initial closed region is determined according to a specific direction, the initial closed region is determined as the updated closed region;

[0121] If the initial closed region is determined in the opposite direction to a specific direction, roll back each sub-segment of the initial closed region and redetermine the closed region until the determined closed region is in the specific direction.

[0122] In some embodiments, after deleting a line segment, at least two original closed regions may be split and merged into one, or the original closed regions may no longer form closed regions.

[0123] For example, see Figure 3 After deleting the line segment, construct along lines 7, 8, 9, and 10 in sequence. The newly created area does not pass through the actual line E.

[0124] Specifically, the edges through 7 are 7-1 and 7-2; since the x-coordinate of 1 is smaller than that of 7, the first half edge is 7-1, and the next edge of 7-1 is 1-11, 11-3, 3-8, 8-2, 2-7; the first region 7-1-11-3-8-2 is obtained, and the traversal path is set to visited;

[0125] In the next traversal, the first edge is 7-2, and the next edges are 2-13, 13-4, 4-6, 6-10, 10-5, 5-12, 12-11, 11-1, and 1-7. The enclosed area formed is clockwise, so no more edges can be added. Set 1-7 as visited, and denote the next edge of half-edge 11-1 as next(11-1).

[0126] next(11-1) = nullptr, rollback, set 11-1 to visited;

[0127] next(12-11) = nullptr, rollback, set 12-11 to visited;

[0128] next(5-12) = nullptr, rollback, set 5-12 to visited;

[0129] next(10-5) = 5-3, next(5-3) = 3-11, next(3-11) = 11-12, next(11-12) = 12-5; Extract the region 5-3-11-12, this region does not pass through the boundary E, and is not added to the region list;

[0130] next(10-5) = nullptr, rollback, sets 10-5 to visited;

[0131] next(6-10) = nullptr, rollback, sets 6-10 to visited;

[0132] next(4-6) = nullptr, rollback, setting 4-6 to visited;

[0133] next(13-4)=4-9, next(4-9)=9-3, next(9-3)=3-5, next(3-5)=5-10,

[0134] next(5-10) = 10-6, next(10-6) = 6-4; Extract the second region 4-9-3-5-10-6, which passes through points 9 and 10 on the boundary of E; Set the region path to visited.

[0135] After truncation, next(13-4) = nullptr, and set 13-4 to visited;

[0136] Next(2-13) = nullptr, setting 2-13 to visited;

[0137] next(7-2)=2-8; next(2-8)=8-3; next(8-3)=3-9; next(3-9)=9-4;

[0138] next(9-4) = 4-13; next(4-13) = 13-2; Extract the third region 2-8-3-9-4-13, which passes through points 8 and 9 on the boundary of E; Set the region path to visited.

[0139] `next(7-2) = nullptr`, stop iterating through 7.

[0140] Starting from 8, the halves 8-2 and 8-3 have already been set to visited; stop iterating through 8.

[0141] Starting from 9, the halves 9-3 and 9-4 have already been set to visited, so stop iterating over 9.

[0142] Starting from 10, the halves 10-5 and 10-6 have already been set as visited, so stop iterating over 10.

[0143] End. A total of three enclosed regions were extracted, namely: 7-1-11-3-8-2, 4-9-3-5-10-6, and 2-8-3-9-4-13.

[0144] In an optional embodiment, determining the initial closed region based on the positional relationship between the sub-segments, starting from the first intersection point in the sorting result at the first position, includes:

[0145] Determine any first sub-segment that includes the first intersection point;

[0146] Perform the following determination steps: Determine the N+1th sub-segment with the largest projected length on the Nth sub-segment among the candidate sub-segments connected to the M+1th sub-intersection point, wherein the M+1th sub-intersection point is another sub-intersection point on the Nth sub-segment other than the Mth sub-intersection point, and N and M are both positive integers greater than or equal to 1, with the initial values ​​of N and M being 1;

[0147] Determine whether the (M+1)th intersection point of the (N+1)th sub-segment is the first intersection point;

[0148] If not, increment both N and M by 1 and repeat the determination step until the (M+1)th sub-intersection is the first intersection.

[0149] If so, the space enclosed by the first intersection point to the (M+1)th intersection point is determined as the initial closed region.

[0150] In some embodiments, see Figure 6 In this diagram, a, b, c, and d are the intersection points in the drawing, and A, B, C, D, and E are the sub-line segments. Taking a as the starting point, the sub-line segments including point a are A and C. In this example, A is chosen as the first sub-line segment. Next, the second intersection point b is determined. The sub-line segments connected to b include B and D. By comparison, B has the smallest angle with A, therefore B is determined as the second sub-line segment. This leads to the third intersection point c. However, c is not the same intersection point as a, so the determination process needs to be repeated to determine the third intersection point c. The sub-line segments connected to c include C and E. By comparison, C has the smallest angle with B, therefore C is determined as the third sub-line segment. Finally, a is the same intersection point as a, thus obtaining the closed area enclosed by a, b, and c.

[0151] It should be noted that the minimum included angle mentioned above refers to the angle between the N line segment and the candidate sub-line segment after rotating the N line segment clockwise with the M+1th intersection point as the rotation point.

[0152] For example, in Figure 6 In the diagram, the angle between C and B is angle 1, and the angle between E and B is angle 2, not angle 3.

[0153] In an optional embodiment, determining the (N+1)th sub-segment with the smallest angle to the Nth sub-segment from among the candidate sub-segments connected to the Mth intersection point of the Nth sub-segment includes:

[0154] Calculate the projection length of each candidate sub-segment onto the Nth sub-segment to obtain a set of projection lengths;

[0155] If the set of projected lengths includes projected lengths greater than zero, the candidate sub-segment corresponding to the maximum value in the projected lengths is determined as the (N+1)th sub-segment.

[0156] If the set of projection lengths does not include projection lengths greater than zero, the candidate sub-segment corresponding to the minimum value in the projection lengths is determined as the (N+1)th sub-segment.

[0157] In some embodiments, there are multiple ways to determine the (N+1)th sub-segment with the smallest angle to the Nth sub-segment. In this embodiment, the (N+1)th sub-segment can be determined by calculating the set of projected lengths of candidate sub-segments on the Nth sub-segment and by using the magnitude of the projected lengths.

[0158] There are several ways to calculate the projection length, such as by using the following formula: Projection length for:

[0159]

[0160]

[0161] Where vector a is the Nth sub-segment and vector b is a candidate sub-segment.

[0162] In an optional embodiment, it further includes:

[0163] The sub-segments that make up the enclosed region are stored in combination.

[0164] In some embodiments, storing sub-segments of each identified closed region facilitates subsequent practice, such as displaying them as closed regions.

[0165] This application presents a method for updating closed regions in drawings, which can adapt to the extraction of various hulls without needing to save the length of the contour path, thus expanding the application scenarios of contour extraction. By using an update method, minor changes do not require recalculation, improving the computational efficiency of the model.

[0166] Based on the same concept, this application provides a device for updating a closed area in a drawing. The specific implementation of this device can be found in the description of the method embodiments section; repeated details will not be repeated here. Figure 7 As shown, the device mainly includes:

[0167] The first acquisition module 701 is used to monitor updated line segments in a drawing, wherein the drawing includes a set of line segments, and the set of line segments includes at least three historical line segments;

[0168] The first determining module 702 is used to determine the target line segment in the set of line segments that intersects with the updated line segment;

[0169] The second determining module 703 is used to determine the first intersection point between the target line segment and the updated line segment;

[0170] The second acquisition module 704 is used to acquire the second intersection point on the target line segment other than the first intersection point;

[0171] The third determining module 705 is used to determine the updated closed region obtained after the update based on the first intersection point and the second intersection point.

[0172] Based on the same concept, this application also provides an electronic device, such as... Figure 8 As shown, the electronic device mainly includes a processor 801, a memory 802, and a communication bus 803. The processor 801 and the memory 802 communicate with each other via the communication bus 803. The memory 802 stores programs that can be executed by the processor 801. The processor 801 executes the programs stored in the memory 802 to achieve the following steps:

[0173] Monitor updated line segments in a drawing, the drawing including a set of line segments, the set of line segments including at least three historical line segments;

[0174] Identify the target line segment in the set of line segments that intersects with the updated line segment;

[0175] Determine the first intersection point between the target line segment and the updated line segment;

[0176] Obtain the second intersection point on the target line segment, excluding the first intersection point;

[0177] The updated closed region is determined based on the first intersection point and the second intersection point.

[0178] The communication bus 803 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 803 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0179] The memory 802 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor 801.

[0180] The processor 801 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., or a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0181] In another embodiment of this application, a computer-readable storage medium is provided, which stores a computer program that, when run on a computer, causes the computer to perform the method for updating a closed area in a drawing as described in the above embodiments.

[0182] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape, etc.), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0183] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0184] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for updating a closed area in a drawing, characterized in that, include: Monitor updated line segments in a drawing, the drawing including a set of line segments, the set of line segments including at least three historical line segments; Identify the target line segment in the set of line segments that intersects with the updated line segment; Determine the first intersection point between the target line segment and the updated line segment; Obtain the second intersection point on the target line segment, excluding the first intersection point; The updated closed region is determined based on the first intersection point and the second intersection point; When the updated line segment is a deleted line segment, determining the updated closed region based on the first intersection point and the second intersection point includes: Sort the first intersection points to obtain the sorting result; Based on the first intersection point and the second intersection point, determine the sub-segments on the target line segment; Starting from the first intersection point in the first position of the sorting result, an initial closed region is determined based on the positional relationship between the sub-segments; If the initial closed region is determined according to a specific direction, the initial closed region is determined as the updated closed region; If the initial closed region is determined in the opposite direction to a specific direction, roll back each sub-segment of the initial closed region and redetermine the closed region until the determined closed region is in the specific direction.

2. The method for updating a closed area in a drawing according to claim 1, characterized in that, The updated line segments in the monitoring drawings include: Monitor whether any historical line segments have been deleted or new line segments have been added to the drawing. If so, determine whether the deleted historical segment or the newly added segment is the updated segment.

3. The method for updating a closed area in a drawing according to claim 1, characterized in that, Determining the target line segment intersecting the updated line segment in the set of line segments includes: Obtain the two first endpoints of the updated line segment; The target line segment intersecting with the set of line segments is determined based on the two first endpoints.

4. The method for updating a closed area in a drawing according to claim 1, characterized in that, When the updated line segment is a newly added line segment, determining the first intersection point between the target line segment and the updated line segment includes: Obtain the two first endpoints of the updated line segment and the two second endpoints of the target line segment; The first intersection point is calculated based on the two first endpoints and the two second endpoints.

5. The method for updating a closed area in a drawing according to claim 1, characterized in that, When the updated line segment is a newly added line segment, determining the updated closed region based on the first intersection point and the second intersection point includes: Based on the first intersection point, after determining that the updated line segment intersects with the target line segment, the first sub-line segment is obtained on the updated line segment; Based on the first intersection point and the second intersection point, determine the second sub-segment obtained on the target line segment after the updated line segment intersects with the target line segment; Using the first sub-segment as the starting segment of the updated closed region, and based on the positional relationship between the second sub-segment and the first sub-segment, other segments of the updated closed region are determined from the second sub-segment.

6. The method for updating a closed area in a drawing according to claim 1, characterized in that, The step of determining the initial closed region based on the positional relationship between the sub-segments, starting from the first intersection point in the sorting result, includes: Determine any first sub-segment that includes the first intersection point; Perform the following determination steps: Determine the N+1th sub-segment with the largest projected length on the Nth sub-segment among the candidate sub-segments connected to the M+1th sub-intersection point, wherein the M+1th sub-intersection point is another sub-intersection point on the Nth sub-segment other than the Mth sub-intersection point, and N and M are both positive integers greater than or equal to 1, with the initial values ​​of N and M being 1; Determine whether the (M+1)th intersection point of the (N+1)th sub-segment is the first intersection point; If not, increment both N and M by 1 and repeat the determination step until the (M+1)th sub-intersection is the first intersection. If so, the space enclosed by the first intersection point to the (M+1)th intersection point is determined as the initial closed region.

7. An apparatus for updating a closed area in a drawing, characterized in that, include: The first acquisition module is used to monitor updated line segments in the drawing, the drawing including a set of line segments, the set of line segments including at least three historical line segments; The first determining module is used to determine the target line segment in the set of line segments that intersects with the updated line segment; The second determining module is used to determine the first intersection point between the target line segment and the updated line segment; The second acquisition module is used to acquire the second intersection point on the target line segment, excluding the first intersection point; The third determining module is used to determine the updated closed region obtained after the update based on the first intersection point and the second intersection point; When the updated line segment is a deleted line segment, determining the updated closed region based on the first intersection point and the second intersection point includes: Sort the first intersection points to obtain the sorting result; Based on the first intersection point and the second intersection point, determine the sub-segments on the target line segment; Starting from the first intersection point in the first position of the sorting result, an initial closed region is determined based on the positional relationship between the sub-segments; If the initial closed region is determined according to a specific direction, the initial closed region is determined as the updated closed region; If the initial closed region is determined in the opposite direction to a specific direction, roll back each sub-segment of the initial closed region and redetermine the closed region until the determined closed region is in the specific direction.

8. An electronic device, characterized in that, include: The processor, communication interface, memory, and communication bus are connected, with the processor, communication interface, and memory communicating with each other via the communication bus. The memory is used to store computer programs; The processor is configured to execute the program stored in the memory to implement the method for updating a closed area in a drawing as described in any one of claims 1-6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method for updating closed areas in a drawing as described in any one of claims 1-6.