Recognition Method, Device, Equipment and Storage Medium for Similar Legends in CAD Drawings

By determining the element weight and position information of the template legend in the CAD drawing and identifying similar legends in combination with the intersection relationship, the problem of low comprehensiveness of similar legend recognition in the prior art is solved, and the recognition accuracy and efficiency are improved.

CN114661925BActive Publication Date: 2025-07-18GLODON CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210368560.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-06
Publication Date
2025-07-18
Estimated Expiration
2042-04-06

AI Technical Summary

Technical Problem

The prior art can only identify exactly the same CAD drawing legend, and cannot identify similar legends with slightly different shapes and rotation angles, resulting in low comprehensiveness and low efficiency.

Method used

By determining the elements of the template legend in the CAD drawing, its weight information and position information, the intersection relationship between the elements is used to calculate the similarity degree to identify the similar legend.

Benefits of technology

The recognition accuracy and comprehensiveness of similar legends are improved, and accurate matching of various components of the template legend is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661925B_ABST
    Figure CN114661925B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, apparatus, device and readable storage medium for identifying similar CAD legends. The method includes: determining a template legend for which similar legends need to be calculated in a CAD drawing, identifying the elements that make up the template legend, and obtaining the intersection relationships between the elements that make up the template legend, wherein the CAD drawing includes multiple legends, and each legend is composed of elements; obtaining the weight information and position information of all the elements that make up the template legend, wherein the weight information includes attribute weight and shape weight; and determining the similar legends of the template legend according to the weight information and position information of all the elements and the intersection relationships between the elements that make up the template legend.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of architectural engineering graphics recognition, and particularly to a method, device, equipment and readable storage medium for recognizing similar legends in CAD drawings. Background Art

[0002] With the development of information technology, cost estimators use quantity calculation software to recognize the legend information in business CAD (Computer Aided Design) drawings, calculate the corresponding quantities, and provide a reference basis for the entire business project. There are a large number of similar legends on business CAD drawings (similar legends refer to two legends with the same shape outline but different sizes, relative positions, etc.). Cost estimators need to list similar legends as the same item and measure them as the same type of legend.

[0003] The legend algorithms in the prior art can only recognize exactly the same legends (with the same shape, size, and rotation angle) in the same drawing. If a legend is a similar legend to the legend to be recognized (with the same shape but slightly different in size or rotation angle), this legend cannot be recognized. Therefore, this recognition method is too limited, resulting in the omission of some similar legends and reducing the comprehensiveness of legend recognition. At the same time, even if there are slight differences between similar legends, they still need to be recognized separately. Due to the large number and large volume of legend types in the entire drawing, the recognition efficiency of similar legends is reduced.

[0004] In view of the technical problem that the prior art can only recognize exactly the same legends, resulting in low comprehensiveness of similar legend recognition, there is currently no effective solution. Summary of the Invention

[0005] The purpose of the present invention is to provide a method, device, equipment and readable storage medium for recognizing similar legends in CAD drawings, which can solve the technical problem that the prior art can only recognize exactly the same legends, resulting in low comprehensiveness of similar legend recognition.

[0006] One aspect of the present invention provides a method for recognizing similar legends in CAD drawings. The method includes: determining a template legend for calculating similar legends required in the CAD drawing, recognizing the elements that make up the template legend, and obtaining the intersection relationships between the elements that make up the template legend, where the CAD drawing includes multiple legends, and each legend is composed of elements; obtaining the weight information and position information of all the elements that make up the template legend, where the weight information includes attribute weight and shape weight; and determining the similar legends of the template legend according to the weight information and position information of all the elements and the intersection relationships between the elements that make up the template legend.

[0007] Optionally, determining a similar legend of the template legend according to the weight information and position information of all the elements and the intersection relationship between the elements constituting the template legend includes: determining similar elements of all the elements according to the weight information and position information of all the elements and the intersection relationship between the elements constituting the template legend; comparing the legends composed of the similar elements with the template legend respectively, and determining the similar legend of the template legend according to the comparison result.

[0008] Optionally, determining similar elements of all the elements according to the weight information and position information of all the elements and the intersection relationship between the elements constituting the template legend includes: determining a reference element among the elements constituting the template legend; matching the weight information and the position information of the reference element with the elements of all the legends in the CAD drawing respectively, and determining similar elements of the reference element according to the matching result; obtaining the weight information and position information of the other elements except the reference element among the elements constituting the template legend, and determining similar elements of the other elements according to the intersection relationship between the elements constituting the template legend, the weight information and position information of the other elements.

[0009] Optionally, matching the weight information and the position information of the reference element with the elements of all the legends in the CAD drawing respectively, and determining similar elements of the reference element according to the matching result includes: matching the weight information of the reference element with the elements of all the legends in the CAD drawing to obtain matching elements of all the reference elements; establishing a coordinate system of the reference element and a coordinate system of the matching elements of the reference element according to the type to which the reference element belongs; determining a distance L between the reference element and the origin of the coordinate system in the coordinate system of the reference element, and determining a distance L' between the matching element and the origin of the coordinate system in the coordinate system of the matching elements of the reference element; calculating a position similarity degree between the reference element and the matching element according to the distance L and the distance L'; determining a total weight value of each matching element according to the position similarity degree, the attribute weight and shape weight of the reference element, and the attribute weight and shape weight of the matching element; if the total weight value meets a preset condition, determining the matching element as a similar element of the reference element.

