Method, apparatus, medium and device for extending line segment in circuit layout

CN122987818APending Publication Date: 2026-10-27ORIGIN QUANTUM INSTR CO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510443366.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0004]本发明的目的是提供一种电路版图中线段的延伸方法、装置、存储介质及电子设备,以解决现有技术中手动延伸线段影响版图布线效率的问题,能够精确、快速完成线段延伸,提高版图布线效率

Benefits of technology

[0045]区别于现有技术的情况,本发明提供的电路版图中线段的延伸方法通过选取线段确定目标线段以及目标线段上延伸的起点,通过生成从起点开始的查找射线来确定是否与预设参考对象相交,在相交时,获取查找射线与预设参考对象的第二交点,并将目标线段延伸至距离最近的第二交点,形成延伸线段。通过上述方式,本发明能够精确、快速完成线段延伸,提高版图布线效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122987818A_ABST
    Figure CN122987818A_ABST
Patent Text Reader

Abstract

The application discloses a method, device, medium and equipment for extending a line segment in a circuit layout. The method comprises the following steps: connecting two selected reference points in the circuit layout to generate a selected line segment; searching for a line segment intersecting with the selected line segment as a target line segment; obtaining a first intersection point of the selected line segment and the target line segment; taking the end point of the two end points of the target line segment closer to the first intersection point as a starting point, and generating a search ray in a direction away from the target line segment according to the slope of the target line segment; detecting whether the search ray intersects with a preset reference object in the circuit layout; when the search ray intersects with the preset reference object, obtaining a second intersection point of the search ray and the preset reference object, and extending the target line segment to the nearest second intersection point to form an extended line segment. The application can accurately and quickly complete line segment extension, and improve the layout routing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of circuit layout design, and in particular to a method, apparatus, medium, and device for extending line segments in a circuit layout. Background Technology

[0002] In circuit layout design, after drawing the layout graphics of circuit entities such as components and pads, it is necessary to arrange traces between the connection points of each layout graphic to represent the circuit connection relationship. Considering factors such as reducing signal interference during transmission, improving circuit reliability, and saving wiring space, the traces are usually broken lines.

[0003] During routing, it is sometimes necessary to extend segments on a laid-out polygonal line. To achieve this, designers often need to manually locate the starting point and coordinates of the extension endpoint. However, current circuit integration is high, and the number of traces on the layout is enormous. Manually extending segments is tedious, time-consuming, and prone to errors, especially when extending multiple segments in batches. Therefore, existing segment extension methods significantly impact layout routing efficiency. Summary of the Invention

[0004] The purpose of this invention is to provide a method, apparatus, storage medium, and electronic device for extending line segments in a circuit layout, so as to solve the problem that manually extending line segments affects the layout routing efficiency in the prior art, and can accurately and quickly complete the line segment extension, thereby improving the layout routing efficiency.

[0005] To solve the above-mentioned technical problems, the present invention provides a method for extending line segments in a circuit layout, comprising:

[0006] Connect the two currently selected reference points in the circuit layout to generate the selected line segment;

[0007] Find the line segment in the circuit layout that intersects with the selected line segment as the target line segment;

[0008] Obtain the first intersection point between the selected line segment and the target line segment;

[0009] Starting from the endpoint of the target line segment that is closer to the first intersection point, a search ray is generated in a direction away from the target line segment according to the slope of the target line segment;

[0010] Detect whether the search ray intersects with a preset reference object in the circuit layout;

[0011] When they intersect, the second intersection point of the search ray and the preset reference object is obtained, and the target line segment is extended to the nearest second intersection point to form an extended line segment.

[0012] Preferably, the step of finding the line segment in the circuit layout that intersects with the selected line segment as the target line segment includes:

[0013] A bounding box is constructed for the line segments in the circuit layout and the selected line segments, and the bounding box is used to perform quadtree intersection detection on the line segments in the circuit layout and the selected line segments;

[0014] Line segments that intersect in the test results will be selected as candidate line segments;

[0015] Find the candidate line segment that intersects with the selected line segment and use it as the target line segment.

[0016] Preferably, the step of finding candidate line segments that intersect with the selected line segment as the target line segment includes:

[0017] Construct a first vector pointing from the first endpoint to the last endpoint of the selected line segment, and a second vector pointing from the first endpoint to the last endpoint of the candidate line segment;

[0018] Calculate the first absolute value of the first cross product of the first vector and the second vector;

[0019] When the first absolute value is greater than the first preset threshold, a third vector is constructed pointing from the first endpoint of the selected line segment to the first endpoint of the candidate line segment;

[0020] Calculate the first ratio of the second cross product of the third vector and the second vector to the first absolute value, and the second ratio of the third cross product of the third vector and the first vector to the first absolute value;

[0021] The candidate line segments whose first ratio and second ratio are both in the range of [0,1] are selected as the target line segments.

[0022] Preferably, obtaining the first intersection point between the selected line segment and the target line segment includes:

[0023] Obtain the coordinates of the first endpoint of the selected line segment and the coordinates of the first vector;

[0024] The first intersection point is determined by using the sum of the product of the first ratio and the x-coordinate of the first vector and the x-coordinate of the first endpoint of the selected line segment as the x-coordinate, and the sum of the product of the first ratio and the y-coordinate of the first vector and the y-coordinate of the first endpoint of the selected line segment as the y-coordinate.

