A wall body recognition modeling method based on two-dimensional CAD drawings
Patent Information
- Application Number
- CN202511177760.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2045-08-21
AI Technical Summary
[0005]鉴于上述的分析,本发明实施例旨在提供一种基于二维CAD图纸的墙体识别建模方法,用以解决现有无法从二维CAD图纸中自动、准确地生成封闭的单线墙体的问题
[0034]与现有技术相比,本发明至少可实现如下有益效果之一:
Smart Images

Figure CN121074939B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data modeling technology, and in particular to a method for wall recognition and modeling based on two-dimensional CAD drawings. Background Technology
[0002] With the popularization of green building concepts, building energy simulation has become an indispensable and crucial part of the building design phase. Building energy models require high geometric accuracy, especially emphasizing that the simulated room must be a completely enclosed solid space. This means that all wall lines forming the room's boundary must be interconnected, forming a complete, seamless closed outline. If any geometric flaws exist in the model (such as unclosed wall lines or gaps), building energy simulation software using solid models will be unable to correctly identify and calculate the space, leading to simulation failure or inaccurate results. Therefore, accurately constructing the geometric information of the walls is one of the technical challenges in the modeling process.
[0003] Building energy simulation software typically requires walls to be simplified into single lines or midlines with specific physical properties, serving as abstract geometry for room boundaries. However, in standard CAD architectural drawings, walls are usually drawn as double lines, representing their inner and outer contours. Manual conversion is not only time-consuming and labor-intensive, but also prone to human error, leading to decreased model accuracy. There is a lack of solutions for automatically and accurately extracting single-line walls.
[0004] Moreover, existing solutions do not pay enough attention to the precise alignment and seamless connection between walls, focusing more on visual effects and the construction of the overall geometry. The wall lines that form the boundary of the room are not closed, making them unsuitable for building energy simulation. Summary of the Invention
[0005] Based on the above analysis, the embodiments of the present invention aim to provide a wall recognition and modeling method based on two-dimensional CAD drawings, in order to solve the problem that existing methods cannot automatically and accurately generate closed single-line walls from two-dimensional CAD drawings.
[0006] This invention provides a wall recognition and modeling method based on two-dimensional CAD drawings, comprising the following steps:
[0007] Extract the set of straight line segments of all walls from a 2D CAD drawing;
[0008] The wall continuity index value of the straight line segment set is calculated based on the first matching condition. Based on the wall continuity index value and the total number of line segments in the straight line segment set, the corresponding wall line grouping method is used to obtain the line segment grouping set.
[0009] Based on the line segment group set, multiple wall centerlines are generated by fitting according to distance and line segment direction;
[0010] The system identifies the suspended endpoints in multiple wall centerlines, obtains the corresponding target intersection points based on other wall centerlines and endpoints in the adjacent area of each suspended endpoint, adjusts the corresponding suspended endpoints based on the target intersection points, and trims and reconstructs the wall centerlines where the target intersection points are located to obtain the optimized wall centerlines, thereby constructing a single-line wall.
[0011] Based on further improvements to the above method, according to the wall continuity index value and the total number of line segments in the set of straight lines, a corresponding wall line grouping method is adopted, including:
[0012] When the wall continuity index value is less than the decision threshold, a wall line grouping method based on geometric features is adopted;
[0013] When the wall continuity index value is greater than or equal to the decision threshold, and the total number of line segments in the set of straight line segments is less than or equal to the scale threshold, the wall line grouping method based on global topology is adopted.
[0014] When the wall continuity index value is greater than or equal to the decision threshold, and the total number of line segments in the set of straight line segments is greater than the scale threshold, a wall line grouping method based on clustering optimization of topological relationships is adopted.
[0015] Based on a further improvement of the above method, the wall continuity index value is obtained by calculating the ratio of the number of line segments in the set of line segments that failed to match according to the first matching condition to the total number of line segments in the set of line segments; the first matching condition includes: the angle difference, distance, length difference and the length of the overlapping part of the parallel projection between the two line segments all satisfy their respective first threshold conditions.
[0016] Based on a further improvement of the above method, a wall line grouping method based on geometric features is used to obtain a set of line segment groups, including:
[0017] The set of line segments is divided into multiple categories based on the direction angle of each line segment;
[0018] After sorting the line segments in each category in descending order of length, the line segment pairs that meet the second matching condition are obtained as a line segment group and put into the line segment group set; each line segment does not participate in other pairings after being paired; the second matching condition includes: the angle difference and distance between the two line segments both meet their respective second threshold conditions.
[0019] Based on a further improvement of the above method, a wall line grouping method based on global topology relationships is used to obtain a set of line segment groups, including:
[0020] Iterate through all line segment pairs in the set of line segments and put the line segment pairs that meet the second matching condition into the set to be grouped; the second matching condition includes: the angle difference and distance between the two line segments both meet their respective second threshold conditions;
[0021] The graph traversal algorithm is used to identify all connected components in the set to be grouped, and each connected component is grouped into a line segment group set.
[0022] Based on further improvements to the above method, a wall line grouping method based on clustering optimization of topological relationships is used to obtain a set of line segment groups, including:
[0023] The geometric center coordinates of each line segment in the set of line segments are used as the feature vector of the line segment, and the set of line segments is divided into multiple clusters using an improved clustering algorithm;
[0024] Each cluster of line segments is treated as a subset, and a wall line grouping method based on global topology is used to obtain a line segment group set.
[0025] Further improvements to the above method result in an improved clustering algorithm based on the K-means algorithm, specifically by refining the selection of initial cluster centers and cluster allocation. The initial cluster centers are selected based on the candidate probabilities of line segments, and the clusters are allocated to the clusters with the smallest overall distance. The candidate probability of a line segment is calculated based on the squared distance between the line segment and the nearest initial cluster center, as well as the angular difference between the line segment and the nearest initial cluster center. The overall distance is calculated by weighting the Euclidean distance between the line segment and the cluster center, and the average angular difference between the line segment and the cluster.
[0026] Based on a further improvement of the above method, multiple wall centerlines are generated by fitting a set of line segment groups according to distance and line segment direction, including:
[0027] For each pair of line segments in the group set, copy the longest line segment and move it along its normal direction by half the distance between the line segment pairs to obtain the centerline of the wall.
[0028] Identify multiple collinear wall centerlines, take the longest wall centerline as the baseline, extend the baseline outward along the two baseline endpoints, project the endpoints of the other wall centerlines onto the extension line, and take the two extreme points on the extension line to form a new line segment, which is the final wall centerline generated from the multiple collinear wall centerlines.
[0029] Based on further improvements to the above method, suspended endpoints in multiple wall centerlines are identified, including:
[0030] Taking each endpoint of the centerline of each wall as the center, a circular area with a radius equal to the connection tolerance is designated as the first neighboring region, and a circular area with a radius equal to the search tolerance is designated as the second neighboring region; the connection tolerance is less than the search tolerance.
[0031] If there are no other wall centerlines in the first neighboring region of the current endpoint, but there is at least one other wall centerline in the second neighboring region, then the current endpoint is a suspended endpoint.
[0032] Based on a further improvement to the above method, the corresponding target intersection point is obtained according to the centerlines and endpoints of other walls in the vicinity of each suspended endpoint, including:
[0033] Calculate the intersection point of the wall centerline where the suspended endpoint is located with the centerline of each other wall in the second adjacent area. If multiple intersection points are calculated, select the intersection point closest to the suspended endpoint as the target intersection point; if no intersection point is calculated, find the endpoint of the wall centerline closest to the suspended endpoint in the second adjacent area as the target intersection point.
[0034] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0035] 1. Automatically identifies and extracts double-line walls from standard 2D CAD drawings, avoiding omissions and errors caused by manual identification; through adaptive calculation of the first matching condition and continuity index, it automatically selects the most suitable line segment grouping strategy according to the complexity of different drawings, improving processing efficiency; by fitting and generating the wall centerline, it effectively eliminates minor misalignments and gaps in the original CAD drawings, ensuring that the wall centerline is geometrically smooth, continuous, and accurate; by adjusting the suspended endpoints, it achieves precise extension and geometric trimming of the wall centerline, forming a closed room outline, which is suitable for building energy modeling requirements, significantly improving the accuracy, efficiency, and usability of the conversion from 2D CAD drawings to single-line walls.
[0036] 2. The clustering algorithm is improved by combining the characteristics of wall lines. The initial cluster centers are selected by considering both spatial density and directional consistency. This helps to select initial centers that are scattered and have diverse directions, thus optimizing the clustering effect. The comprehensive distance is calculated by weighting spatial distance and directional similarity to cluster line segments, so that the line segments are assigned to clusters that are "similar in location and direction", thereby improving the accuracy of clustering.
[0037] 3. By identifying endpoints in a "suspended" state and automatically finding target intersections to adjust endpoint positions, the problem of unclosed wall centerlines is solved, the topological relationship between wall centerlines is optimized, and single-line wall modeling is more accurate; the manual correction process is eliminated, and modeling efficiency is greatly improved.
[0038] 4. Establish a standardized process for generating single-line walls, so that different operators can obtain highly consistent single-line wall models when processing the same CAD drawings, thereby improving the repeatability of the modeling process.
[0039] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0040] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.
[0041] Figure 1 This is a flowchart of a wall recognition and modeling method based on two-dimensional CAD drawings in an embodiment of the present invention. Detailed Implementation
[0042] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0043] A specific embodiment of the present invention discloses a wall recognition and modeling method based on two-dimensional CAD drawings, such as... Figure 1 As shown, it includes the following steps:
[0044] S1. Extract the set of straight line segments of all walls from the 2D CAD drawing.
[0045] It should be noted that by configuring or pre-setting extraction rules, the layer containing the wall can be identified and extracted from the 2D CAD drawing, and the geometric lines within it can be extracted, including: straight lines, curves and polylines (combined lines formed by connecting multiple line segments or arc segments).
[0046] For example, the name of the layer containing the wall usually contains the keyword "WALL". This is preset as the extraction rule, so that the layer containing the wall can be automatically identified by searching for the keyword.
[0047] Furthermore, the straight lines are placed into a set of line segments. The curves and polylines are then linearized to obtain a series of short straight line segments that approximate the arc segments in the curves and polylines, which are also placed into the set of line segments. The straight line segments contained in the set of line segments are simply referred to as line segments.
[0048] The linearization process is a curve linearization method based on adaptive recursive sampling, including:
[0049] By setting the maximum deviation tolerance, the maximum allowable vertical distance between the midpoint of the generated piecewise straight line and the original curve is represented. By setting the maximum number of recursions, infinite recursion is prevented due to extremely complex curve shapes or data errors.
[0050] During recursion, a straight line segment is created based on the start and end points of each curve. The point on the curve that is farthest from the straight line segment is found, and the perpendicular distance from that point to the straight line segment is calculated. If the perpendicular distance is less than or equal to the difference threshold or the maximum number of recursions has been reached, the linearization process is completed. Otherwise, the curve is divided into two sub-curves based on the farthest point, and this step is repeated until the perpendicular distance from the new farthest point to the corresponding straight line segment is less than or equal to the difference threshold or the maximum number of recursions has been reached.
[0051] S2. Calculate the wall continuity index value of the straight line segment set according to the first matching condition. Based on the wall continuity index value and the total number of line segments in the straight line segment set, obtain the line segment group set using the corresponding wall line grouping method.
[0052] In order to efficiently process CAD drawings of varying complexity, this embodiment quantifies the geometric complexity of the set of straight line segments of the wall by calculating the wall continuity index value. Then, based on the evaluation results, the most appropriate method is automatically used to group the wall lines, thereby constructing a more accurate single-line wall.
[0053] Specifically, the Wall Continuity Index (WCI) is used to assess the degree of fragmentation of wall lines and the complexity of geometric construction in drawings. The higher the WCI value, the more discontinuous and fragmented the walls are, and the more complex the drawing structure.
[0054] The wall continuity index value is obtained by calculating the ratio of the number of line segments in the set of line segments that failed to match according to the first matching condition to the total number of line segments in the set of line segments; the first matching condition includes: the angle difference, distance, length difference and the length of the overlapping part of the parallel projection between the two line segments all satisfy their respective first threshold conditions.
[0055] It should be noted that calculating the number of line segments in the set that failed to match according to the first matching condition includes:
[0056] After sorting the line segments in the set of line segments in descending order of length, each pair of line segments that meets the first matching condition is retrieved sequentially. Once a line segment is paired, it is no longer included in any other pairings. In other words, once two line segments are successfully matched, they are removed from the set of line segments. The number of line segments remaining in the set after the traversal is complete is the number of unmatched line segments.
[0057] Among them, the first threshold condition in the first matching condition is relatively strict, used to quickly identify simple and obvious wall segment pairs. The first matching condition includes: the angle difference between the two line segments is less than the first threshold of angle, such as 1 degree, to ensure that the parallelism of the two line segments is extremely high; the distance between the two line segments (i.e., the average vertical distance) is within the first threshold range of distance, such as in the typical wall thickness range of 180mm-260mm; the length difference between the two line segments is less than the first threshold of their average length, such as 10%; and the length of the overlapping part of the parallel projection between the two line segments is greater than the first threshold of the length of the two line segments, such as 90%.
[0058] Furthermore, based on the wall continuity index value and the total number of line segments in the set of straight lines, the corresponding wall line grouping method is determined, including:
[0059] When the wall continuity index value is less than the decision threshold, it indicates that the vast majority of wall lines in the CAD drawing are continuous and regular, and can be found directly through simple geometric matching. In this case, the wall is judged as a "simple structure," and a wall line grouping method based on geometric features is adopted.
[0060] When the wall continuity index value is greater than or equal to the decision threshold, and the total number of line segments in the straight line segment set is less than or equal to the scale threshold, it indicates that there are a large number of fragmented, misaligned or irregular wall lines in the CAD drawing. At this time, the wall is judged as a "complex structure" but "controllable in scale", and a wall line grouping method based on global topology is adopted.
[0061] When the wall continuity index value is greater than or equal to the decision threshold, and the total number of line segments in the set of straight line segments is greater than the scale threshold, the wall is judged to be a "complex structure" and "large in scale", and a wall line grouping method based on clustering optimization of topological relationships is adopted.
[0062] For example, the decision threshold is set to 20%, and the size threshold is set to 1000.
[0063] (1) Wall line grouping method based on geometric features
[0064] ① Divide the set of line segments into multiple categories based on the direction angle of each line segment.
[0065] It's important to note that parallelism is a necessary condition for matching; the two edges of a wall must be parallel. Therefore, two line segments with significantly different directions (such as a horizontal line segment and a vertical line segment) cannot be successfully paired. Thus, classifying line segments based on their direction angles first ensures that matching only occurs between line segments with similar directions, improving computational efficiency.
[0066] Iterate through all line segments and calculate the direction angle of each segment (e.g., the angle with the positive X-axis, ranging from [0, 180) degrees). Divide the [0, 180) degree angle space into multiple categories according to a set angle interval, for example, one category for every 10 degrees. Place each line segment into the corresponding category based on its direction angle.
[0067] ② After sorting the line segments in each category in descending order of length, obtain the line segment pairs that meet the second matching condition as a line segment group and put them into the line segment group set; each line segment will not participate in other pairings after being paired; the second matching condition includes: the angle difference and distance between the two line segments both meet their respective second threshold conditions.
[0068] It should be noted that the second matching condition includes: the angle difference between the two line segments is less than a second threshold for angle, and the distance between the two line segments is within a second threshold range for distance. The second threshold in the second matching condition is larger than the first threshold for the same item in the first matching condition. For example, the second threshold for angle is 2 degrees, and the second threshold range for distance is 200mm-600mm.
[0069] In this method, once a line segment finds a matching line segment, no other possible pairings are obtained. It is a "first-come, first-served" strategy, which is used for wall lines with simple geometric structures and good wall continuity. The calculation is simple and fast.
[0070] (2) Wall line grouping method based on global topology
[0071] ① Iterate through all line segment pairs in the line segment set and put the line segment pairs that meet the second matching condition into the set to be grouped.
[0072] It should be noted that this step involves iterating through all other line segments for each line segment to obtain all line segment pairs that meet the second matching condition.
[0073] For example, for line segment A, traversing all other line segments yields the following line segment pairs: (A,D), (A,E), and (A,F); for line segment D, traversing all other line segments yields the following line segment pairs: (D,A), (D,B), and (D,C); for line segment E, the line segment pair is (E,B); and for line segment F, the line segment pair is (F,C).
[0074] ② Use a graph traversal algorithm to identify all connected components in the set to be grouped, and group each connected component into a line segment group set.
[0075] It should be noted that each line segment is treated as a node, and there is an edge between any two nodes in each line segment pair. Graph traversal algorithms, such as depth-first search or breadth-first search, are used to identify all connected components. Each connected component represents a set of multiple nodes.
[0076] Specifically, initialize a set of "visited" line segments, traverse and take out a line segment from the set to be grouped as the current line segment, use it as the starting point, and use the graph traversal algorithm to obtain all the reachable line segments according to the line segment pairs to form a connected component as a line segment group. All line segments in this line segment group are moved into the set of "visited" line segments. Repeat this process until all nodes in the set to be grouped are moved into the set of "visited" line segments.
[0077] For example, starting with line segment A, a breadth-first search algorithm is used to find line segments D, E, and F based on all line segment pairs containing line segment A, and add them to connected component 1. At this time, connected component 1 is (A,D,E,F). Then, line segment pairs containing line segments D, E, and F are searched. Among them, the line segment pairs of D are (D,A), (D,B), and (D,C). Since A is already in connected component 1, B and C are added to connected component 1. Since B and C, which are contained in the line segment pairs of E and F, are already in connected component 1, and no other new line segments can be added, all line segments that are directly or indirectly related to line segment A have been found. The six line segments (A,D,E,F,B,C) in connected component 1 constitute the same double-line wall.
[0078] It should be noted that when constructing each connected component, each pair of line segments it contains is recorded to facilitate the subsequent generation of the median.
[0079] This method, by constructing a global topological relationship, more accurately handles complex walls composed of multi-segment lines, resulting in higher recognition accuracy.
[0080] (3) Wall line grouping method based on clustering optimization of topological relationships
[0081] ①The geometric center coordinates of each line segment in the set of line segments are used as the feature vector of the line segment, and the set of line segments is divided into multiple clusters using an improved clustering algorithm.
[0082] It should be noted that the improved clustering algorithm is derived from the K-means algorithm by modifying the selection of initial cluster centers and the allocation of clusters. Specifically, the initial cluster centers are selected based on the candidate probability of the line segments, and the clusters are allocated to the clusters with the smallest comprehensive distance. The candidate probability of a line segment is calculated based on the squared distance between the line segment and the nearest known cluster center, as well as the angular difference between the line segment and the line segment containing the nearest known cluster center. The comprehensive distance is calculated by weighting the Euclidean distance between the line segment and the cluster center, as well as the average angular difference between the line segment and the cluster.
[0083] Specifically, the random initialization of standard K-means may lead to uneven distribution of cluster centers, with multiple centers even falling into the same dense region, affecting the convergence speed and the final result. This embodiment incorporates the directional characteristics of the wall lines when selecting initial cluster centers, ensuring that the initial cluster centers are as far apart as possible, thus considering both spatial density and directional consistency.
[0084] One line segment is randomly selected from the set of line segments, and its geometric center is used as the first initial cluster center. The candidate probability of each other line segment is obtained based on the squared distance of each line segment to the nearest initial cluster center, and the angle difference between each line segment and the line segment containing the nearest initial cluster center, as shown in the following formula:
[0085]
[0086] Where, p i Let d represent the normalized candidate probability of line segment i, N represent the number of line segments not selected as initial cluster centers, and d represent the number of line segments not selected as initial cluster centers. i Let h represent the squared Euclidean distance from line segment i to the nearest initial cluster center, C represent the initial set of cluster centers, and h represent the initial set of cluster centers. i and Let c represent the coordinates of the geometric center of line segment i and the initial cluster center c, respectively. j coordinates The geometric center of line segment i and the initial cluster center c are represented. j The Euclidean distance between them, θ i The angle difference between line segment i and the line segment containing the nearest initial cluster center is expressed in radians; and Let i represent the vector and magnitude of line segment i, respectively. and Let represent the vector and magnitude of the line segment containing the nearest initial cluster center, respectively.
[0087] It should be noted that the higher the candidate probability, the higher the probability of being selected. After selecting the second initial cluster center based on the candidate probability, the candidate probability of the remaining line segments is calculated again according to the above method, and new initial cluster centers are selected, until the required number is selected.
[0088] Furthermore, clusters are allocated based on the initial cluster centers.
[0089] Existing K-meas algorithms only focus on spatial distance, ignoring the directional properties of the line segments themselves. This may lead to a sloping wall being incorrectly assigned to a cluster of horizontal walls simply because it is closer to the center of that cluster in terms of spatial location. Therefore, this embodiment uses a weighted average of spatial distance and directional similarity to calculate a comprehensive distance for clustering line segments, so that the line segments are assigned to clusters that are "similar in location and direction".
[0090] Specifically, the combined distance is calculated using the following formula:
[0091]
[0092] in, This represents the distance from line segment s to the initial cluster center c. j The combined distance, w space and w angle h represents the spatial distance weight and the directional similarity weight, respectively. s θ represents the coordinates of the geometric center of line segment s. s This represents the average angular difference between the line segment and the cluster. and Let s represent the vector and magnitude of line segment s, respectively. and These represent the initial cluster centers c. j The average direction vector and magnitude of the cluster.
[0093] Furthermore, after assigning each line segment to the cluster that minimizes the integrated distance, each cluster is updated, including: recalculating the average position of the geometric center point of all line segments in each cluster as the new cluster center, and calculating the average direction vector based on the direction vector of all line segments in each cluster.
[0094] Repeat the above cluster assignment and update process until the cluster center of each cluster no longer changes or the preset number of iterations is reached, thus completing the clustering.
[0095] ② Take the line segments in each cluster as a subset, and use the wall line grouping method based on global topology to obtain the line segment group set.
[0096] This method is a further optimization of the global topological relationship wall line grouping method, aiming to solve the problem of low efficiency in global traversal in large and complex drawings. By pre-partitioning line segments through an improved clustering algorithm, the global complex problem is decomposed into multiple local simple problems, thereby significantly improving the execution efficiency of the algorithm while ensuring high recognition accuracy.
[0097] S3. Based on the line segment group set, multiple wall centerlines are generated by fitting according to the distance and line segment direction.
[0098] First, for each pair of line segments in the group set, copy the longest line segment and move it along its normal direction by half the distance between the line segments to obtain the centerline of the wall.
[0099] Preferably, if there are multiple line segment pairs in a line segment group, the line segment pairs containing the same line segment are merged into one line segment pair to generate the wall centerline. For example, if the line segment group (A,D,E,F,B,C) contains (A,D) and (D,A), only one wall centerline needs to be generated to avoid redundant calculations.
[0100] Specifically, calculate the distance between the geometric center point of one line segment and the projection point of the other line segment in the line segment pair, and calculate the distance between these two points to obtain the line segment pair spacing; copy the longest line segment and move it along its normal direction by half the line segment pair spacing to obtain the wall centerline.
[0101] Secondly, considering that in actual CAD drawings, a complete wall may be divided into multiple discontinuous line segments due to drawing habits, opening treatments, etc., these line segments may not be perfectly aligned with each other, but rather have slight misalignment or gaps. This embodiment uses collinearity identification to obtain the centerlines of multiple wall segments that belong to the same wall but are divided, and then uses a straight line fitting algorithm to generate a "best-fit straight line" that best represents the direction of these discontinuous line segments.
[0102] Specifically, multiple collinear wall centerlines are identified, the longest of which is taken as the baseline. The baseline is extended outward along the two baseline endpoints, and the endpoints of the other wall centerlines are projected onto the extension line. Based on the baseline endpoints and projection points on the extension line, two extreme points are taken to form new line segments, which are used as the final wall centerlines generated from the multiple collinear wall centerlines.
[0103] Among them, several collinear wall centerlines were identified, including:
[0104] When the wall line grouping method based on geometric features is used in step S2, each line segment group in the line segment grouping set is a line segment pair; at this time, if multiple wall centerlines satisfy that the line segment direction difference is less than the direction tolerance threshold and the difference between endpoints is less than the distance tolerance threshold, then multiple wall centerlines are collinear.
[0105] When the wall line grouping method based on global topology or the wall line grouping method based on clustering optimization topology is used in step S2, the line segment group in the line segment group set is a connected component and contains at least one line segment pair. At this time, if multiple wall centerlines are generated in a line segment group, the multiple wall centerlines in the line segment group are automatically collinear and no further identification is required. If only one wall centerline is generated in a line segment group, it is directly used as the final wall centerline.
[0106] Furthermore, in this embodiment, instead of simply connecting the endpoints of multiple collinear wall centerlines, the longest wall centerline is used as the baseline. By extending and projecting, a continuous and complete line segment covering the lengths of multiple collinear wall centerlines is obtained. This effectively eliminates minor misalignments and gaps in the original CAD drawings, ensuring that the final generated single-line wall is geometrically smooth, continuous, and accurate.
[0107] S4. Identify the suspended endpoints in multiple wall centerlines. Obtain the corresponding target intersection points by acquiring other endpoints and other wall centerlines in the adjacent area of each suspended endpoint. Adjust the corresponding suspended endpoints according to the target intersection points and trim and reconstruct the wall centerlines where the target intersection points are located to obtain the optimized wall centerlines, thereby constructing a single-line wall.
[0108] It should be noted that, in order to ensure that the multiple wall centerlines generated in step S3 form a room outline with correct topological relationship and geometrically tight closure, this step realizes the precise extension and geometric trimming of the wall centerlines, solves the problem of unclosed wall centerlines, and replaces the manual adjustment and fixed length extension in the existing technology.
[0109] Specifically, the endpoint types of the wall centerline are identified through the following steps:
[0110] Taking each endpoint of the centerline of each wall as the center, a circular area with a radius equal to the connection tolerance is designated as the first neighboring area, and a circular area with a radius equal to the search tolerance is designated as the second neighboring area; the connection tolerance is less than the search tolerance; for example, the connection tolerance is 10mm and the search tolerance is 400mm.
[0111] If there are one or more other wall centerlines in the first neighboring region of the current endpoint, it means that the wall centerline where the current endpoint is located has formed a T-shaped, L-shaped or cross-shaped connection with other wall centerlines. The current endpoint is a connected endpoint and does not need to be processed.
[0112] If there are no other wall centerlines in the first neighboring region of the current endpoint, but there is at least one other wall centerline in the second neighboring region, it means that the current endpoint should be connected to a nearby wall centerline, but is currently in a "suspended" state. The current endpoint is a suspended endpoint and needs further correction.
[0113] If the current endpoint does not have any other wall centerlines or endpoints in the first and second neighboring regions, the wall centerline where the current endpoint is located may correspond to an independent wall, or it may be a drawing error. The current endpoint is a questionable endpoint and needs to be further checked manually.
[0114] This step processes the suspended endpoints, automatically finding their most suitable connection target to form a closed state.
[0115] Specifically, the target intersection point is obtained based on the centerlines and endpoints of other walls in the adjacent area of each suspended endpoint, including:
[0116] Calculate the intersection point of the wall centerline where the suspended endpoint is located with the centerline of each other wall in the second adjacent area. If multiple intersection points are calculated, select the intersection point closest to the suspended endpoint as the target intersection point; if no intersection point is calculated, find the endpoint of the wall centerline closest to the suspended endpoint in the second adjacent area as the target intersection point.
[0117] Furthermore, the corresponding suspended endpoints are adjusted according to the target intersection point. That is, the endpoints of the wall centerline where the suspended endpoints are located are directly modified to the coordinates of the target intersection point, thereby dynamically extending the wall centerline by a precise length, so that the extended wall centerline and the wall centerline where the target intersection point is located form a T-shaped connection.
[0118] To maintain the correctness of the topological relationship, the wall centerline where the target intersection point is located is trimmed and reconstructed. That is, the original wall centerline where the target intersection point is located is divided into two new, shorter line segments. The original wall centerline where the target intersection point is located is removed, and the two newly formed line segments are used as the two wall centerlines.
[0119] After processing each suspended endpoint, the optimized wall centerline is obtained, and then a single-line wall is constructed.
[0120] Compared with existing technologies, this embodiment provides a wall recognition and modeling method based on 2D CAD drawings. It automatically identifies and extracts double-line walls from standard 2D CAD drawings, avoiding omissions and errors caused by manual identification. Through adaptive calculation of the first matching condition and continuity index, it automatically selects the most suitable line segment grouping strategy according to the complexity of different drawings, improving processing efficiency. By fitting and generating the wall centerline, it effectively eliminates minor misalignments and gaps in the original CAD drawings, ensuring that the wall centerline is geometrically smooth, continuous, and accurate. By adjusting the suspended endpoints, it achieves precise extension and geometric trimming of the wall centerline, forming a closed room outline, which is suitable for building energy modeling requirements and significantly improves the accuracy, efficiency, and usability of the conversion from 2D CAD drawings to single-line walls. The clustering algorithm is improved by combining the characteristics of wall lines and considering both spatial density and directional consistency to select initial cluster centers. This helps to select dispersed and directionally diverse initial centers, optimizing the clustering effect. A weighted average distance is calculated based on spatial distance and directional similarity to cluster line segments, assigning them to clusters that are "similar in location and direction," thus improving clustering accuracy. By identifying endpoints in a "suspended" state and automatically finding target intersections for endpoint position adjustment, the problem of incomplete wall centerlines is solved, optimizing the topological relationships between wall centerlines and making single-line wall modeling more accurate. This eliminates the need for manual correction, significantly improving modeling efficiency. A standardized single-line wall generation process is established, enabling different operators to obtain highly consistent single-line wall models when processing the same CAD drawings, improving the repeatability of the modeling process.
[0121] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0122] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A wall recognition and modeling method based on two-dimensional CAD drawings, characterized in that, Includes the following steps: Extract the set of straight line segments of all walls from the 2D CAD drawing; The wall continuity index value of the set of straight line segments is calculated according to the first matching condition. Based on the wall continuity index value and the total number of line segments in the set of straight line segments, the corresponding wall line grouping method is used to obtain the line segment grouping set. The first matching condition includes: the angle difference, distance, length difference and the length of the overlapping part of the parallel projection between two line segments all meet their respective first threshold conditions. The wall continuity index value is obtained by calculating the ratio of the number of line segments in the set of line segments that failed to match according to the first matching condition to the total number of line segments in the set of line segments; Based on the line segment group set, multiple wall centerlines are generated by fitting according to distance and line segment direction; The system identifies the suspended endpoints in multiple wall centerlines, obtains the corresponding target intersection points based on other wall centerlines and endpoints in the adjacent area of each suspended endpoint, adjusts the corresponding suspended endpoints based on the target intersection points, and trims and reconstructs the wall centerlines where the target intersection points are located to obtain the optimized wall centerlines, thereby constructing a single-line wall.
2. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 1, characterized in that, Based on the wall continuity index value and the total number of line segments in the set of straight lines, the corresponding wall line grouping method is adopted, including: When the wall continuity index value is less than the decision threshold, a wall line grouping method based on geometric features is adopted; When the wall continuity index value is greater than or equal to the decision threshold, and the total number of line segments in the set of straight line segments is less than or equal to the scale threshold, the wall line grouping method based on global topology is adopted. When the wall continuity index value is greater than or equal to the decision threshold, and the total number of line segments in the set of straight line segments is greater than the scale threshold, a wall line grouping method based on clustering optimization of topological relationships is adopted.
3. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 2, characterized in that, A wall line grouping method based on geometric features is used to obtain a set of line segment groups, including: The set of line segments is divided into multiple categories based on the direction angle of each line segment; After sorting the line segments in each category in descending order of length, the line segment pairs that meet the second matching condition are obtained as a line segment group and put into the line segment group set; each line segment does not participate in other pairings after being paired; the second matching condition includes: the angle difference and distance between the two line segments both meet their respective second threshold conditions.
4. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 2, characterized in that, A wall line grouping method based on global topology is used to obtain a set of line segment groups, including: Iterate through all line segment pairs in the set of line segments and put the line segment pairs that meet the second matching condition into the set to be grouped; the second matching condition includes: the angle difference and distance between the two line segments both meet their respective second threshold conditions; The graph traversal algorithm is used to identify all connected components in the set to be grouped, and each connected component is grouped into a line segment group set.
5. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 4, characterized in that, A wall line grouping method based on clustering optimization of topological relationships is used to obtain a set of line segment groups, including: The geometric center coordinates of each line segment in the set of line segments are used as the feature vector of the line segment, and the set of line segments is divided into multiple clusters using an improved clustering algorithm; Each cluster of line segments is treated as a subset, and a wall line grouping method based on global topology is used to obtain a line segment group set.
6. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 5, characterized in that, The improved clustering algorithm is derived from the K-means algorithm by modifying the selection of initial cluster centers and the allocation of clusters. The initial cluster centers are selected based on the candidate probabilities of line segments, and the clusters are allocated to the clusters with the smallest overall distance. The candidate probability of a line segment is calculated based on the squared distance between the line segment and the nearest initial cluster center, and the angular difference between the line segment and the nearest initial cluster center. The overall distance is calculated by weighting the Euclidean distance between the line segment and the cluster center, and the average angular difference between the line segment and the cluster.
7. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 2, characterized in that, The method of generating multiple wall centerlines based on line segment grouping sets and fitting distance and line segment direction includes: For each pair of line segments in the group set, copy the longest line segment and move it along its normal direction by half the distance between the line segment pairs to obtain the centerline of the wall. Identify multiple collinear wall centerlines, take the longest wall centerline as the baseline, extend the baseline outward along the two baseline endpoints, project the endpoints of the other wall centerlines onto the extension line, and take the two extreme points on the extension line to form a new line segment, which is the final wall centerline generated from the multiple collinear wall centerlines.
8. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 1 or 2, characterized in that, The identification of suspended endpoints among multiple wall centerlines includes: Taking each endpoint of the centerline of each wall as the center, a circular area with a radius equal to the connection tolerance is designated as the first neighboring region, and a circular area with a radius equal to the search tolerance is designated as the second neighboring region; the connection tolerance is less than the search tolerance. If there are no other wall centerlines in the first neighboring region of the current endpoint, but there is at least one other wall centerline in the second neighboring region, then the current endpoint is a suspended endpoint.
9. The wall recognition and modeling method based on two-dimensional CAD drawings according to claim 8, characterized in that, The step of obtaining the corresponding target intersection point based on the centerlines and endpoints of other walls in the adjacent area of each suspended endpoint includes: Calculate the intersection point of the wall centerline where the suspended endpoint is located with the centerline of each other wall in the second adjacent area. If multiple intersection points are calculated, select the intersection point closest to the suspended endpoint as the target intersection point; if no intersection point is calculated, find the endpoint of the wall centerline closest to the suspended endpoint in the second adjacent area as the target intersection point.
Citation Information
Patent Citations
Ellipse detection method based on arc supporting line segment
CN107301638A
Architectural CAD drawing-based indoor topological map generating method and system
CN108536923A