Method for identifying closed region of plane multi-connected domain
By traversing the edges of the plane multi-connection domain twice, searching for adjacent sides with the smallest angle of clockwise rotation with this side, the problem of additional calculation of the closed area contained in the previous technology is solved, and more efficient and precise closed area identification.
Patent Information
- Application Number
- CN202411453107.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-02-11
AI Technical Summary
When searching closed areas automatically, the prior art requires additional calculation of the closed areas contained in layers to eliminate repeated calculations, resulting in low recognition efficiency and accuracy.
By traversing all edges twice, search for the adjacent edge with the smallest angle of clockwise rotation with the edge, and delete the closed area output clockwise. Without judging the encirclement of the closed area, you can directly search for all the plane multi-connection domains Close the area and output the enclosure points of the closed area in counterclockwise order.
This method does not need to judge the inclusion relationship of the closed area, but directly passes through the traversal of the edges in both directions, improving the efficiency and accuracy of the closed area recognition, making the preprocessing steps more concise.
Smart Images

Figure CN119416285A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automatic search for closed areas, and in particular to a closed area recognition method for a planar multi-connected domain. Background Art
[0002] Automatically finding closed regions is not only a preprocessing step required to solve certain geometric problems, but is also widely used in finite element meshing, 3D rapid modeling, pattern recognition, geology and other fields.
[0003] The existing scheme deletes the used points one by one and finally traverses all the closed areas. However, in the traversal process, the closed areas contained in each layer are additionally calculated, so it is necessary to eliminate the closed areas that are repeatedly calculated by judging the topological inclusion relationship of the traversal results. The above problem needs to be solved urgently. To this end, a closed area identification method for planar multi-connected domains is proposed. Summary of the invention
[0004] The technical problem to be solved by the present invention is: how to solve the problem in the prior art that additional calculations are needed to include closed areas in layers to eliminate closed areas that are repeatedly calculated, while improving recognition efficiency and accuracy. A closed area recognition method for a planar multi-connected domain is provided, which traverses all edges twice, searches for the adjacent edge with the smallest clockwise rotation angle with the edge, and then deletes the closed area output in the clockwise direction. All closed areas in the planar multi-connected domain can be searched out without judging the encirclement of the closed area, and the enclosure points of the closed area are output in counterclockwise order, which can make the preprocessing steps simpler and more efficient in actual engineering applications.
[0005] The present invention solves the above technical problems through the following technical solutions, and the present invention comprises the following steps:
[0006] S1: Obtain the data of the points and edges of the target graphics by sorting out the DXF file of the target graphics;
[0007] S2: Number all edges without duplication, starting from the first direction of the first set of edge data, with the first point of the edge as the starting point and the second point as the target point;
[0008] S3: Search for the remaining points connected to the current target point along the current direction, and find the branch points on the edge that meet the requirements; take the second point as the current starting point, the branch point as the current target point, and continue to search for the remaining points connected to the current target point along the current direction until the searched target point is the initial starting point, completing a closed area search;
[0009] S4: After completing the closed area search process, a closed area search result is obtained, and it is determined whether the closed area search result is retained or deleted;
[0010] S5: starting from the second direction of the edge in the first set of edge data, taking the second point of the edge as the starting point and the first point as the target point, repeating the process of steps S3 to S4, the second direction is opposite to the first direction;
[0011] S6: Starting from the second set of edge data, the process of steps S2 to S5 is repeated in sequence until the last set of edge data is reached, and the traversal of all data is completed, thereby obtaining all closed area search results.
[0012] Furthermore, in step S1, the data of points and edges in the target figure are displayed in the form of a data table, and the data table includes multiple groups of point data and multiple groups of edge data, wherein each group of point data includes the number of a single point and the x, y coordinate values in a rectangular coordinate system, and each group of edge data is the number of two points on a single edge.
[0013] Furthermore, in step S3, when the point connected to the current target point is unique, that is, there is only one branch point, the search continues downward.
[0014] Furthermore, in step S3, when the point connected to the current target point is not unique, that is, there are multiple branch points connected to the current target point, a clockwise search method is used for judgment. The specific process of the clockwise search method is as follows: take the current target point as the center of the circle, and the line segment between the current target point and the previous point as the radius. Use the line segment to rotate clockwise, and the first edge that contacts the line segment is the target edge. The next step is to search along the target edge, and the target edge includes the current target point and one of the branch points.
[0015] Furthermore, in step S4, when determining whether the closed area search result is to be retained or deleted, if the closed area is a counterclockwise enclosed result obtained using the clockwise search method, it is retained; if a clockwise enclosed result is obtained, it is deleted.
[0016] Furthermore, when judging whether a closed area is a counterclockwise enclosure result or a clockwise enclosure result, the shoelace formula is used to calculate the area within the polygonal area according to the order of vertex coordinates. When the area is a positive value, it indicates that the closed area is a counterclockwise enclosure result, and when the area is a negative value, it indicates that the closed area is a clockwise enclosure result, wherein the closed area is a polygonal area.
[0017] Furthermore, in step S4, the closed area search result is a sequence formed by the numbers of the points in the target figure.
[0018] Compared with the prior art, the present invention has the following advantages: the closed area identification method of the planar multi-connected domain does not need to judge the inclusion relationship of the closed area, and can directly and concisely search for all closed areas by traversing the edges in two directions, and output the enclosed points of the closed areas in counterclockwise order, which can make the preprocessing steps simpler and more efficient in actual engineering applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1a is a position diagram of each point of the closed area target figure to be searched in the first embodiment of the present invention, wherein the numbers 1-16 in the diagram are the sequence numbers of each point;
[0020] Figure 1b is a search result diagram of the target graphic in the first embodiment of the present invention, wherein the numbers 1-6 in the diagram are the serial numbers of the closed areas obtained by the search;
[0021] Figure 2 This is a schematic diagram of the angle calculation of the vector 1→2 in step 1 and the angle calculation of multiple branch vectors 2→16 and 2→10 in step 2 in embodiment 1 of the present invention;
[0022] Figure 3 This is a calculation flow chart of the clockwise search method in Embodiment 1 of the present invention;
[0023] Figure 4a It is a clockwise enclosed schematic diagram in the first embodiment of the present invention;
[0024] Figure 4b It is a counterclockwise enclosed schematic diagram in the first embodiment of the present invention;
[0025] Figure 5 Schematic diagram of the clockwise search method in the first embodiment of the present invention;
[0026] Figure 6 is a schematic diagram of a search process of the first direction of the first group of edges in the first embodiment of the present invention using a clockwise search method;
[0027] Figure 7 is a schematic diagram of a search process of the second direction of the first group of edges in the first embodiment of the present invention using a clockwise search method;
[0028] Figure 8 is a calculation flow chart of the counterclockwise search method in the second embodiment of the present invention;
[0029] Fig. 9 is a schematic diagram of the counterclockwise search method in the second embodiment of the present invention;
[0030] Fig.10 It is a schematic diagram of the search process of the first direction of the first group of edges in the second embodiment of the present invention using the counterclockwise search method. DETAILED DESCRIPTION
[0031] The following is a detailed description of an embodiment of the present invention. This embodiment is implemented on the premise of the technical solution of the present invention, and a detailed implementation method and a specific operation process are given, but the protection scope of the present invention is not limited to the following embodiment.
[0032] Embodiment 1
[0033] In this embodiment, the closed region recognition method of the planar multi-connected domain is used to identify the Figure 1a The search result is Figure 1b shown.
[0034] As shown in Table 1 and Table 2, the data table of the midpoints and edges of the target graphics is obtained by sorting the CAD DXF file. The data description in the data table is as follows:
[0035] Table 1 Point Data Table
[0036]
[0037] Table 2 Edge data table
[0038]
[0039]
[0040] The 1st to 16th lines of point information: the 1st column is the point number, and the 2nd and 3rd columns are the x and y coordinate values of each point in the rectangular coordinate system.
[0041] In the edge information, rows 1 to 21: the first column is the edge number, and the second and third columns are the edge composition (for example, row 1 is the edge composed of point 1 and point 2).
[0042] This embodiment provides a technical solution: a closed area identification method for a planar multi-connected domain, which uses a traversal method to search for enclosed areas, and uses each edge as an initial edge to enclose from two directions. The first enclose is performed from one direction, and the second enclose is performed from the opposite direction to ensure that no closed areas are missed. (For example: the edge of the first row in the edge data table is composed of point 1 and point 2. The first enclose is performed from the direction from 1 to 2 to search for closed areas. After the first search is completed, the second enclose is performed from the opposite direction, that is, from 2 to 1. In this way, all closed areas formed by this edge are found)
[0043] In this embodiment, the method specifically includes the following steps:
[0044] Step 1: Starting from the first direction of the edge in the first set of data (from 1 to 2), with point 1 (15.5448, 9.7154) as the starting point and point 2 (18.2330, 6.0154) as the target point, calculate the angle between vector 1→2 and the positive direction of the x-axis in the two-dimensional plane coordinate system (that is, the plane rectangular coordinate system where the x and y coordinates are located), as follows: Figure 2 As shown, the angle is 5.34 and the unit is radians.
[0045] Step 2: Find the remaining points (except point 1) connected to point 2. In this embodiment, there are two points connected to point 2, namely point 10 (considered as a branch point) and point 16 (considered as a branch point). Calculate the angles between the vectors 2→10 and 2→16 and the positive direction of the x-axis respectively. Figure 2 As shown, the angles are 4.17 and 3.14 respectively.
[0046] Step 3: Now start to judge and search towards point 10 or point 16. Figure 3 The calculation flow chart shown is obtained.
[0047] Data explanation in the flowchart: The initial edge vector S is vector 1→2;
[0048] The target edge vector T represents vectors 2→16, 2→10 respectively;
[0049] S.rad represents the angle of the initial vector 1→2;
[0050] T.rad represents the angle of the target branch vector 2→16, 2→10;
[0051] M.rad represents the result obtained by substituting T.rad in sequence and calculating through the flowchart.
[0052] Substitute the target branch vectors into the flow chart for calculations, and compare the results. The vector T corresponding to the minimum value of M.rad is the result of the judgment. The following is a description of the relevant information:
[0053] Taking this embodiment as an example, Figure 5 The specific calculation process of using the clockwise search method is described as follows:
[0054] (1): At this time, the angle of S.rad from 1 to 2 is 5.34, and the direction of S is the negative direction of the y axis, that is, π≤S.rad<
[0055] 2π. The flow chart branches to the right.
[0056] (2): Determine the position of the vector 2→10. At this time, 4.17>5.34-π. According to the flow chart, M.rad=2π-T.rad+(S.rad-π)=2π-4.17+(5.34-π)≈4.31 is calculated.
[0057] (3): Determine the position of vector 2→16. At this time, 3.14>5.34-π. According to the flow chart, M.rad=2π-T.rad+(S.rad-π)=2π-3.14+(5.34-π)≈5.34.
[0058] (4): At this time, 4.31<5.34, so the vector 2→10 corresponding to 4.31 is the calculation result, and the next branch point is point 10.
[0059] It should be noted that the flowchart ( Figure 3 ) is abstracted as a circle with the target point as the center and the line segment between the target point and the previous point as the radius, rotating in a clockwise direction. The first edge that contacts the current first edge is the target edge.
[0060] Step 4: Repeat steps 2 and 3 until the search returns to the starting point (point 1), completing the search process of a closed area. Taking this embodiment as an example, Figure 6 This is the process of determining the first direction (1→2) of the first edge using the clockwise search method.
[0061] In this step, when repeating steps 2 and 3, in addition to the initial starting point and target point, the last point found is used as the new target point.
[0062] It should be noted that after completing a closed area search, it is necessary to determine whether it meets the requirements. Using the clockwise search method, it is necessary to delete all clockwise enclosed areas and retain the counterclockwise enclosed areas. For example, starting from the first direction (1→2) of the first edge, Figure 6 The search results are (1 2 10 9 8 7 6 5 4 3 1), which is enclosed clockwise, so delete it.
[0063] As a more specific example, the enclosed area is automatically judged to be clockwise or counterclockwise using the shoelace formula, also known as the Gaussian area formula or a special case of Green's formula, which is a mathematical formula for calculating the area of a polygon. The formula determines the area of a polygon by the order of the vertex coordinates. If the vertex order is clockwise, the calculated area value is negative, and counterclockwise order gives a positive area value. Figure 6 For example, the coordinates of points 1 2 10 9 8 7 6 5 4 3 are (x1,y1), (x2,y2), (x3,y3), (x4,y4)…(x n ,y n). Using the formula for the above coordinates:
[0064]
[0065] We get S=-154.808<0, which is a clockwise enclosure, so delete it.
[0066] Step 5: Repeat the process (steps 1 to 4) starting from the second direction of the edge in the first set of data (from 2 to 1, opposite to the first direction), with point 2 (18.2330, 6.0154) as the starting point and point 1 (15.5448, 9.7154) as the target point. The result of the second traversal is (2 1 3 4 5 11 13 16 2) counterclockwise enclosed, and this enclosed area result is retained. Taking this embodiment as an example, Figure 7 This is the process of determining the first direction (2→1) of the first edge using the clockwise search method.
[0067] Step 6: Starting from the second set of data, repeat the above process (steps 1 to 5) in sequence until the last edge (formed by points 15 and 10), completing the traversal of all data and finding all closed areas.
[0068] Embodiment 2
[0069] In addition, in the first embodiment, step 3 describes the clockwise search method. This embodiment also provides another counterclockwise search method, the key of which is to calculate the rotation direction of M.rad. Figure 8 This is the calculation flow chart of the counterclockwise search method. Fig. 9 This is a specific diagram of the counterclockwise search method. If the counterclockwise search method is used, all counterclockwise enclosed results must be deleted and the clockwise enclosed results must be retained. Fig.10 The result of the counterclockwise search method is different from the clockwise search result in Example 1. Figure 7 Be consistent.
[0070] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A closed region identification method for a planar multi-connected domain, characterized in that: The following steps are involved: S1: Obtain the data of the points and edges of the target graphics by sorting out the DXF file of the target graphics; S2: Number all edges without duplication, starting from the first direction of the first set of edge data, with the first point of the edge as the starting point and the second point as the target point; S3: Search for the remaining points connected to the current target point along the current direction, and find the branch points on the edge that meet the requirements; take the second point as the current starting point, the branch point as the current target point, and continue to search for the remaining points connected to the current target point along the current direction until the searched target point is the initial starting point, completing a closed area search; S4: After completing the closed area search process, a closed area search result is obtained, and it is determined whether the closed area search result is retained or deleted; S5: starting from the second direction of the edge in the first set of edge data, taking the second point of the edge as the starting point and the first point as the target point, repeating the process of steps S3 to S4, the second direction is opposite to the first direction; S6: Starting from the second set of edge data, the process of steps S2 to S5 is repeated in sequence until the last set of edge data is reached, and the traversal of all data is completed, thereby obtaining all closed area search results.
2. The closed region identification method of a planar multi-connected domain according to claim 1, characterized in that: In step S1, the data of points and edges in the target figure are displayed in the form of a data table, and the data table includes multiple groups of point data and multiple groups of edge data, wherein each group of point data includes the number of a single point and the x, y coordinate values in a rectangular coordinate system, and each group of edge data is the number of two points on a single edge.
3. The closed region identification method of a planar multi-connected domain according to claim 1, characterized in that: In step S3, when the point connected to the current target point is unique, that is, there is only one branch point, the search continues downward.
4. The closed region identification method of a planar multi-connected domain according to claim 1, characterized in that: In step S3, when the point connected to the current target point is not unique, that is, there are multiple branch points connected to the current target point, a clockwise search method is used for judgment. The specific process of the clockwise search method is as follows: take the current target point as the center of the circle, and the line segment between the current target point and the previous point as the radius. Use the line segment to rotate clockwise, and the first edge that contacts the line segment is the target edge. The next step is to search along the target edge, and the target edge includes the current target point and one of the branch points.
5. The closed region identification method of a planar multi-connected domain according to claim 4, characterized in that: In step S4, when determining whether the closed area search result is to be retained or deleted, if the closed area is a counterclockwise enclosed result obtained using the clockwise search method, it is retained; if a clockwise enclosed result is obtained, it is deleted.
6. A closed region identification method of a planar multi-connected domain according to claim 5, characterized in that: When judging whether a closed area is a counterclockwise enclosure result or a clockwise enclosure result, the shoelace formula is used to calculate the area within the polygonal area according to the order of vertex coordinates. When the area is a positive value, it indicates that the closed area is a counterclockwise enclosure result, and when the area is a negative value, it indicates that the closed area is a clockwise enclosure result, where the closed area is the polygonal area.
7. The closed region identification method of a planar multi-connected domain according to claim 1, characterized in that: In step S4, the closed area search result is a sequence formed by the numbers of the points in the target figure.
Citation Information
Cited By
Mold processing visual monitoring method, device and system and storage medium
CN121559973A