[0025] Preferably, detecting whether the search ray intersects with a preset reference object in the circuit layout includes:

[0026] All line segments that make up the preset reference object in the circuit layout are taken as cut-off line segments;

[0027] Construct a normalized vector for the target line segment, a fourth vector from the first endpoint of the cutoff line segment to the starting point, a fifth vector from the first endpoint of the cutoff line segment to the last endpoint, and rotate the normalized vector by 90 degrees to form a sixth vector.

[0028] Calculate the second absolute value of the first dot product of the fifth vector and the sixth vector;

[0029] When the second absolute value is greater than the second preset threshold, calculate the third ratio of the fourth cross product of the fifth vector and the fourth vector to the second absolute value, and the fourth ratio of the second dot product of the fourth vector and the sixth vector to the second absolute value;

[0030] When the third ratio is greater than or equal to zero and the fourth ratio is in the range [0,1], it is determined that the search ray intersects with the preset reference object.

[0031] Preferably, obtaining the second intersection point between the search ray and the preset reference object includes:

[0032] Obtain the coordinates of the starting point and the coordinates of the normalized vector;

[0033] The second intersection point is determined by using the sum of the product of the third ratio and the x-coordinate of the normalized vector and the x-coordinate of the starting point as the x-coordinate, and the sum of the product of the third ratio and the y-coordinate of the normalized vector and the y-coordinate of the starting point as the y-coordinate.

[0034] Preferably, after forming the extended line segment, the extension method further includes:

[0035] When connecting other line segments at the starting point of the target line segment and / or to endpoints far from the starting point, the other line segments connecting the starting point are separated from the extended line segment, and / or the other line segments connecting endpoints of the target line segment far from the starting point are merged with the extended line segment.

[0036] To address the aforementioned technical problems, the present invention also provides a device for extending line segments in a circuit layout, comprising:

[0037] The connection module is used to connect two currently selected reference points in the circuit layout and generate selected line segments.

[0038] The search module is used to find the line segment in the circuit layout that intersects with the selected line segment as the target line segment;

[0039] The acquisition module is used to acquire the first intersection point between the selected line segment and the target line segment;

[0040] The generation module is used to generate a search ray starting from the endpoint of the target line segment that is closer to the first intersection point, and in accordance with the slope of the target line segment, in a direction away from the target line segment.

[0041] The detection module is used to detect whether the search ray intersects with a preset reference object in the circuit layout;

[0042] The extension module is used to obtain the second intersection point of the search ray and the preset reference object when they intersect, and extend the target line segment to the nearest second intersection point to form an extended line segment.

[0043] To address the aforementioned technical problems, the present invention also provides a storage medium storing a computer program configured to execute, during runtime, the method for extending line segments in the circuit layout described in any of the preceding claims.

[0044] To address the aforementioned technical problems, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method for extending line segments in a circuit layout as described in any of the preceding claims.

[0045] Unlike existing technologies, the line segment extension method in circuit layout provided by this invention selects a line segment to determine the target line segment and the starting point for extension on the target line segment. It then generates a search ray starting from the starting point to determine if it intersects with a preset reference object. Upon intersection, it obtains the second intersection point between the search ray and the preset reference object and extends the target line segment to the nearest second intersection point, forming the extended line segment. Through this method, this invention can accurately and quickly complete line segment extension, improving layout routing efficiency.

[0046] The device for extending line segments in the circuit layout, the storage medium, and the electronic device provided by this invention belong to the same inventive concept as the method for extending line segments in the circuit layout, and therefore have the same beneficial effects, which will not be repeated here. Attached Figure Description

[0047] Figure 1 This is a flowchart illustrating a method for extending line segments in a circuit layout according to an embodiment of the present invention.

[0048] Figure 2 This is a schematic diagram of the selected line segment and the target line segment in the circuit layout.

[0049] Figure 3 A schematic diagram for locating rays.

[0050] Figure 4 This is a schematic diagram of a search ray intersecting with a preset reference object.

[0051] Figure 5 This is a schematic diagram showing the target line segment before and after extension.

[0052] Figure 6 This is a schematic diagram of line segments and the bounding box for selecting line segments in a circuit layout.

[0053] Figure 7 This is a schematic diagram of the first vector and the second vector.

[0054] Figure 8 This is a schematic diagram of the normalized vector, the fourth vector, the fifth vector, and the sixth vector.

[0055] Figure 9 This is a schematic diagram showing the extension of two line segments on a broken line.

[0056] Figure 10 A schematic block diagram of a line segment extension device in a circuit layout provided for another embodiment of the present invention. Detailed Implementation

[0057] The specific embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. The advantages and features of the present invention will become clearer from the following description and claims. It should be noted that the drawings are all in a very simplified form and use non-precise proportions, and are only used to facilitate and clarify the illustration of the embodiments of the present invention.

[0058] In the description of this invention, it should be understood that the terms "center", "upper", "lower", "left", "right", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0059] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0060] Please see Figure 1 This invention provides a method for extending line segments in a circuit layout, the method comprising the following steps:

[0061] S1: Connect the two currently selected reference points in the circuit layout to generate the selected line segment.

