Label grading avoiding arrangement method and system for two-dimensional drawing
Through the automatic layout method of labeling and grading avoidance for two-dimensional drawings, and using technical means such as scatter drawings and mirror partitions, the problems of low labeling and easy overlap in the existing technology are solved, and the automatic avoidance and reasonable layout of labeling are realized, which significantly improves the readability and aesthetics of the drawings.
Patent Information
- Application Number
- CN202510689150.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2045-05-27
AI Technical Summary
The existing CAD software lacks effective avoidance in labeling arrangement, which leads to labeling being prone to overlap and confusion, and requires a lot of manual intervention, which is inefficient.
A method of automatic layout of labeling and grading avoidance for two-dimensional drawings is proposed. By constructing scatter diagrams, mirror partitions and hierarchical avoidance arrangement strategies, automatic avoidance and reasonable layout of labeling is realized.
It effectively solves the overlapping problem of labeling in complex layouts, realizes uniform distribution of labeling in the drawing frame, significantly improves the readability and aesthetics of the drawings, and improves the automation and efficiency of labeling arrangements.
Smart Images

Figure CN120197250A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of engineering digitalization technology, and in particular to a method and system for arranging annotation hierarchical avoidance for two-dimensional drawings. Background Art
[0002] With the increasing complexity of modern engineering, the workload and difficulty of engineering drawing have increased significantly, which has put forward higher requirements for drawing efficiency and drawing quality. Computer-aided design (CAD) technology, with its parametric modeling and geometric calculation engine, has realized digital editing of graphics, coordinate transformation and massive data management, effectively improving the reusability and design standardization of drawings. However, in two-dimensional drawings, annotations are an important part of the drawings, but due to the fixed position of components in the drawings, there are spatial conflicts between annotations and components, and annotations often need to be flexibly moved to avoid components and other annotations to ensure the readability and aesthetics of the drawings.
[0003] Although existing CAD software such as AutoCAD can provide the function of exporting annotation characters, it lacks effective avoidance processing in the arrangement of annotations, which easily leads to overlapping and chaotic annotations. Although some avoidance methods have been used to adjust the annotation position by simple sliding, this method is inefficient and still requires a lot of manual intervention.
[0004] In response to the above problems, the present invention proposes a method for automatic arrangement of annotation hierarchical avoidance for two-dimensional drawings. This method can realize automatic avoidance and reasonable arrangement of annotations in the design of two-dimensional drawings with dense annotations. Designers do not need to manually adjust a large number of annotations one by one, thereby significantly reducing the drawing workload, shortening the drawing cycle, and improving drawing efficiency. Summary of the invention
[0005] The present disclosure provides a method and system for hierarchical avoidance arrangement of annotations for two-dimensional drawings, which can realize automatic avoidance and reasonable arrangement of annotations in the design of two-dimensional drawings with dense annotations, effectively solve the overlapping problem of annotations in complex layouts, and realize uniform distribution of annotations in the drawing frame, significantly improving the overall readability and aesthetics of the drawings, while greatly improving the automation level and efficiency of annotation arrangement.
[0006] In a first aspect, the present disclosure provides a method for arranging annotations in a hierarchical avoidance manner for a two-dimensional drawing, comprising: Step S1: Obtain the two-dimensional CAD drawing data to be processed; Step S2: construct a scatter plot, fit a cutting path according to the scatter plot and execute cutting to generate a frame; Step S3: performing mirror partitioning according to the center of gravity of the pipeline object within the frame range; Step S4: Arrange the annotations in an offset avoidance manner based on a hierarchical avoidance arrangement strategy.
[0007] In some embodiments, the two-dimensional drawing data includes at least pipeline objects and annotations.
[0008] In some embodiments, step S2 includes: constructing a scatter plot, calculating a cutting path according to the scatter plot, and continuously cutting along the cutting path according to the cutting unit to obtain at least one rectangular drawing frame.
[0009] In some embodiments, step S3 includes: Step S31: Centroid calculation: within the range of the drawing frame, calculate the centroid of all pipeline objects in the drawing frame by averaging the coordinates of the midpoints of all pipe segments; Step S32: Mirror partitioning: using the axis where the centroid is located as the dividing line, divide the drawing frame into an upper half area and a lower half area, and divide each pipe segment object into the corresponding area according to the coordinates of the midpoint of the pipe segment object, where the axis where the centroid is located is a straight line passing through the centroid and parallel to the horizontal border of the drawing frame.
[0010] In some embodiments, step S4 includes: Step S41: Select a target total annotation width, where the target total annotation width includes an annotation width and an annotation interval width; Step S42: Arrange the annotations within the pipe segment object using a two-way offset arrangement algorithm; Step S43: After completing the offset avoidance arrangement within the pipe segment object, use a nearest avoidance algorithm within the layoutable space to arrange the annotations between pipe segment objects.
[0011] In some embodiments, the two-way offset arrangement algorithm includes: 1) Sort the annotations within the pipe segment object according to the left-right order of the annotation leader starting points and determine a first sorting number; 2) Using the reference line as the central axis, calculate the offset of each annotation within the pipe segment object based on the principle of uniform distribution of an arithmetic sequence and perform an automated offset avoidance arrangement.
[0012] In some embodiments, the nearest avoidance algorithm within the layoutable space includes: 1) For a half area of the drawing frame, first sort the annotation sets of each pipe segment object according to the left-right order of the midpoint coordinates of each pipe segment object and determine a second sorting number; 2) Calculate the layoutable space of the annotation set block corresponding to the current pipe segment object; The layoutable space of the annotation set block with the second sorting number of j ( ) is calculated as follows: ; In the formula, , x represents the target total annotation width, Represents the annotation width, and m represents the interval width between annotations. Represents the drawing frame width. Represents the number of annotations in the j-th annotation set block. Represents the total number of annotations in all annotation set blocks that are in the same half area as the j-th annotation set block and are on the right side of the j-th annotation set block, that is , Represents the offset of the (j - 1)-th annotation set block. Set When , ; j represents the second sorting number of the annotation set block, j is an integer, and ; 3) Determine the nearest offset of the annotation set block corresponding to the current pipe segment object , and perform automatic offset avoidance layout. Among them, the nearest offset is the offset with the shortest parallel distance between the central axis of the current annotation set block and the reference line where the midpoint of the current pipe segment object is located within the layout space of the annotation set block corresponding to the current pipe segment object ; 4) Repeat the above steps 2) - 3) to determine the offsets of each annotation set in this half area ; 5) For the other half of the drawing frame, repeat the above steps 1) - 4).
[0013] In some embodiments, step S41 includes: 1) Calculate the maximum value that can be set for the total annotation width based on the drawing frame width and the first annotation quantity, and determine the maximum value that can be set for the annotation width in combination with the minimum value of the annotation interval width; 2) Determine whether the maximum value that can be set for the annotation width is not less than the minimum value of the first preset range. If so, proceed to step 3). If not, prompt the user to select a larger-sized drawing frame or reduce the number of annotations; 3) Determine the second preset range based on the first preset range and the maximum value that can be set for the annotation width, and display the second preset range to the user; in response to the selected annotation width by the user, determine the value range of the annotation interval width, and calculate the target total annotation width based on the selected annotation interval width by the user.
[0014] In some embodiments, step S2 includes: 1) Construct a scatter plot and calculate the width of the banded area where the scatter points are distributed; 2) Select the drawing frame size and scale the banded area where the scatter points are distributed; 3) Fit the cropping path based on the scatter plot and determine the cropping unit. The cropping unit is the drawing frame width minus the reserved redundancy; 4) Along the cutting path, perform step-by-step cutting with the cutting unit as the step size to generate a drawing frame.
[0015] In a second aspect, the present disclosure provides a hierarchical avoidance layout system for two-dimensional drawings, which is used to execute the hierarchical avoidance layout method for two-dimensional drawings. The system includes: A drawing acquisition module, which is used to acquire two-dimensional CAD drawing data to be processed; A drawing frame generation module, which is used to construct a scatter plot, fit the cutting path according to the scatter plot and execute cutting to generate a drawing frame; A mirror partition module, which is used to perform mirror partitioning within the drawing frame according to the center of gravity of the pipeline object; An automatic layout module, which is used to perform offset avoidance layout on the annotations based on the hierarchical avoidance layout strategy.
[0016] The beneficial effect of the present disclosure is that, compared with the prior art, the present disclosure has the following advantages: 1) The implementation scheme of the present disclosure is applicable to the intelligent annotation layout optimization of various pipeline network CAD drawings (such as urban underground water pipe networks, power line networks, gas pipelines, etc.). By optimizing the layout of annotations hierarchically, first perform local layout optimization of annotations within the pipe segment object to ensure that the annotations within each pipe segment object are evenly distributed and do not overlap; then perform global optimization between pipe segment objects. By accurately calculating the offset of each annotation set block, avoid interference between annotations of different pipe segment objects. On the one hand, this method splits the problem of global annotation layout optimization into first-level avoidance with linear complexity (within the pipe segment object) and second-level avoidance with polynomial complexity (between pipe segment objects). Through the hierarchical layout strategy, the time complexity of the algorithm is reduced from O(n²) to O(n log n), significantly improving the processing speed of large-scale pipeline network drawings; on the other hand, this method not only effectively solves the overlap problem of annotations in complex layouts, but also realizes the even distribution of annotations within the drawing frame, significantly improving the overall readability and aesthetics of the drawing, and at the same time greatly improving the automation degree and efficiency of annotation layout.
[0017] 2) When validating the frame accommodation capacity in the embodiments of the present disclosure, based on the actual engineering application requirements, the first preset range is used as the parameter range of the annotation width to ensure clear and easy-to-identify font display. According to whether the maximum value of the annotation width meets the minimum requirement of the first preset range, it can be accurately determined whether the frame has the ability to accommodate all annotations. If it is found that the frame does not have the ability to accommodate all annotations, the user is prompted to select a larger-sized frame or reduce the number of annotations in a timely manner, avoiding problems such as overlapping annotations or unclear font display due to insufficient space. Moreover, on the basis of meeting the accommodation capacity, the user is allowed to flexibly select the annotation width within the second preset range according to actual needs. This free setting mechanism not only ensures a reasonable layout of annotations within the frame but also meets the personalized requirements of different projects for the aesthetics and clarity of annotations.
[0018] 3) By combining the concave hull polygon algorithm, appropriate scaling strategy, setting of cropping redundancy, and coverage inspection and correction, the embodiments of the present disclosure significantly improve the accuracy and efficiency in the cropping process, ensuring the precision of subsequent automatic annotation layout. This method optimizes the cropping process, reduces manual intervention, and improves the processing speed and automation level of large-scale data sets. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0020] Figure 1 It is a schematic flowchart of a method for hierarchical avoidance layout of annotations for two-dimensional drawings provided by an embodiment of the present disclosure; Figure 2 It is an annotation example for two-dimensional drawings provided by an embodiment of the present disclosure; Figure 3 It is a schematic diagram of mirror partitioning provided by an embodiment of the present disclosure; Figure 4 It is a schematic flowchart of a method for offset avoidance layout of annotations based on a hierarchical avoidance layout strategy provided by an embodiment of the present disclosure; Figure 5 It is a schematic diagram of annotation layout in a frame provided by an embodiment of the present disclosure; Figure 6 It is a schematic diagram of annotation layout within a pipe segment provided by an embodiment of the present disclosure; Figure 7 It is a schematic flowchart of a two-way offset layout algorithm provided by an embodiment of the present disclosure; Figure 8 It is a schematic diagram of annotation layout between pipe segments provided by an embodiment of the present disclosure; Figure 9 It is a schematic flowchart of a nearest avoidance algorithm within a layoutable space provided by an embodiment of the present disclosure; Figure 10 Schematic diagram of the annotation hierarchical avoidance layout system for two-dimensional drawings provided by the embodiments of the present disclosure.
[0021] Through the above-mentioned drawings, specific embodiments of the present disclosure have been shown, and more detailed descriptions will be given hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present disclosure in any way, but to illustrate the concept of the present disclosure to those skilled in the art by referring to specific embodiments. Detailed implementation manners
[0022] The present disclosure will be further described below with reference to the drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present disclosure and cannot be used to limit the protection scope of the present disclosure.
[0023] It should be noted that the step sequence of the present disclosure is only for illustrative purposes. During actual execution, the sequence can be adjusted as needed, or some steps can be executed in parallel, unless the execution of a certain step clearly depends on the result of the previous step. Otherwise, the sequence between steps does not constitute a limitation to the present disclosure.
[0024] The annotation hierarchical avoidance layout method and system for two-dimensional drawings provided by the present disclosure are developed based on a CAD graphics-aided design platform (such as AutoCAD, MicroStation, etc.). It can be used as an independent plugin or integrated into the CAD platform, and is mainly applied to the intelligent annotation layout optimization of CAD drawings of various pipeline networks (such as urban underground water pipe networks, power line networks, gas pipelines, etc.).
[0025] As Figure 1 shown, this embodiment provides an annotation hierarchical avoidance layout method for two-dimensional drawings, which is applied to a CAD platform and includes the following steps: Step S1: Obtain two-dimensional CAD drawing data to be processed; Specifically, the two-dimensional drawing data can be obtained through methods such as importing electronic files (such as DWG or DXF formats), database query, or manual input, and stored in a structured form for subsequent processing. In this embodiment, the drawing data is obtained by database query. The database can be deployed on a local computing device or in the cloud. The data in the database is checked and entered by construction personnel on-site, and json format data is obtained through the database query interface for drawing the drawings.
[0026] In this embodiment, the drawing data includes a two-dimensional pipeline model drawn using Polyline or Line entities (it can be understood that the "pipeline object" and "pipe segment object" mentioned in the method steps of the following embodiments refer to entity objects in the model space), which is used to describe the annotation of defect point information and the leader line for pointing the annotation to the defect point position. Among them, the pipeline entity attributes include layer information, geometric position coordinate data, defect point position information, length parameters, and the pipeline number in the extended attributes; the defect point annotation is stored in an independent annotation layer, and is associated with the defect point in the corresponding pipeline entity through the leader line annotation, and includes extended attribute data such as defect description and repair measures.
[0027] The system extracts the geometric data and attribute information of the above entity objects by parsing the data structure of the CAD drawing, providing a data basis for subsequent processing.
[0028] Among them, the defect description and repair measures are the annotations to be processed, and will ultimately be drawn in the two-dimensional drawing in the form of leader line annotations. Examples of defect information and repair measure annotations are as Figure 2 shown, including the defect description "2nd level rupture at 2.7 meters of 53YS0041 - 53YS0038", and the repair measures "Mechanically fabricated spiral wound lining method + segment lining method (3S module method)"; where "53YS0041 - 53YS0038" is the pipe segment number, a 2nd level rupture defect appears at 2.7 meters of this pipe segment, and two measures of "mechanically fabricated spiral wound lining method" and "segment lining method (3S module method)" are required to repair this defect.
[0029] Step S2: Construct a scatter plot, fit the cropping path according to the scatter plot, and execute cropping to generate a drawing frame; In this embodiment, the annotation objects in the two-dimensional drawing are pipelines (such as urban groundwater pipelines, etc.), and the defect descriptions and repair measure annotations to be processed are marked at the defect points on the pipelines through leader lines. Therefore, the endpoints and midpoints of the pipe segment objects of all pipeline objects in the pipeline network object can be used as sampling points, and a scatter plot is constructed by extracting the endpoint and midpoint coordinates of the pipe segment objects. Since various pipelines (such as urban groundwater pipelines, etc.) are mainly distributed along both sides of the road, the scatter plot is also roughly distributed in a strip along the road.
[0030] It should be noted that the division method of the pipe segments on the pipeline can adopt, for example, the length fixed-distance method, the turning point / node method, etc., and the present disclosure does not make specific limitations on this.
[0031] When constructing a scatter plot, generally the sampling method is adopted, and representative sampling points are selected to accurately reflect the distribution of the target elements.
[0032] Subsequently, the cutting path is calculated based on the scatter plot. Along the cutting path, continuous cutting is performed in sequence according to the cutting unit to obtain at least one rectangular drawing frame.
[0033] Among them, the cutting path is a curved path calculated by fitting according to the distribution of the scatter plot. The algorithm for calculating the cutting path by fitting according to the distribution of the scatter plot in this embodiment can adopt existing technologies, such as the least squares method, B-spline curve, etc. The present disclosure does not make specific limitations thereto. The calculated cutting path in this embodiment is close to the road central axis.
[0034] Optionally, the cutting unit can be a unit of the preset drawing frame width, or the set cutting unit is slightly smaller than the drawing frame width.
[0035] In this embodiment, the drawing frame can select standard A0, A1, A2, or A3 drawing sheets, etc. Optionally, the preset drawing frame width adopts the drawing frame width of the standard A3 drawing sheet. The width of the standard A3 drawing sheet is 420 mm, the height is 297 mm, the drawing area width is 385 mm, and the height is 277 mm. The drawing area of 385 mm * 277 mm is the drawing frame size for cutting. Specifically, in the cutting process, when the drawing frame width is selected as the cutting unit, the specific operation is as follows: starting from the starting point of the curved path, continuous cutting is performed in sequence with a standard of 385 mm as the cutting unit to generate multiple rectangular drawing frames.
[0036] The subsequent steps are calculation and processing performed separately within each drawing frame.
[0037] Step S3: Perform mirror partitioning according to the centroid of the pipeline object within the drawing frame range; In this embodiment, considering that various pipelines (such as urban underground water pipelines, etc.) are mainly distributed in a strip shape along both sides of the road, therefore, vertical mirror partitioning is first performed on each pipe segment object of the pipeline object.
[0038] In an optional implementation manner, the step S3 specifically includes: Step S31: Centroid calculation: Within the drawing frame range, calculate the centroid of all pipeline objects in the drawing frame by taking the average value of the coordinates of the midpoints of all pipe segment objects.
[0039] Step S32: Mirror partitioning: Taking the axis where the centroid is located as the dividing line, divide the drawing frame into an upper half area and a lower half area. According to the coordinates of the midpoints of the pipe segment objects, divide each pipe segment object into the corresponding area. In this embodiment, the axis where the centroid is located refers to the straight line passing through the centroid and parallel to the horizontal border of the drawing frame. As Figure 3 shown, the pipe segment objects with midpoints in the upper half area belong to the upper half area, and the annotations contained therein are arranged in the upper half area. The pipe segment objects with midpoints in the lower half area belong to the lower half area, and the annotations contained therein are arranged in the lower half area.
[0040] It can be seen that the mirror partition utilizes the strip characteristics of pipelines (such as urban underground water pipelines, etc.) distributed along the road. By calculating the centroid of the pipeline object to construct the mirror dividing line, the drawing frame is divided into two independent arrangement areas above and below. The originally concentrated annotations are divided into area ownership according to the spatial position of the pipe segment object, so as to split the global annotation avoidance arrangement into local arrangement optimization calculations, effectively reducing the calculation complexity, and then improving the processing speed of large-scale pipe network drawings.
[0041] Step S4: Perform offset avoidance arrangement on the annotations based on the hierarchical avoidance arrangement strategy.
[0042] Generally, each drawing frame includes several pipe segment objects, and each pipe segment object includes several annotations. The pipe segment objects are in a parallel relationship with each other. Therefore, when arranging the annotations, not only need to consider how to arrange the annotations within the pipe segment object, but also need to consider how to arrange the annotations between different pipe segment objects. As Figure 5 shown, the outer rectangle is the drawing frame, and this drawing frame contains six pipe segment objects, and each pipe segment object contains several annotations.
[0043] Therefore, this hierarchical avoidance arrangement strategy can be divided into two levels: avoidance within the pipe segment object and avoidance between the pipe segment objects. Among them, the avoidance within the pipe segment object is the first-level avoidance, and the avoidance between the pipe segment objects is the second-level avoidance. Therefore, to arrange all the annotations based on the hierarchical avoidance arrangement strategy, it is necessary to first perform local arrangement on the annotations within the pipe segment object, and then perform avoidance arrangement between the annotations of different pipe segment objects (that is, within the pipe segment objects within the drawing frame), and finally realize the optimization of the global annotation arrangement.
[0044] In an optional implementation manner, as Figure 4 shown, the step S4: Perform offset avoidance arrangement on the annotations based on the hierarchical avoidance arrangement strategy specifically includes: Step S41: Select the total width of the target annotation, and the total width of the target annotation includes the annotation width and the annotation interval width; In actual engineering, in order to ensure that the annotation font is clearly displayed, it is usually necessary to set a parameter range for the annotation width and the annotation interval width. The user selects the total width of the target annotation including the annotation width and the annotation interval width within the parameter range, and thus obtains the final total width of the annotation. It can be understood that the length of the annotation can be preset according to the actual engineering requirements. Since the annotation arrangement optimization mainly considers the avoidance arrangement in the annotation width direction, the setting of the annotation length is not limited here.
[0045] Step S42: Use the two-way offset arrangement algorithm to arrange the annotations within the pipe segment object; In this embodiment, an axis passing through the midpoint of the pipe segment object and perpendicular to the direction of the mirror partition dividing line is defined as the reference line, as Figure 6As shown in the figure, the dashed line in the figure is the reference line of the pipe segment object. The offset d of the annotation is defined as the parallel distance between the central axis of the annotation and the reference line, that is, when the central axis of the annotation is on the reference line, the offset d = 0; when the central axis of the annotation is on the right side of the reference line, the offset d>0; when the central axis of the annotation is on the left side of the reference line, the offset d<0. Among them, the rectangular box is the area range actually occupied by the annotation. In engineering drawings, annotations usually appear in the form of rectangular boxes.
[0046] The central axis of the annotation refers to a straight line passing through the center point of the annotation box and parallel to the long side of the annotation box, and the annotation box is a rectangular box used to replace the form of the annotation.
[0047] In an alternative embodiment, referring to Figure 7 , the two-way offset arrangement algorithm specifically includes: 1) Sort the annotations in the pipe segment object according to the left-right order of the starting points of the annotation leads and determine the first sorting number; Specifically, before calculating the offset of each annotation, it is first necessary to sort the annotations in the pipe segment object. Since the starting point of the annotation lead is a defect point on the pipe segment object and the position of the defect point is fixed, the annotations can be sorted according to the left-right order of the lead starting points. As Figure 6 shown, there are n annotations in this pipe segment object, and the first sorting numbers of the annotations from left to right are 0 to n-1.
[0048] 2) Taking the reference line as the central axis, calculate the offset of each annotation in the pipe segment object based on the principle of uniform distribution of arithmetic progression and perform automatic offset avoidance arrangement; Processing the offset based on the principle of uniform distribution of arithmetic progression can evenly arrange the annotations in the pipe segment object at equal intervals.
[0049] The offset of the annotation with the first sorting number is calculated as follows:
[0050] It can be seen that in the formula is an arithmetic progression with a common difference of , where , x represents the total width of the target annotation, represents the width of the annotation, represents the interval width between annotations, n is the number of annotations in this pipe segment, represents the first sorting number of the annotation, is an integer, and .
[0051] Finally, based on the offset of each annotation and the position of the baseline, the annotations within the pipe segment object are automatically offset and arranged to ensure that there is no overlap between the annotations. Thus, it can ensure that the annotations within the pipe segment object are evenly distributed near the central area of the pipe segment object, realizing the optimized arrangement of the annotations within the pipe segment object.
[0052] Step S43: After completing the offset avoidance arrangement within the pipe segment object, use the nearest avoidance algorithm within the layout space to arrange the annotations between pipe segment objects; It can be understood that after the avoidance processing within the pipe segment object, several annotations within each pipe segment object form an annotation set block. Define the central axis of the annotation set block as the axis that is collinear with the baseline in step S42 before the avoidance between pipe segment objects, and the width of each annotation set block is , where x represents the total width of the target annotation, represents the number of annotations in the j-th annotation set block.
[0053] As Figure 8 shown, the dashed rectangles in the figure are the annotation set blocks of the pipe segment object, and they will be used as a whole for the avoidance calculation between pipe segment objects. In this embodiment, define the parallel distance from the central axis of each annotation set block (i.e., the central axis of the dashed rectangle) to the left side line of the drawing frame as the offset of the annotation set block. Then the key to the avoidance between pipe segments is to calculate the offset corresponding to the annotation set block of each pipe segment object.
[0054] According to the ideological theory in operations research of first clarifying the constraint conditions and then finding the extreme value under the constraint conditions, a nearest avoidance algorithm within the layout space is obtained. After completing the offset avoidance arrangement within the pipe segment object, use the nearest avoidance algorithm within the layout space to perform the offset avoidance arrangement between pipe segment objects.
[0055] It should be noted that the drawing frame has been divided into two upper and lower half areas, and the two half areas should be sorted and subsequent calculations independently without interference; however, the processing methods for the two half areas are exactly the same.
[0056] Referring to Figure 9 , the specific implementation steps of the nearest avoidance algorithm within the layout space are as follows: 1) For the half area of the drawing frame, first sort the annotation set blocks of each pipe segment object according to the left-right order of the midpoint coordinates of each pipe segment object, and determine the second sorting number; Specifically, sort the annotation set blocks of the pipe segment objects according to the left-right order of the midpoint coordinates of each pipe segment object. As Figure 8 shown, there are N annotation set blocks in this half area of the drawing frame, numbered from left to right in sequence, and thus the range of the second sorting number is determined to be from 0 to N - 1.
[0057] 2) Calculate the available layout space of the annotation set block corresponding to the current pipe segment object ( ); The available layout space of the annotation set block with the second sorting number j ( ) is calculated as follows: ;
[0058] In the formula, , x represents the total width of the target annotation, represents the annotation width, m represents the interval width between annotations, represents the drawing frame width, represents the number of annotations in the j-th annotation set block, represents the total number of annotations of all annotation set blocks that are in the same half area (upper half area or lower half area) as the j-th annotation set block and are on the right side of the j-th annotation set block, that is , represents the offset of the (j - 1)-th annotation set block. When , , ; j represents the second sorting number of the annotation set block, j is an integer, and .
[0059] The "available layout space" is the drawing frame area that enables the annotation set block of the current pipe segment object not to overlap with the annotation set blocks of other pipe segment objects. Among them, represents the minimum offset value at which the annotation set block with the second sorting number j does not overlap with adjacent annotation set blocks, represents the maximum offset value at which the annotation set block with the second sorting number j does not overlap with adjacent annotation set blocks, and both constitute the constraint interval for the layout of the annotation set block of the current pipe segment object, that is, the available layout space; 3) Determine the nearest offset of the annotation set block corresponding to the current pipe segment object , and perform automatic offset avoidance arrangement. Among them, the nearest offset is the offset with the shortest parallel distance between the central axis of the current annotation set block and the reference line where the midpoint of the current pipe segment object is located within the available layout space ( ) of the annotation set block corresponding to the current pipe segment object .
[0060] The available layout space ( ) can all achieve non-overlap between the annotation set block of the current pipe segment object and the annotation set blocks of other pipe segment objects. However, the central axis of the current annotation set block (the central axis of the dashed rectangle frame) and the reference line where the midpoint of the current pipe segment object is located (that is Figure 6When it is closest to the (middle dotted line), the dimension leader can be the shortest and the layout can be the most beautiful. According to this method, the nearest offset can be obtained within the layout space ( ) .
[0061] 4) Repeat the above steps 2) - step 3) to determine the offset of each dimension set block in this half area , and automatically offset and arrange each dimension set block between pipe segment objects according to the offset of each dimension set block to ensure that there is no overlap in the arrangement between the dimension set blocks of different pipe segment objects.
[0062] As an example scheme, assume the following parameters: , , , the width of the drawing frame , the number of upper half area dimensions , , , ; then according to the calculation: , , ; according to the nearest avoidance algorithm calculation in the layout space, it can be obtained that: When, the layout space is (6mm, 352mm). Among them, is the offset when the central axis of the dimension set block is closest to the reference line where the midpoint of the current pipe segment object is within the layout space (6mm, 352mm). When and , the processing method is the same as above.
[0063] 5) For the other half of the drawing frame, repeat the above steps 1) - step 4), that is, use the same processing method to arrange the dimensions between pipe segment objects in the two half areas.
[0064] This ensures that there is no overlap between the dimension set blocks of different pipe segment objects, and they are distributed as evenly as possible near the central area of each pipe segment object, so as to realize the optimized arrangement of all dimensions within the drawing.
[0065] In this embodiment, by optimizing the arrangement of annotations hierarchically, the local arrangement of annotations within the pipe segment object is optimized first to ensure that the annotations within each pipe segment object are evenly distributed and non-overlapping. Subsequently, global optimization is performed among the pipe segment objects. By accurately calculating the offsets of each annotation set block, mutual interference between the annotations of different pipe segment objects is avoided. On the one hand, this method splits the problem of global annotation arrangement optimization into a first-level avoidance with linear complexity (within the pipe segment object) and a second-level avoidance with polynomial complexity (between the pipe segment objects), greatly reducing the computational complexity and significantly improving the processing speed of large-scale pipe network drawings. On the other hand, this method not only effectively solves the problem of annotation overlap in complex layouts but also achieves the even distribution of annotations within the drawing frame, improving the readability, overall aesthetics, and automation efficiency of the drawings.
[0066] In an alternative embodiment, in step S41: select the target total annotation width, where the target total annotation width includes the annotation width and the annotation interval width. The specific operation steps are as follows: 1) Calculation of the maximum value that can be set for the annotation width. Calculate the maximum value that can be set for the total annotation width based on the drawing frame width and the number of the first annotations, and determine the maximum value that can be set for the annotation width in combination with the minimum value of the annotation interval width.
[0067] To ensure that all annotations can be accommodated within the drawing frame, it is necessary to first determine the maximum value that can be set for the annotation width.
[0068] In actual engineering, to ensure that the annotation font is clearly displayed, it is usually necessary to set a parameter range for the annotation interval width. For example, the minimum value of the annotation interval width can be set to a fixed value (such as 0.5 mm), or determined proportionally according to the annotation width (for example ).
[0069] Specifically, calculating the maximum value that can be set for the total annotation width based on the drawing frame width and the number of the first annotations, and determining the maximum value that can be set for the annotation width in combination with the minimum value of the annotation interval width includes: Obtain the number of annotations in the half area with more annotations among the upper and lower half areas as the number of the first annotations, denoted as , obtain the drawing frame width L. The calculation formula for the maximum value that can be set for the total annotation width is: .
[0070] Finally, calculate the maximum value that can be set for the annotation width according to the minimum value of the annotation interval width.
[0071] 2) Verification of the drawing frame accommodation capacity. Determine whether the maximum value that can be set for the annotation width is not less than the minimum value of the first preset range. If so, proceed to step 3). If not, prompt the user to select a larger-sized drawing frame or reduce the number of annotations; In actual engineering, in order to ensure that the dimensioning font is clearly displayed, it is usually necessary to set parameter ranges for the dimensioning width and the dimensioning interval width. For example, the preset parameter range of the dimensioning width usually ranges from 2.5 mm to 10 mm.
[0072] In this step, the first preset value range of the dimensioning width is the preset parameter range of the dimensioning width. For example, in actual engineering, the first preset range of the dimensioning width usually ranges from 2.5 mm to 10 mm.
[0073] When verifying the accommodating capacity of the drawing frame, the following specific situations are included: If the maximum value that the dimensioning width can be set is not less than the minimum value of the first preset range, it means that the drawing frame can accommodate all the dimensionings, and proceed to step 3); If the maximum value that the dimensioning width can be set is less than the minimum value of the first preset range, it means that the drawing frame cannot accommodate all the dimensionings. At this time, the user should be prompted to select a larger-sized drawing frame or reduce the number of dimensionings.
[0074] Specifically, taking the minimum value of the above first preset value range , as an example, the total dimensioning width , assuming that there are 128 dimensionings in the half area with a larger number of dimensionings in the drawing frame, then in an A3 standard drawing frame, the maximum value that the total dimensioning width can be set is . At this time, it can just accommodate all the dimensionings. However, in extreme cases, for example, if the number of dimensionings in the half area with a larger number of dimensionings in a drawing frame exceeds 128, the maximum value that the dimensioning width can be set will be less than 2.5 mm, which cannot meet the requirement of the minimum value of the first preset range, indicating that the drawing frame cannot accommodate all the dimensionings. At this time, the user should be prompted to select a larger-sized drawing frame or reduce the number of dimensionings to ensure that all the dimensionings can be accommodated.
[0075] 3) Setting the target total dimensioning width. Determine the second preset range according to the first preset range and the maximum value that the dimensioning width can be set, and display the second preset range to the user; In response to the dimensioning width selected by the user, determine the value range of the dimensioning interval width, and calculate the target total dimensioning width according to the dimensioning interval width selected by the user.
[0076] Specifically, in this embodiment, the second preset range is displayed to the user through the user interface. The second preset range is jointly determined by the first preset range and the maximum value that the dimensioning width can be set. For example, if it is obtained that the maximum value that the total dimensioning width can be set is 4 mm, and the minimum value of the dimensioning interval width , then the maximum value that the dimensioning width can be set is 3.5 mm. At this time, determine the second preset range as (2.5 mm - 3.5 mm). Another example, if it is obtained that the maximum value that the total dimensioning width can be set is 12 mm, and the minimum value of the dimensioning interval width , the maximum value of the marked width can be set to 11.5 mm. At this time, the second preset range is determined to be (2.5 mm - 10 mm).
[0077] That is to say, within the second preset range, the user can select the marked width according to actual needs, and all marks can be ensured to be accommodated in the drawing frame.
[0078] After the user selects the marked width within the second preset range, the maximum value that can be set for the marked interval width is obtained by subtracting the marked width selected by the user from the maximum value that can be set for the total marked width calculated in step 1), thereby determining the value range of the marked interval width. For example, when the maximum value that can be set for the total marked width is 4 mm and the user selects a marked width of 3 mm within the second preset range (2.5 mm - 3.5 mm), the maximum value that can be set for the marked interval width is 1 mm. Therefore, the value range of the marked interval width is (0.5 mm - 1 mm). Finally, the target total marked width is determined according to the marked interval width selected by the user.
[0079] Further optionally, it further includes: in response to the user selecting a larger-sized drawing frame, returning to step S2 for re-cutting the drawing.
[0080] When verifying the accommodation capacity of the drawing frame in this embodiment, based on the actual engineering application requirements, the first preset range (such as 2.5 mm to 10 mm) is used as the parameter range of the marked width to ensure that the font is clearly displayed and easy to identify. Whether the maximum value that can be set for the marked width meets the minimum requirement of the first preset range can accurately judge whether the drawing frame has the ability to accommodate all marks. If it is found that the drawing frame does not have the ability to accommodate all marks, the user is prompted in time to select a larger-sized drawing frame or reduce the number of marks, avoiding problems such as mark overlap or unclear font display due to insufficient space.
[0081] Furthermore, on the basis of meeting the accommodation capacity, a second preset range (such as 2.5 mm to 3.5 mm) is introduced to allow the user to flexibly select the marked width according to actual needs. This free setting mechanism satisfies the personalized requirements of different projects for the aesthetics and clarity of marks while ensuring a reasonable layout of marks within the drawing frame. By intuitively showing the user the second preset range and the value range of the marked interval width, it is convenient for the user to quickly select parameters within a reasonable range, reducing the complexity of parameter setting. In addition, in extreme cases, if the drawing frame cannot accommodate all marks, the system will actively prompt the user to select a larger-sized drawing frame or reduce the number of marks, avoiding the inconvenience caused by the user repeatedly adjusting parameters.
[0082] In an alternative embodiment, the step S2: constructing a scatter plot, fitting a cutting path according to the scatter plot and performing cutting to generate a drawing frame includes the following steps: 1) Construct a scatter plot and calculate the width of the strip area where the scatter points are distributed.
[0083] In this embodiment, the scatter plot is fitted by the concave hull polygon algorithm to generate the concave hull polygon of the scatter plot. Subsequently, sampling calculations are performed on the concave hull polygon to obtain the width of the strip area. , for example, statistical values such as the average value or the maximum value of the widths of all sampling points can be taken as the width of the strip area. . It should be noted that other boundary fitting algorithms can also be used in this solution, and the present application does not make specific limitations in this regard.
[0084] 2) Select the drawing frame size and scale the strip area where the scatter points are distributed.
[0085] To ensure that the selected drawing frame can cover the scatter point distribution area, if is too large or too small compared to the height of the drawing frame for cutting, then the strip area where the scatter points are distributed needs to be appropriately scaled.
[0086] The specific operation is as follows: Select the drawing frame size for cutting and obtain the height h of the drawing frame; judge the size relationship with h. If is too large or too small, then the strip area is appropriately scaled.
[0087] In this embodiment, it is set that is less than the height h of the drawing frame and greater than 0.5h, that is satisfies the following conditions: < h, and, > 0.5×h. Preferably, when, the display effect is the best.
[0088] 3) Fit the cutting path according to the scatter plot and determine the cutting unit. The cutting unit is the drawing frame width minus the reserved redundancy.
[0089] In this embodiment, the fitting method of the cutting path refers to the description in step S2, and the specific process will not be elaborated here. During the cutting process, it is set that the cutting unit is slightly less than the drawing frame width, that is, the cutting unit is the drawing frame width minus the reserved redundancy. Although this method may cause a certain degree of overlap between adjacent drawing frames, it can effectively avoid the situation that the scatter points at the junction of the drawing frames overflow the drawing frames. Specifically, the ratio between the reserved redundancy and the drawing frame width is usually set to 3% - 10%; preferably, the reserved redundancy accounts for 5% of the drawing frame width.
[0090] For example, when using the drawing frame of A3 drawing paper, the reserved redundancy is 385 × 0.05 = 19.25mm, and the cutting unit is actually set to 385 × 0.95 = 365.75mm.
[0091] 4) Along the cutting path, use the cutting unit as the step size to perform step-by-step cutting to generate a frame.
[0092] During the cutting process, the specific operation is to start from the starting point. On the cutting path curve, cut out a target curve segment every curve length of one cutting unit. Place a frame on each target curve segment respectively, so that the center point of each frame is located at the midpoint of the target curve. Perform step-by-step continuous cutting, and set the horizontal direction of the frame according to the tangent direction of the midpoint of the target curve to generate multiple rectangular frames. That is to say, the length of the target curve is one cutting unit.
[0093] It should be noted that in this embodiment, the cutting unit is set slightly smaller than the frame width to ensure that even if the cutting path contains straight line segments, there is still a certain degree of overlap between adjacent frames. By setting the cutting unit by subtracting the reserved redundancy from the frame width, it can ensure that there is a continuous coverage relationship between frames in various path forms (including straight line segments and curve segments), thus avoiding the situation that the scattered points at the joints of the frames overflow the frames.
[0094] Further optionally, after step 4) it further includes: 5) Coverage inspection and correction after cutting.
[0095] After the cutting is completed, coverage inspection and correction are required. The specific steps are as follows: Check whether there are scattered points overflowing the frame. If there is no overflow, it is determined that the cutting passes; if there is an overflow, then according to the coordinates of the overflow scattered points, make a small adjustment to the position of the frame (such as moving the frame up or down); After correction, re-check the coverage rate of the scattered points by the frame, that is, the proportion of the scattered points within the frame among all the scattered points; if the coverage rate of the scattered points by the frame is higher than the preset threshold, it is determined that the cutting passes; otherwise, adjust the scaling ratio of the scattered point distribution band area or the cutting unit length, and re-perform the cutting. Preferably, the preset threshold of the coverage rate is preferably set to 90%.
[0096] This embodiment significantly improves the accuracy and efficiency in the cutting process and ensures the accuracy of subsequent automatic annotation layout by combining the concave hull polygon algorithm, appropriate scaling strategy, cutting redundancy setting, and coverage inspection and correction. Specifically, first, fit the scattered point diagram into a band area and perform scaling in combination with the frame size to ensure that the cutting can fully cover the scattered point distribution area. The setting of the cutting redundancy effectively avoids the overflow of scattered points between adjacent frames, thus ensuring the integrity of the scattered points at the frame boundaries. In addition, through the coverage inspection and correction steps after cutting, the position of the frame can be further accurately adjusted to avoid the omission of scattered points and ensure a high coverage rate of the scattered points by the frame. This method optimizes the cutting process, reduces manual intervention, and improves the processing speed and automation level of large-scale data sets.
[0097] On the other hand, as Figure 10 shown, this embodiment provides a labeling hierarchical avoidance arrangement system 100 for two-dimensional drawings, which is used to execute the labeling hierarchical avoidance arrangement method for two-dimensional drawings as described in the above embodiments. The system includes: A drawing acquisition module 101, which is used to acquire two-dimensional CAD drawing data to be processed; A drawing frame generation module 102, which is used to construct a scatter plot, fit a cutting path according to the scatter plot and execute cutting to generate a drawing frame; A mirror partition module 103, which is used to perform mirror partitioning within the drawing frame according to the center of gravity of the pipeline object; An automatic arrangement module 104, which is used to perform offset avoidance arrangement on the labels based on a hierarchical avoidance arrangement strategy.
[0098] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative labor.
[0099] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0100] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A method for grading and avoiding arrangement of annotations for two-dimensional drawings, characterized in that, Including: Step S1: Obtain two-dimensional CAD drawing data to be processed; Step S2: Construct a scatter plot, fit a cutting path according to the scatter plot, and execute cutting to generate a drawing frame; Step S3: Perform mirror partitioning within the drawing frame according to the centroid of the pipeline object; Step S4: Perform offset avoidance arrangement on the annotations based on a hierarchical avoidance arrangement strategy.
2. The annotation hierarchical avoidance arrangement method for two-dimensional drawings according to claim 1, characterized in that The two-dimensional CAD drawing data includes at least pipeline objects and annotations.
3. The annotation hierarchical avoidance arrangement method for two-dimensional drawings according to claim 1, characterized in that The step S2 includes: constructing a scatter plot, calculating a cutting path according to the scatter plot, and continuously cutting along the cutting path according to the cutting unit to obtain at least one rectangular drawing frame.
4. The method for hierarchical avoidance arrangement of annotations for two-dimensional drawings according to claim 1, wherein The step S3 includes: Step S31: Centroid calculation: Within the drawing frame, calculate the centroid of all pipeline objects in the drawing frame by averaging the coordinates of the midpoints of all pipe segment objects; Step S32: Mirror partitioning: Taking the axis where the centroid is located as the dividing line, divide the drawing frame into an upper half area and a lower half area, and divide each pipe segment object into the corresponding area according to the coordinates of the midpoint of the pipe segment object, where the axis where the centroid is located is a straight line passing through the centroid and parallel to the horizontal border of the drawing frame.
5. The annotation hierarchical avoidance arrangement method for two-dimensional drawings according to claim 1, characterized in that The step S4 includes: Step S41: Select the total width of the target annotation, where the total width of the target annotation includes the annotation width and the annotation interval width; Step S42: Arrange the annotations within the pipe segment object using a two-way offset arrangement algorithm; Step S43: After completing the offset avoidance arrangement within the pipe segment object, use the nearest avoidance algorithm within the layoutable space to arrange the annotations between pipe segment objects.
6. The method for grading and avoiding arrangement of annotations for two-dimensional drawings according to claim 5, characterized in that The two-way offset arrangement algorithm includes: 1) Sort the annotations within the pipe segment object according to the left-right order of the starting points of the annotation leads and determine the first sorting number; 2) Taking the reference line as the central axis, calculate the offset amount of each annotation within the pipe segment object based on the principle of uniform distribution of an arithmetic sequence, and perform automatic offset avoidance arrangement.
7. The annotation hierarchical avoidance arrangement method for two-dimensional drawings according to claim 5, wherein The nearest avoidance algorithm within the layoutable space includes: 1) For a half area of the drawing frame, first sort the annotation sets of each pipe segment object according to the left-right order of the midpoint coordinates of each pipe segment object, and determine the second sorting number; 2) Calculate the layoutable space of the annotation set block corresponding to the current pipe segment object; The layout space of the annotation set block with the second sorting number j ( ) is calculated as follows: ; In the formula, , x represents the total width of the target annotation, represents the annotation width, m represents the interval width between annotations, represents the drawing frame width, represents the number of annotations in the j-th annotation set block, represents the total number of annotations in all annotation set blocks that are in the same half area as the j-th annotation set block and on the right side of the j-th annotation set block, that is , represents the offset of the (j - 1)-th annotation set block; it is set that when , ; j represents the second sorting number of the annotation set block, j is an integer, and ; 3) Determine the nearest offset of the annotation set block corresponding to the current pipe segment object , and perform automatic offset avoidance layout. Among them, the nearest offset is the offset with the shortest parallel distance between the central axis of the current annotation set block and the reference line where the midpoint of the current pipe segment object is located within the layout space of the annotation set block corresponding to the current pipe segment object ; 4) Repeat the above steps 2) - 3) to determine the offset of each annotation set in this half region ; 5) For the other half area of the drawing frame, repeat the above steps 1)-step 4).
8. The annotation hierarchical avoidance arrangement method for two-dimensional drawings according to claim 5, wherein, The step S41 includes: 1) Calculate the maximum value that the total annotation width can be set according to the drawing frame width and the first annotation quantity, and determine the maximum value that the annotation width can be set in combination with the minimum value of the annotation interval width; 2) Determine whether the maximum value that the annotation width can be set is not less than the minimum value of the first preset range. If so, proceed to step 3). If not, prompt the user to select a larger-sized drawing frame or reduce the annotation quantity; 3) Determine the second preset range according to the first preset range and the maximum value that the annotation width can be set, display the second preset range to the user; in response to the selected annotation width by the user, determine the value range of the annotation interval width, and calculate the total width of the target annotation according to the selected annotation interval width by the user.
9. The annotation hierarchical avoidance arrangement method for two-dimensional drawings according to any one of claims 1-6, characterized in that The step S2 includes: 1) Construct a scatter plot and calculate the width of the scatter distribution band area; 2) Select the drawing frame size and scale the scatter distribution band area; 3) Fit the cutting path according to the scatter plot and determine the cutting unit, where the cutting unit is the frame width minus the reserved redundancy; 4) Along the cutting path, perform step-by-step cutting with the cutting unit as the step size to generate the frame.
10. A labeling hierarchical avoidance and arrangement system for two-dimensional drawings, which is used to execute the labeling hierarchical avoidance and arrangement method for two-dimensional drawings described in any one of claims 1-9, characterized in that, The system includes: A drawing acquisition module for acquiring two-dimensional CAD drawing data to be processed; A frame generation module for constructing a scatter plot, fitting the cutting path according to the scatter plot and performing cutting to generate a frame; A mirror partitioning module for performing mirror partitioning within the frame range according to the center of gravity of the pipeline object; An automatic layout module for performing offset avoidance layout on the annotations based on the hierarchical avoidance layout strategy.
Citation Information
Patent Citations
Drawing marking method and system
CN109325214A
Method for realizing avoidance arrangement of annotation characters in design drawing
CN114781013A
Drawing annotation arrangement method and system and related equipment
CN117454457A
Cited By
BIM (Building Information Modeling)-based pressurized air supply system diagram automatic drawing and intelligent labeling method and system
CN121502896A