Universal 3D printing global continuous path planning method and system
By generating a globally continuous path through vector operations and reinforcement learning, the problems of path interruption and low computational efficiency in complex porous structures are solved, and the accuracy and performance of 3D printing are improved.
Patent Information
- Application Number
- CN202510874426.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-09-19
AI Technical Summary
Existing 3D printing technology has poor path continuity, low computational efficiency, and insufficient adaptability in complex porous structures, resulting in poor printing accuracy and weak mechanical properties.
Vector operations are used to calculate the inner and outer contour offset contours, interference is eliminated through monotone chain decomposition and self-intersection point set generation, the path is planned based on the pointer network based on reinforcement learning, and the paths are connected by combining Bezier curve smoothing and greedy search algorithm to generate a globally continuous path.
It improves the molding accuracy and mechanical properties of 3D printing of complex porous structures, reduces computing time costs, and adapts to the needs of multiple scenarios.
Smart Images

Figure CN120663538A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing or control technology for 3D printing, and in particular to a universal 3D printing global continuous path planning method and system. Background Art
[0002] Path planning is the core of 3D printing, directly affecting the precision, mechanical properties and production efficiency of molded parts. The current mainstream filling methods (such as polyline filling, triangle filling, grid filling and contour offset filling) have significant drawbacks when dealing with complex porous structures:
[0003] Poor path continuity: Existing methods (including improved contour offset, honeycomb filling, and emerging sinusoidal / Hibbert curve filling) still produce path intersections and interruptions in complex contours, resulting in discontinuous material extrusion. This causes local material accumulation or faults, reducing dimensional accuracy and weakening the mechanical properties of the component.
[0004] Low computational efficiency: Although the solution of dividing the sub-regions and then connecting the paths can alleviate the interruption problem, it is heavily dependent on the region division results, has high computational complexity, and generates a large number of redundant paths and sharp corners, exacerbating print head jitter and waste of consumables.
[0005] Insufficient adaptability: When the gap between the inner and outer contours is small or there are dense holes, the offset contour is prone to self-intersection / intersection. Traditional algorithms cannot effectively eliminate interference, resulting in filling path overlap or deviation from the contour boundary, affecting surface quality.
[0006] Current research focuses on two directions:
[0007] Improve traditional fill patterns: such as optimizing offset step lengths or introducing curved paths, but this cannot fundamentally solve the global continuity problem;
[0008] Divide and conquer strategy: Split the contour into sub-areas and plan them separately, then splice the paths together. However, empty travel and sudden turns are easily generated at the connections, and the computational load increases exponentially with the complexity.
[0009] Therefore, there is an urgent need for a general, efficient planning method that can ensure global path continuity to adapt to complex porous structures and improve printing quality and reliability. Summary of the Invention
[0010] To this end, an embodiment of the present invention provides a universal 3D printing global continuous path planning method and system for solving the problems of frequent path interruptions, low computational efficiency, and poor printing accuracy and weak mechanical properties caused by redundant corners when printing complex porous structures in the prior art.
[0011] To solve the above problems, an embodiment of the present invention provides a general 3D printing global continuous path planning method, which includes:
[0012] Input the STL model and slice it to obtain the cross-sectional profile of each layer;
[0013] Taking the extrusion line width as the offset distance, vector operations are used to calculate the offset contours of the inner and outer contours, where the inner contour is offset outward and the outer contour is offset inward;
[0014] When the offset contours self-intersect or intersect, the interference is eliminated through monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction;
[0015] The unit length of the grid line is calculated based on the filling rate and the extrusion line width, the grid points in the filling area are generated, and the intersection points of the offset contour and the grid line are extracted as boundary points to form a path point set.
[0016] A mathematical model for path planning is established with the goal of minimizing path length and angle;
[0017] A pointer network based on reinforcement learning is used to solve the mathematical model and obtain a continuous filling path that traverses all path point sets;
[0018] The curvature constraint of the path is smoothed by using the n-order Bezier curve, and the curvature parameters are controlled to avoid overlapping of adjacent paths.
[0019] A greedy search algorithm is used to connect the outer contour, the smoothed filling path and the inner contour with the minimum distance to generate a global continuous path for 3D printing.
[0020] Preferably, when the offset contours self-intersect or intersect, the method of eliminating interference by monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction includes:
[0021] Decompose the biased profile into monotone chains;
[0022] Calculate the self-intersection point set of the monotone chain and traverse the generated ring;
[0023] The validity of the ring is determined based on the positional relationship between the ring and the original contour;
[0024] Reconstruct a new contour without interference from the valid rings.
[0025] Preferably, the method of calculating the unit length of the grid lines based on the filling rate and the extrusion line width and generating the grid points in the filling area includes:
[0026] The unit length Gu of the grid line is calculated from the ratio of the extrusion line width d and the fill rate μ. The extrusion line width d and the print layer height l need to meet the following constraints:
[0027]
[0028] The ray method is used to determine whether a grid point is within the fill area. A ray is drawn along a certain direction through the grid point to determine the number of intersections between the ray and the inner and outer contours. If the number of intersections is odd, the point is within the fill area; otherwise, the point is outside the fill area.
[0029] Preferably, the method for establishing a mathematical model for path planning with the goal of minimizing path length and angle is:
[0030]
[0031]
[0032] Where ξ is the path point access sequence; f(ξ) is the objective function value; f1(ξ) is the path length function; f2(ξ) is the angle sum function; f1(ξ0) and f2(ξ0) correspond to the initial solutions of f1(ξ) and f2(ξ) respectively; ω1 and ω2 are the weight coefficients of the path length and angle sum, respectively, satisfying ω i >0,∑ω i =1; n is the total number of path points; x ij is the path access label variable; K is the number of all non-empty subsets of V, where V is the set of path points; st indicates that the constraint conditions are met.
[0033] Preferably, the path length function f1(ξ) is expressed as:
[0034]
[0035] Where, d ij is the distance between two path points.
[0036] Preferably, the fold angle and function f2(ξ) are expressed as:
[0037]
[0038] Where, P i (x i ,y i ), P i+1 (x i+1 ,y i+1 ), P i+2 (x i+2 ,y i+2 ) are three consecutive points on the path, α i =∠P i P i+ 1P i+2 is a vector and Angle.
[0039] Preferably, the pointer network includes:
[0040] Encoder: A long short-term memory network that converts waypoints into latent memory states;
[0041] Decoder: Generates path point probability distribution through attention mechanism:
[0042]
[0043] Where p is the probability distribution vector; ξ θ is a parameterized policy function; a i Number of the path point to be selected; s i is the current state; u i is the unnormalized score; v is the trainable weight vector; is the key weight matrix; is the query weight matrix; q is the query vector, r i is a reference vector containing context information of all waypoints.
[0044] Preferably, the equation of the n-th order Bezier curve is:
[0045]
[0046] Where P(t) is the coordinate of the point on the curve; m is the order of the Bezier curve; j is the summation index; P j is the coordinate of the jth control point; t is the parameter of the curve, and its value range is [0, 1];
[0047] The formula for calculating the curvature at any point on the curve is:
[0048]
[0049] Where k(t) is the curvature value, x′(t) is the first-order derivative in the x-direction; x″(t) is the second-order derivative in the x-direction; y′(t) is the first-order derivative in the y-direction; and y″(t) is the second-order derivative in the y-direction.
[0050] Preferably, the method of using a greedy search algorithm to connect the outer contour, the smoothed filling path, and the inner contour with the minimum distance to generate a 3D printing global continuous path includes:
[0051] Input path data point set;
[0052] The path points are sorted in order of outer contour, smoothed filled path and inner contour;
[0053] Generate a neighborhood point set by the coordinate threshold to narrow the search range;
[0054] Find the starting point of the path through a greedy search algorithm;
[0055] Reorder the path points;
[0056] Outputs an ordered set of data points for a globally continuous path.
[0057] An embodiment of the present invention further provides a universal 3D printing global continuous path planning system, which is used to implement the universal 3D printing global continuous path planning method described above, specifically comprising:
[0058] Model input and slicing module, used to input STL model and slice it to obtain the cross-sectional profile of each layer;
[0059] The contour offset generation module is used to calculate the offset contours of the inner and outer contours using vector operations with the extrusion line width as the offset distance, where the inner contour is offset outward and the outer contour is offset inward;
[0060] The offset contour interference elimination module is used to eliminate interference when the offset contour self-intersects or intersects through monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction;
[0061] The path point generation module is used to calculate the unit length of the grid line based on the fill rate and extrusion line width, generate the grid points in the fill area, and extract the intersection points of the offset contour and the grid line as boundary points to form a path point set.
[0062] A path planning mathematical model building module is used to build a path planning mathematical model with the goal of minimizing the path length and the angle;
[0063] The path solving module is used to solve the mathematical model using a pointer network based on reinforcement learning to obtain a continuous filling path that traverses all path point sets;
[0064] The path smoothing module is used to smooth the path with curvature constraints using an n-order Bezier curve, controlling the curvature parameters to avoid overlapping of adjacent paths.
[0065] The path connection module is used to connect the outer contour, the smoothed filling path and the inner contour with the minimum distance using a greedy search algorithm to generate a global continuous path for 3D printing.
[0066] It can be seen from the above technical solutions that the present invention has the following beneficial effects:
[0067] (1) The present invention avoids path crossing, interruption and material accumulation through global continuous path planning (such as interference elimination to ensure contour accuracy, Bezier curve smoothing path, and greedy algorithm connection path), making the connection between printing layers closer, and effectively improving the molding accuracy of complex porous structure 3D printing; the continuous and contour-fitting path reduces stress concentration, enhances the mechanical properties of the printed body, and solves the accuracy and performance defects caused by traditional filling methods.
[0068] (2) The present invention adapts to complex porous structures (including internal and external contours and hollow areas) throughout the entire process, from STL slicing and contour offsetting to interference processing, path point generation and connection, without relying on specific model segmentation, and covers multi-scenario 3D printing needs; based on the reinforcement learning pointer network to solve the path and the greedy search algorithm to connect the paths, redundant calculations are reduced, and a global continuous path is quickly planned. Compared with traditional area division and search methods, the planning efficiency is greatly improved and the time cost is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the implementation cases of the present invention or the technical solutions in the prior art, the following briefly describes the drawings required for use in the embodiments. By referring to the drawings, the features and advantages of the present invention will be more clearly understood. The drawings are for illustration only and should not be construed as limiting the present invention in any way. Those skilled in the art can derive other drawings based on these drawings without inventive effort. Among them:
[0070] Figure 1 A flowchart of a general 3D printing global continuous path planning method provided by the present invention;
[0071] Figure 2 Flowchart of the method for eliminating interference of offset contour intersection or self-intersection in the present invention;
[0072] Figure 3 Schematic diagram of the network structure in the present invention;
[0073] Figure 4 Schematic diagram of the path smoothing process in the present invention;
[0074] Figure 5 A flow chart of path connection in the present invention;
[0075] Figure 6 This is a flow chart of an example of path planning in the present invention;
[0076] Figure 7 A block diagram of a universal 3D printing global continuous path planning system provided by the present invention. DETAILED DESCRIPTION
[0077] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0078] Example 1
[0079] In order to solve the problems of frequent path interruption, low computational efficiency, and poor printing accuracy and weak mechanical properties caused by redundant corners when printing complex porous structures in the existing technology, Figure 1 As shown, the present invention proposes a universal 3D printing global continuous path planning method, which includes:
[0080] S1: Input the STL model and slice it to obtain the cross-sectional profile of each layer;
[0081] S2: Using the extrusion line width as the offset distance, use vector operations to calculate the offset contours of the inner and outer contours.
[0082] The inner contour is biased outwards and the outer contour is biased inwards;
[0083] S3: When the offset contours self-intersect or intersect, the interference is eliminated through monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction;
[0084] S4: Calculate the unit length of the grid line based on the fill rate and extrusion line width, generate grid points within the fill area, and extract the intersection points of the offset contour and the grid line as boundary points to form a path point set;
[0085] S5: Establish a mathematical model for path planning with the goal of minimizing path length and angle;
[0086] S6: A pointer network based on reinforcement learning is used to solve the mathematical model and obtain a continuous filling path that traverses all path point sets;
[0087] S7: Curvature-constrained smoothing of the path is performed using an n-order Bezier curve, and curvature parameters are controlled to avoid overlapping of adjacent paths.
[0088] S8: A greedy search algorithm is used to connect the outer contour, the smoothed filling path, and the inner contour with the minimum distance to generate a global continuous path for 3D printing.
[0089] From the above technical solution, it can be seen that the present invention proposes a universal global continuous path planning method for 3D printing. Step S1 inputs STL model slices to obtain the cross-sectional contour of each layer, providing a basis for path planning; Step S2 uses the extrusion line width as the offset distance, and uses vector operations to calculate the inner and outer contour offset contours to clarify the boundary of the filling area; S3 eliminates interference by monotone chain decomposition when the offset contours self-intersect or intersect, ensuring the correctness of the contour topology; S4 generates grid points and boundary points based on the filling rate and extrusion line width to form a path point set, and accurately defines the filling area; S5 establishes a mathematical model with the goal of minimizing the path length and the sum of the corners to determine the planning direction; S6 uses a pointer network solution model based on reinforcement learning to obtain a continuous filling path and optimize the path order; S7 uses an n-order Bezier curve to smooth the path and constrain the curvature to avoid overlap and improve the path quality; S8 uses a greedy search algorithm to connect the outer contour, filling path and inner contour to generate a global continuous path with the minimum air distance. This method effectively solves the existing problems through the coordination of various steps, improves printing accuracy, mechanical properties and computational efficiency, and realizes high-quality 3D printing of complex porous structures.
[0090] In step S1, the STL model is input and sliced to obtain the cross-sectional profile of each layer.
[0091] Specifically, the STL (Stereo Lithography) model is one of the most commonly used file formats in 3D printing. It approximates the surface geometry of a three-dimensional object using a triangular mesh of facets, each defined by three vertex coordinates and a normal vector (indicating the surface orientation). As input data for 3D printing, the STL model provides the object's three-dimensional geometric outline, serving as the basis for subsequent path planning.
[0092] Furthermore, the 3D STL model is cut into a series of 2D sections with uniform thickness along a specific direction (usually the Z-axis direction) so that the 3D printer can print layer by layer. The principle is: by setting the slice thickness (i.e. the printing layer height l), the constraints of the extrusion line width d and l must be met. ) generates a series of slice planes parallel to the XY plane at equal intervals in the Z-axis direction of the STL model. Each slice plane intersects with the triangular mesh of the STL model to generate the cross-sectional contour line of that layer.
[0093] Furthermore, the specific process of obtaining the cross-sectional profile is as follows:
[0094] Import STL model: Import the STL file that stores the geometric information of the three-dimensional object into the 3D printing path planning software.
[0095] Slice parameter settings: Set the slice thickness (print layer height l), which affects printing accuracy and efficiency: the smaller the thickness, the higher the accuracy, but the longer the printing time. Determine the slicing direction (usually the Z-axis direction, that is, perpendicular to the printing platform).
[0096] Calculate Slice Intersection Lines: The slicing plane intersects each triangle of the STL model and calculates the intersection line segments. For each triangle, if two of its vertices are on one side of the slicing plane and one vertex is on the other side, then the slicing plane and the triangle intersect on a line segment. If all three vertices are on the same side, there is no intersection line.
[0097] Contour extraction and closure: All slice intersections are sequentially connected to form closed contours. Since STL models may contain multiple disconnected areas (such as the inner and outer contours of complex porous structures), each slice layer may generate multiple closed contours.
[0098] Distinguish between inner and outer contours: Determine the outer contour (the outer boundary of the object) and the inner contour (the boundary of holes and hollow parts) by rules such as the contour's winding direction (clockwise or counterclockwise) or area size.
[0099] Output cross-sectional profile data: Store the cross-sectional profile of each layer in the form of a coordinate point set as input data for subsequent contour offset and path planning.
[0100] In step S2, the extrusion line width is used as the offset distance, and vector operations are used to calculate the offset contours of the inner and outer contours, wherein the inner contour is offset outward and the outer contour is offset inward.
[0101] This method offsets the cross-sectional profile to generate the boundaries of the infill area, ensuring that subsequent infill paths closely follow the profile, avoiding gaps or overlaps between the infill path and the profile. This ensures the precision and mechanical properties of the 3D printed object. This method is suitable for 3D printing complex porous structures, such as models with hollows, holes, or multiply connected regions, where the offset profile is required to accurately determine the boundaries of the infill area.
[0102] Specifically, the principle of using vector operations to calculate the offset profile in the present invention is:
[0103] Offset direction and distance:
[0104] Direction: The inner contour is offset outward, and the outer contour is offset inward, ensuring that the offset contour faces the inside of the fill area.
[0105] Distance: The offset distance is the extrusion line width d (i.e. the width of the material extruded by the 3D printer nozzle). This distance must meet the constraints of the printing layer height l. To ensure the stability of material stacking.
[0106] The core logic of vector operations:
[0107] The vector relationship between adjacent points on the contour is used to calculate the offset direction and offset of each point to ensure that the offset contour is geometrically parallel and equidistant to the original contour.
[0108] By normalizing and synthesizing vectors, the position of the bias point can be precisely controlled to avoid the errors in the curve contour caused by traditional geometric bias methods (such as coordinate translation).
[0109] Furthermore, the calculation formula of the bias point is:
[0110]
[0111] Where P is any point on the contour, P′ is its corresponding offset point, d is the offset distance, P1 and P2 are two points adjacent to P on the contour, and θ is the vector and Angle.
[0112] In step S3, when the offset contours self-intersect or intersect, the interference is eliminated through monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction.
[0113] Interference can occur when the original contour is complex and porous (such as multiply connected areas or sharp corners) or when the gap between the inner and outer contours is small. The offset contour may intersect with itself (the contour lines intersect with themselves) or with the original inner and outer contours. For example, when the inner contour is offset outward, if the spacing between adjacent inner contours is less than 2d, they may overlap after the offset. When the outer contour is offset inward, the offset lines at sharp corners may intersect with each other.
[0114] In order to eliminate the interference of the offset contour, avoid material accumulation, path overlap or printing defects during 3D printing path planning, and ensure the continuity of the filling path and the molding accuracy of the printed body, such as Figure 2 As shown, the present invention proposes a method for eliminating interference of offset contour intersection or self-intersection, and the process is as follows:
[0115] 1. Decompose the offset contour into a monotone chain
[0116] Definition of monotone chain: In plane geometry, a monotone chain refers to a sequence of curve segments that increases or decreases monotonically along a coordinate axis (such as the X-axis or the Y-axis).
[0117] Decomposition method:
[0118] The closed curve of the offset contour is split into several monotone chains. The projection of each chain on the X-axis (or Y-axis) has no return, which is convenient for subsequent self-intersection point calculation.
[0119] For example, for a closed polygonal contour, the contour can be decomposed into two monotone chains, one above the other, by sorting the vertex coordinates by their X values.
[0120] 2. Find the self-intersection point set
[0121] Calculation logic: For the decomposed monotone chain, all possible self-intersecting line segment pairs are calculated using the geometric intersection algorithm.
[0122] Specific steps:
[0123] Traverse each pair of monotone chains and check whether the line segments intersect;
[0124] Use vector cross products or parametric equations to solve the coordinates of the line segment intersections and record all self-intersection points.
[0125] 3. Traverse the self-intersection points to generate a ring
[0126] The logic of loop generation: starting from the self-intersection point, traverse along the contour line until returning to the starting point to form a closed loop.
[0127] Example: If the contour line intersects itself at point P, starting from P, traverse along two contour lines with different directions until returning to P again, generating two closed loops.
[0128] 4. Validity of the discriminant ring
[0129] Validity judgment criteria:
[0130] Geometric rules: Valid rings should satisfy the topological relationship of the "inner-outer" contour. For example, the area of the ring generated by the outer contour offset should be smaller than the original outer contour, and the area of the ring generated by the inner contour offset should be larger than the original inner contour.
[0131] Direction rule: The direction of the ring (clockwise or counterclockwise) determines whether it is the boundary of the fill area. For example, the outer contour is usually surrounded by counterclockwise, and the inner contour is surrounded by clockwise.
[0132] Invalid ring processing: If the area of the ring is too small, inconsistent with the original contour topology, or the direction is wrong, it will be judged as an invalid ring and discarded.
[0133] 5. Reconstruction to obtain new contours
[0134] Reconstruction method: retain all valid rings, eliminate invalid rings and interference segments, and reconnect the contour segments of valid rings to form a new contour without interference.
[0135] Result: The new contour ensures that the offset path boundary is clear without intersection or overlap, providing an accurate geometric basis for subsequent path point generation.
[0136] In step S4, the unit length of the grid line is calculated based on the filling rate and the extrusion line width, the grid points in the filling area are generated, and the intersection points of the offset contour and the grid line are extracted as boundary points to form a path point set.
[0137] Specifically, this invention proposes a method for acquiring path points in the fill area. Path points are composed of grid points and boundary points. To meet the preset fill rate, the grid unit length is calculated by combining the fill rate and the extrusion line width, thereby generating evenly distributed grid points within the fill area. At the same time, to ensure that the fill path closely fits the contour and avoids gaps or overlaps, the boundary points of the fill area are determined by using the intersection of the offset contour and the grid lines, as follows:
[0138] 1) Grid points of the filling area
[0139] To achieve the set fill rate, the grid line unit length Gu is calculated using the ratio of the extrusion line width d and the fill rate μ. The extrusion line width d and the print layer height l must meet the constraints:
[0140]
[0141] A ray method is used to determine whether a grid point is within the infill region: a ray is emitted from the grid point in a certain direction and the number of intersections between the ray and the inner and outer contours is counted. If the number of intersections is odd, the point is considered within the infill region; if it is even, it is outside the infill region.
[0142] 2) Boundary points of the filling area
[0143] To ensure the fill path fits the contour, the boundary points are determined by offsetting the intersection of the contour and the grid lines. Using the extrusion line width as the offset distance, the inner and outer contours are offset (the inner contour is offset outward, the outer contour is offset inward). This offset calculation is performed using the cross product method. The offset distance is equal to the extrusion line width d. The offset point calculation formula is shown above.
[0144] In step S5, a mathematical model for path planning is established with the goal of minimizing the path length and the sum of the bending angles.
[0145] Specifically, by comprehensively considering constraints such as fill rate and avoiding path overlap, the present invention aims to reduce path angles and shorten path length, constructing a mathematical model to obtain a continuous fill path by traversing path points within the fill area.
[0146] 1) The path length function is expressed as:
[0147]
[0148] Where n is the total number of path points, d ij (d ij >0, i≠j) is the distance between two path points, x ij Mark whether a path point has been visited, and any solution ξ is a permutation of all path points.
[0149] 2) The angle sum function is expressed as:
[0150]
[0151] Where, P i (x i ,y i ), P i+1 (x i+1 ,y i+1 ), P i+2 (x i+2 ,y i+2 ) are three consecutive points on the path, α i =∠P i P i+ 1P i+2 is a vector and Angle.
[0152] 3) The mathematical model of path planning is established as follows:
[0153]
[0154] Where ξ is the path point access sequence; f(ξ) is the objective function value; f1(ξ) is the path length function; f2(ξ) is the angle sum function; f1(ξ0) and f2(ξ0) correspond to the initial solutions of f1(ξ) and f2(ξ) respectively; ω1 and ω2 are the weight coefficients of the path length and angle sum, respectively, satisfying ω i >0,∑ω i =1; n is the total number of path points; x ij is the path visit marker variable; K is the number of all non-empty subsets of V, where V is the set of path points; st represents the satisfaction of the constraints. The constraints ensure that each path point is visited only once and that all path points are traversed. The solution is a permutation ξ containing all path points that minimizes the objective function f(ξ).
[0155] In step S6, a pointer network based on reinforcement learning is used to solve the mathematical model to obtain a continuous filling path that traverses all path point sets.
[0156] Specifically, the present invention trains a recursive neural network through reinforcement learning, solves the mathematical model, and plans a continuous filling path that traverses all path points. The network structure is as follows Figure 3As shown, the neural network architecture uses the chain rule to factorize the path probability. The resulting components are sequentially processed by softmax modules. A pointer network is used as the actor policy model. This model consists of two modules: an encoder and a decoder, each containing long-short-term memory units. The encoder network examines the input state, processing one waypoint at a time, and converts it into a series of latent memory states. The decoder network uses a pointing mechanism to predict the probability distribution over upcoming waypoints to optimize the objective function.
[0157] Furthermore, the pointing mechanism is parameterized by two learned attention matrices and an attention vector, and the probability distribution strategy over all candidate path points is:
[0158]
[0159] Where p is the probability distribution vector; ξ θ is a parameterized policy function; a i Number of the path point to be selected; s i is the current state; u i is the unnormalized score; v is the trainable weight vector; is the key weight matrix; is the query weight matrix; q is the query vector, r i is a reference vector containing the context information of all waypoints. i =argmax(p) predicts the next waypoint to visit.
[0160] Furthermore, the present invention uses the policy gradient method of reinforcement learning to optimize the parameters of the pointer network to control the stable update during optimization:
[0161]
[0162] in, is the gradient operator; J(θ|s) is the policy objective function; θ is the parameter of the optimization policy pointer network, b(s) is the benchmark function value that does not depend on the policy, It is an estimate of the optimization function at time t, and the variance of the gradient is reduced by estimating the function value.
[0163] In step S7, the path is smoothed with curvature constraints using an n-th order Bezier curve, and the curvature parameters are controlled to avoid overlapping of adjacent paths.
[0164] Specifically, the present invention uses a Bezier curve to smooth the path. The n-order Bezier curve is composed of control points {P0, P1, ... P n} OK, calculate the interpolation point using the curve equation, the curve equation is as follows:
[0165]
[0166] Where P(t) is the coordinate of the point on the curve; m is the order of the Bezier curve; j is the summation index; P j is the coordinate of the jth control point; t is the parameter of the curve, and its value range is [0,1].
[0167] The formula for calculating the curvature at any point on the curve is:
[0168]
[0169] Where k(t) is the curvature value, x′(t) is the first-order derivative in the x-direction; x″(t) is the second-order derivative in the x-direction; y′(t) is the first-order derivative in the y-direction; and y″(t) is the second-order derivative in the y-direction.
[0170] Different curvature parameters yield different smoothing effects. If the curvature parameter k is large, the path will still have sharp corners; if k is small, the path will be significantly deformed, reducing the distance between adjacent paths and causing overlap.
[0171] Furthermore, the path smoothing process is as follows Figure 4 As shown in the figure: first input the path point set, set the number of insertion points and the curvature parameter threshold, and generate the midpoint set and segmentation point set of the original data; then translate the vertices, generate control points, and then use the nth-order Bezier curve equation for interpolation; finally, iterate repeatedly until the optimal curvature parameter is determined, and output the smoothed path point set.
[0172] In step S8, a greedy search algorithm is used to connect the outer contour, the smoothed filling path, and the inner contour with the minimum distance to generate a global continuous path for 3D printing.
[0173] Specifically, in order to connect the inner and outer contours and the filling path with a shorter distance, the input to be processed is the data point set of the inner and outer contours and the filling path, and the target output is the data point set of the continuous path. The present invention uses a greedy search algorithm to achieve path connection. The process is as follows Figure 5 As shown in the figure: input the data point set of the path; sort the path points in order of outer contour, smoothed filled path and inner contour; generate a neighborhood point set based on the coordinate threshold to narrow the search range; find the starting point of the path through the greedy search algorithm; reorder the path points; output the ordered data point set of the global continuous path.
[0174] To further illustrate the advantages of the present invention, a complex porous pattern is used as an example to plan a path. Given a known cross-sectional profile, the profile offset line is calculated and interference is eliminated. Path points in the fill area are obtained and a mathematical model for solving the path is established. The path is obtained by traversing the path points through a pointer network based on reinforcement learning. The path is smoothed, and the inner and outer contours and the fill path are connected to finally obtain a globally continuous path. The example process is as follows: Figure 6 shown.
[0175] Example 2
[0176] like Figure 7 As shown, the present invention provides a universal 3D printing global continuous path planning system, which is used to implement the universal 3D printing global continuous path planning method of the above embodiment 1, specifically comprising:
[0177] The model input and slicing module 100 is used to input the STL model and slice it to obtain the cross-sectional profile of each layer;
[0178] The contour offset generation module 200 is used to calculate the offset contours of the inner and outer contours using vector operations with the extrusion line width as the offset distance, wherein the inner contour is offset outward and the outer contour is offset inward;
[0179] The offset contour interference elimination module 300 is used to eliminate interference by monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction when the offset contour self-intersects or intersects;
[0180] A path point generation module 400 is used to calculate the unit length of the grid line based on the fill rate and the extrusion line width, generate grid points within the fill area, and extract the intersection points of the offset contour and the grid line as boundary points to form a path point set;
[0181] A path planning mathematical model building module 500 is used to build a path planning mathematical model with the goal of minimizing the path length and the angle;
[0182] A path solving module 600 is used to solve a mathematical model using a pointer network based on reinforcement learning to obtain a continuous filling path that traverses all path point sets;
[0183] A path smoothing module 700 is used to perform curvature-constrained smoothing on the path using an n-th order Bezier curve, controlling the curvature parameters to avoid overlapping of adjacent paths;
[0184] The path connection module 800 is used to connect the outer contour, the smoothed filling path and the inner contour with the minimum distance using a greedy search algorithm to generate a global continuous path for 3D printing.
[0185] A universal 3D printing global continuous path planning system of this embodiment is used to implement the aforementioned universal 3D printing global continuous path planning method. Therefore, the specific implementation methods of the universal 3D printing global continuous path planning system can be seen in the embodiment part of the universal 3D printing global continuous path planning method mentioned above. For example, the model input and slicing module 100, the contour offset generation module 200, the offset contour interference elimination module 300, the path point generation module 400, the path planning mathematical model establishment module 500, the path solving module 600, the path smoothing module 700, and the path connection module 800 are respectively used to implement steps S1, S2, S3, S4, S5, S6, S7, and S8 in the above-mentioned universal 3D printing global continuous path planning method. Therefore, its specific implementation methods can refer to the description of the corresponding embodiments of each part. In order to avoid redundancy, they will not be repeated here.
[0186] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0187] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0188] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0189] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain within the scope of protection of the present invention.
Claims
1. A general 3D printing global continuous path planning method, characterized in that: include: Input the STL model and slice it to obtain the cross-sectional profile of each layer; Taking the extrusion line width as the offset distance, vector operations are used to calculate the offset contours of the inner and outer contours, where the inner contour is offset outward and the outer contour is offset inward; When the offset contours self-intersect or intersect, the interference is eliminated through monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction; The unit length of the grid line is calculated based on the filling rate and the extrusion line width, the grid points in the filling area are generated, and the intersection points of the offset contour and the grid line are extracted as boundary points to form a path point set. A mathematical model for path planning is established with the goal of minimizing path length and angle; A pointer network based on reinforcement learning is used to solve the mathematical model and obtain a continuous filling path that traverses all path point sets; The curvature constraint of the path is smoothed by using the n-order Bezier curve, and the curvature parameters are controlled to avoid overlapping of adjacent paths. A greedy search algorithm is used to connect the outer contour, the smoothed filling path and the inner contour with the minimum distance to generate a global continuous path for 3D printing.
2. The universal 3D printing global continuous path planning method according to claim 1, characterized in that: When the offset contours self-intersect or intersect, the method for eliminating interference by monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction includes: Decompose the biased profile into monotone chains; Calculate the self-intersection point set of the monotone chain and traverse the generated ring; The validity of the ring is determined based on the positional relationship between the ring and the original contour; Reconstruct a new contour without interference from the valid rings.
3. The universal 3D printing global continuous path planning method according to claim 1, characterized in that: The method of calculating the unit length of the grid line based on the filling rate and the extrusion line width and generating the grid points in the filling area includes: The unit length Gu of the grid line is calculated from the ratio of the extrusion line width d and the fill rate μ. The extrusion line width d and the print layer height l need to meet the following constraints: The ray method is used to determine whether a grid point is within the fill area. A ray is drawn along a certain direction through the grid point to determine the number of intersections between the ray and the inner and outer contours. If the number of intersections is odd, the point is within the fill area; otherwise, the point is outside the fill area.
4. The universal 3D printing global continuous path planning method according to claim 1, characterized in that: The method for establishing a mathematical model for path planning with the goal of minimizing path length and angle is as follows: Where ξ is the path point access sequence; f(ξ) is the objective function value; f1(ξ) is the path length function; f2(ξ) is the angle sum function; f1(ξ0) and f2(ξ0) correspond to the initial solutions of f1(ξ) and f2(ξ) respectively; ω1 and ω2 are the weight coefficients of the path length and angle sum, respectively, satisfying ω i >0,∑ω i =1; n is the total number of path points; x ij is the path access marker variable; K is the number of all non-empty subsets of V, where V is the set of path points; st means that the constraints are met.
5. The universal 3D printing global continuous path planning method according to claim 4, characterized in that: The path length function f1(ξ) is expressed as: Where, d ij is the distance between two path points.
6. The universal 3D printing global continuous path planning method according to claim 4, characterized in that: The fold angle and function f2(ξ) are expressed as: Where, P i (x i ,y i ),P i+1 (x i+1 ,y i+1 ),P i+2 (x i+2 ,y i+2 ) are three consecutive points on the path, α i =∠P i P i+1 P i+2 is a vector and Angle.
7. The universal 3D printing global continuous path planning method according to claim 1, characterized in that: The pointer network includes: Encoder: A long short-term memory network that converts waypoints into latent memory states; Decoder: Generates path point probability distribution through attention mechanism: Where p is the probability distribution vector; ξ θ is a parameterized policy function; a i Number the path point to be selected; s i is the current state; u i is the unnormalized score; v is the trainable weight vector; is the key weight matrix; is the query weight matrix; q is the query vector, r i is a reference vector containing context information of all waypoints.
8. The universal 3D printing global continuous path planning method according to claim 1, characterized in that: The equation of the n-th order Bezier curve is: Where P(t) is the coordinate of the point on the curve; m is the order of the Bezier curve; j is the summation index; P j is the coordinate of the jth control point; t is the parameter of the curve, and its value range is [0,1]; The formula for calculating the curvature at any point on the curve is: Where k(t) is the curvature value, x′(t) is the first-order derivative in the x-direction; x″(t) is the second-order derivative in the x-direction; y′(t) is the first-order derivative in the y-direction; and y″(t) is the second-order derivative in the y-direction.
9. The universal 3D printing global continuous path planning method according to claim 1, characterized in that: The method for generating a 3D printing global continuous path by connecting the outer contour, the smoothed filling path, and the inner contour with the minimum distance using a greedy search algorithm includes: Input path data point set; The path points are sorted in order of outer contour, smoothed filled path and inner contour; Generate a neighborhood point set by the coordinate threshold to narrow the search range; Find the starting point of the path through a greedy search algorithm; Reorder the path points; Outputs an ordered set of data points for a globally continuous path.
10. A universal 3D printing global continuous path planning system, characterized in that: The system is used to implement the universal 3D printing global continuous path planning method according to any one of claims 1 to 9, specifically comprising: Model input and slicing module, used to input STL model and slice it to obtain the cross-sectional profile of each layer; The contour offset generation module is used to calculate the offset contours of the inner and outer contours using vector operations with the extrusion line width as the offset distance, where the inner contour is offset outward and the outer contour is offset inward; The offset contour interference elimination module is used to eliminate interference when the offset contour self-intersects or intersects through monotone chain decomposition, self-intersection point set generation, loop validity judgment and contour reconstruction; The path point generation module is used to calculate the unit length of the grid line based on the fill rate and extrusion line width, generate the grid points in the fill area, and extract the intersection points of the offset contour and the grid line as boundary points to form a path point set. A path planning mathematical model building module is used to build a path planning mathematical model with the goal of minimizing the path length and the angle; The path solving module is used to solve the mathematical model using a pointer network based on reinforcement learning to obtain a continuous filling path that traverses all path point sets; The path smoothing module is used to smooth the path with curvature constraints using an n-order Bezier curve, controlling the curvature parameters to avoid overlapping of adjacent paths. The path connection module is used to connect the outer contour, the smoothed filling path and the inner contour with the minimum distance using a greedy search algorithm to generate a global continuous path for 3D printing.
Citation Information
Cited By
3D printing local enhancement path planning method and system based on finite element analysis
CN121257215A
Shared bicycle scheduling variable VRP search method based on deep reinforcement learning driving
CN121936782A
Nail feeding device capable of being suitable for different pedicle screw threads and thread design method of nail feeding device
CN122056676A