[0062] A reference point is a point in the circuit layout. The position of a reference point can be determined based on external input. For example, if a user clicks the mouse, the location of the mouse is selected as the reference point. Alternatively, if the user inputs two coordinates in sequence, those two coordinate points become two reference points.

[0063] The line connecting two reference points is the selected line segment, and the direction of the line connecting the two reference points is the direction of the selected line segment. The direction of the line connection requires determining one reference point as the first endpoint and the other reference point as the last endpoint. In this embodiment, the first selected reference point can be used as the first endpoint according to the selection order of the reference points.

[0064] Please see Figure 2 This is a schematic diagram of the selected line segment and the target line segment in the circuit layout. The two reference points are R1 and R2, with reference point R1 being the start endpoint and reference point R2 being the end endpoint. Connecting reference points R1 and R2 generates the selected line segment RF.

[0065] S2: Find the line segment in the circuit layout that intersects with the selected line segment as the target line segment.

[0066] The circuit layout contains many objects, including line segments, polylines, and graphics. Polylines are formed by connecting line segments one by one, and graphics are also closed shapes formed by connecting the beginning and end of line segments. Therefore, the circuit layout is composed of line segments.

[0067] Please continue reading. Figure 2 Line segment RF is selected to intersect with line segments L1, L2, and L3 in the circuit layout, but does not intersect with line segment L4. Therefore, line segments L1, L2, and L3 are selected as target line segments.

[0068] S3: Get the first intersection point between the selected line segment and the target line segment.

[0069] Among them, the intersection of the selected line segment and the target line segment will have an intersection point, which is the first intersection point.

[0070] Please continue reading. Figure 2 Select the first intersection point of line segment RF with target line segment L1 as J1, the first intersection point of line segment RF with target line segment L2 as J2, and the first intersection point of line segment RF with target line segment L3 as J3.

[0071] S4: Starting from the endpoint closer to the first intersection point of the target line segment, generate a search ray in the direction away from the target line segment according to the slope of the target line segment.

[0072] The distances between the first intersection point and the two endpoints of the target line segment can be determined by coordinate calculation. By comparing the distances, the endpoint closer to the first intersection point can be identified, and this endpoint can be used as the starting point to generate a search ray. The slope of the search ray is the slope of the target line segment, but the ray direction is away from the target line segment; therefore, the search ray and the target line segment are on the same straight line.

[0073] Please refer to the following: Figure 3 , Figure 3 This is a schematic diagram of the search ray. For target line segment L1, endpoint B is closer to the first intersection point J1, so search ray S1 is generated starting from endpoint B. For target line segment L2, endpoint B is closer to the first intersection point J2, so search ray S2 is generated starting from endpoint B. For target line segment L3, endpoint A is closer to the first intersection point J3, so search ray S3 is generated starting from endpoint A.

[0074] S5: Detect whether the search ray intersects with a preset reference object in the circuit layout.

[0075] The preset reference object is a pre-defined object, which can be a line segment, a polyline, or a closed shape. The search ray is mathematically defined to extend infinitely, therefore it can only intersect or not intersect with the preset reference object on the circuit layout.

[0076] Please refer to the following: Figure 4 , Figure 4 This is a schematic diagram showing the intersection of a search ray and a preset reference object. The preset reference object K is a broken line. Search ray S1 intersects with two line segments of the preset reference object K, search ray S2 intersects with two line segments of the preset reference object K, and search ray S3 does not intersect with the preset reference object K.

[0077] S6: When intersecting, obtain the second intersection point between the search ray and the preset reference object, and extend the target line segment to the nearest second intersection point to form an extended line segment.

[0078] The process involves finding a ray that intersects with a preset reference object, resulting in an intersection point. There may be more than one intersection point; these are called second intersection points. If there is only one second intersection point, it is the closest to the target line segment, and the target line segment is directly extended to that second intersection point. If there are multiple second intersection points, the one closest to the target line segment must be selected, and then the target line segment is extended to that closest second intersection point.

[0079] Please refer to the following: Figure 5 , Figure 5This is a diagram showing the target line segment before and after extension. The upper part of the diagram shows the target line segment before extension, and the lower part shows the extended line segment formed after extension. Find the intersection of ray S1 with two line segments of the preset reference object K. The second intersection points are M1 and M2. The second intersection point M1 is closest to the target line segment L1, so the target line segment L1 is extended to the second intersection point M1, generating the extended line segment EX1. Find the intersection of ray S2 with two line segments of the preset reference object K. The second intersection points are M3 and M4. The second intersection point M3 is closest to the target line segment L2, so the target line segment L2 is extended to the second intersection point M3, generating the extended line segment EX2.

[0080] In this embodiment, if the search ray does not intersect with the preset reference object, it means that the extension condition is not met, and a prompt indicating that the extension has failed can be generated to prompt the user to re-determine the preset reference object or target line segment.

[0081] In the above manner, the method for extending line segments in a circuit layout provided by this invention first generates a selected line segment connecting two reference points. Then, it determines intersecting target line segments and their first intersection point using the selected line segments. Next, it generates a search ray starting from the endpoint of the target line segment closer to the first intersection point. When the search ray intersects with a preset reference object, it obtains the second intersection point on the preset reference object. Finally, it extends the target line segment to the nearest second intersection point, forming an extended line segment. Since multiple target line segments can be determined at once, and all target line segments are uniformly extended to the preset reference object, this invention can accurately and quickly complete line segment extension, improving layout routing efficiency.