[0010] Optionally, determining a total weight value of each matching element according to the position similarity degree, the attribute weight and shape weight of the reference element, and the attribute weight and shape weight of the matching element includes: determining the total weight value by the following method: total weight value = (attribute weight of the matching element + shape weight of the matching element) * 0.8 + position similarity degree * 0.2 * (attribute weight of the reference element + shape weight of the reference element).

[0011] Optionally, determining a reference element among the elements constituting the template legend includes: determining whether there is an element whose category is a block element in the template legend. If so, determining the block element with the smallest ID as the reference element; otherwise, performing the next determination operation; determining whether there is an element whose category is a line element in the template legend. If so, determining the line element with the largest length as the reference element; otherwise, determining the first element in the template legend as the reference element.

[0012] Another aspect of the present invention provides an apparatus for identifying similar legends in CAD drawings. The apparatus includes: an identification module for determining a template legend for which similar legends need to be calculated in a CAD drawing, identifying the elements constituting the template legend, and obtaining the intersection relationships between the elements constituting the template legend. Wherein, the CAD drawing includes multiple legends, and each legend is composed of elements; an acquisition module for acquiring the weight information and position information of all the elements constituting the template legend, where the weight information includes attribute weight and shape weight; a determination module for determining similar legends of the template legend according to the weight information and position information of all the elements and the intersection relationships between the elements constituting the template legend.

[0013] Optionally, the determination module includes: a first determination sub-module for determining similar elements of all the elements according to the weight information and position information of all the elements and the intersection relationships between the elements constituting the template legend; a second determination sub-module for comparing the legends composed of the similar elements with the template legend respectively, and determining similar legends of the template legend according to the comparison results.

[0014] Another aspect of the present invention provides a computer device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. The feature is that when the processor executes the computer program, it implements the method for identifying similar legends in CAD drawings described in any of the above embodiments.

[0015] Another aspect of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the method for identifying similar legends in CAD drawings described in any of the above embodiments. Further, the computer-readable storage medium mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc.; the data storage area can store data created according to the use of blockchain nodes, etc.

[0016] In this embodiment, the recognition of similar legends of the template legend is realized through the weight information and position information of the elements and the intersection relationship between the elements constituting the template legend, making the analysis of the legend more granular and comprehensive, enabling accurate matching of each component of the template legend, and improving the recognition accuracy of similar legends. Based on this application, the technical problem of only being able to recognize exactly the same legends, resulting in low comprehensiveness in the recognition of similar legends, is solved, and the recognition accuracy and comprehensiveness of similar legends are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0018] Figure 1 FIG. shows an optional flowchart of a method for recognizing similar legends in CAD drawings provided in Embodiment 1 of the present invention;

[0019] Figure 2 FIG. shows an optional application schematic diagram of a template legend in CAD drawings provided in Embodiment 2 of the present invention;

[0020] Figure 3 FIG. shows an optional application schematic diagram of the intersection relationship of a template legend in CAD drawings provided in Embodiment 2 of the present invention;

[0021] Figure 4 FIG. shows an optional application schematic diagram of a reference element of a template legend in CAD drawings provided in Embodiment 2 of the present invention;

[0022] Figure 5 FIG. shows an optional application schematic diagram of the coordinate system of a reference element of a template legend in CAD drawings provided in Embodiment 2 of the present invention;

[0023] Figure 6 FIG. shows an optional application schematic diagram of a similar element of a template legend in CAD drawings provided in Embodiment 2 of the present invention;

[0024] Figure 7 FIG. shows a structural block diagram of a device for recognizing similar legends in CAD drawings provided in Embodiment 3 of the present invention; and

[0025] Figure 8 FIG. shows a block diagram of a computer device suitable for implementing a method for recognizing similar legends in CAD drawings provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0026] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0027] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the presence of additional identical elements in the process, method, article or device including the element.

[0028] Embodiment 1

[0029] This embodiment provides a method for identifying similar legends in CAD drawings. Figure 1 The flowchart of the method for identifying similar legends in CAD drawings is shown. As Figure 1 shown, the method for identifying similar legends in CAD drawings may include steps S1 to S3, where:

[0030] Step S1, determine the template legend for which similar legends need to be calculated in the CAD drawing, identify the elements that make up the template legend, and obtain the intersection relationships between the elements that make up the template legend. Among them, the CAD drawing includes multiple legends, and each legend is composed of elements.

[0031] In engineering and product design, in order to make the entire design process more intuitive, simple and labor-saving, CAD (Computer Aided Design) drawings are usually used to display specific business projects. The CAD drawings corresponding to different business scenarios are different. Among them, there are also multiple legends in the CAD drawing, corresponding to different business functions. For example, in the CAD drawing of the installation of the ventilation and air-conditioning specialty, there are multiple legends such as air valves, air outlets and fans. Each legend can be composed of different basic elements, such as basic elements like straight lines, circles, arcs, fills and blocks. Among the multiple legends in CAD, there are similar legends (multiple legends with the same shape outline but not necessarily equal in size, relative position, etc.). The estimator needs to search for and count the similar legends according to business requirements to complete the quantity calculation of the CAD drawing corresponding business.

[0032] Determine the template legend for calculating similar legends required from CAD drawings according to business requirements, identify the template legend, obtain the constituent elements of the template legend, and the intersection relationships between the constituent elements.

[0033] Step S2, obtain the weight information and position information of all elements constituting the template legend, where the weight information includes attribute weight and shape weight.

