A STL 3D model layout optimization method based on genetic algorithm
Through genetic algorithms, the problem of low component arrangement efficiency in mechanical equipment design is solved, and the solution of optimal arrangement scheme and the improvement of space utilization is achieved.
Patent Information
- Application Number
- CN202210911001.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-07-29
AI Technical Summary
In the design of mechanical equipment, multi-component arrangement optimization mainly relies on two-dimensional or semi-regular three-dimensional geometric models, and cannot truly characterize the component outline, resulting in low design efficiency and inability to solve the optimal arrangement scheme, resulting in wasted time and space resources.
The STL three-dimensional model arrangement optimization method based on genetic algorithm is adopted. By adjusting the feature vector of the STL model, the genetic algorithm is used to solve the optimal layout combination to ensure that the components have no interference under the minimum feature volume and form an optimal layout scheme.
Really characterize the contour features of the model, improve the practicality and design efficiency of layout optimization, can directly guide the design and 3D printing process, and improve space utilization.
Smart Images

Figure CN115270219B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of engineering design, and in particular to an STL three-dimensional model arrangement optimization method based on a genetic algorithm. Background Art
[0002] In order to optimize the layout of multiple components in a limited space, it is necessary to establish the initial outline and geometric coordinate information of the components, take the minimum characteristic volume as the goal, adjust the layout posture of each component through the characteristic vector, solve the optimal layout combination of semi-regular components of mechanical equipment, and form a layout plan for mechanical equipment components with the smallest characteristic volume.
[0003] Currently, most multi-component layout optimization solutions simplify the components into two-dimensional models or semi-regular three-dimensional geometric models before performing layout optimization. Since the geometric models used for layout optimization cannot truly represent all the contour information of the components, the layout solutions generated based on the above principles cannot be directly used to guide the design process.
[0004] In the traditional design process, the arrangement and combination of components are mainly performed manually in computer-aided design software such as CAD. This is not only inefficient, but also unable to solve the optimal arrangement plan of components, resulting in a waste of time and space resources. Summary of the Invention
[0005] Given the aforementioned technical problem of finding the optimal arrangement of semi-regular components in mechanical equipment failing to guide the design process, a genetic algorithm-based STL 3D model arrangement optimization method is proposed. By adjusting the STL model's pose using eigenvectors, a genetic algorithm is used to find the optimal arrangement of the STL model, finding the eigenvectors corresponding to all components under the minimum eigenvolume constraint.
[0006] The technical means adopted in the present invention are as follows:
[0007] A genetic algorithm-based STL three-dimensional model layout optimization method, comprising:
[0008] S1. Convert the geometric model of the components to be arranged into an STL model and import it into MATLAB, reading the vertex and normal vector information of the triangles contained in each component;
[0009] S2. Initialize the genetic algorithm model, including defining the fitness function, setting the number of iterations, and generating an initial population with a population size of p;
[0010] S3. Adjust the arrangement of the STL model using the genetic information x of the individuals in the p initial populations, and refresh the vertex information of the triangles of the STL model;
[0011] S4, for the triangular facet vertex information of the three-dimensional model obtained in step S3, calculate the volume of the interference part bounding box between each STL model , and the volume of the interfering part bounding box Set as constraint condition;
[0012] S5: The volume of the interference part bounding box obtained in step S4 , and the volume of the AABB bounding box containing all components The fitness function is obtained by summing up;
[0013] S6, based on the constraints defined in S4 and the fitness function defined in S5, use the genetic algorithm to iteratively optimize the current population, gradually making is equal to 0, tends to a minimum;
[0014] S7. Determine whether the maximum number of iterations has been reached. If so, output the arrangement result. If not, return to step S4.
[0015] Furthermore, the geometric model of the components to be arranged is converted into an STL model, including: exporting the STL model from the three-dimensional model drawn by CAD.
[0016] Furthermore, obtaining the genetic information x of an individual includes:
[0017] The 1×6n array obtained by directly encoding the degree of freedom of the component is used as the gene ,and In order, components 、 、 The translation distance in the axis direction and the 、 、 The rotation angle of the axis.
[0018] Furthermore, obtaining the genetic information x of the individual also includes: converting the model to any posture v by translating and rotating the triangular facets on the STL model.
[0019] Furthermore, the volume of the interference bounding box between each STL model is calculated Previously, it also included judging the interference between various STL models, including:
[0020] The projection method is used to make an initial judgment on the interference between the STL models. If the projections of two components on any coordinate plane do not intersect, it can be determined that the two components do not interfere with each other. If the projections of the two components on each coordinate plane intersect, the STL models are intersected. If the STL models intersect, it is determined that interference occurs between the models, otherwise it is considered that no interference occurs.
[0021] Furthermore, the volume of the interference bounding box between each STL model is calculated ,include:
[0022] S401, obtain the maximum and minimum projections of component 1 on the x, y and z axes 、 and ,Pick:
[0023]
[0024] The length, width and height of the AABB bounding box Box1 of the component can be obtained by the same method as the length, width and height of the AABB bounding box Box2 of component 2;
[0025] S402. Find the intersection of the length, width, and height of Box1 and Box2 L, W, and H ,like L, W, and H Are not empty sets, then L, W, and H Create Box3 and filter out the triangle face sets u1 and u2 where components 1 and 2 intersect with Box3;
[0026] S403. If the maximum number of iterations has not been reached and u1 and u2 are not empty, u1 and u2 are rotated around the z-axis by a certain angle and then used as component 1 and component 2, and S401-S402 are repeated. Otherwise, the loop is exited and the process goes to S404.
[0027] When there is an empty set in S404, u1 and u2, directly let the volume of the interference part Otherwise, the volume of the intersecting area of the interference part volume bounding box is calculated , the sum of the bounding box volumes of component 1 and component 2 is V, let , set the threshold ,like , then let Keep the original value unchanged, if , then intersect the triangles of the two sets u1 and u2. If the triangles intersect, let Keep the original value unchanged, otherwise .
[0028] Furthermore, the fitness function is:
[0029]
[0030] in, is the fitness function, is the maximum value of the triangle vertex coordinates projected on the x-axis, is the minimum value of the triangle vertex coordinates projected on the x-axis, is the maximum value of the triangle vertex coordinates projected on the y-axis, is the minimum value of the triangle vertex coordinates projected on the y-axis, is the maximum value of the triangle vertex coordinates projected on the z-axis, is the minimum value of the triangle vertex coordinates projected on the z-axis, is the weight coefficient.
[0031] Compared with the prior art, the present invention has the following advantages:
[0032] 1. The operating object of the present invention is an STL three-dimensional model, which can truly characterize the contour features of the model. Compared with the arrangement of traditional plane graphics and semi-regular three-dimensional models, it is more in line with the needs of actual production.
[0033] 2. The present invention can give each component full degrees of freedom by defining the independent variables of the genetic algorithm, and directly encode the degrees of freedom of the component as genes, providing a theoretical basis for solving the truly global optimal solution.
[0034] 3. The present invention provides an STL three-dimensional model layout optimization method based on a genetic algorithm, which directly performs layout optimization design on the STL three-dimensional model. The layout results can not only be used directly to guide the design work, but also to guide the placement of each component in the 3D printing production process to improve space utilization.
[0035] The present invention utilizes an STL model, which is easy to process and can represent the true contour features of the model, for layout optimization. This allows for direct manipulation of the positional information of the triangle vertices on the STL model while maximizing the restoration of the model's geometric features, effectively improving the practicality of the layout optimization results. For these reasons, the present invention is suitable for widespread adoption in the field of engineering design. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0037] Figure 1 The figure is a flow chart of the STL three-dimensional model arrangement optimization method based on genetic algorithm of the present invention.
[0038] Figure 2 It is a schematic diagram of the process of finding the intersection of STL models in the present invention.
[0039] Figure 3 is the STL model of the motor pump used in the embodiment.
[0040] Figure 4 : is the STL model of the low-pressure valve block used in the embodiment.
[0041] Figure 5 : is the STL model of the fuel tank used in the embodiment.
[0042] Figure 6 : is the STL model of the high-pressure valve block used in the embodiment.
[0043] Figure 7 FIG. 4 is an STL model of the actuator used in the embodiment.
[0044] Figure 8 A top view of the optimized design scheme for the arrangement of five complex components in an embodiment.
[0045] Figure 9 This is a front view of the optimized design scheme for the arrangement of five complex components in the embodiment.
[0046] Figure 10 A side view of the optimized design scheme for the arrangement of five complex components in an embodiment. DETAILED DESCRIPTION
[0047] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0048] For the convenience of explanation, as shown in Table 1, the following symbols introduced in this article are first explained uniformly:
[0049] Table 1 Symbols
[0050]
[0051] The present invention provides a genetic algorithm-based STL three-dimensional model layout optimization method, which aims to solve the optimal layout combination of semi-regular components of mechanical equipment and form a layout scheme of mechanical equipment parts with the smallest characteristic volume. Specifically, this problem studies the STL models of n components, and determines the position information of each component in the same three-dimensional space without interference between them. The goal is to minimize the volume of the AABB bounding box of the assembly containing all components. Specifically, if Figure 1 As shown, the present invention includes the following steps:
[0052] S1. Convert the geometric model of the components to be arranged into an easy-to-handle STL model and import it into MATLAB, and read the vertex coordinates and normal vector information of the triangles contained in each component;
[0053] The STL model of the component can be directly saved as an STL format file from CAD software; after importing the model into MATLAB, refer to Figures 3 to 7 , respectively, the coordinates of the model's triangle vertex , stored in the coordinate information matrix X, Y, Z, and the position information of the triangle vertex is stored in the site matrix to facilitate subsequent data processing;
[0054] S2. Define the fitness function, set the number of iterations, crossover ratio and randomly initialize the population Individual coding sequences in the
[0055] The coding sequence is a decimal real number sequence containing 6n elements, and the value range of the 6(i-1)+3th to 6ith codes in the coding sequence is ,in .
[0056] Specifically, in step S2, the algorithm is initialized, the size of the population nPop is set, the maximum number of iterations of the population MaxInt is set, and the crossover ratio of the population CrossoverFraction is set.
[0057] S3. Through population The individual coding sequence in the STL model adjusts the arrangement posture and refreshes the vertex information of the STL model triangles;
[0058] Specifically, the poses of the 1st to nth models are adjusted in sequence through the coding sequence x, and the vertex information of the triangle corresponding to the i-th component is obtained through the site triangle position information matrix 、 and ,make ;make
[0059] ;
[0060] ;
[0061] ;
[0062] Let the rotation matrix , then , , ;
[0063] S4, for the triangular facet vertex information of the three-dimensional model obtained in step S3, calculate the volume V1 of the interference area between each STL model and set it as a constraint condition;
[0064] Specifically, in step S4, this example uses the interference volume between the i-th and j-th STL models as an example to illustrate the calculation of the volume of the interference area between each STL model. Figure 2 , the steps are as follows:
[0065] S401, obtain the maximum and minimum values of the triangle vertex coordinate matrix Xi, Yi and Zi of the i-th STL model on the x, y, and z axes 、 and , similarly, the projection value corresponding to the j-th STL model AABB bounding box can be obtained 、 and ;Find the intersection of the projection intervals of the i-th and j-th components on each coordinate axis. If all intersections are not empty sets, the interval of the AABB bounding box of the interference area can be obtained. 、 and The AABB bounding box Box of the triangle facets where the two components may intersect can be determined through the above three coordinate intervals.
[0066] S402. The analytical expression of the three-dimensional space plane is , from which the analytical equations of the six planes of Box can be determined, let , the vertices of the triangle Substitution Get a 6×1 array According to the properties of the analytical expression, when the triangle does not intersect the plane The three elements in the same sign can be used to filter out the triangle facets that intersect the two components and the Box. u1 and u2 ;
[0067] S403. If the exit conditions are not met and u1 andu2 Are not empty sets, u1 and u2 After rotating a certain angle around the specified axis, repeat S401 and S402 as component 1 and component 2, otherwise jump out of the loop and enter S404;
[0068] S404, u1 and u2 When there is an empty set in , directly let the volume of the interference part Otherwise, the volume of the intersecting area of the interference part volume bounding box is calculated , the sum of the bounding box volumes of component 1 and component 2 is ,make , set the threshold ,like , then let Keep the original value unchanged, if , then intersect the triangles of the two sets u1 and u2. If the triangles intersect, let Keep the original value unchanged, otherwise .
[0069] S405: To avoid interference and collision between components, Components corresponding constraints, among which , the constraints are:
[0070]
[0071]
[0072]
[0073]
[0074]
[0075] S5. Multiply the volume V1 of the interference area obtained in step S4 by a preset weight coefficient. , and the volume of the AABB bounding box containing all components The sum of is used as the fitness function, that is:
[0076]
[0077] in, is the fitness function, is the maximum value of the triangle vertex coordinates projected on the x-axis, is the minimum value of the triangle vertex coordinates projected on the x-axis, is the maximum value of the triangle vertex coordinates projected on the y-axis, is the minimum value of the triangle vertex coordinates projected on the y-axis, is the maximum value of the triangle vertex coordinates projected on the z-axis, is the minimum value of the triangle vertex coordinates projected on the z-axis, is the weight coefficient.
[0078] S6, based on the constraints and fitness function defined in S4 and S5, use genetic algorithm to iteratively optimize the current population, gradually making is equal to 0, tends to a minimum;
[0079] S7, determine whether the maximum number of iterations has been reached, if so, output the arrangement result, refer to Figures 8 to 10 , otherwise return to step S4.
[0080] The guiding significance of this invention for design is that by simply importing each component into the program and arranging them, the arrangement method corresponding to the minimum characteristic volume of the components can be obtained; similarly, it can also be used to improve the space utilization of 3D printing equipment.
[0081] The present invention can be used to optimize the layout design of three-dimensional models, converting them into triangular meshes and optimizing the design by utilizing the highly operable data of triangular mesh models. The present invention can also introduce the pose of the triangular mesh model into actual CAD software to guide the engineering design process.
[0082] The embodiments described above are merely descriptions of the implementation methods of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should fall within the scope of protection determined by the claims of the present invention.
Claims
1. A STL three-dimensional model arrangement optimization method based on genetic algorithm, characterized in that: include: S1. Convert the geometric model of the components to be arranged into an STL model and import it into MATLAB, reading the vertex and normal vector information of the triangles contained in each component; S2. Initialize the genetic algorithm model, including defining the fitness function, setting the number of iterations, and generating an initial population with a population size of p; S3. Adjust the arrangement of the STL model using the genetic information x of the individuals in the p initial populations, and refresh the vertex information of the triangles of the STL model; S4, for the triangular facet vertex information of the STL model obtained in step S3, calculate the volume of the interference part bounding box between each STL model , and the volume of the interfering part bounding box Set as constraint conditions; calculate the volume of the interference bounding box between each STL model The steps include: S401, obtain the maximum and minimum projections of component 1 on the x, y and z axes 、 and ,Pick: As the length, width and height of the AABB bounding box Box1 of the component, the length, width and height of the AABB bounding box Box2 of component 2 can be obtained in the same way. S402. Find the intersection of the length, width, and height of Box1 and Box2 L, W, and H ,like L, W, and H Are not empty sets, then L, W, and H Create Box3 and filter out the triangle face sets u1 and u2 where components 1 and 2 intersect with Box3. S403. If the maximum number of iterations has not been reached and u1 and u2 are not empty, u1 and u2 are rotated around the z axis by a certain angle and then used as components 1 and 2 to repeat S401-S402. Otherwise, the loop is exited and the process goes to S404. When there is an empty set in S404, u1 and u2, directly let the volume of the interference part Otherwise, the volume of the intersecting area of the interference part volume bounding box is calculated , the sum of the bounding box volumes of component 1 and component 2 is V, let , set the threshold ,like , then let Keep the original value unchanged, if , then intersect the triangles of the two sets u1 and u2. If the triangles intersect, let Keep the original value unchanged, otherwise ; S5: The volume of the interference part bounding box obtained in step S4 , and the volume of the AABB bounding box containing all components The fitness function is obtained by summing up; S6, based on the constraints defined in S4 and the fitness function defined in S5, use the genetic algorithm to iteratively optimize the current population, gradually making is equal to 0, tends to a minimum; S7. Determine whether the maximum number of iterations has been reached. If so, output the arrangement result. If not, return to step S4.
2. The STL three-dimensional model arrangement optimization method based on genetic algorithm according to claim 1, characterized in that: Convert the geometric model of the components to be arranged into an STL model, including: exporting the STL model from the 3D model drawn by CAD.
3. The STL three-dimensional model arrangement optimization method based on genetic algorithm according to claim 1, characterized in that: Obtaining individual genetic information x includes: The 1×6n array obtained by directly encoding the degree of freedom of the component is used as the gene ,and In order, components 、 、 The translation distance in the axis direction and the 、 、 The rotation angle of the axis.
4. The STL three-dimensional model arrangement optimization method based on genetic algorithm according to claim 3, characterized in that: Obtaining the genetic information x of an individual also includes: converting the model to any posture v by translating and rotating the triangular facets on the STL model.
5. The STL three-dimensional model arrangement optimization method based on genetic algorithm according to claim 1, characterized in that: Calculate the volume of the interfering bounding boxes between STL models Previously, it also included judging the interference between various STL models, including: The projection method is used to make an initial judgment on the interference between the STL models. If the projections of two components on any coordinate plane do not intersect, it can be determined that the two components do not interfere with each other. If the projections of the two components on each coordinate plane intersect, the STL models are intersected. If the STL models intersect, it is determined that interference occurs between the models, otherwise it is considered that no interference occurs.
6. The STL three-dimensional model arrangement optimization method based on genetic algorithm according to claim 1, characterized in that: The fitness function is: in, is the fitness function, is the maximum value of the triangle vertex coordinates projected on the x-axis, is the minimum value of the triangle vertex coordinates projected on the x-axis, is the maximum value of the triangle vertex coordinates projected on the y-axis, is the minimum value of the triangle vertex coordinates projected on the y-axis, is the maximum value of the triangle vertex coordinates projected on the z-axis, is the minimum value of the triangle vertex coordinates projected on the z-axis, is the weight coefficient.
Citation Information
Patent Citations
Ship pipeline route optimum design method
CN104699899A
Information recommendation method, device and system and storage medium
CN112131457A