[0082] In a circuit layout, only a small number of line segments intersect with the selected line segment. To reduce the number of line segments to search in the circuit layout, in some embodiments of this application, the step of searching for the line segment intersecting with the selected line segment in the circuit layout as the target line segment, i.e., step S2, includes:

[0083] S21: Construct bounding boxes for line segments and selected line segments in the circuit layout, and use the bounding boxes to perform quadtree intersection detection on line segments and selected line segments in the circuit layout.

[0084] The circumbound box is the rectangle that encloses the line segment. After determining the reference coordinate system, we can find the minimum, maximum, minimum, and maximum x-coordinates of the line segment, and use these as two diagonal vertices to generate the circumbound box.

[0085] When constructing the bounding box, for line segments that are not parallel to the coordinate axes of the reference coordinate system, the minimum x-coordinate, minimum y-coordinate, maximum x-coordinate, and maximum y-coordinate of the line segment are taken as the diagonal vertices to construct the bounding box. For line segments that are parallel to the coordinate axes of the reference coordinate system, the bounding box with the line segment as the axis of symmetry is constructed with a preset width.

[0086] After the bounding box is constructed, the intersection of the bounding boxes can be detected using the quadtree algorithm.

[0087] S22: Select line segments that intersect as candidate line segments.

[0088] In this method, if the bounding box of the selected line segment intersects with the bounding box of another line segment, then that line segment may intersect the selected line segment, and that line segment is considered a candidate line segment. If the bounding box of the selected line segment does not intersect with the bounding box of another line segment, then that line segment definitely does not intersect the selected line segment. Therefore, by using the quadtree intersection detection results, candidate line segments that may intersect with the selected line segment can be selected, eliminating most other line segments.

[0089] S23: Find the candidate line segment that intersects with the selected line segment and use it as the target line segment.

[0090] Among the candidate line segments, some intersect with the selected line segment, while others do not. By finding the candidate line segments that intersect with the selected line segment, the target line segment is obtained.

[0091] Please see Figure 6 This diagram illustrates the line segments and their bounding boxes in a circuit layout. Assume there are five line segments L1, L2, L3, L4, and L5 in the circuit layout. The bounding boxes of the selected line segment RF and L1, L2, L3, L4, and L5 are shown as dashed lines in the diagram. Since the bounding boxes of L1, L2, L3, and L4 intersect with the bounding box of the selected line segment RF, while the bounding box of L5 does not intersect with the bounding box of the selected line segment RF, L1, L2, L3, and L4 are considered candidate line segments. Furthermore, since candidate line segments L1, L2, and L3 intersect with the selected line segment RF, while candidate line segment L4 does not intersect with the selected line segment RF, candidate line segments L1, L2, and L3 are chosen as the target line segment.

[0092] Furthermore, when searching for candidate line segments that intersect with the selected line segment, a vector search method can be used. Specifically, the step of searching for candidate line segments that intersect with the selected line segment as the target line segment, i.e., step S23, includes:

[0093] S231: Construct a first vector pointing from the first endpoint to the last endpoint of the selected line segment, and a second vector pointing from the first endpoint to the last endpoint of the candidate line segment.

[0094] In this vector, the magnitude of the first vector is the straight-line distance from the first endpoint to the last endpoint of the selected line segment, and the direction of the first vector is from the first endpoint to the last endpoint of the selected line segment. The magnitude of the second vector is the straight-line distance from the first endpoint to the last endpoint of the candidate line segment, and the direction of the first vector is from the first endpoint to the last endpoint of the candidate line segment. Please refer to [link / reference]. Figure 7 This is a schematic diagram of the first vector and the second vector. The first vector is vector V1, which points from the first endpoint A of the selected line segment to the last endpoint B. The second vector is vector V2, which points from the first endpoint A of the candidate line segment to the last endpoint B.

[0095] S232: Calculate the first absolute value of the first cross product of the first vector and the second vector.

[0096] The first cross product CP1 is calculated as V1.x*V2.y - V1.y*V2.x, where V1.x and V1.y are the x and y coordinates of the first vector V1, respectively, and V2.x and V2.y are the x and y coordinates of the second vector V2, respectively. The x-coordinate of the first vector V1 is the x-coordinate of the tail endpoint B of the selected line segment minus the x-coordinate of the head endpoint A, and the y-coordinate of the first vector V1 is the y-coordinate of the tail endpoint B of the selected line segment minus the y-coordinate of the head endpoint A. Similarly, the x-coordinate of the second vector V2 is the x-coordinate of the tail endpoint B of the candidate line segment minus the x-coordinate of the head endpoint A, and the y-coordinate of the second vector V2 is the y-coordinate of the tail endpoint B of the candidate line segment minus the y-coordinate of the head endpoint A.