[0034] The weight information and position information reflect the degree of feature presentation of elements in the legend. After obtaining the elements constituting the template legend, determine the weight information and position information of all elements to quantify each element, facilitate the statistics of the self-characteristics of the elements, enhance the fine-grainedness of element matching, and improve the matching accuracy. Among them, the weight information includes attribute weight and shape weight, and the position information is the spatial layout of each element in the template legend. Preferably, the attributes of a straight-line element include "line type", "line width", "color", and "curve type", and the corresponding attribute weights are 3, 7, 7, and 7 respectively; the shapes of a straight-line element include "radius", "direction", and "length", and the corresponding shape weights are 5, 7, and 1.

[0035] Step S3, determine the similar legends of the template legend according to the weight information and position information of all elements, and the intersection relationships between the elements constituting the template legend.

[0036] Take the weight information and position information of all elements of the template legend, and the intersection relationships between the elements constituting the template legend as matching conditions, and regard the legends that meet each matching condition as the similar legends of the template legend to complete the identification of the similar legends of the template legend.

[0037] In this embodiment, in the process of determining the similar legends of the template legend, starting from the dimension information of elements, by obtaining the characteristic information (weight information and position information) of each element in the template legend and the intersection relationships between elements, the analysis of the legend is more fine-grained and comprehensive, and can accurately match each component part of the template legend, improving the recognition accuracy of similar legends.

[0038] Optionally, step S3 includes steps S31 to S32, where:

[0039] Step S31, determine the similar elements of all elements according to the weight information and position information of all elements, and the intersection relationships between the elements constituting the template legend.

[0040] Since a legend is composed of elements, matching the elements is a prerequisite for determining the similar legends of the template legend. Quantify the self-characteristics of the elements according to the weight information and position information of all elements and the intersection relationships between the elements constituting the template legend, and then determine the similar elements of all elements.

[0041] Optionally, step S31 includes steps A1 to A3, where:

[0042] Step A1, determining a reference element among the elements constituting the template legend;

[0043] For facilitating the analysis of each component part of the template legend, it is necessary to determine an element with iconic features as the reference element to perform corresponding positioning on the template legend, obtain the spatial layout of each element in the template legend and the connection relationship between elements, improve the accuracy of element analysis of the template legend, and further make the matching similar legend more fitting with the template legend, thereby improving the recognition accuracy of similar legends in CAD drawings.

[0044] Optionally, step A1 includes steps A11 to A12, where:

[0045] Step A11, determining whether there is an element whose category is a block element in the template legend. If so, determining the block element with the smallest ID as the reference element; otherwise, performing the next judgment operation;

[0046] Step A12, determining whether there is an element whose category is a line element in the template legend. If so, determining the line element with the largest length as the reference element; otherwise, determining the first element in the template legend as the reference element.

[0047] In this embodiment, by statistically analyzing the characteristic values of the categories of each element in the legend, the larger the characteristic value, the more stable the effect shown by the element is and the less likely it is to be affected. Using this element as the reference element can improve the accuracy rate of element analysis in the template legend. By setting a priority rule based on the characteristic values of the categories of elements and determining the reference element according to the priority rule, where the preset priority rule includes the following three judgment conditions: the block element with the smallest ID (the serial number for code compilation of the CAD drawing), the line element with the largest length, and the first element in the template legend (the first element to be compiled). The priority levels of the three judgment conditions are arranged from high to low in the above manner. The higher the priority, the elements in the template legend are judged step by step according to the priority rule, and meeting any one of the judgment conditions can be used as the reference element.

[0048] Specifically, after obtaining the template legend, first determine whether there is an element whose category is a block element among the elements constituting the template legend. If so, select the block element with the smallest ID as the reference element; otherwise, use the next-level priority rule for judgment, determine whether there is an element whose category is a line element in the template legend. If so, select the line element with the largest length as the reference element; otherwise, select the first element compiled in the template legend as the reference element.

[0049] Step A2: Match the weight information and position information of the reference element with the elements of all the legends in the CAD drawing respectively, and determine the similar elements of the reference element according to the matching results.

[0050] After determining the reference element of the template legend, match the weight information and position information of the reference element with the elements of all the legends in the CAD drawing respectively, and take the elements that meet the conditions of the matching results as the similar elements of the reference element.

[0051] It is determined that the similar elements of the reference element have the same meaning as the reference element, and both play a role in positioning, so as to obtain the spatial layout of the elements in the legend to which the similar elements of the reference element belong and the connection relationship between the elements, improving the recognition efficiency and accuracy of similar legends.

[0052] Optionally, Step A2 may include Step A21 to Step A26, where:

[0053] Step A21: Match the weight information of the reference element with the elements of all the legends in the CAD drawing to obtain the matching elements of all the reference elements.

[0054] Specifically, match the weight information (attribute weight) of the reference element with the elements of all the legends in the CAD drawing. If the attribute weight of any element in the CAD drawing is greater than the first preset threshold, determine that element as the matching element of the reference element.

[0055] For example, the attribute weights of the reference element include a color weight of 7, a line type weight of 3, and a line width weight of 7, and the first preset threshold is 9. When an element has the same color and line type as the reference element, the attribute weight of this element is 7 + 3 = 10, which is greater than the first preset threshold, so this element is the matching element of the reference element.

[0056] Step A22: Establish the coordinate system of the reference element and the coordinate system of the matching elements of the reference element according to the type to which the reference element belongs.

[0057] After obtaining the matching elements of the reference element, since the reference element and the matching elements belong to the same category, by judging the type information to which the reference element belongs, the coordinate system of the reference element and the coordinate system of the matching elements of the reference element can be established according to the type to which the reference element belongs. Among them, when the type to which the reference element belongs is a block element, establish the self - coordinate system of the block element as the coordinate system of the reference element; when the type to which the reference element belongs is a straight - line element, since the straight - line elements in the CAD drawing are in the form of line segments, determine the mid - point of the straight - line element as the origin of the coordinate system, take the straight - line direction as the x - axis, and the normal direction of this straight line as the y - axis to establish the corresponding coordinate system.

