DWG drawing comparison method and system
By decomposing and multithreading the basic graphics of DWG drawings in parallel, the problems of degradation of drawing comparison and poor performance in the prior art are solved, and efficient and accurate drawing comparison results are achieved, reducing the comparison time.
Patent Information
- Application Number
- CN202410967055.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-12-13
AI Technical Summary
The existing DWG drawing comparison methods have problems such as decreasing clarity, long comparison time, and poor performance. Especially when scaling and printing, the accuracy and efficiency of the comparison results cannot be guaranteed.
By reading and decomposing different categories of basic graphics in DWG drawings, multi-threaded parallel processing and region comparison are used to traverse and compare the basic graphics and label them according to key attributes, reducing the number of comparisons and improving the comparison efficiency.
It realizes a simpler, more efficient and accurate drawing comparison, reduces the comparison time, ensures the accuracy and efficiency of comparison results, and improves the performance of drawing comparison.
Smart Images

Figure CN119131830A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of drawing comparison, and in particular to a DWG drawing comparison method and system. Background Art
[0002] In the process of computer drawing, it is inevitable to modify the drawings repeatedly, which will produce different versions of drawings, and then there will be a need to compare the differences between different versions of drawings. In order to compare the differences between different versions of drawings, there are currently a variety of software that provide drawing comparison functions or drawing comparison methods. Common drawing comparison methods include AutoVue drawing comparison, CAXA drawing comparison, ODA drawing comparison, etc. However, the existing comparison and comparison methods have certain defects, including:
[0003] (1) AutoVue drawing comparison is to open the display views of two files and then compare them. The comparison process is to compare the currently displayed view in bitmap format. When the scaling exceeds the bitmap accuracy of the current view, the bitmap displayed in the current view is used for re-comparison. This method is fast and the comparison result is accurate to pixels. However, this comparison process requires opening the DWG drawing view. When the DWG bitmap is scaled and compared in real time, its clarity is still good. When the DWG bitmap comparison is completed and the drawing comparison result is printed, its clarity is constant. Enlarging the printed result will cause the clarity to decrease and become blurred. In other words, this method is a comparison in bitmap format. When printing, only the bitmap of the comparison result can be printed, and its clarity cannot be guaranteed.
[0004] (2) When comparing ODA drawings, ODA will convert the drawings into SVG format. When exporting SVG using the sample program provided by ODA, it can be found that the coordinates of the same graphic will change in the SVG exported under different views and display scales. When the SVG format image is converted into a bitmap for comparison, the same graphic will be identified as different. Therefore, ODA cannot obtain a stable bitmap and cannot ensure the accuracy of the comparison. In addition, using ODA to parse the graphics in the DWG drawings and then compare them is only related to the basic data saved in the DWG file and is not affected by the display environment. The comparison process can be carried out in the background, and the processing of the comparison results can be controlled according to business needs, such as saving in DWG, PDF and other formats, and then using the comparison results in different environments. However, the comparison time of this method is relatively long and the performance is poor.
[0005] (3) The CAXA drawing comparison is similar to the drawing comparison example provided by ODA. Both of them compare the graphics in the DWG drawing one by one. Its advantage is fast speed, but its applicable scenarios are limited. When the previously created graphics are deleted, the comparison results of the subsequent graphics will be recognized as differences, resulting in subsequent recognition errors. Summary of the invention
[0006] To address the deficiencies of the above-mentioned prior art, the present invention provides a DWG drawing comparison method and system, which read and decompose basic graphics of different categories in DWG drawings, traverse and compare according to the basic graphics, and mark according to the comparison results, so as to achieve a simpler, more efficient and accurate drawing comparison; discard the same basic graphics that have been compared during the traversal process to reduce the number of searches for subsequent graphics; the comparison process is carried out in regions to reduce the number of calculations; the comparison processes of different categories and different regions are all processed in parallel by multi-threading to reduce the comparison time; through the above-mentioned performance optimization methods of reducing the number of comparisons, partitioned comparison, and parallel processing, the performance of drawing comparison is further improved, while ensuring the accuracy of the comparison results, the comparison efficiency is improved and the comparison time is reduced.
[0007] In a first aspect, the present invention provides a DWG drawing comparison method.
[0008] A DWG drawing comparison method, comprising:
[0009] Obtain the old and new DWG drawing files to be compared, and read and decompose the basic graphics in the drawing files respectively;
[0010] Classify the basic graphics and construct basic graphics lists of different categories in the new and old DWG drawing files; each category of the basic graphics list includes all basic graphics of the category in the drawing file, and each basic graphic has corresponding key attributes;
[0011] Compare all basic graphics of each category respectively, traverse all basic graphics in the two-column basic graphics list of each category, compare the two basic graphics according to the key attributes, and generate the comparison result;
[0012] Based on the comparison results, different colors are used to mark the basic graphics, and the final drawing comparison results are output.
[0013] According to a further technical solution, the categories of the basic graphics include straight lines, single-line text, arrows, circles, rectangles, trapezoids, and arcs, and the key attributes of the basic graphics include the positions of key points of the graphics.
[0014] A further technical solution is that for two lists of basic graphics of two categories to be compared, for a basic graphic in the first list of basic graphics, each basic graphic in the second list of basic graphics is traversed and compared according to key attributes. If there are two basic graphics with the same key attributes, the two basic graphics are considered to be the same, and the two basic graphics are saved in the comparison result, and the same graphics are marked with the same color; if there are no two basic graphics with the same key attributes, the two basic graphics are considered to be different, and the two basic graphics are saved in the comparison result, and different graphics are marked with different colors;
[0015] Traverse each basic graphic in the first column of the basic graphic list to complete the comparison of the two columns of basic graphic lists.
[0016] A further technical solution is that in the process of traversing all the basic graphics in the two columns of basic graphic lists, when it is determined by comparison that two basic graphics are the same, the two basic graphics are removed from their respective lists and the comparison of the next basic graphic is performed.
[0017] A further technical solution is to divide the new and old DWG drawing files into identical areas before comparing the basic graphics of each category respectively, and then compare the basic graphics of each category for each identical area.
[0018] A further technical solution is to perform the comparison of basic graphics of different categories in parallel and the comparison of basic graphics in different areas in parallel.
[0019] In a second aspect, the present invention provides a DWG drawing comparison system.
[0020] A DWG drawing comparison system, comprising:
[0021] The basic graphics extraction module is used to obtain the old and new DWG drawing files to be compared, and read and decompose the basic graphics in the drawing files respectively;
[0022] The list generation module is used to classify basic graphics and construct basic graphics lists of different categories in the new and old DWG drawing files; each category of the basic graphics list includes all basic graphics of the category in the drawing file, and each basic graphic has corresponding key attributes;
[0023] A comparison module is used to compare all basic graphics of each category respectively, traverse all basic graphics in the two-column basic graphics list of each category, compare the two basic graphics according to key attributes, and generate a comparison result;
[0024] The comparison result output module is used to mark the basic graphics with different colors based on the comparison results, and finally output the drawing comparison results.
[0025] In a third aspect, the present invention further provides an electronic device comprising a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the steps of the method described in the first aspect are completed.
[0026] In a fourth aspect, the present invention further provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the steps of the method described in the first aspect.
[0027] One or more of the above technical solutions have the following beneficial effects:
[0028] The present invention provides a DWG drawing comparison method and system, which read and decompose basic graphics of different categories in DWG drawings, perform traversal comparison according to the basic graphics, and mark according to the comparison results, so as to realize simpler, more efficient and accurate drawing comparison; discard the same basic graphics that have been compared during the traversal process, so as to reduce the number of searches for subsequent graphics; perform the comparison by region, so as to reduce the number of calculations; the comparison processes of different categories and different regions are all processed in parallel by multi-threading, so as to reduce the comparison time; through the above-mentioned performance optimization methods of reducing the number of comparisons, partition comparison and parallel processing, the performance of drawing comparison is further improved, and while ensuring the accuracy of the comparison results, the comparison efficiency is improved and the comparison time is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0030] Figure 1 This is an overall flow chart of the DWG drawing comparison method according to an embodiment of the present invention;
[0031] Figure 2 A schematic diagram of a basic graphics list of different categories in two old and new DWG drawing files in an embodiment of the present invention;
[0032] Figure 3 A schematic diagram of a basic graphic list of straight line categories of new and old drawings in an embodiment of the present invention;
[0033] Figure 4 It is a schematic diagram of the result of comparing and verifying the new and old drawings in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] It should be noted that the following detailed descriptions are exemplary only, are intended to describe specific embodiments, are intended to provide further explanation of the present invention, and are not intended to limit exemplary embodiments according to the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those of ordinary skill in the art to which the present invention belongs. In addition, it should also be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0035] Embodiment 1
[0036] Considering that DWG drawing files contain multiple types / categories of graphics, most of which are composed of basic graphics. After decomposition, the basic graphics can be obtained. Therefore, the drawings and graphics are first decomposed before comparison, and then only the comparison of the basic graphics is processed during the comparison, thereby simplifying the drawing comparison process. Therefore, this embodiment provides a DWG drawing comparison method, such as Figure 1 As shown, including:
[0037] Obtain the old and new DWG drawing files to be compared, and read and decompose the basic graphics in the drawing files respectively;
[0038] Classify the basic graphics and construct basic graphics lists of different categories in the new and old DWG drawing files; each category of the basic graphics list includes all basic graphics of the category in the drawing file, and each basic graphic has corresponding key attributes;
[0039] Compare all basic graphics of each category respectively, traverse all basic graphics in the two-column basic graphics list of each category, compare the two basic graphics according to the key attributes, and generate the comparison result;
[0040] Based on the comparison results, different colors are used to mark the basic graphics, and the final drawing comparison results are output.
[0041] Specifically, obtain the old and new DWG drawing files to be compared, read and decompose the basic graphics in the old and new DWG drawing files respectively, and classify the basic graphics. The categories of the basic graphics include straight lines, single-line text, arrows, circles, rectangles, trapezoids, arcs, etc. For example, dimensioning consists of single-line text, straight lines, and fills (arrows), and multi-line text consists of single-line text. Then, create a list of basic graphics containing different categories of the old and new DWG drawing files, such as Figure 2 As shown in the figure, each category of basic graphics list includes all basic graphics of this category in the drawing file. Take the basic graphic of straight line as an example. Figure 3 As shown, the basic graphics list of the straight line category of the new and old drawings includes m and n straight line basic graphics respectively; in addition, each basic graphic has corresponding key attributes, and the key attributes of the basic graphic include the key point positions of the graphics, such as the key point positions of the straight line are the starting point and end point positions of the straight line, the key point positions of the circle are the center point position and radius of the circle, and the key positions of the arc are the center point, starting point and end point positions of the arc, etc.
[0042] After that, all basic graphics in each category are compared separately, and all basic graphics in the two-column basic graphics list of each category are traversed. The two basic graphics to be compared are compared according to the key attributes, and the comparison results are generated. According to the comparison results, the basic graphics are marked with different colors, and finally the drawing comparison results are output.
[0043] Specifically, during the comparison process, all basic graphics in the two-column basic graphic list of each category are traversed, that is: for the two-column basic graphic list of two categories to be compared, for a basic graphic in the first column of the basic graphic list, each basic graphic in the second column of the basic graphic list is traversed, and compared according to the key attributes. If there are two basic graphics with the same key attributes, the two basic graphics are considered to be the same, and the two basic graphics are saved in the comparison result, and the same color is used to mark them as the same graphics; if there are no two basic graphics with the same key attributes, the two basic graphics are considered to be different, and the two basic graphics are saved in the comparison result, and different colors are used to mark them as different graphics.
[0044] For example, if there is a straight line in the new drawing, a search is performed in the list of basic straight line graphics in the old drawing to find out whether there is a straight line whose starting point and end point are the same as those in the new drawing; if there are two basic graphics with the same key attributes, it is considered that there is an identical straight line in the two DWG files, that is, there are two identical basic graphics, and the two basic graphics (one of the straight lines) are saved in the comparison result and marked as the same graphics with the same color; otherwise, if there are no two basic graphics with the same key attributes, the straight line in the new drawing is considered to be a newly added graphic, and the two basic graphics are saved in the comparison result, and marked as different graphics with different colors, that is, the straight line is saved in the comparison result and marked as a graphic that only exists in the new drawing.
[0045] Based on the above comparison method, each basic graphic in the first column of the basic graphic list is traversed to complete the comparison of the two columns of the basic graphic list. After traversal, the drawing comparison result is finally output.
[0046] Furthermore, during the graphic comparison process, when traversing all the basic graphics in the two columns of basic graphic lists, when it is determined that there are two identical basic graphics, these two basic graphics are removed from their respective lists and the next basic graphic is compared, thereby reducing the number of searches for subsequent graphics.
[0047] For example, if there are m straight lines in the new drawing and n straight lines in the old drawing (n>=m), in the worst case, the number of calculations required to compare all the straight lines is n. m When m and n become larger, the time required for comparison will increase exponentially, which may lead to performance problems. By removing the same graphs found during the traversal process, the maximum number of comparisons can be reduced to Based on the currently provided drawings (containing 38,000 graphics, including 11,000 straight lines and 23,000 arcs), the time required for comparing the graphics was more than 28 seconds without removing the found graphics. However, if the found graphics were removed immediately, the time required for comparing the graphics was about 10 seconds, which is about 1 / 3 of the original time.
[0048] Furthermore, when there are many basic graphics of a certain type in the drawing, a large number of comparisons are still required to find the same graphics. Therefore, in this embodiment, before comparing the basic graphics of each category, the old and new DWG drawing files are divided into the same area, and then the basic graphics of each category are compared for each same area. By dividing the area, only searching locally can effectively reduce the number of comparisons required to find a graphic, thereby reducing the overall comparison time.
[0049] For example, if there are m straight lines in the new drawing and n straight lines in the old drawing, and if t regions are divided, the number of graphics in each region is set to an upper limit. If the number of graphics is still too large, the split interval can be reduced and the region can be split further to make the number of graphics in each region more balanced, and the maximum number of times required to compare all the straight lines is reduced to Based on the currently provided drawings (containing 38,000 graphics, including 11,000 straight lines and 23,000 arcs), after dividing the areas, the time required to compare the graphics is about 3.3 seconds, which is shortened to about 1 / 3 of the time when no areas are divided.
[0050] By dividing the area, we can effectively avoid the exponential growth of the comparison time when the number of graphics increases. The number of graphics in the drawings currently provided is about 38,000, which is the largest scale of drawings for customers. The area is divided only along the X axis. It has been verified that the improvement effect of dividing the area along the X and Y axes at the same time is not obvious. If the number of graphics in the drawing far exceeds the current scale, dividing the area along the X and Y axes at the same time should improve the calculation efficiency. If the DWG drawing file is three-dimensional data, the area can be divided along the X, Y, and Z axes.
[0051] Furthermore, considering that the graphics in the drawings are of different types, only the same type needs to be compared during comparison. Therefore, when the operating environment is suitable for multi-threading, the comparison of basic graphics of different categories can be performed in parallel; and for the same type of graphics, after the division of regions, the comparison of graphics in each region is also independent, and the comparison of basic graphics in different regions can be performed in parallel. Taking the current drawings with about 38,000 graphics as an example, after dividing the regions into 1,000 graphics per region, the comparison time of each region is reduced to tens to hundreds of milliseconds, and the number of regions is not large, and multi-threaded parallel computing is not used. If the number of graphics in the drawings far exceeds the current scale, you can consider using parallel computing to reduce the comparison time.
[0052] The following example verifies this. The number of basic graphics after decomposition in the DWG drawing is close to 38,000. The time for comparing the graphics alone is about 0.33 seconds, and the time for reading, comparing, and saving the comparison results to the DWG file is about 1.2 seconds. The comparison results are as follows: Figure 4 As shown in (a) (the drawing contains a large number of basic graphics, only the inconsistent parts are clearly displayed and emphasized here), the dark area in the figure is the inconsistent part, and the light area is the consistent part; the graphics in the drawing are copied twice, and the basic graphics are close to 76,000. The time for comparing the graphics alone is about 0.39 seconds, and the time for reading, comparing, and saving the comparison results to the DWG file is about 1.6 seconds. The comparison results are as follows Figure 4 As shown in (b), the dark area in the figure is the inconsistent part, and the light area is the consistent part. The graphics in the drawing are copied 4 times. At this time, there are nearly 150,000 basic graphics. The time for comparing the graphics is about 0.56 seconds, and the time for reading, comparing, and saving the comparison results to the DWG file is about 2.3 seconds. The comparison results are shown in Figure 4 As shown in (c), the dark area in the figure is the inconsistent part, and the light area is the consistent part; the graphics in the drawing are copied 8 times. At this time, there are nearly 300,000 basic graphics. The time for comparing the graphics alone is about 1.1 seconds, and the time for reading, comparing, and saving the comparison results to the DWG file is about 3.9 seconds. The comparison results are as follows Figure 4 As shown in (d), the dark area in the figure is the part where the comparison is inconsistent, and the light area is the part where the comparison is consistent. Obviously, the method described in this embodiment can achieve more efficient and accurate drawing graphic comparison, and as the number of drawing graphics increases, the comparison time will not increase exponentially, but can achieve further efficiency improvement.
[0053] Embodiment 2
[0054] This embodiment provides a DWG drawing comparison system, including:
[0055] The basic graphics extraction module is used to obtain the old and new DWG drawing files to be compared, and read and decompose the basic graphics in the drawing files respectively;
[0056] The list generation module is used to classify basic graphics and construct basic graphics lists of different categories in the new and old DWG drawing files; each category of the basic graphics list includes all basic graphics of the category in the drawing file, and each basic graphic has corresponding key attributes;
[0057] A comparison module is used to compare all basic graphics of each category respectively, traverse all basic graphics in the two-column basic graphics list of each category, compare the two basic graphics according to key attributes, and generate a comparison result;
[0058] The comparison result output module is used to mark the basic graphics with different colors based on the comparison results, and finally output the drawing comparison results.
[0059] Embodiment 3
[0060] This embodiment provides an electronic device, including a memory and a processor, and computer instructions stored in the memory and running on the processor. When the computer instructions are run by the processor, the steps in the DWG drawing comparison method as described above are completed.
[0061] Embodiment 4
[0062] This embodiment also provides a computer-readable storage medium for storing computer instructions. When the computer instructions are executed by a processor, the steps in the DWG drawing comparison method described above are completed.
[0063] The steps involved in the above embodiments 2 to 4 correspond to the method embodiment 1, and the specific implementation methods can refer to the relevant description part of embodiment 1. The term "computer-readable storage medium" should be understood as a single medium or multiple media including one or more instruction sets; it should also be understood to include any medium that can store, encode or carry an instruction set for execution by a processor and enable the processor to execute any method in the present invention.
[0064] Those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computer device, or alternatively, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. The present invention is not limited to any specific combination of hardware and software.
[0065] The above description is only a preferred embodiment of the present invention. Although the specific implementation mode of the present invention is described in conjunction with the accompanying drawings, it is not a limitation of the protection scope of the present invention. Those skilled in the art should understand that on the basis of the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative work are still within the protection scope of the present invention.
Claims
1. A DWG drawing comparison method, Its characteristics are: include: Obtain the old and new DWG drawing files to be compared, and read and decompose the basic graphics in the drawing files respectively; Classify the basic graphics and construct basic graphics lists of different categories in the new and old DWG drawing files; each category of the basic graphics list includes all basic graphics of the category in the drawing file, and each basic graphic has corresponding key attributes; Compare all basic graphics of each category respectively, traverse all basic graphics in the two-column basic graphics list of each category, compare the two basic graphics according to the key attributes, and generate the comparison result; Based on the comparison results, different colors are used to mark the basic graphics, and the final drawing comparison results are output.
2. The DWG drawing comparison method according to claim 1, Its characteristics are: The categories of the basic graphics include straight lines, single-line text, arrows, circles, rectangles, trapezoids, and arcs. The key attributes of the basic graphics include the positions of key points of the graphics.
3. The DWG drawing comparison method according to claim 1, Its characteristics are: For two categories of two lists of basic graphics to be compared, for a basic graphic in the first list of basic graphics, traverse each basic graphic in the second list of basic graphics and compare them according to key attributes. If there are two basic graphics with the same key attributes, the two basic graphics are considered to be the same, and the two basic graphics are saved in the comparison result, and the same graphics are marked with the same color; if there are no two basic graphics with the same key attributes, the two basic graphics are considered to be different, and the two basic graphics are saved in the comparison result, and different graphics are marked with different colors; Traverse each basic graphic in the first column of the basic graphic list to complete the comparison of the two columns of basic graphic lists.
4. The DWG drawing comparison method according to claim 3, Its characteristic is that In the process of traversing all the basic graphics in the two columns of basic graphic lists, when it is determined that there are two identical basic graphics, the two basic graphics are removed from their respective lists, and the comparison of the next basic graphic is performed.
5. The DWG drawing comparison method according to claim 1, Its characteristic is that Before comparing each category of basic graphics respectively, divide the old and new DWG drawing files into the same area, and then compare the basic graphics of each category for each same area.
6. The DWG drawing comparison method according to claim 5, Its characteristics are: The comparison of basic graphics of different categories is performed in parallel, and the comparison of basic graphics in different areas is performed in parallel.
7. A DWG drawing comparison system, Its characteristics are: include: The basic graphics extraction module is used to obtain the old and new DWG drawing files to be compared, and read and decompose the basic graphics in the drawing files respectively; The list generation module is used to classify basic graphics and construct basic graphics lists of different categories in the new and old DWG drawing files; each category of the basic graphics list includes all basic graphics of the category in the drawing file, and each basic graphic has corresponding key attributes; A comparison module is used to compare all basic graphics of each category respectively, traverse all basic graphics in the two-column basic graphics list of each category, compare the two basic graphics according to key attributes, and generate a comparison result; The comparison result output module is used to mark the basic graphics with different colors based on the comparison results, and finally output the drawing comparison results.
8. The DWG drawing comparison system as claimed in claim 7, Its characteristics are: The categories of the basic graphics include straight lines, single-line text, arrows, circles, rectangles, and trapezoids, and the key attributes of the basic graphics include the positions of key points of the graphics.
9. An electronic device, Its characteristics are: The method comprises a memory and a processor, and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the steps of a DWG drawing comparison method as described in any one of claims 1 to 6 are completed.
10. A computer-readable storage medium, Its characteristics are: Used to store computer instructions, which, when executed by a processor, complete the steps of a DWG drawing comparison method as described in any one of claims 1-6.