[0097] Please continue reading. Figure 7 Assume the coordinates of the first endpoint A of the selected line segment are (2,4) and the coordinates of the last endpoint B are (2,0), and the coordinates of the first endpoint A of the candidate line segment are (0,1) and the coordinates of the last endpoint B are (3,1). Then the coordinates of the first vector V1 are (0,-4) and the coordinates of the second vector V2 are (3,0). Therefore, the first cross product PR1 = 12 and the first absolute value VA1 = 12.

[0098] S233: When the first absolute value is greater than the first preset threshold, construct a third vector pointing from the first endpoint of the selected line segment to the first endpoint of the candidate line segment.

[0099] The first preset threshold can be set according to actual needs, sufficient to determine whether two line segments are parallel or overlapping within the computer's precision range, for example, set to 1e-9. If the first absolute value is greater than the first preset threshold, it indicates that the two line segments are not parallel or overlapping. However, at this point, it cannot be considered that the selected line segment intersects with the candidate line segment; a third vector needs to be constructed. The magnitude of the third vector is the straight-line distance from the first endpoint of the selected line segment to the first endpoint of the candidate line segment, and the direction of the third vector is the direction from the first endpoint of the selected line segment to the first endpoint of the candidate line segment.

[0100] Please continue reading. Figure 7The third vector is V3, which is the vector V3 from the first endpoint A of the selected line segment to the first endpoint A of the candidate line segment.

[0101] S234: Calculate the first ratio of the second cross product of the third vector and the second vector to the first absolute value, and the second ratio of the third cross product of the third vector and the first vector to the first absolute value.

[0102] The formula for calculating the first ratio ra1 is (second cross product CP2) / VA1, and the formula for calculating the second cross product CP2 is V3.x*V2.y-V3.y*V2.x, where V3.x and V3.y are the x and y coordinates of the third vector V3, respectively. The formula for calculating the second ratio ra2 is (third cross product CP3) / VA1, and the formula for calculating the third cross product CP3 is V3.x*V1.y-V3.y*V1.x.

[0103] Please continue reading. Figure 7 The coordinates of the third vector V3 are (-2, -3), the second cross product PR2 = 9, the third cross product CP3 = 8, then the first ratio ra1 = 9 / 12 = 3 / 4, and the second ratio ra2 = 8 / 12 = 2 / 3.

[0104] S235: Select the candidate line segments whose first ratio and second ratio are both in the range of [0,1] as the target line segments.

[0105] The first ratio and the second ratio are both within the range of [0,1], indicating that the candidate line segment must intersect with the selected line segment, and therefore should be taken as the target line segment.

[0106] Please continue reading. Figure 7 The first ratio ra1 = 3 / 4 and the second ratio ra2 = 2 / 3 are both within the range [0,1]. Therefore, it can be determined that the candidate line segment intersects with the selected line segment. Figure 7 It can be seen from this that the candidate line segment and the selected line segment do indeed intersect.

[0107] Furthermore, the step of obtaining the first intersection point between the selected line segment and the target line segment, i.e., step S3, includes:

[0108] S31: Obtain the coordinates of the first endpoint of the selected line segment and the coordinates of the first vector.

[0109] S32: Use the product of the first ratio and the x-coordinate of the first vector and the sum of the x-coordinates of the first endpoints of the selected line segment as the x-coordinate, and use the product of the first ratio and the y-coordinate of the first vector and the sum of the y-coordinates of the first endpoints of the selected line segment as the y-coordinate, to determine the first intersection point.

[0110] Please continue reading. Figure 7If we select the coordinates of the first endpoint A of the line segment as (2,4) and the coordinates of the first vector V1 as (0,-4), then the x-coordinate of the first intersection point J1 is J1.x=ra1*0+2=2, and the y-coordinate of the first intersection point is J1.y=ra1*-4+4=1. Therefore, the coordinates of the first intersection point J1 are (2,1).

[0111] In some embodiments of this application, the step of detecting whether the search ray intersects with a preset reference object in the circuit layout, i.e., step S5, includes:

[0112] S51: Obtain all line segments of the preset reference object in the circuit layout as cutoff line segments.

[0113] Regardless of whether the preset reference object is a line segment, a polyline, or a closed shape, the smallest constituent unit is a line segment. These line segments that make up the preset reference object are all considered as termination line segments.

[0114] S52: Construct the normalized vector of the target line segment, the fourth vector from the first endpoint of the cutoff line segment to the starting point, the fifth vector from the first endpoint of the cutoff line segment to the end point, and rotate the normalized vector by 90 degrees to form the sixth vector.

[0115] The normalized vector of the target line segment is obtained by normalizing the vector whose magnitude is the length of the target line segment and whose direction is the direction from the endpoint furthest from the starting point to the starting point. The direction of the normalized vector remains unchanged. For example, if the coordinates of a vector are (3,4), then its magnitude is 5, and the coordinates of the normalized vector are (3 / 5,4 / 5).

[0116] The magnitude of the fourth vector is the straight-line distance from the first endpoint of the cutting-off segment to the starting point, and the direction of the fourth vector is from the first endpoint of the cutting-off segment to the starting point. The magnitude of the fifth vector is the straight-line distance from the first endpoint of the cutting-off segment to the last endpoint, and the direction of the fifth vector is from the first endpoint of the cutting-off segment to the last endpoint.