[0058] Preferably, each reference element is defined to have a range box, which is determined by the size of the template legend. When constructing the coordinate system, the range box is consistent with the actual layout of the coordinate system, and is used to determine the range of all elements belonging to the template legend. Calculate the shape weights of the reference element and the matching element to obtain the shape ratio of the matching element to the reference element. Judge the shape ratio, and determine the range box of the matching element according to the judgment result, so as to obtain the matching legend to which the matching element belongs. When the shape ratio is less than or equal to 1, the range box of the matching element is the same as that of the reference element; if the shape ratio is greater than 1, expand the range box of the reference element according to the shape ratio and make it consistent with the layout of the coordinate system of the matching element to obtain the range box of the matching element. By expanding the range box of the matching element, it is possible to avoid the situation where the matching element cannot be matched because it exceeds the original legend range after translation, rotation, or flipping in the coordinate system, and the matching accuracy can be improved.

[0059] Step A23: Determine the distance L between the reference element and the origin of the coordinate system in the coordinate system of the reference element, and determine the distance L' between the matching element and the origin of the coordinate system in the coordinate system of the matching element of the reference element;

[0060] Step A24: Calculate the position similarity between the reference element and the matching element according to the distance L and the distance L'.

[0061] Determine the origin of the coordinate system in the coordinate system of the reference element, and calculate the distance between the reference element and the origin of the coordinate system. At the same time, determine the corresponding origin of the coordinate system in the coordinate system of the matching element of the reference element, and calculate the distance between the matching element and the corresponding origin of the coordinate system. Calculate the two obtained distances according to the preset formula to obtain the position similarity between the reference element and the matching element. Preferably, the preset formula is position similarity = 1 - std::abs(L - L') / std::max(L - L'), where std::abs is the absolute value and std::max is the maximum value.

[0062] Step A25: Determine the total weight value of each matching element according to the position similarity, the attribute weight of the reference element, and the shape weight.

[0063] Obtain the weight information (attribute weight and shape weight) of the reference element, the weight information of the matching element, and their position similarity to determine the total weight value of each matching element.

[0064] Optionally, step A25 determines the total weight value through the following formula, where:

[0065] Total weight value = (attribute weight of the matching element + shape weight of the matching element) * 0.8 + position similarity * 0.2 * (attribute weight of the reference element + shape weight of the reference element),

[0066] Specifically, the numerical values such as 0.8 and 0.2 in the above formula are not fixedly set and can be correspondingly changed according to different scenarios. This embodiment does not make any limitations.

[0067] Step A26, if the total weight value meets the preset condition, determine that the matching element is a similar element of the reference element.

[0068] Judge the calculated total weight value. If the total weight value meets the preset condition, use the matching element as the similar element of the reference element. Among them, the preset condition is that when there are multiple matching elements of the reference element in a certain legend, compare the total weight values of each matching element and the reference element, and select the matching element with the largest total weight value as the similar element of the reference element.

[0069] Step A3, obtain the weight information and position information of the other elements except the reference element among the elements constituting the template legend, and determine the similar elements of the other elements according to the intersection relationship between the elements constituting the template legend, the weight information and position information of the other elements.

[0070] Obtain the weight information and position information of the other elements except the reference element among the elements constituting the template legend. Similar to the process of determining the similar elements of the reference element (Steps A23 to A26), perform corresponding calculations on the intersection relationship between the elements constituting the template legend, the weight information and position information of the other elements through the above steps, obtain the total weight values of the similar elements of each other element, and determine the similar elements of the other elements according to the total weight values.

[0071] Step S32, compare the legends composed of similar elements with the template legend respectively, and determine the similar legend of the template legend according to the comparison result.

[0072] Calculate the total weight value of the template legend through the reference element and other elements. At the same time, calculate the total weight value of the legend to which the similar elements of the reference element and other elements belong. Compare the total weight values of each legend with the total weight value of the template legend to obtain the comparison result. If the comparison result is greater than the second preset threshold, determine that the corresponding legend is the similar legend of the template legend. Preferably, the second preset threshold can be 0.75.

[0073] In this embodiment, the recognition of the similar legend of the template legend is realized through the weight information and position information of the elements and the intersection relationship between the elements constituting the template legend, making the analysis of the legend more granular and comprehensive, capable of accurately matching each component of the template legend, and improving the recognition accuracy of the similar legend. Based on this application, the technical problem of only being able to recognize exactly the same legend, resulting in low comprehensiveness of similar legend recognition, is solved, and the recognition accuracy of similar legends is improved.

[0074] Embodiment Two

[0075] Embodiment 2 of the present invention also provides an overall process for a method of identifying similar legends in CAD drawings. Specifically, it is implemented through the following method:

[0076] 1. Define weights

[0077] 1) In order to distinguish the characteristics of legend elements, weight values are predefined for various types of elements in advance. By analyzing the CAD drawing legends and according to the degree of characteristics (importance) occupied by the CAD elements in the legends, the weights of various types of elements are defined. During the optimization process, the element weight values will be adjusted to achieve the optimal solution. Table 1 below shows the weights defined for a certain CAD drawing. The legend composition elements of this CAD drawing include five types: straight lines, circles, fills, arcs, and blocks. Preferably, according to the number of elements in the CAD drawing legend, the weights are defined, and the defined weights are shown in Table 1. The weight of the straight line is 3, the weight of the circle is 9, the fill is 5, the arc is 5, and the block is 9.

