Equidistant bias method for closed-loop graph
Through the isometric bias method of closed-loop graphics, using edge preprocessing and curve intersection processing, the problems of self-intersection, overlap or incomplete enclosure during graphics bias are solved, and high-precision and stable graphics bias effect are achieved. .
Patent Information
- Application Number
- CN202510039836.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-10
- Publication Date
- 2025-02-14
AI Technical Summary
When performing 2D graphics bias, the prior art has problems such as self-intersection, overlap or not completely closed, which leads to the inability of CAD software to accurately calculate the path when performing bias operations, resulting in errors, and users need to repair or adjust the graphics objects.
A method of isometric biasing for closed-loop graphics is proposed. Through edge preprocessing, curve intersection processing, illegal curve deletion and other steps, the integrity of the graphics is automatically repaired and biased to ensure the accuracy and integrity of the bias results.
It realizes automatic repair of graphics integrity and isometric bias, solving the problems of self-intersection, overlap or incomplete enclosure during graphics bias in the prior art, and has broad applicability, high precision and stability.
Smart Images

Figure CN119444936A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the fields of computer-aided design and computational graphics, and in particular to an isometric offset method for closed loop graphics. Background Art
[0002] The offset technology of 2D graphics is one of the basic problems in computer graphics. Using a certain algorithm, each edge of the graphics is offset outward and inward along the normal of the edge at a specified distance to form a new graphics. If the offset object has geometric problems such as self-intersection, overlap or incomplete closure, the CAD software may not be able to accurately calculate the path when performing the offset operation, resulting in errors. At this time, the user needs to repair or adjust the graphic object to ensure its geometric integrity so that the offset operation can be performed normally, and the offset operation cannot delete the original graphics. Summary of the invention
[0003] The purpose of the present invention is to overcome the limitations of the existing pattern offset technology and provide an equidistant offset method for a closed loop pattern. The technical solution adopted by the present invention is as follows:
[0004] A method for isometric offsetting of a closed loop figure comprises the following steps:
[0005] S1, input any closed loop figure and offset distance d, when d>0, the figure is offset outward, when d<0, the figure is offset inward;
[0006] S2, check and preprocess the input object;
[0007] S3, before offsetting, merge the adjacent edges that are collinear or cocircular to ensure the accuracy of the adjacent edges after offsetting; when the adjacent edges are all line segments and parallel, merge them into one line segment; when the adjacent edges are all arcs and cocircular, merge them into one arc;
[0008] S4, generating an initial bias curve for all edge normal biases;
[0009] S5, processing offset curves, including: processing the intersection problem of adjacent convex angle offset curves, processing the existing intersection problem of adjacent offset curves, deleting illegal offset curves located in the expansion area, deleting other illegal offset curves, retaining only one of the curves that completely overlap after offsetting, and processing the closure problem of offset curves;
[0010] S6, search for all result loops composed of bias curves, remove the loops in the result loops whose distance from the figure before bias is less than |d|-ε, where ε is a small positive value that can be customized by the user, representing the solution accuracy of the figure. The result of the inward bias of the figure is a simple figure composed of one or more closed loop figures, and the result of the outward bias is a closed loop figure with the number of inner loops equal to 0, or a composite figure composed of an outer loop and the number of inner loops greater than 0, and output the figure bias result.
[0011] Furthermore, the closed loop figure is a closed contour composed of arcs and line segments, and there is no figure inside the contour.
[0012] Furthermore, the offset distance d, when d>0, the figure is biased outward, and the offset result is a closed loop figure with the number of inner rings equal to 0, or a composite figure composed of an outer ring and the number of inner rings greater than 0. When d<0, the figure is biased inward, and the offset result is a simple figure composed of one or more closed loop figures.
[0013] Further, step S2 comprises the following steps:
[0014] S201:|d|≤ε, directly return to the original graph, ε is a small positive value that can be customized by the user, representing the accuracy of the graph solution;
[0015] S202: d<0, and |d| is greater than half of the shortest side length of the minimum bounding box of the closed loop graphic, the calculation ends, and the bias result is empty;
[0016] S203: The input figure is a circle with a radius of r. The new circle radius r′=r+d is calculated and the new circle is returned. When r′≤0, the offset result is empty.
[0017] Furthermore, for all edge normal offsets, when the edge is a line segment, its normal is perpendicular to the line segment; when the edge is an arc, an arc tangent is made, and its normal passes through the tangent point and is perpendicular to the tangent; when d>0, each edge has an outer normal offset, and when d<0, each edge has an inner normal offset; when the arc is offset toward the center of the circle and |d|≥the arc radius, the offset result is empty, the arc edge disappears after the offset, and the marking result curve is an empty curve.
[0018] Furthermore, the processing of the intersection problem of adjacent convex angle offset curves includes:
[0019] S501: Screening processing objects, the processing objects are two adjacent edges that form a convex angle before offsetting, and the two edges do not disappear after offsetting, and the convex angle is defined as follows: when offsetting outward, the inner angle of the figure formed by the two adjacent edges is less than 180°, which is a convex angle; when offsetting inward, the outer angle of the figure formed by the two adjacent edges is less than 180°, which is a convex angle;
[0020] S502: Solve the intersection of geometric elements of the processing object. The intersection of curve geometric elements. The geometric element of a line segment is an infinitely long straight line. The geometric element of an arc is a full circle corresponding to the same radius. When the offset curves of two adjacent sides have multiple intersections, the first intersection along the two offset curves in one direction is selected as the meeting point.
[0021] S503: trimming or extending the offset curves of two adjacent edges to the meeting point. When the meeting point is on the offset curve, trimming is performed. When the meeting point is on the extension line of the offset curve, extension and repair are performed.
[0022] S504: until all adjacent convex corner offset curves are processed.
[0023] Furthermore, the processing of the existing intersection problem of adjacent offset curves includes:
[0024] S505: traverse each bias curve and obtain the next bias curve adjacent to it before the bias;
[0025] S506: Check whether the current bias curve and the next bias curve are both not empty, and whether their lengths are greater than a small positive value ε;
[0026] S507: Identify whether the current bias curve and the next bias curve have an intersection. If there is no intersection, continue to process the next set of bias curves. If there is an intersection, take the first intersection of the current bias curve and the next bias curve as the meeting point.
[0027] S508: trimming with the meeting point as the segmentation point;
[0028] S509: until all existing intersection offset curves are processed.
[0029] Furthermore, the deleting of illegal offset curves located in the expansion area includes: using the expansion area of all edges as a trimming tool to trim off the portion of the offset curve extending into the expansion area; the expansion area refers to a closed solid area surrounded by the curves before and after the offset and the line segments connecting the endpoints of an edge before the offset and the endpoints after the offset, after connecting the endpoints of the edge with the endpoints of the corresponding curve after the offset with a line segment. Each edge has an expansion area. In particular, when the edge is an arc and the curve disappears after the offset, the sector-shaped area surrounded by the arc curve after connecting the endpoints of the arc with the center of the arc with a line segment is the expansion area of the arc edge.
[0030] Furthermore, the deleting of other illegal bias curves includes: when biased inward, deleting the portion of the bias curve extending outside the original closed loop figure; when biased outward, deleting the portion of the bias curve extending into the original closed loop figure.
[0031] Furthermore, the processing of the bias curve closure problem includes:
[0032] S510: Obtain all open endpoints in the bias curve, and establish a list OP for storing the open endpoints. The open endpoint refers to the point where the distance between the endpoint of the bias curve and all other curves is greater than a positive minimum value ε, that is, the point is in an open state;
[0033] S511: Count the number of open endpoints in the list OP. If the number of open endpoints is an odd number, end the processing of this problem.
[0034] S512: Any two open endpoints in the list OP are paired into a line segment, and a list GL is established to store all possible line segments;
[0035] S513: re-sorting the list GL, sorting the line segments from short to long;
[0036] S514: extracting line segments from the list GL in order of length as the repair line segments, and removing the two endpoints of the extracted line segments from the list OP until all open endpoints in the list OP are removed;
[0037] S515: Add the final patching line segment to the offset curve list and return it.
[0038] Compared with the existing technology, the present invention can automatically repair the integrity of the graphics and offset the graphics, and delete the original graphics through steps such as edge preprocessing, curve intersection processing, and illegal curve deletion. It has the advantages of wide applicability, high precision and stability, complex graphics processing capabilities, and good computing performance, and can be widely used in various computer-aided design, manufacturing, simulation and other fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] FIG1 is a schematic flow chart of an equidistant offset method for a closed loop graphic provided by an embodiment of the present invention;
[0041] FIG2 is a diagram showing the results of inward and outward deviation according to an embodiment of the present invention;
[0042] FIG3 is a closed loop graph G provided by an embodiment of the present invention;
[0043] FIG4 is a diagram showing a process of the closed loop pattern G being biased inward in the first embodiment of the present invention;
[0044] FIG5 is a schematic diagram of the intersection processing of adjacent convex angle offset curves of the figure G10 in FIG4;
[0045] FIG6 is a diagram showing a process of the closed loop pattern G being biased outward in the second embodiment of the present invention;
[0046] FIG7 is a schematic diagram of the intersection processing of adjacent convex angle offset curves of the figure G20 in FIG6;
[0047] FIG8 is a schematic diagram of the closure of the bias curve processed in the third embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] The inward biasing step of the present invention is further described in detail below in conjunction with specific embodiment 1.
[0050] As shown in FIG1 , a method for isometric offsetting of a closed loop graphic specifically comprises the following steps:
[0051] S1, input a closed loop figure G and offset distance d as shown in FIG2. When d>0, the figure is offset outward, and when d<0, the figure is offset inward.
[0052] S2, perform inspection preprocessing on the input object. Specifically includes the following steps:
[0053] S201: Determine whether |d|≤ε is true, if so, directly return to the original graph;
[0054] S202: If d<0, and |d| is greater than the length of the minimum bounding box of the closed loop graphic, the calculation ends and the offset result is empty;
[0055] S203: If the input figure is a circle with a radius of r, calculate a new circle radius r′=r+d and return the new circle. When r′≤0, the offset result is empty.
[0056] S3, before offsetting, merge the adjacent edges that are collinear or cocircular to ensure the accuracy of the adjacent edges after offsetting; when the adjacent edges are line segments and parallel, merge them into one line segment; when the adjacent edges are arcs and cocircular, merge them into one arc.
[0057] S4, for all edge normal offsets, generate the initial offset curve. When the edge is a line segment, its normal is perpendicular to the line segment. When the edge is an arc, make an arc tangent, and its normal passes through the tangent point and is perpendicular to the tangent; as shown in the closed loop figure G and the initial offset curve G10 in Figures 3 and 4, when d<0, the normal inside each edge is offset, where the arc C1 is offset toward the center of the circle, |d|> the arc radius of the arc C1, the offset result is empty, the arc C1 disappears after the offset, and the marking result curve is an empty curve.
[0058] S5, process the bias curve.
[0059] The intersection problem of adjacent convex corner offset curves is handled by the following steps:
[0060] S501: Screening processing objects, the processing objects are two adjacent edges that form a convex angle before offsetting, and the two edges do not disappear after offsetting, and the convex angle is defined as follows: when offsetting outward, the inner angle of the figure formed by the two adjacent edges is less than 180°, which is a convex angle; when offsetting inward, the outer angle of the figure formed by the two adjacent edges is less than 180°, which is a convex angle;
[0061] As shown in Figures 3 and 5, the graph is biased inward, and the edge p of the closed loop graph G 10 p 11 and arc edge p 11 p 12 adjacent, and the angle formed on the outside of the figure is less than 180°, side p 10 p 11 After biasing, the bias curve P is generated 10 P 11 , side p 11 p 12 After biasing, the bias curve P is generated 11 ′P 12 , so the bias curve P 10 P 11 and the bias curve P 11 ′P 12 For processing object.
[0062] S502: Solving the bias curve P 10 P 11 and the bias curve P 11 ′P 12 The intersection of geometric elements. When there are multiple intersections, the first intersection along the two offset curves in one direction is selected as the meeting point. As shown in Figure 5, the offset curve P 10 P 11 The geometric element is S1, the offset curve P 11 ′P 12 The geometric element is R1, along P 10 P 11 P 11 ′P12 or P 12 P 11 ′P 11 P 10 The first intersection point of the geometric element S1 and the geometric element R1 is the meeting point X;
[0063] S503: When the meeting point is on the offset curve, trimming is performed; when the meeting point is on the extension line of the offset curve, extension repair is performed to repair the two edges to the meeting point. As shown in FIG5 , the meeting point X is on the extension line of the offset curve, and the curve P is extended. 10 P 11 and curve P 11 ′P 12 Repair to point X;
[0064] S504: All adjacent convex corner offset curves are processed. As shown in FIG. 4 , a graph G11 is the intersection result of adjacent convex corner offset curves.
[0065] Dealing with the existing intersection problem of adjacent offset curves includes the following steps:
[0066] S505: traverse each bias curve and obtain the next bias curve adjacent to it before the bias. As shown in FIG4, when the graph G11 is traversed counterclockwise, the bias curve L 11 is the bias curve L 10 The next offset curve adjacent to it before the offset;
[0067] S506: Check the offset curve L 10 and the bias curve L 11 Are they all not empty, and whether their length is greater than a small positive value ε;
[0068] S507: Identify whether the current bias curve and the next bias curve have an intersection. If there is no intersection, continue to process the next set of bias curves. If there is an intersection, take the first intersection of the current bias curve and the next bias curve as the meeting point. As shown in FIG4, curve L 10 and curve L 11 The meeting point is along the curve L 11 The first intersection point D 1 ;
[0069] S508: D 1 Trim for split points;
[0070] S509: All existing intersection offset curves are processed, and the result is shown in graph G12 in FIG. 4 .
[0071] Delete illegal offset curves in the expansion area: Use the expansion area of all edges as a trimming tool to trim the part of the offset curve that extends into the expansion area; the expansion area refers to the closed solid area surrounded by the curves before and after the offset and the connecting line segments of the endpoints after the offset is connected with a line segment. Each edge has an expansion area. In particular, when the edge is an arc and the curve disappears after the offset, the sector area surrounded by the arc curve after the arc endpoint is connected with the arc center with a line segment is the expansion area of the arc edge. As shown in Figure 4, the total expansion area M is formed between all edges of the closed loop figure G and the corresponding offset curves in figure G12. The offset curves extending into the expansion area are deleted to obtain figure G13.
[0072] Delete other illegal offset curves: When the offset is inward, delete the part of the offset curve that extends outside the original closed loop figure; when the offset is outward, delete the part of the offset curve that extends into the original closed loop figure. As shown in Figure 4, the figure G is offset inward, and the part of the offset curve G13 that extends outside the figure G is deleted to obtain the figure G14.
[0073] After offsetting, only one of the curves that completely overlap is retained.
[0074] Dealing with the bias curve closure problem includes the following steps:
[0075] S510: Obtain all open endpoints in the bias curve, and establish a list OP for storing the open endpoints. The open endpoint refers to the point where the distance between the endpoint of the bias curve and all other bias curves is greater than a positive minimum value ε, that is, the point is in an open state;
[0076] S511: Count the number of open endpoints in the list OP. The number of open endpoints is 0, which proves that the bias curve is closed.
[0077] S6, search for all result rings composed of bias curves, remove the rings in the result rings whose distance from the figure before bias is less than |d|-ε, ε is a small positive value that can be customized by the user, representing the solution accuracy of the figure. The result of the inward bias of the figure is a simple figure composed of one or more closed loop figures, and the result of the outward bias is a closed loop figure with the number of inner rings equal to 0 or a composite figure composed of an outer ring and the number of inner rings greater than 0. Output the figure bias result, as shown in Figure 2, and obtain the result figure G14 after the inward bias of figure G.
[0078] The outward biasing step of the present invention is further described in detail below in conjunction with specific embodiment 2.
[0079] As shown in FIG1 , a method for isometric offsetting of a closed loop graphic specifically comprises the following steps:
[0080] S1, input a closed loop figure G and offset distance d as shown in Figure 2.
[0081] S2, perform inspection preprocessing on the input object. Specifically includes the following steps:
[0082] S201: Determine whether |d|≤ε is true, if true, directly return to the original loop;
[0083] S202: If d<0, and |d| is greater than the length of the minimum bounding box of the closed loop graphic, the calculation ends and the offset result is empty;
[0084] S203: If the input figure is a circle with a radius of r, calculate a new circle radius r′=r+d and return the new circle. When r′≤0, the offset result is empty.
[0085] S3, before offsetting, merge the adjacent edges that are collinear or cocircular to ensure the accuracy of the adjacent edges after offsetting; when the adjacent edges are line segments and parallel, merge them into one line segment; when the adjacent edges are arcs and cocircular, merge them into one arc.
[0086] S4, for all edge normal offsets, generate the initial offset curve. When the edge is a line segment, its normal is perpendicular to the line segment. When the edge is an arc, make an arc tangent, and its normal passes through the tangent point and is perpendicular to the tangent; as shown in the closed loop figure G and the initial offset curve G20 in Figures 3 and 6, when d>0, each edge outer normal is offset, where the arc C2 is offset toward the center of the circle, |d|> the arc radius of the arc C2, the offset result is empty, the arc C2 disappears after the offset, and the marking result curve is an empty curve.
[0087] S5, process the bias curve.
[0088] The intersection problem of adjacent convex corner offset curves is handled by the following steps:
[0089] S501: Screening processing objects, the processing objects are two adjacent edges that form a convex angle before biasing, and the two edges do not disappear after biasing. The convex angle is defined as follows: when biased outward, the angle formed by the two adjacent edges on the inner side of the figure is less than 180°, which is a convex angle; when biased inward, the angle formed by the two adjacent edges on the outer side of the figure is less than 180°, which is a convex angle;
[0090] As shown in Figures 3 and 7, the graph is biased outward, and the edge p of the closed loop graph G 20 p 21 and edge p 21 p 22 adjacent, and the angle formed on the inside of the figure is less than 180°, side p 20 p 21 After biasing, the bias curve P is generated 20 P 21 , side p21 p 22 After biasing, the bias curve P is generated 21 ′P 22 , so the bias curve P 20 P 21 and the bias curve P 21 ′P 22 For processing object.
[0091] S502: Solving the bias curve P 20 P 21 and the bias curve P 21 ′P 22 The intersection of geometric elements. When there are multiple intersections, the first intersection along the two offset curves in one direction is selected as the meeting point. As shown in Figure 7, the offset curve P 20 P 21 The geometric element is S2, the offset curve P 21 ′P 22 The geometric element is R2, along P 20 P 21 P 21 ′P 22 or P 22 P 21 ′P 21 P 20 The first intersection point of the geometric element S2 and the geometric element R2 is the meeting point Y;
[0092] S503: When the meeting point is on the offset curve, trimming is performed; when the meeting point is on the extension line of the offset curve, extension repair is performed to repair the two edges to the meeting point. As shown in FIG7 , the meeting point Y is on the extension line of the offset curve, and the curve P is extended. 20 P 21 and curve P 21 ′P 22 Repair to point Y;
[0093] S504: All adjacent convex corner offset curves are processed, as shown in FIG6 , and a graph G21 is the intersection result of the adjacent convex corner offset curves, and the loop is exited.
[0094] Dealing with the existing intersection problem of adjacent offset curves includes the following steps:
[0095] S505: traverse each bias curve and obtain the next bias curve adjacent to it before the bias. As shown in FIG7, when the graph G21 is traversed counterclockwise, the bias curve L 21 is the bias curve L 20 The next offset curve adjacent to it before the offset;
[0096] S506: Check the offset curve L 20and the bias curve L 21 Are they all not empty, and whether their length is greater than a small positive value ε;
[0097] S507: Identify whether the current bias curve and the next bias curve have an intersection. If there is no intersection, continue to process the next set of bias curves. If there is an intersection, take the first intersection of the current bias curve and the next bias curve as the meeting point, as shown in FIG7 . 20 and curve L 21 The meeting point is along the curve L 21 The first intersection point D 2 ;
[0098] S508: D 2 Trim for split points;
[0099] S509: All existing intersection offset curves are processed, and the result is shown in the graph G22 in FIG. 7 , and the loop is exited.
[0100] Delete illegal offset curves in the expansion area: Use the expansion area of all edges as a trimming tool to trim the part of the offset curve that extends into the expansion area; the expansion area refers to the closed solid area surrounded by the curves before and after the offset and the connecting line segments of the endpoints after the offset is connected with a line segment. Each edge has an expansion area. In particular, when the edge is an arc and the curve disappears after the offset, the sector area surrounded by the arc curve after the arc endpoint is connected with the arc center with a line segment is the expansion area of the arc edge. As shown in Figure 7, the total expansion area N is formed between all edges of the closed loop figure G and the corresponding offset curves in figure G22. The offset curves extending into the expansion area are deleted to obtain figure G23.
[0101] Delete other illegal offset curves: When the offset is inward, delete the part of the offset curve that extends outside the original closed loop figure; when the offset is outward, delete the part of the offset curve that extends into the original closed loop figure. As shown in Figure 7, the figure G is offset outward, and the part of the offset curve G23 that extends into the figure G is deleted to obtain the figure G24.
[0102] After offsetting, only one of the curves that completely overlap is retained.
[0103] Dealing with the bias curve closure problem includes the following steps:
[0104] S510: Obtain all open endpoints in the bias curve, and establish a list OP for storing the open endpoints. The open endpoint refers to the point where the distance between the endpoint of the bias curve and all other curves is greater than a positive minimum value ε, that is, the point is in an open state;
[0105] S511: Count the number of open endpoints in the list OP. The number of open endpoints is 0, which proves that the bias curve is closed.
[0106] S6, search for all result loops composed of the bias curve, remove the loops in the result loops whose distance from the figure before the bias is less than |d|-ε, ε is a small positive value that can be customized by the user, representing the solution accuracy of the figure, the result of the inward bias of the figure is a simple figure composed of one or more closed loop figures, the result of the outward bias is a closed loop figure with the number of inner loops equal to 0 or a composite figure composed of an outer loop and the number of inner loops greater than 0, output the figure bias result, as shown in Figure 2, and obtain the result figure G24 after the figure G is biased outward.
[0107] The following is a further detailed description of the method for processing the curve closure problem of the present invention in conjunction with the specific embodiment three.
[0108] Dealing with the bias curve closure problem includes the following steps:
[0109] S510: As shown in FIG8 , all open endpoints in the offset curve H are obtained, and a list OP is established for storing the open endpoints;
[0110] S511: Count the number of open endpoints in the list OP. If the number of open endpoints is an odd number, end the processing of this problem. As shown in FIG8 , obtain the open endpoints of the graph H, obtain 4 open endpoints A, B, C, and D, and place them in the endpoint list OP;
[0111] S512: Any two of the open endpoints in the list OP are paired into a line segment, and a list GL is established to store all possible line segments. The line segment list GL of the graph H includes the following possible line segments: AB, AC, AD, BC, BD, CD;
[0112] S513: re-sort the list GL by line segment length from short to long, in the following order: AB, CD, BC, AC, BD, AD;
[0113] S514: Line segments are sequentially taken from the list GL in order of length as the repair line segments, and the two endpoints of the taken line segments are removed from the list OP until the open endpoints in the list OP are removed. After the repair line segments AB and CD are sequentially taken from the list GL in order of length, the points A, B, C, and D in the list OP are all removed, and the acquisition from the list GL is completed;
[0114] S515: Add the final patching line segments AB and CD to the offset curve list and return.
[0115] Those skilled in the art should understand that, in the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0116] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. A method for equidistant offset of a closed loop graph, characterized in that: The method comprises the following steps: S1, input any closed loop figure and offset distance d, when d>0, the figure is offset outward, when d<0, the figure is offset inward; S2, check and preprocess the input object; S3, before offsetting, merge the adjacent edges that are collinear or cocircular to ensure the accuracy of the adjacent edges after offsetting; when the adjacent edges are all line segments and parallel, merge them into one line segment; when the adjacent edges are all arcs and cocircular, merge them into one arc; S4, generating an initial bias curve for all edge normal biases; S5, processing the offset curve, including: processing the intersection problem of adjacent convex angle offset curves, processing the existing intersection problem of adjacent offset curves, deleting the illegal offset curves located in the expansion area, deleting other illegal offset curves, retaining only one of the curves that completely overlap after offsetting, and processing the closure problem of the offset curve; S6, search for all result loops composed of bias curves, remove the loops in the result loops whose distance from the figure before bias is less than |d|-ε, where ε is a small positive value that can be customized by the user, representing the solution accuracy of the figure. The result of the inward bias of the figure is a simple figure composed of one or more closed loop figures, and the result of the outward bias is a closed loop figure with the number of inner loops equal to 0 or a composite figure composed of an outer loop and the number of inner loops greater than 0, and output the figure bias result.
2. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: The closed loop figure is a closed contour composed of arcs and line segments, and there is no figure inside the contour.
3. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: The offset distance d, when d>0, the figure is offset outward, and the offset result is a closed loop figure with the number of inner rings equal to 0, or a composite figure composed of an outer ring and the number of inner rings greater than 0. When d<0, the figure is offset inward, and the offset result is a simple figure composed of one or more closed loop figures.
4. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: Step S2 comprises the following steps: S201:|d|≤ε, directly return to the original graph; S202: d<0, and |d| is greater than half of the shortest side length of the minimum bounding box of the closed loop graphic, the calculation ends, and the bias result is empty; S203: The input figure is a circle with a radius of r. The new circle radius r′=r+d is calculated and the new circle is returned. When r′≤0, the offset result is empty.
5. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: For all edge normal offsets, when the edge is a line segment, its normal is perpendicular to the line segment; when the edge is an arc, a tangent to the arc is made, and its normal passes through the tangent point and is perpendicular to the tangent; when d>0, each edge has an outer normal offset, and when d<0, each edge has an inner normal offset; When the arc is offset toward the center of the circle and |d|≥arc radius, the offset result is empty, the arc edge disappears after the offset, and the result curve is marked as an empty curve.
6. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: The processing of the intersection problem of adjacent convex angle offset curves in step S5 includes: S501: Screening processing objects, the processing objects are two adjacent edges that form a convex angle before offsetting, and the two edges do not disappear after offsetting, and the convex angle is defined as follows: when offsetting outward, the inner angle of the figure formed by the two adjacent edges is less than 180°, which is a convex angle; when offsetting inward, the outer angle of the figure formed by the two adjacent edges is less than 180°, which is a convex angle; S502: Solving the intersection of geometric elements of the processing object. The geometric element of the line segment is an infinitely long straight line, and the geometric element of the arc is a full circle corresponding to the same radius. When the offset curves of two adjacent edges have multiple intersections, the first intersection along the two offset curves in one direction is selected as the meeting point. S503: trimming or extending the offset curves of two adjacent edges to the meeting point. When the meeting point is on the offset curve, trimming is performed. When the meeting point is on the extension line of the offset curve, extension and repair are performed. S504: until all adjacent convex corner offset curves are processed.
7. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: The processing of the existing intersection problem of adjacent offset curves in step S5 includes: S505: traverse each bias curve and obtain the next bias curve adjacent to it before the bias; S506: Check whether the current bias curve and the next bias curve are both not empty, and whether their lengths are greater than a small positive value ε; S507: Identify whether the current bias curve and the next bias curve have an intersection. If there is no intersection, continue to process the next set of bias curves. If there is an intersection, take the first intersection of the current bias curve and the next bias curve as the meeting point. S508: trimming with the meeting point as the segmentation point; S509: until all existing intersection offset curves are processed.
8. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: The step S5 of deleting the illegal offset curve located in the expansion area includes: using the expansion area of all edges as a trimming tool to trim off the portion of the offset curve extending into the expansion area; the expansion area refers to a closed solid area surrounded by the curves before and after the offset and the endpoint connecting line segments after connecting the endpoints of an edge before the offset with the corresponding curve endpoints after the offset with a line segment. Each edge has an expansion area. In particular, when the edge is an arc and the curve disappears after the offset, the sector-shaped area surrounded by the arc curve after connecting the arc endpoints and the arc center with a line segment is the expansion area of the arc edge.
9. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: Deleting other illegal bias curves in step S5 includes: when biased inward, deleting the portion of the bias curve extending outside the original closed loop figure; when biased outward, deleting the portion of the bias curve extending into the original closed loop figure.
10. The method for equidistant offset of a closed loop figure according to claim 1, characterized in that: The processing of the bias curve closure problem in step S5 includes: S510: Obtain all open endpoints in the bias curve, and establish a list OP for storing the open endpoints. The open endpoint refers to the point where the distance between the endpoint of the bias curve and all other bias curves is greater than a positive minimum value ε, that is, the point is in an open state; S511: Count the number of open endpoints in the list OP. If the number of open endpoints is an odd number, end the processing of this problem. S512: Any two open endpoints in the list OP are paired into a line segment, and a list GL is established to store all possible line segments; S513: re-sorting the list GL, sorting the line segments from short to long; S514: extracting line segments from the list GL in order of length as the repair line segments, and removing the two endpoints of the extracted line segments from the list OP until all open endpoints in the list OP are removed; S515: Add the final patching line segment to the offset curve list and return it.
Citation Information
Patent Citations
Girdling track generation method based on side equidistance offset
CN105652799A
Polygon curve offset algorithm with islands
CN109636879A
Two-dimensional polygon offset method
CN109887052A
Checking minimum width, minimum distance and maximum curvature of planar region boundaries defined by arbitrary parametric curves
US10627713B1
Method for inversion of corresponding line mileage and offset by using known coordinate point
US20230259668A1