[0117] The sixth vector can be formed by rotating the normalized vector 90 degrees clockwise or counterclockwise. In this embodiment, counterclockwise rotation is used.

[0118] Please see Figure 8 This is a schematic diagram of the normalized vector, the fourth vector, the fifth vector, and the sixth vector. Assume the starting point S of the search ray has coordinates (1,1), and S is also the endpoint of the target line segment. The other endpoint A of the target line segment has coordinates (-3,1). Then, the vector pointing from endpoint A to starting point S is (4,0), the coordinates of the normalized vector G are (1,0), the fourth vector is V4 (the vector pointing from the first endpoint A of the cutoff line segment to the starting point S), the fifth vector is V5 (the vector pointing from the first endpoint A of the cutoff line segment to the last endpoint B), and the coordinates of the sixth vector V6 are (0,1).

[0119] S53: Calculate the second absolute value of the first dot product of the fifth vector and the sixth vector.

[0120] The formula for calculating the first dot product DP1 is V5.x*V6.x + V5.y*V6.y, where V5.x and V5.y are the x and y coordinates of the fifth vector V5, respectively, and V6.x and V6.y are the x and y coordinates of the sixth vector V6, respectively. The x-coordinate of the fifth vector V5 is the x-coordinate of the first endpoint A of the cutoff segment minus the x-coordinate of the starting point, and the y-coordinate of the sixth vector V6 is the y-coordinate of the last endpoint B of the cutoff segment minus the y-coordinate of the first endpoint A.

[0121] Please continue reading. Figure 8 Find the starting point S of the ray (dashed line in the figure) with coordinates (1,1), the first endpoint A of the ending line segment with coordinates (2,0), the last endpoint B with coordinates (3,2), and the fifth vector V5 with coordinates (1,2). Therefore, the first dot product DP1 = 2 and the second absolute value VA2 = 2.

[0122] S54: When the second absolute value is greater than the second preset threshold, calculate the third ratio of the fourth cross product of the fifth vector and the fourth vector to the second absolute value, and the fourth ratio of the second dot product of the fourth vector and the sixth vector to the second absolute value.

[0123] The second preset threshold can be set according to actual needs, and should be able to determine whether two line segments are parallel or overlapping within the computer's precision range; for example, it can be set to 1e-9. However, if the second absolute value is greater than the second preset threshold, it only indicates that the two line segments are not parallel or overlapping, and does not mean that the two line segments intersect. Further calculation of the third and fourth ratios is required.

[0124] The formula for calculating the third ratio ra3 is (fourth cross product CP4) / VA2, the formula for calculating the fourth cross product CP4 is V5.x*V4.y-V5.y*V4.x, the formula for calculating the fourth ratio ra4 is (second dot product DP2) / VA2, and the formula for calculating the second dot product DP2 is V4.x*V6.x+V4.y*V6.y.

[0125] Please continue reading. Figure 8 The coordinates of the fourth vector V4 are (-1,1), the coordinates of the fifth vector V5 are (1,2), the coordinates of the sixth vector V6 are (0,1), the fourth cross product CP4 = 3, the second dot product DP2 = 1, then the third ratio ra3 = 3 / 2, and the fourth ratio ra4 = 1 / 2.

[0126] S55: When the third ratio is greater than or equal to zero and the fourth ratio is in the range [0,1], determine that the search ray intersects with the preset reference object.

[0127] The third ratio is greater than or equal to zero, and the fourth ratio is in the range of [0,1]. This indicates that the search ray intersects with the cutoff segment of the preset reference object. The cutoff segment is a line segment that makes up the preset reference object, so it is determined that the search ray intersects with the preset reference object.

[0128] Please continue reading. Figure 8 The third ratio ra3 = 3 / 2 is greater than or equal to zero, and the fourth ratio ra4 = 1 / 2 is in the range [0,1]. Therefore, it can be determined that the search ray intersects with the preset reference object. Figure 8 It can be seen from the data that the search ray does indeed intersect with the line segment AB of the preset reference object.

[0129] Further, the step of obtaining the second intersection point between the search ray and the preset reference object includes:

[0130] S61: Obtain the coordinates of the starting point and the coordinates of the normalized vector.

[0131] S62: Use the product of the third ratio and the x-coordinate of the normalized vector and the sum of the x-coordinate of the starting point as the x-coordinate, and use the product of the third ratio and the y-coordinate of the normalized vector and the sum of the y-coordinate of the starting point as the y-coordinate to determine the second intersection point.

[0132] Please continue reading. Figure 8 The coordinates of the starting point are (1,1), and the coordinates of the normalized vector G are (1,0). Then the x-coordinate of the second intersection point M1 is M1.x = ra3*1+1 = 5 / 2, and the y-coordinate of the second intersection point M1 is M1.y = ra3*0+1 = 1. Therefore, the coordinates of the second intersection point M1 are (5 / 2,1).

[0133] In some embodiments of this application, if the target line segment is not isolated but part of a layout object—for example, if the layout object is a polyline and the target line segment is a segment within that polyline, or if the layout object is a polygon and the target line segment is an edge of that polygon—then it is also necessary to consider whether the extended target line segment maintains its connection with the previously connected line segments. Therefore, please refer to [further details needed]. Figure 1 After forming the extended line segment, the extension method of this application further includes:

[0134] S7: When connecting other line segments at the starting point of the target line segment and / or to endpoints far from the starting point, separate the other line segments connecting the starting point from the extended line segment, and / or merge the other line segments connecting endpoints far from the starting point of the target line segment with the extended line segment.

[0135] In this scenario, if the starting point of the target line segment connects to other line segments, then after the extension segment is formed, the starting point is no longer a common endpoint of the two line segments. Therefore, the other line segments connecting to the starting point are separated from the extension segment. Conversely, if the endpoint of the target line segment furthest from the starting point connects to other line segments, then after the extension segment is formed, the endpoint of the target line segment furthest from the starting point is still a common endpoint of the two line segments. Therefore, the other line segments connecting the endpoint of the target line segment furthest from the starting point are merged with the extension segment. In other words, if a line segment on a broken line is extended, the broken line may be split into several parts.

[0136] Please see Figure 9 , Figure 9 This is a diagram illustrating the extension of two line segments on a broken line. The left side of the diagram shows the line segment before extension, and the right side shows the line segment after extension. The broken line consists of three line segments L1, L2, and L3. Assuming line segment L2 is the target line segment and is extended to form extended line segment H2, the starting point of the target line segment L2 connects to line segment L3. Therefore, line segment L3 is separated from extended line segment H2. The endpoint of the target line segment L2 furthest from its starting point connects to line segment L1. Therefore, line segment L1 is merged with extended line segment H2. Ultimately, the broken line is divided into two parts: one part consists of line segment L1 and extended line segment H2, and the other part consists of line segment L3.

[0137] Please refer to Figure 10 Another embodiment of the present invention also provides a means for extending line segments in a circuit layout, the means comprising:

[0138] The connection module 11 is used to connect the two currently selected reference points in the circuit layout and generate the selected line segment.

[0139] A reference point is a point in the circuit layout. The position of a reference point can be determined based on external input. For example, if a user clicks the mouse, the location of the mouse is selected as the reference point. Alternatively, if the user inputs two coordinates in sequence, those two coordinate points become two reference points.

[0140] The line connecting two reference points is the selected line segment, and the direction of the line connecting the two reference points is the direction of the selected line segment. The direction of the line connection requires determining one reference point as the first endpoint and the other reference point as the last endpoint. In this embodiment, the first selected reference point can be used as the first endpoint according to the selection order of the reference points.

[0141] The search module 12 is used to find the line segment in the circuit layout that intersects with the selected line segment as the target line segment.

[0142] The circuit layout contains many objects, including line segments, polylines, and graphics. Polylines are formed by connecting line segments one by one, and graphics are also closed shapes formed by connecting the beginning and end of line segments. Therefore, the circuit layout is composed of line segments.

[0143] The acquisition module 13 is used to acquire the first intersection point between the selected line segment and the target line segment. Specifically, if the selected line segment intersects the target line segment, an intersection point exists, and this intersection point is the first intersection point.

[0144] The generation module 14 is used to generate a search ray starting from the endpoint of the target line segment that is closer to the first intersection point, and in accordance with the slope of the target line segment, in a direction away from the target line segment.

[0145] The distances between the first intersection point and the two endpoints of the target line segment can be determined by coordinate calculation. By comparing the distances, the endpoint closer to the first intersection point can be identified, and this endpoint can be used as the starting point to generate a search ray. The slope of the search ray is the slope of the target line segment, but the ray direction is away from the target line segment; therefore, the search ray and the target line segment are on the same straight line.

[0146] The detection module 15 is used to detect whether the search ray intersects with a preset reference object in the circuit layout.

[0147] The preset reference object is a pre-defined object, which can be a line segment, a polyline, or a closed shape. The search ray is mathematically defined to extend infinitely, therefore it can only intersect or not intersect with the preset reference object on the circuit layout.

[0148] The extension module 16 is used to obtain the second intersection point of the search ray and the preset reference object when they intersect, and extend the target line segment to the nearest second intersection point to form an extended line segment.

[0149] The process involves finding a ray that intersects with a preset reference object, resulting in an intersection point. There may be more than one intersection point; these are called second intersection points. If there is only one second intersection point, it is the closest to the target line segment, and the target line segment is directly extended to that second intersection point. If there are multiple second intersection points, the one closest to the target line segment must be selected, and then the target line segment is extended to that closest second intersection point.

[0150] The line segment extension device in the circuit layout of this embodiment may also include other technical features of the line segment extension method in the circuit layout of the foregoing embodiment, implement all the steps of the line segment extension method in the circuit layout of the foregoing embodiment, and have the same technical effect as the line segment extension method in the circuit layout of the foregoing embodiment, which will not be repeated here.

[0151] The present invention also provides a storage medium storing a computer program configured to execute, when running, the method for extending line segments in the circuit layout of the foregoing embodiments.

[0152] Specifically, in this embodiment, the storage medium may include, but is not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.

[0153] The present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method for extending line segments in the circuit layout of the foregoing embodiments.

[0154] Specifically, the memory and processor can be connected via a data bus. Furthermore, the aforementioned electronic device may also include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0155] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," or "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.