[0078] Table 1

[0079] Straight line Circle Filling Arc Block 3 9 5 5 9

[0080] 2) In the comparison process of each element, its own weight value also needs to be set according to its own characteristics. It mainly includes two aspects of weights: attributes and shapes. Among them, preferably, the attributes mainly include: "line type", "line width", "color", "curve type", and the shapes mainly include: "radius", "direction", "length".

[0081] The following shows an example of the weight of a straight line element. The weight code of the straight line is as follows: m_oFactorscale.insert(QString::fromStdWString(L"line type"), 3);

[0082] m_oFactorscale.insert(QString::fromStdWString(L"line width"), 7);

[0083] m_oFactorscale.insert(QString::fromStdWString(L"color"), 7);

[0084] m_oFactorscale.insert(QString::fromStdWString(L"curve type"), 7);

[0085] m_dTotalPropFactor = 24;

[0086] m_oFactorscale.insert(QString::fromStdWString(L"Radius"), 5);

[0087] m_oFactorscale.insert(QString::fromStdWString(L"Direction"), 7);

[0088] m_oFactorscale.insert(QString::fromStdWString(L"Length"), 1);

[0089] m_dTotalShapFactor = 13;

[0090] The larger the value in the above code, the greater the weight value of this item, and it is more obvious in presenting the legend features. It can be seen that the specific weights of each attribute of the straight-line element are: the weight of "line type" is 3, the weight of "line width" is 7, the weight of "color" is 7, the weight of "curve type" is 7, and the sum of attribute weights is 24; the specific weights of the shape of the straight-line element are: the weight of "radius" is 5, the weight of "direction" is 7, the weight of "length" is 1, and the sum of shape weights is 13.

[0091] 2. Preprocessing

[0092] 1) According to the types of each element in the template legend, corresponding to the weight values defined in 1, calculate the weight value corresponding to each element, and sum them to calculate the total weight of the template legend.

[0093] Figure 2 Shows an application schematic diagram of the template legend, as Figure 2 shown. This template legend consists of 1 circle and 2 straight lines, so the total weight of this legend is considered to be: 15 = 9 + 3 * 2.

[0094] 2) Initialize the intersection relationship in the template legend

[0095] Why use the intersection relationship: During the matching search process, since the elements are less affected by factors such as size, direction, and distance, it is very easy to make mistakes. By analyzing the relationship between the legend elements, it is considered that the intersection relationship feature is very obvious, which can improve the recognition accuracy and efficiency.

[0096] Figure 3 Shows an application schematic diagram of the intersection relationship of the template legend, as Figure 3 shown. (1:2,3)(2:1,3)(3:1,2) all intersect, and the intersection information is recorded for later use in the matching process. Among them, (1:2,3) means that 1 intersects with 2 and 3 respectively.

[0097] 3) Sort the template legend

[0098] According to the weights corresponding to each type of element in 1), sort the elements in the template legend from largest to smallest. The sorted result is: 2, 1, 3. This sorting can be used as the matching order when matching other elements later. When matching other elements, match them in the order of weight size, which can improve the recognition efficiency and accelerate the matching efficiency.

[0099] 4) Merge & deduplicate

[0100] Due to the display device configuration problem, in CAD drawings, regular graphics such as circles and ellipses are composed of a large number of small short lines. To improve the recognition rate and efficiency of similar legends in the template legend, first merge them and then recognize.

[0101] At the same time, there may be overlapping lines in the template legend, which will interfere with the recognition result. Therefore, remove the short lines with an overlap degree > 90%, and keep the longer lines to ensure the recognition accuracy.

[0102] Before matching the reference element and other elements, first perform the merging and deduplication processing of the graphic quality of the CAD legend to exclude interference items and improve the accuracy of subsequent matching.

[0103] 3. Find the reference element

[0104] In the template legend, select a reference element according to the following priorities: the block element with the smallest ID, the longest straight line, and the first element in the template.

[0105] Figure 4 Shows an application schematic diagram of the reference element of the template legend, such as Figure 4 As shown, according to the priority, find the longest straight line as the reference element.

[0106] 4. Establish a relative coordinate system

[0107] According to the reference element selected in the template legend, find the matching element in the CAD drawing whose own weight value (color, line type, line width, etc.) is greater than the threshold, and establish a corresponding relative coordinate system for the reference element and the matching element to realize the search and matching of similar elements of other elements except the reference element in the template legend.

[0108] Figure 5 Shows an application schematic diagram of the coordinate system of the reference element of the template legend, such as Figure 5As shown, Figure (a) shows the establishment of a coordinate system with a straight line as the reference element, and Figures (b) and (c) show the coordinate systems established for the matching elements according to the element characteristics. Specifically, since the block element belongs to a two-dimensional element (compared with a line), it can have its own coordinate system (taking the vertex of one corner of the block element as the origin and its own coordinate system as one coordinate system). The straight line (actually a line segment with a starting point in the graph) element is a one-dimensional element, and the midpoint of the straight line (line segment) is taken as the origin to establish 4 local (4 quadrants) coordinate systems.

[0109] When the reference element is the largest straight line element, the reference element forms 1 local coordinate; among the matching elements found in the atlas, taking the direction of the straight line as the X-axis and the normal as the Y-axis, 4 local coordinate systems will be formed (rotation and mirroring need to be considered, so there are 4 local coordinate systems).

[0110] 5. Match one legend

[0111] 1) Match according to the intersection relationship first

