A railway subgrade drawing annotation automatic layout optimization method based on force-directed algorithm
The automatic layout optimization method for railway subgrade drawing annotations based on force-oriented algorithm solves the problems of messy and overlapping annotation positions on drawings, realizes efficient, standardized and intelligent layout optimization of drawings, and improves the readability and adjustment efficiency of drawings.
Patent Information
- Application Number
- CN202511396840.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-09-28
AI Technical Summary
In existing technologies, the annotations on railway subgrade engineering drawings suffer from problems such as cluttered, overlapping, and obstructed annotation positions, resulting in poor readability of the drawings and low efficiency of manual adjustments, making it difficult to meet the needs of modern railway subgrade engineering for efficient, standardized, and intelligent drawing.
A force-guided algorithm-based approach is adopted to add semantic information to drawing annotations, dividing them into adjustable and fixed annotations. Repulsive forces and associated attractive forces are calculated, and the position of adjustable annotations is optimized by using the resultant force of force guidance, so as to avoid annotation conflicts and overlaps and ensure semantic relevance.
The layout of railway subgrade drawings has been optimized, avoiding overlapping and conflicting annotations, improving the readability and efficiency of the drawings, and meeting the needs of efficient, standardized, and intelligent drafting.
Smart Images

Figure CN120876673B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer-aided design of railway subgrade engineering, and specifically relates to an automatic layout optimization method for railway subgrade drawing annotations based on a force-oriented algorithm. This method can be extended to other engineering fields for drawing annotation layout optimization. Background Technology
[0002] With the continuous advancement of railway infrastructure construction in my country, the informatization level of railway subgrade engineering design and construction is improving daily. Computer-aided design (CAD) technology has been widely applied to the drafting and management of railway subgrade engineering drawings. As an important basis for engineering design and construction, the accuracy and standardization of the annotations in these drawings directly affect the smooth implementation of the project and subsequent operation and maintenance management. With the popularization of 3D modeling technologies such as BIM (Building Information Modeling), more and more railway subgrade engineering drawings are automatically generated from 3D models. However, due to the differences in expression and information organization between 3D models and 2D CAD drawings, CAD drawings directly exported from 3D models often have many problems at the annotation level, such as cluttered, overlapping, and obstructed annotations. These problems not only affect the readability of the drawings but also bring difficulties to subsequent construction and technical briefings. In addition, traditional subgrade drawing annotation mainly relies on manual methods, requiring designers to arrange the positions of various annotations (such as linear annotations, elevation annotations, and slope annotations) according to engineering specifications and experience. While this method can take into account the actual needs of the project, as the scale of the project expands and the number of drawings surges, the workload of manual adjustments becomes enormous, inefficient, and prone to omissions, errors, or strong subjectivity, making it difficult to meet the needs of modern railway subgrade engineering for efficient, standardized, and intelligent drafting. Summary of the Invention
[0003] The purpose of this invention is to provide an automatic layout optimization method for railway subgrade drawing annotations based on a force-directed algorithm. By combining the semantic information of the drawing annotations, the method simulates the repulsive force between drawing annotations and the attractive force between the drawing annotations and the annotated objects. The method uses the force-directed resultant force of the repulsive and attractive forces to optimize the layout of adjustable annotations in the drawing annotations, so as to ensure that the drawing annotations and the annotated objects maintain semantic relevance while avoiding conflicts and overlaps between drawing annotations.
[0004] This invention provides an automatic layout optimization method for railway subgrade drawing annotations based on a force-oriented algorithm, comprising:
[0005] Step S1: Add semantic information to all drawing annotations on the railway subgrade drawings;
[0006] Step S2: Based on the semantic information, identify the annotation type of the drawing annotation and divide all drawing annotations into adjustable annotations and fixed annotations;
[0007] Step S3: Calculate the repulsive force between any two drawing annotations in all drawing annotations using the pre-built repulsive force model; calculate the associated attractive force between each adjustable annotation and the corresponding annotated object using the pre-built spring attraction model;
[0008] Step S4: Keep the positions of all fixed labels fixed; for each adjustable label, combine all the repulsive forces acting on the adjustable label to obtain a resultant repulsive force, combine the resultant repulsive force with the associated attractive force to obtain a force-directing resultant force, and optimize the position of the adjustable label according to the force-directing resultant force.
[0009] Step S5: Repeat steps S3 and S4 a preset number of times to obtain the railway subgrade drawings with optimized layout.
[0010] As a preferred embodiment, identifying the type of drawing annotations based on the semantic information and classifying all drawing annotations into adjustable annotations and fixed annotations includes:
[0011] The drawing annotations with annotation types of linear annotation, slope annotation, and leader line annotation are classified as adjustable annotations;
[0012] Drawing annotations with annotation types of elevation annotation and fill material annotation are classified as fixed annotations.
[0013] As a preferred embodiment, calculating the repulsion between any two drawing annotations in all drawing annotations using a pre-built repulsion model includes:
[0014] For each drawing annotation, the bounding box of the current drawing annotation is determined based on the number of characters and the text format. The bounding box is used to determine whether there is overlap between different drawing annotations.
[0015] Calculate the repulsive force between two non-overlapping drawing annotations using a common repulsive force model;
[0016] The strong repulsion model is used to calculate the repulsion force between two overlapping drawing annotations.
[0017] As a preferred embodiment, calculating the repulsive force between two non-overlapping drawing annotations using a common repulsive force model includes:
[0018] Obtain the repulsive force coordinate difference vector between the center points of the bounding boxes of two drawings;
[0019] The basic repulsive force vector is obtained by multiplying the repulsive force coordinate difference vector by the reciprocal of the preset power of the repulsive force coordinate difference vector.
[0020] Multiplying the basic repulsion vector by the repulsion coefficient yields the repulsion between two non-overlapping drawing annotations.
[0021] As a preferred embodiment, calculating the repulsive force between two overlapping drawing annotations using a strong repulsive force model includes:
[0022] Obtain the overlap of the bounding boxes marked on two drawings; determine the repulsion enhancement factor based on the overlap, and multiply the repulsion enhancement factor by a preset repulsion coefficient to obtain the strong repulsion coefficient;
[0023] Obtain the repulsive force coordinate difference vector between the center points of the bounding boxes of two drawings;
[0024] The basic strong repulsive force vector is obtained by multiplying the repulsive force coordinate difference vector with the reciprocal of the magnitude of the repulsive force coordinate difference vector.
[0025] Multiplying the basic strong repulsion vector by the strong repulsion coefficient yields the repulsion force between two overlapping drawing annotations.
[0026] As a preferred embodiment, calculating the affinity between each adjustable label and its corresponding labeled object using a pre-built spring-gravity model includes:
[0027] Obtain the gravitational coordinate difference vector between the center point of the adjustable annotation bounding box and the center point of the annotated object;
[0028] The fundamental gravitational vector is obtained by multiplying the gravitational coordinate difference vector by the reciprocal of its magnitude.
[0029] The deformation is obtained by subtracting the magnitude of the gravitational coordinate difference vector from the initial spring length;
[0030] Multiplying the basic gravity vector, deformation, and spring coefficient yields the associated gravity between the adjustable label and the corresponding labeled object.
[0031] As a preferred embodiment, optimizing the position of the adjustable label based on the force-directing resultant force includes:
[0032] Determine the normal direction of the adjustable annotation text as the movement direction for position optimization, and set the maximum movement distance of the adjustable annotation for each position optimization.
[0033] The resultant force is projected onto the direction of movement to obtain the resultant force component.
[0034] If the resultant force component is greater than or equal to the preset component threshold, the adjustable label moves the maximum moving distance along the moving direction to complete the position optimization.
[0035] If the resultant force component is less than a preset component threshold, the movement ratio is determined according to the ratio of the resultant force component to the preset component threshold. The single movement distance is obtained by multiplying the movement ratio and the maximum movement distance. The adjustable marker moves the single movement distance along the movement direction to complete the position optimization.
[0036] In a preferred embodiment, step S5 introduces an iteration termination mechanism for the adjustable annotation. Step S5 includes:
[0037] Set an adjustable semantic boundary distance between the annotation and the annotated object in the direction of movement;
[0038] During the cyclic execution of steps S3 and S4, when the adjustable label gradually moves away from the labeled object in the moving direction and reaches the semantic boundary distance, the iteration termination mechanism is triggered.
[0039] In response to the triggering of the iteration termination mechanism, the bounding box of each drawing annotation is determined according to the number of characters and the text format, and the existence of drawing annotations that overlap with the currently adjustable annotations is determined based on the bounding box.
[0040] If the judgment result is that it does not exist, the current position of the adjustable label is determined as the final position and no further position optimization is performed;
[0041] If the determination result is that there is, adjust the text format of the adjustable annotation to reduce the bounding box of the adjustable annotation by a preset ratio, and then determine again whether there is a drawing annotation that overlaps with the current adjustable annotation;
[0042] If the result of the second judgment is that it does not exist, the adjustable label will maintain the current text format and determine the current position as the final position without further position optimization;
[0043] If the result of the second judgment is still that it exists, calculate the resultant force of the strong repulsive force on the adjustable annotation and the drawing annotation that overlaps with it, so that the adjustable annotation moves in the direction of the resultant force of the strong repulsive force. When there is no drawing annotation that overlaps with the adjustable annotation, maintain the current text format and determine the current position as the final position without further position optimization.
[0044] Compared to existing technologies, this invention offers the following advantages: It divides all drawing annotations into adjustable and fixed annotations, and simulates the repulsive force between any two drawing annotations to obtain a repulsive force network and the associated attractive force between each adjustable annotation and its corresponding annotated object. For each adjustable annotation, it calculates the resultant repulsive force associated with the current adjustable annotation in the repulsive force network, and combines this resultant repulsive force with the associated attractive force acting on the current adjustable annotation to obtain a force-directing resultant force. The position of the adjustable annotation is optimized based on this force-directing resultant force, and all adjustable annotations are continuously and dynamically adjusted through multiple iterations. This invention can gradually optimize the layout of the entire railway subgrade drawing while ensuring semantic relevance between drawing annotations and annotated objects and avoiding conflicts and overlaps between drawing annotations. Attached Figure Description
[0045] Figure 1 This is a flowchart illustrating the automatic layout optimization method for railway subgrade drawing annotation based on a force-oriented algorithm, according to an embodiment of the present invention.
[0046] Figure 2 This is a schematic diagram of the repulsive force between drawing annotations and the attractive force between drawing annotations and the annotated object according to an embodiment of the present invention;
[0047] Figure 3 This is a schematic diagram of the position optimization calculation of linear labels according to an embodiment of the present invention;
[0048] Figure 4 This is a schematic diagram illustrating the optimized calculation of the slope marking location according to an embodiment of the present invention. Detailed Implementation
[0049] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.
[0050] In the prior art known to the inventors of this invention, the layout of railway subgrade drawings mainly suffers from the following problems: First, the distance between the drawing annotations and the annotated objects is too large, resulting in a loss of semantic relevance; second, the layout of the various drawing annotations is too dense, and there are even overlaps between the drawing annotations, which directly affects the readability of the drawings. Therefore, how to optimize the drawing layout while ensuring semantic relevance and avoiding overlapping conflicts of drawing annotations is an urgent problem to be solved in the field of drawing optimization.
[0051] Combination Figure 1 This embodiment provides an automatic layout optimization method for railway subgrade drawing annotations based on a force-oriented algorithm, which includes:
[0052] Step S1: Add semantic information to all drawing annotations on the railway subgrade drawings;
[0053] Combination Figure 2 Specifically, this embodiment adds the XXBZ text information identifier to linear annotations, the BGBZ text information identifier to elevation annotations, the PDBZ_BFB text information identifier to percentage-based slope annotations, the PDBZ_BL text information identifier to proportional slope annotations, the TCCLBZ text information identifier to fill material annotations, and the QTWBBZ text information identifier to other text annotations. For example, text descriptions of a specific local structure, construction process, or special treatment in a drawing are considered other text annotations. This embodiment also establishes a Rel_XXBZ association between linear annotations and the annotated object, and a Rel_PDBZ association between slope annotations and the annotated object. These associations between linear annotations and the annotated object, and between slope annotations and the annotated object, are used for subsequent gravity calculations.
[0054] Step S2: Based on the semantic information, identify the annotation type of the drawing annotation and divide all drawing annotations into adjustable annotations and fixed annotations;
[0055] This embodiment classifies drawing annotations of linear, slope, and leader line types as adjustable annotations; and drawing annotations of elevation, fill material, and other text types as fixed annotations. Fixed annotations are strongly associated with the annotated object, their positions are not easily adjusted, and they are generally less likely to overlap or conflict with other drawing annotations. Therefore, the approach of this embodiment is to keep fixed annotations fixed while optimizing the layout of movable and adjustable annotations to improve the readability of the entire railway subgrade drawing.
[0056] Step S3: Calculate the repulsive force between any two drawing annotations in all drawing annotations using the pre-built repulsive force model; calculate the associated attractive force between each adjustable annotation and the corresponding annotated object using the pre-built spring attraction model;
[0057] Specifically, based on the problem to be solved in this embodiment, this embodiment establishes a repulsion model between drawing annotations. The repulsion represents that the drawing annotations need to be as far apart as possible to avoid overlapping conflicts that would affect the readability of the drawing. In addition, a spring attraction model is established between the adjustable annotation and the annotated object. The spring principle is used to simulate the association attraction between the adjustable annotation and the annotated object. The association attraction represents that the adjustable annotation and the annotated object need to maintain a reasonable distance. Once the distance is too large, they need to move closer to each other to maintain semantic relevance.
[0058] In this embodiment, step S3 specifically includes:
[0059] Step S31: Calculate the repulsive force between any two drawing annotations in all drawing annotations using the pre-built repulsive force model. Each drawing annotation is subject to repulsive forces from other drawing annotations. Each repulsive force is associated with two drawing annotations, and the repulsive forces between all drawing annotations together form a repulsive force network.
[0060] Step S31 specifically includes:
[0061] Step S311: For each drawing annotation, determine the bounding box of the current drawing annotation based on the number of characters and the text format. The bounding box is used to determine whether there is overlap between the various drawing annotations.
[0062] Understandably, while close proximity and density between drawing annotations merely increase the difficulty of reading the drawing, overlapping annotations directly impact readability, making it difficult for readers to determine the correct information. Therefore, this embodiment first determines whether drawing annotations overlap with other drawing annotations when calculating the repulsive force between them.
[0063] Step S312: Calculate the repulsion force between two non-overlapping drawing annotations using a common repulsion force model. Step S312 specifically includes: obtaining the repulsion force coordinate difference vector between the center points of the bounding boxes of the two drawing annotations; multiplying the repulsion force coordinate difference vector with the reciprocal of the modulus of the repulsion force coordinate difference vector to obtain the basic repulsion force vector; and multiplying the basic repulsion force vector with the repulsion force coefficient to obtain the repulsion force between the two non-overlapping drawing annotations.
[0064] The expression for the ordinary repulsive force model is:
[0065]
[0066] in, This indicates the repulsive force between two drawing annotations. It is the repulsion coefficient. This represents the repulsive force coordinate difference vector between the center points of the bounding boxes of two drawings. This represents the magnitude of the repulsive force coordinate difference vector between the center points of the boundary frames marked on two drawings.
[0067] Step S313: Calculate the repulsive force between two overlapping drawing annotations using a strong repulsive force model. Step S313 includes: obtaining the overlap degree of the bounding boxes of the two drawing annotations; determining the repulsive force enhancement factor based on the overlap degree, wherein the repulsive force enhancement factor is proportional to the overlap degree; multiplying the repulsive force enhancement factor by a preset repulsive force coefficient to obtain a strong repulsive force coefficient; obtaining the repulsive force coordinate difference vector between the center points of the bounding boxes of the two drawing annotations; multiplying the repulsive force coordinate difference vector by the reciprocal of the magnitude of the repulsive force coordinate difference vector to obtain a basic strong repulsive force vector; multiplying the basic strong repulsive force vector by the strong repulsive force coefficient to obtain the repulsive force between the two overlapping drawing annotations.
[0068] The expression for the strong repulsion model is:
[0069]
[0070] in, This indicates the repulsive force between two drawing annotations. This indicates the repulsion enhancement factor (as an example, when the overlap is 50%, the repulsion enhancement factor is 5). It is the repulsion coefficient. This represents the repulsive force coordinate difference vector between the center points of the bounding boxes of two drawings. This represents the magnitude of the repulsive force coordinate difference vector between the center points of the boundary frames marked on two drawings.
[0071] Step S3 also includes:
[0072] Step S32: Calculate the associated gravitational force between each adjustable label and its corresponding labeled object using a pre-built spring gravity model. Step S32 includes: obtaining the gravity coordinate difference vector between the center point of the bounding box of the adjustable label and the center point of the labeled object; multiplying the gravity coordinate difference vector by the reciprocal of its magnitude to obtain the basic gravity vector; subtracting the magnitude of the gravity coordinate difference vector from the initial spring length to obtain the deformation; and multiplying the basic gravity vector, the deformation, and the spring coefficient to obtain the associated gravitational force between the adjustable label and its corresponding labeled object.
[0073] The expression for the spring gravity model is:
[0074]
[0075] in, This indicates the affinity between the adjustable annotation and the corresponding annotated object. Indicates the spring constant. This represents the gravitational coordinate difference vector between the center point of the bounding box of the adjustable annotation and the center point of the annotated object. This represents the magnitude of the gravitational coordinate difference vector between the center point of the bounding box of the adjustable annotation and the center point of the annotated object. It is the initial spring length.
[0076] Step S4: Keep the positions of all fixed labels fixed; for each adjustable label, combine all the repulsive forces acting on the adjustable label to obtain a resultant repulsive force, and then combine the resultant repulsive force with the associated attractive force to obtain a force-directing resultant force. Optimize the position of the adjustable label according to the force-directing resultant force; after the position optimization of all adjustable labels is completed, clear all the repulsive forces and associated attractive forces calculated in step S3 for the next position iteration optimization.
[0077] The process of combining the resultant force of repulsive forces with the associated attractive forces to obtain the resultant force of force-directed forces is combined with... Figure 2 Taking adjustable annotations as linear annotations as an example, this railway subgrade drawing includes linear annotations, slope annotations, elevation annotations, fill material annotations, and other text annotations. Points A, C, D, E, F, and G represent the center points of the bounding boxes of the linear annotations, slope annotations, fill material annotations, other text annotations, and elevation annotations, respectively; point B represents the center point of the object being annotated by the linear annotation.
[0078] The expression for the resultant repulsive force on this linear label is:
[0079]
[0080] in, This represents the resultant repulsive force acting on the linear label. It is the repulsion coefficient. It is the coordinate difference vector between points A and C. It is the coordinate difference vector between points A and E. It is the vector difference between the coordinates of points A and D. It is the coordinate difference vector between points A and F. It is the coordinate difference vector between point A and point G.
[0081] The expression for the associated gravitational force acting on this linear label is:
[0082]
[0083] in, This indicates the associated gravitational force acting on the linear label. It is the spring constant. It is the coordinate difference vector between points A and B. It is the initial spring length.
[0084] The linear label is subjected to the resultant force of the force. The expression is:
[0085]
[0086] Step S4, which involves optimizing the position of the adjustable label based on the force-guided resultant force, includes:
[0087] Step S41: Determine the normal direction of the adjustable annotation text as the movement direction for position optimization, and set the maximum movement distance of the adjustable annotation for each position optimization.
[0088] Step S42: Project the force into the resultant force in the direction of movement to obtain the resultant force component;
[0089] Combination Figure 3 Continuing with the example of adjustable labels as linear labels, The normal direction of the adjustable annotation text is the direction of movement for position optimization. To guide the direction of the resultant force, The resultant force component is obtained by projecting the force-directed resultant force onto the direction of position optimization.
[0090] Step S43: If the resultant force component is greater than or equal to the preset component threshold, the adjustable label moves the maximum moving distance along the moving direction (for example, it can be set to 1 unit length) to complete the position optimization;
[0091] Step S44: If the resultant force component is less than the preset component threshold, then the movement ratio is determined according to the ratio of the resultant force component to the preset component threshold. The single movement distance is obtained by multiplying the movement ratio and the maximum movement distance. The adjustable marker moves the single movement distance along the movement direction to complete the position optimization.
[0092] Specifically, this embodiment optimizes the position of adjustable annotations by combining the resultant force of the repulsive force (to maintain distance between drawing annotations) and the associated attractive force (to maintain a reasonable distance between the adjustable annotation and the annotated object). This ensures the semantic relevance between the drawing annotations and the annotated object, as well as the readability of the entire drawing. Furthermore, if an adjustable annotation has multiple overlapping drawing annotations, the repulsive force on that annotation may be significant. Under such a strong repulsive force, the adjustable annotation may move a considerable distance and completely detach from the annotated object. To prevent positional loss of control during a single optimization, this embodiment sets a maximum single movement distance for the adjustable annotation. When the resultant force component is greater than or equal to a preset component threshold, the adjustable annotation is only allowed to move the maximum distance, thus preventing positional loss of control.
[0093] Step S5: Repeat steps S3 and S4 a preset number of times (for example, 1000 times) to obtain the railway subgrade drawing with optimized layout. Understandably, the original layout of railway subgrade drawings in CAD format directly exported from 3D software may be quite complex, making it difficult to obtain a readable railway subgrade drawing through a single position optimization. Therefore, this embodiment uses an iterative loop for layout optimization. During the iterative loop, after each position optimization, the positions of all adjustable annotations may change, and the corresponding attractive and repulsive force network will also be updated. Therefore, under the limitation of the maximum moving distance, this embodiment can continuously and dynamically adjust all adjustable annotations to gradually achieve layout optimization of the entire railway subgrade drawing.
[0094] Furthermore, the purpose of layout optimization in this embodiment is to make railway subgrade drawings clear and readable. In CAD drawings exported from 3D models, drawing annotations are usually close to the annotated objects and easily overlap with other drawing annotations. Therefore, during the iteration process, some adjustable annotations may gradually move away from the annotated objects under the strong repulsive force generated by overlapping drawing annotations, overcoming the associative attraction of the annotated objects. If the distance between the adjustable annotation and the annotated object is too large, it will be difficult for the reader to establish the association between the drawing annotation and the annotated object, thus causing the drawing annotation to lose its semantic relevance. Therefore, to avoid these adjustable annotations gradually moving away from the annotated objects due to strong repulsive force and losing their semantic relevance, this embodiment introduces an iteration termination mechanism in the iterative loop of step S5. Step S5 includes:
[0095] Step S51: Set the semantic boundary distance between the adjustable label and the labeled object in the moving direction;
[0096] Understandably, in order to prevent some adjustable labels from gradually moving away from the labeled object under the repulsive force and losing semantic relevance, this embodiment sets a semantic boundary distance between the adjustable label and the labeled object in the moving direction. Once the distance between the adjustable label and the labeled object in the moving direction reaches the semantic boundary distance, it means that if the adjustable label continues to move away from the labeled object, it may lose semantic relevance. At this time, it is necessary to intervene and control to prevent the adjustable label from moving further away from the labeled object.
[0097] During the cyclic execution of steps S52, S3 and S4, when the adjustable label gradually moves away from the labeled object in the moving direction and reaches the semantic boundary distance, the iteration termination mechanism is triggered. In this embodiment, the iteration termination mechanism can effectively prevent some adjustable labels from moving too far away from the labeled object and losing semantic relevance.
[0098] Step S53: In response to the iteration termination mechanism being triggered, determine the bounding box of each drawing annotation based on the number of characters and the text format, and determine whether there is a drawing annotation that overlaps with the currently adjustable annotation based on the bounding box; since the most likely reason for the iteration termination mechanism being triggered is the existence of overlap conflict, overlap is first determined by the bounding box.
[0099] Step S54: If the judgment result is that no such object exists, the current position of the adjustable annotation is determined as the final position and no further position optimization is performed. In subsequent iterations, the adjustable annotation will no longer undergo position optimization, but it will still participate in the repulsion calculation to ensure the integrity of the repulsion network composed of all repulsion forces. Since the adjustable annotation has been in a dangerous position where it may lose semantic relevance after multiple iterations, if there are no overlapping drawing annotations, it means that the readability of the annotation is not substantially affected. In this case, the current position of the adjustable annotation is directly determined as the final position to maintain semantic relevance. If the judgment result is that a certain object exists, the text format of the adjustable annotation is adjusted to reduce the bounding box of the adjustable annotation by a preset ratio (usually 0.8-0.9; the reduction should not be too large, as unclear fonts after reduction will directly affect the readability of the drawing). The system then checks again whether there are any drawing annotations overlapping with the current adjustable annotation. Since the adjustable annotation is already far from the annotated object, it is not suitable to continue moving it. In this embodiment, adjusting the text format of the adjustable annotation is chosen to avoid overlap.
[0100] Step S55: If the result of the second judgment is "not present," the adjustable annotation maintains its current text format and its current position is determined as the final position without further position optimization. At this point, the readability of the annotation is not substantially affected, and the final position can be directly determined to maintain semantic relevance. If the result of the second judgment is still "present," the resultant force of the strong repulsive force on the adjustable annotation from the overlapping drawing annotations is calculated, causing the adjustable annotation to move along the direction of the resultant force. When there are no overlapping drawing annotations, the current text format is maintained, and the current position is determined as the final position without further position optimization. If overlap still exists after adjusting the text format during drawing processing, it is generally due to excessive overlap between the adjustable annotation and one or more drawing annotations in the direction of movement. In this case, to avoid overlap as quickly as possible, the adjustable annotation is moved along the direction of the resultant force until there is no overlap, thereby minimizing the position adjustment range while maintaining the annotation's semantics.
[0101] In another specific embodiment, combined with Figure 4 If the adjustable annotation is a slope annotation, the drawing standard requirements for slope annotations stipulate that the center point of the boundary frame of the slope annotation must be restricted to a rectangular frame. Figure 4The rectangle (defined by points H, I, J, and K) is enclosed within the slope direction of the labeled object to maintain semantic association with the labeled slope. The length of this rectangle aligns with the slope direction of the labeled object, and its height is orthogonal to the slope direction. The length of the rectangle... The height of the rectangle is the difference between the length of the labeled ramp segment (points L and M are the two endpoints of the ramp segment) and the length of the text indicating the slope. The parallel distance between the HI and KJ sides is half the text height of the initial text format for the slope label. The parallel distance between the length of the rectangle closest to the slope (KJ side) and the slope being labeled is also equal to the height of the rectangle. .
[0102] like Figure 4 As shown, a coordinate system is established with the horizontal base of the ramp as the x-axis and the vertical direction as the y-axis. The expressions for each boundary point of the rectangle in this coordinate system are as follows:
[0103]
[0104] Wherein, point N is the projection of point K onto the ramp. Indicates the height of the rectangle. Indicates the length of the rectangle. Indicates the length of line segment LN. The length of the text indicating the slope is half its length. Indicates slope, Represents the coordinates of point N. Represents the coordinates of point L. Represents the coordinates of point K. Represents the coordinates of point H. Represents the coordinates of point J. This represents the coordinates of point I.
[0105] When the adjustable annotation is a slope annotation, the iteration termination mechanism is triggered when the center point of the slope annotation's bounding box reaches the long side (HI side) of the rectangle furthest from the slope. First, it checks if there are any drawing annotations overlapping with the slope annotation. If not, the current position of the slope annotation is determined as its final position, and no further position optimization is performed. If there are, the text format of the slope annotation is adjusted to reduce the bounding box size by a preset ratio (usually 0.8-0.9). It then checks again if there are any drawing annotations overlapping with the current adjustable annotation. If the second check finds no overlap, the slope annotation retains its current text format, and its current position is determined as its final position, with no further position optimization performed. It's important to note that if the second check still finds overlap, since the center point of the slope annotation's bounding box is confined within the rectangle, the goal is to minimize the sum of overlaps between the slope annotation's bounding box and all other drawing annotations. The slope annotation is moved along the rectangle's boundary to determine the target position with the minimum sum of overlaps, and this target position is determined as the final position of the slope annotation, with no further position optimization performed.
[0106] Due to the bounding box limitation, after each location optimization, it is necessary to verify whether the center point of the slope label's bounding box is inside the bounding box. If the center point of the slope label's bounding box is not inside the bounding box, the slope label is reset to its position before the location optimization.
[0107] The expression to verify whether the center point of the slope annotation's bounding box is located within the rectangle is:
[0108]
[0109] in, This indicates the coordinates of the center point of the bounding box used to annotate the slope. and These represent the first and second cross products, respectively, for determining whether the center point of the bounding box of the slope label is between the KH and IJ edges; and These represent the third and fourth cross products, respectively, used to determine whether the center point of the bounding box for the slope annotation lies between the JK and HI edges. If the above expression is satisfied, it means that the center point of the slope label's bounding box is located within the rectangle; if it is not satisfied, it means that the center point of the slope label's bounding box is not located within the rectangle.
[0110] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0111] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0112] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0113] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0114] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A method for automatic layout optimization of railway subgrade drawing annotations based on a force-oriented algorithm, characterized in that, include: Step S1: Add semantic information to all drawing annotations on the railway subgrade drawings; Step S2: Based on the semantic information, identify the annotation type of the drawing annotation and divide all drawing annotations into adjustable annotations and fixed annotations; Step S3: Calculate the repulsive force between any two drawing annotations in all drawing annotations using the pre-built repulsive force model; calculate the associated attractive force between each adjustable annotation and the corresponding annotated object using the pre-built spring attraction model; Step S4: Keep the positions of all fixed labels fixed; for each adjustable label, combine all the repulsive forces acting on the adjustable label to obtain a resultant repulsive force, combine the resultant repulsive force with the associated attractive force to obtain a force-directing resultant force, and optimize the position of the adjustable label according to the force-directing resultant force. Step S5: Repeat steps S3 and S4 a preset number of times to obtain the optimized railway subgrade drawings. The repulsive force between any two drawing annotations in all drawing annotations is calculated using a pre-built repulsive force model, including: For each drawing annotation, the bounding box of the current drawing annotation is determined based on the number of characters and the text format. The bounding box is used to determine whether there is overlap between different drawing annotations. Calculate the repulsive force between two non-overlapping drawing annotations using a common repulsive force model; Calculate the repulsive force between two overlapping drawing annotations using a strong repulsive force model; The association force between each adjustable label and its corresponding labeled object is calculated using a pre-built spring-gravity model, including: Obtain the gravitational coordinate difference vector between the center point of the adjustable annotation bounding box and the center point of the annotated object; The fundamental gravitational vector is obtained by multiplying the gravitational coordinate difference vector by the reciprocal of its magnitude. The deformation is obtained by subtracting the magnitude of the gravitational coordinate difference vector from the initial spring length; Multiplying the basic gravity vector, deformation, and spring coefficient yields the associated gravity between the adjustable label and the corresponding labeled object. Optimizing the position of adjustable labels based on the force-directing resultant force includes: Determine the normal direction of the adjustable annotation text as the movement direction for position optimization, and set the maximum movement distance of the adjustable annotation for each position optimization. The resultant force is projected onto the direction of movement to obtain the resultant force component. If the resultant force component is greater than or equal to the preset component threshold, the adjustable label moves the maximum moving distance along the moving direction to complete the position optimization. If the resultant force component is less than a preset component threshold, the movement ratio is determined according to the ratio of the resultant force component to the preset component threshold. The single movement distance is obtained by multiplying the movement ratio and the maximum movement distance. The adjustable marker moves the single movement distance along the movement direction to complete the position optimization.
2. The automatic layout optimization method for railway subgrade drawing annotation based on force-oriented algorithm according to claim 1, characterized in that, Based on the semantic information, the type of the drawing annotation is identified, and all drawing annotations are divided into adjustable annotations and fixed annotations, including: The drawing annotations with annotation types of linear annotation, slope annotation, and leader line annotation are classified as adjustable annotations; Drawing annotations with annotation types of elevation annotation and fill material annotation are classified as fixed annotations.
3. The automatic layout optimization method for railway subgrade drawing annotation based on force-oriented algorithm according to claim 1, characterized in that, The calculation of the repulsive force between two non-overlapping drawing annotations using a common repulsive force model includes: Obtain the repulsive force coordinate difference vector between the center points of the bounding boxes of two drawings; The basic repulsive force vector is obtained by multiplying the repulsive force coordinate difference vector by the reciprocal of the preset power of the magnitude of the repulsive force coordinate difference vector. Multiplying the basic repulsion vector by the repulsion coefficient yields the repulsion between two non-overlapping drawing annotations.
4. The automatic layout optimization method for railway subgrade drawing annotation based on force-oriented algorithm according to claim 1, characterized in that, The calculation of the repulsive force between two overlapping drawing annotations using the strong repulsive force model includes: Obtain the overlap of the bounding boxes marked on two drawings; determine the repulsion enhancement factor based on the overlap, and multiply the repulsion enhancement factor by a preset repulsion coefficient to obtain the strong repulsion coefficient; Obtain the repulsive force coordinate difference vector between the center points of the bounding boxes of two drawings; The basic strong repulsive force vector is obtained by multiplying the repulsive force coordinate difference vector with the reciprocal of the magnitude of the repulsive force coordinate difference vector. Multiplying the basic strong repulsion vector by the strong repulsion coefficient yields the repulsion force between two overlapping drawing annotations.
5. The automatic layout optimization method for railway subgrade drawing annotation based on force-oriented algorithm according to claim 1, characterized in that, Step S5 introduces an iteration termination mechanism for adjustable annotations. Step S5 includes: Set an adjustable semantic boundary distance between the annotation and the annotated object in the direction of movement; During the cyclic execution of steps S3 and S4, when the adjustable label gradually moves away from the labeled object in the moving direction and reaches the semantic boundary distance, the iteration termination mechanism is triggered. In response to the triggering of the iteration termination mechanism, the bounding box of each drawing annotation is determined according to the number of characters and the text format, and the existence of drawing annotations that overlap with the currently adjustable annotations is determined based on the bounding box. If the judgment result is that it does not exist, the current position of the adjustable label is determined as the final position and no further position optimization is performed; If the determination result is that there is, adjust the text format of the adjustable annotation to reduce the bounding box of the adjustable annotation by a preset ratio, and then determine again whether there is a drawing annotation that overlaps with the current adjustable annotation; If the result of the second judgment is that it does not exist, the adjustable label will maintain the current text format and determine the current position as the final position without further position optimization; If the result of the second judgment is still that it exists, calculate the resultant force of the strong repulsive force on the adjustable annotation and the drawing annotation that overlaps with it, so that the adjustable annotation moves in the direction of the resultant force of the strong repulsive force. When there is no drawing annotation that overlaps with the adjustable annotation, maintain the current text format and determine the current position as the final position without further position optimization.
Citation Information
Patent Citations
Image label layout optimization method and system
CN117115300A
Force-directed graph layout method and apparatus, electronic device, and storage medium
US20250182353A1