[0156] The above are merely preferred embodiments of the present invention and do not constitute any limitation on the present invention. Any equivalent substitutions or modifications made by those skilled in the art to the technical solutions and content disclosed in the present invention without departing from the scope of the present invention shall be deemed to have remained within the protection scope of the present invention.

Claims

1. A method for extending line segments in a circuit layout, characterized in that, include: Connect the two currently selected reference points in the circuit layout to generate the selected line segment; Find the line segment in the circuit layout that intersects with the selected line segment as the target line segment; Obtain the first intersection point between the selected line segment and the target line segment; Starting from the endpoint of the target line segment that is closer to the first intersection point, a search ray is generated in a direction away from the target line segment according to the slope of the target line segment; Detect whether the search ray intersects with a preset reference object in the circuit layout; When they intersect, the second intersection point of the search ray and the preset reference object is obtained, and the target line segment is extended to the nearest second intersection point to form an extended line segment.

2. The extension method according to claim 1, characterized in that, The step of finding the line segment in the circuit layout that intersects with the selected line segment as the target line segment includes: A bounding box is constructed for the line segments in the circuit layout and the selected line segments, and the bounding box is used to perform quadtree intersection detection on the line segments in the circuit layout and the selected line segments; Line segments that intersect in the test results will be selected as candidate line segments; Find the candidate line segment that intersects with the selected line segment and use it as the target line segment.

3. The extension method according to claim 2, characterized in that, The step of finding candidate line segments that intersect with the selected line segment as the target line segment includes: Construct a first vector pointing from the first endpoint to the last endpoint of the selected line segment, and a second vector pointing from the first endpoint to the last endpoint of the candidate line segment; Calculate the first absolute value of the first cross product of the first vector and the second vector; When the first absolute value is greater than the first preset threshold, a third vector is constructed pointing from the first endpoint of the selected line segment to the first endpoint of the candidate line segment; Calculate the first ratio of the second cross product of the third vector and the second vector to the first absolute value, and the second ratio of the third cross product of the third vector and the first vector to the first absolute value; The candidate line segments whose first ratio and second ratio are both in the range of [0,1] are selected as the target line segments.

4. The extension method according to claim 3, characterized in that, The step of obtaining the first intersection point between the selected line segment and the target line segment includes: Obtain the coordinates of the first endpoint of the selected line segment and the coordinates of the first vector; The first intersection point is determined by using the sum of the product of the first ratio and the x-coordinate of the first vector and the x-coordinate of the first endpoint of the selected line segment as the x-coordinate, and the sum of the product of the first ratio and the y-coordinate of the first vector and the y-coordinate of the first endpoint of the selected line segment as the y-coordinate.

5. The extension method according to claim 1, characterized in that, The step of detecting whether the search ray intersects with a preset reference object in the circuit layout includes: All line segments that make up the preset reference object in the circuit layout are taken as cut-off line segments; Construct a normalized vector for the target line segment, a fourth vector from the first endpoint of the cutoff line segment to the starting point, a fifth vector from the first endpoint of the cutoff line segment to the last endpoint, and rotate the normalized vector by 90 degrees to form a sixth vector. Calculate the second absolute value of the first dot product of the fifth vector and the sixth vector; When the second absolute value is greater than the second preset threshold, calculate the third ratio of the fourth cross product of the fifth vector and the fourth vector to the second absolute value, and the fourth ratio of the second dot product of the fourth vector and the sixth vector to the second absolute value; When the third ratio is greater than or equal to zero and the fourth ratio is in the range [0,1], it is determined that the search ray intersects with the preset reference object.

6. The extension method according to claim 5, characterized in that, Obtaining the second intersection point between the search ray and the preset reference object includes: Obtain the coordinates of the starting point and the coordinates of the normalized vector; The second intersection point is determined by using the sum of the product of the third ratio and the x-coordinate of the normalized vector and the x-coordinate of the starting point as the x-coordinate, and the sum of the product of the third ratio and the y-coordinate of the normalized vector and the y-coordinate of the starting point as the y-coordinate.

7. The extension method according to claim 1, characterized in that, After forming the extended line segment, the extension method further includes: When connecting other line segments at the starting point of the target line segment and / or to endpoints far from the starting point, the other line segments connecting the starting point are separated from the extended line segment, and / or the other line segments connecting endpoints of the target line segment far from the starting point are merged with the extended line segment.

8. A device for extending a line segment in a circuit layout, characterized in that, include: The connection module is used to connect two currently selected reference points in the circuit layout and generate selected line segments. The search module is used to find the line segment in the circuit layout that intersects with the selected line segment as the target line segment; The acquisition module is used to acquire the first intersection point between the selected line segment and the target line segment; The generation module is used to generate a search ray starting from the endpoint of the target line segment that is closer to the first intersection point, and in accordance with the slope of the target line segment, in a direction away from the target line segment. The detection module is used to detect whether the search ray intersects with a preset reference object in the circuit layout; The extension module is used to obtain the second intersection point of the search ray and the preset reference object when they intersect, and extend the target line segment to the nearest second intersection point to form an extended line segment.

9. A storage medium, characterized in that, The storage medium stores a computer program configured to execute, when running, the method for extending line segments in a circuit layout as described in any one of claims 1 to 9.

10. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method for extending line segments in a circuit layout as described in any one of claims 1 to 7.