[0112] Figure 6 The application schematic diagram of the matching of similar elements of the template legend is shown, specifically showing the process of determining the matching legend (b) through the matching of similar elements of the template legend (a). As Figure 6 shown, in step 2.2 of the template legend, intersection relationships (1:2,4)(2:1,3)(3:2,4)(4:1,3)(5:6)(6:5) will be established.

[0113] Taking 1 as the reference element, start looking from 1 first. If a similar 1` is found (how to find similarity will be described in 4.5.2), then according to the template intersection relationship - (1:2,4), start looking for 2 and 4. Since 1 intersects with 2 and 4, it is considered that there will be lines 2` and 4` in the atlas that intersect with 1`. Among the lines intersecting with 1` found in the atlas, find the 2` and 4` that are most similar to 2 and 4.

[0114] 2) Match similar elements

[0115] A. According to the reference element of the template legend, find the elements ` within a certain range in the corresponding coordinate system. According to the self-Box (range box) of the reference element 1 of the template, expand a certain range to form a larger Box to cope with the change in length. According to the relative coordinate system established in step 4, convert the Box into Box`, and find the set of matching elements ` of the template legend in the CAD drawing.

[0116] B. Calculate the similarity weight value between Element 1 and Element 1' in the element set. (In this embodiment, "`" is used to distinguish between the template element and the similar element. The element with "`" represents the similar element, and the element without "`" is the original element. For example, Element 1' is the similar element of Element 1).

[0117] Judge the element type. Different elements have different similarity weights defined in 1.2 and different similarity methods. (Taking lines as an example).

[0118] B1. Calculate the attribute similarity weight between Line 1 and Line 1' (line type, color, line width, line style).

[0119] Taking Figure 3 the template legend as an example: If the line types are different and all others are the same, the attribute similarity weight value = 7 + 7 + 7 = 21; if all are the same, the attribute similarity weight value = 3 + 7 + 7 + 7 = 24;

[0120] B2. Calculate the shape similarity weight between Line 1 and Line 1' (radius, direction, length).

[0121] Radius: If it is a straight line, the default radius is equal, and the weight value +5

[0122] Direction: Judge whether the directions are on the same straight line. Since a line segment has two directions when drawing a line, it needs to be judged twice. There is a certain allowable error (currently 12° is adopted).

[0123] Length: Calculate the length similarity of the line. It refers to the ratio of the same length part to the longer line. Length similarity = 1 - std::abs(dLength1 - dLength2) / std::max(dLength1, dLength2), where std::abs is the absolute value and std::max is the maximum value; the weight value = length similarity * length weight. When the straight lines are exactly the same, the shape similarity weight = 5 + 7 + 1 = 13; when the straight line directions are the same but there are differences in length, one length is 5 and the other is 4. Length similarity = 1 - (5 - 4) / 5 = 0.8, and the shape similarity weight = 5 + 7 + 1 * 0.8 = 12.8

[0124] C. Calculate the position similarity

[0125] According to the established relative coordinate system: Coordinate System 1 - Coordinate System 1', calculate the position similarity.

[0126] C1. Calculate the distance dLength1 from Element 1 to the origin of Coordinate System 1, and calculate the distance dLength1' from Element 1' to the origin of Coordinate System 1';

[0127] C2. Calculate the position similarity = 1 - std::abs(dLength1 - dLength1`) / std::max(dLength1, dLength1`), where std::abs is the absolute value and std::max is the maximum value;

[0128] D. Calculate the total weight value

[0129] Definition: Total weight value = Similarity weight value * 0.8 + Position similarity * 0.2 * Maximum similarity weight value = (Attribute similarity weight + Shape similarity weight value) * 0.8 + Position similarity * 0.2 * (Maximum attribute similarity weight + Maximum shape similarity weight value)

[0130] For example: Total weight value = (21 + 12.8) * 0.8 + 0.8 * 0.2 * (24 + 13) = 32.96. When the reference element and the matching element are exactly the same, it is the maximum weight value. Maximum weight value = (24 + 13) * 0.8 + 1 * 0.2 * (24 + 13) = 37

[0131] E. Find the optimal solution for the similarity of Element 1

[0132] 1. Traverse the set of elements `, and calculate the total weight value of each possible Element 1 - Element 1`

[0133] 2. Find the optimal solution - there may be multiple matching elements for the reference element in a legend. Then, the Element 1` with the maximum total weight value is considered the similar element of Element 1.

[0134] 3) Match similar legends

[0135] Loop through each element in the template legend and execute 2). Find the corresponding matching similar elements ` for all elements in the template legend. Add up the total weight values of all similar elements ` to get the total weight value W` of the legend. Then calculate the total weight value W of the template legend. Divide them to get the similarity of the entire legend. Similarity S = W` / W. After calculating the similarity of the entire legend, determine whether it is greater than the set similarity threshold SV (currently set to 0.75, the maximum similarity is 1). If S >= SV, it is considered a similar legend; if S < SV, it is considered not similar.

[0136] For example: A legend composed of 8 lines, and the total weight value of each line is 32.96 calculated in 4.5.2.4, the maximum weight value is 37, W` = 32.96 * 8 = 263.68, W = 37 * 8 = 296, S = 263.68 / 296 = 0.8908 = 89.08%. Since S >= SV, this legend and the template legend are similar legends.

[0137] 6. Find other similar legends

[0138] If other template legends need to be matched, continue to step 5 to find other similar legends.

[0139] Embodiment III

[0140] Embodiment III of the present invention also provides an identification device for similar legends in CAD drawings. This identification device for similar legends in CAD drawings corresponds to the identification method for similar legends in CAD drawings provided in Embodiment I above. The corresponding technical features and technical effects will not be elaborated in detail in this embodiment, and the relevant parts can refer to Embodiment I above. Specifically, Figure 7 shows a structural block diagram of the identification device for similar legends in CAD drawings. As Figure 7 shown, the identification device 700 for similar legends in CAD drawings includes an identification module 701, an acquisition module 702, and a determination module 703, where:

[0141] The identification module 701 is used to determine the template legend for which similar legends need to be calculated in the CAD drawing, identify the elements that make up the template legend, and obtain the intersection relationships between the elements that make up the template legend. Among them, the CAD drawing includes multiple legends, and each legend is composed of elements;

[0142] The acquisition module 702 is connected to the identification module 701 and is used to acquire the weight information and position information of all the elements that make up the template legend, where the weight information includes attribute weight and shape weight;

[0143] The determination module 703 is connected to the acquisition module 702 and is used to determine the similar legends of the template legend according to the weight information and position information of all the elements, and the intersection relationships between the elements that make up the template legend.

[0144] Optionally, the determination module includes: a first determination sub-module, which is used to determine the similar elements of all the elements according to the weight information and position information of all the elements, and the intersection relationships between the elements that make up the template legend; a second determination sub-module, which is used to compare the legends composed of the similar elements with the template legend respectively, and determine the similar legends of the template legend according to the comparison results.

[0145] Optionally, the first determination sub-module includes: a first determination unit, which is used to determine a reference element among the elements that make up the template legend; a matching unit, which is used to match the weight information and position information of the reference element with the elements of all the legends in the CAD drawing respectively, and determine the similar elements of the reference element according to the matching results; a second determination unit, which is used to acquire the weight information and position information of the other elements except the reference element among the elements that make up the template legend, and determine the similar elements of the other elements according to the intersection relationships between the elements that make up the template legend, the weight information and position information of the other elements.

[0146] Optionally, the matching unit includes: a matching subunit for matching the weight information of the reference element with all the elements of the legends in the CAD drawing to obtain the matching elements of all the reference elements; a building subunit for building the coordinate system of the reference element and the coordinate system of the matching element of the reference element according to the type to which the reference element belongs; a first determination subunit for determining the distance L between the reference element and the origin of the coordinate system in the coordinate system of the reference element, and determining the distance L' between the matching element and the origin of the coordinate system in the coordinate system of the matching element of the reference element; a calculation subunit for calculating the position similarity between the reference element and the matching element according to the distance L and the distance L'; a second determination subunit for determining the total weight value of each matching element according to the position similarity, the attribute weight and the shape weight of the reference element, and the attribute weight and the shape weight of the matching element; a third determination subunit for determining that the matching element is a similar element of the reference element if the total weight value meets a preset condition.

[0147] Optionally, the second determination subunit determines the total weight value by the following method, including: total weight value = (attribute weight of the matching element + shape weight of the matching element) * 0.8 + position similarity * 0.2 * (attribute weight of the reference element + shape weight of the reference element).

[0148] Optionally, when the first determination unit executes the step of determining a reference element among the elements constituting the template legend, it specifically is used for: determining whether there is an element whose type belongs to the block element in the template legend, if so, determining the block element with the smallest ID as the reference element, otherwise performing the next determination operation; determining whether there is an element whose category belongs to the straight line element in the template legend, if so, determining the straight line element with the largest length as the reference element, otherwise determining the first element in the template legend as the reference element.

[0149] Embodiment 4

[0150] Figure 8 The block diagram of the computer device suitable for implementing the method for identifying similar legends of CAD drawings provided in Embodiment 4 of the present invention is shown. In this embodiment, the computer device 800 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers) that executes a program, etc. As Figure 8 shown, the computer device 800 of this embodiment at least includes but is not limited to: a memory 801, a processor 802, and a network interface 803 that can communicate with each other through the system bus. It should be noted that, Figure 8 only the computer device 800 with components 801 - 803 is shown, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented.

[0151] In this embodiment, the memory 803 includes at least one type of computer-readable storage medium. The readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 801 may be an internal storage unit of the computer device 800, such as the hard disk or memory of the computer device 800. In other embodiments, the memory 801 may also be an external storage device of the computer device 800, such as a plug-in hard disk equipped on the computer device 800, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Of course, the memory 801 may also include both the internal storage unit and the external storage device of the computer device 800. In this embodiment, the memory 801 is generally used to store the operating system installed in the computer device 800 and various application software, such as the program code of the method for identifying similar legends in CAD drawings.

[0152] In some embodiments, the processor 802 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 802 is generally used to control the overall operation of the computer device 800. For example, it performs control and processing related to data interaction or communication with the computer device 800. In this embodiment, the processor 802 is used to run the program code of the steps of the method for identifying similar legends in CAD drawings stored in the memory 801.

[0153] In this embodiment, the method for identifying similar legends in CAD drawings stored in the memory 801 may also be divided into one or more program modules and executed by one or more processors (in this embodiment, the processor 802) to complete the present invention.

[0154] The network interface 803 may include a wireless network interface or a wired network interface, which is generally used to establish a communication link between the computer device 800 and other computer devices. For example, the network interface 803 is used to connect the computer device 800 to an external terminal via a network, and to establish a data transmission channel and a communication link between the computer device 800 and the external terminal. The network may be an enterprise internal network (Intranet), the Internet, the Global System of Mobile communication (GSM for short), Wideband Code Division Multiple Access (WCDMA for short), 4G network, 5G network, Bluetooth, Wi-Fi or other wireless or wired networks.

[0155] Embodiment 4

[0156] This embodiment also provides a computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disc, server, App application store, etc. A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the method for identifying similar legends in CAD drawings are implemented.

[0157] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the embodiments of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a sequence different from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.

[0158] It should be noted that the serial numbers of the embodiments of the present invention are only for description and do not represent the superiority or inferiority of the embodiments.

[0159] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0160] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. A method for identifying similar legends in CAD drawings, characterized in that, The method includes: Determine the template legend for calculating similar legends required in the CAD drawing, identify the elements that make up the template legend, and obtain the intersection relationships between the elements that make up the template legend, where the CAD drawing includes multiple legends, and each legend is composed of elements; Obtain the weight information and position information of all the elements that make up the template legend, where the weight information includes attribute weight and shape weight; Determine the similar legends of the template legend according to the weight information and position information of all the elements, and the intersection relationships between the elements that make up the template legend; The step of determining the similar legends of the template legend according to the weight information and position information of all the elements, and the intersection relationships between the elements that make up the template legend includes: Determine the similar elements of all the elements according to the weight information and position information of all the elements, and the intersection relationships between the elements that make up the template legend; Compare the legends composed of the similar elements with the template legend respectively, and determine the similar legends of the template legend according to the comparison results; The step of determining the similar elements of all the elements according to the weight information and position information of all the elements, and the intersection relationships between the elements that make up the template legend includes: Determine a reference element among the elements that make up the template legend; Match the weight information and the position information of the reference element with the elements of all the legends in the CAD drawing respectively, and determine the similar elements of the reference element according to the matching results; Obtain the weight information and position information of the other elements except the reference element among the elements that make up the template legend, and determine the similar elements of the other elements according to the intersection relationships between the elements that make up the template legend, the weight information and position information of the other elements; The step of matching the weight information and the position information of the reference element with the elements of all the legends in the CAD drawing respectively, and determining the similar elements of the reference element according to the matching results includes: Match the weight information of the reference element with the elements of all the legends in the CAD drawing to obtain the matching elements of all the reference elements; Establish the coordinate system of the reference element and the coordinate system of the matching elements of the reference element according to the type to which the reference element belongs; Determine the distance L between the reference element and the origin of the coordinate system in the coordinate system of the reference element, and determine the distance L' between the matching element and the origin of the coordinate system in the coordinate system of the matching elements of the reference element; Calculate the position similarity between the reference element and the matching element according to the distance L and the distance L'; Determine the total weight value of each matching element according to the position similarity, the attribute weight and shape weight of the reference element, and the attribute weight and shape weight of the matching element; If the total weight value meets the preset condition, determine the matching element as the similar element of the reference element.

2. The method according to claim 1, wherein Determining the total weight value of each of the matching elements according to the position similarity, the attribute weights and shape weights of the reference element, and the attribute weights and shape weights of the matching elements includes: Determining the total weight value by the following method: Total weight value = (attribute weight of the matching element + shape weight of the matching element) * 0.8 + position similarity * 0.2 * (attribute weight of the reference element + shape weight of the reference element).

3. The method according to any one of claims 1-2, characterized in that Determining a reference element among the elements constituting the template legend includes: Judging whether there is an element whose category is a block element in the template legend. If so, determining the block element with the smallest ID as the reference element; otherwise, performing the next judgment operation; Judging whether there is an element whose category is a straight-line element in the template legend. If so, determining the straight-line element with the largest length as the reference element; otherwise, determining the first element in the template legend as the reference element.

4. An identification device for similar legends in CAD drawings, characterized in that, The device includes: An identification module, configured to determine a template legend for calculating similar legends required in a CAD drawing, identify the elements constituting the template legend, and obtain the intersection relationships between the elements constituting the template legend, where the CAD drawing includes multiple legends, and each legend is composed of elements; An acquisition module, configured to acquire the weight information and position information of all elements constituting the template legend, where the weight information includes an attribute weight and a shape weight; A determination module, configured to determine a similar legend of the template legend according to the weight information and position information of all the elements, and the intersection relationships between the elements constituting the template legend; A first determination sub-module, configured to determine similar elements of all the elements according to the weight information and position information of all the elements, and the intersection relationships between the elements constituting the template legend; A second determination sub-module, configured to compare the legends composed of the similar elements with the template legend respectively, and determine a similar legend of the template legend according to the comparison results; The first determination sub-module is further configured to determine a reference element among the elements constituting the template legend; match the weight information and the position information of the reference element with the elements of all legends in the CAD drawing respectively, and determine similar elements of the reference element according to the matching results; acquire the weight information and position information of other elements except the reference element among the elements constituting the template legend, and determine similar elements of the other elements according to the intersection relationships between the elements constituting the template legend, the weight information and position information of the other elements; A matching module is configured to match the weight information of the reference elements with all the elements of the legends in the CAD drawing to obtain the matching elements of all the reference elements; establish the coordinate system of the reference elements and the coordinate system of the matching elements of the reference elements according to the types to which the reference elements belong; determine the distance L between the reference element and the origin of the coordinate system in the coordinate system of the reference element, and determine the distance L' between the matching element and the origin of the coordinate system in the coordinate system of the matching element of the reference element; calculate the position similarity between the reference element and the matching element according to the distance L and the distance L'; determine the total weight value of each matching element according to the position similarity, the attribute weight and shape weight of the reference element, and the attribute weight and shape weight of the matching element; if the total weight value meets a preset condition, determine the matching element as the similar element of the reference element.

5. A computer device, the computer device comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 3 when executing the computer program.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program implements the method according to any one of claims 1 to 3 when executed by the processor.

Citation Information

Patent Citations

  • Graphics primitive identification matching method and device, computer equipment and readable storage medium

    CN112598092A