A complex gap repair method for 3D models based on optimization
Through an optimized method for repairing complex gaps in 3D models, gaps in CAD models can be identified and repaired, solving the accuracy and efficiency issues in gap detection and repair, and achieving high-quality model repair. It is suitable for fields such as architectural design, mechanical design, and medical equipment.
Patent Information
- Application Number
- CN202411516094.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-10-29
AI Technical Summary
Existing technologies have difficulty in accurately identifying and efficiently repairing complex gaps in 3D CAD models, which affects model effectiveness and simulation efficiency.
An optimization-based method for repairing complex gaps in three-dimensional models is adopted. By traversing the B-Rep model boundary, a connection relationship diagram of the gap edges is constructed, the ring structure is identified, and the smoothness error, surface difference error and gap scale error are used to optimize the patching surface equation, and finally the geometric topology and geometry modification are performed.
The accuracy of gap detection and identification is improved, ensuring that the repaired model has little difference from the original model, the gap disappears, the connection is smooth, and the repair quality is excellent. It is suitable for products such as architectural design, mechanical design, and medical equipment.
Smart Images

Figure CN119475461B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer three-dimensional model repair, and in particular to a method for repairing complex gaps in three-dimensional models based on optimization. Background Art
[0002] With the rapid development of computer technology, 3D CAD models are widely used in various fields. However, during the 3D CAD modeling process or when converting 3D CAD models, model gap errors can occur. These errors may arise from weak modeling operations, improper modeling operations, or model exchange between heterogeneous systems. These errors can undermine the validity and accuracy of the model, and have a serious negative impact on subsequent applications such as simulation and machining.
[0003] Repairing gaps in models is crucial, but it presents numerous challenges. First, the structure of the model at the gaps can be extremely complex, and the types of gaps can be diverse, making it difficult to automatically and accurately identify gap errors. Second, during the repair process, there is no single method, making it difficult to determine the optimal repair method to ensure that the final model is consistent with the ideal state. Finally, both identifying and repairing model gaps involves a large number of computations, increasing complexity and time consumption, making it difficult to ensure high efficiency.
[0004] Gap repair in commercial software is done manually by engineers, providing two operations: boundary movement and surface filling, which seriously affects efficiency. Currently, the commonly used repair method mainly focuses on filling the surface at the gap. However, due to the small size of the gap, the size of the filled surface is small, which affects the efficiency of subsequent simulations. Although people have proposed several methods for detecting and repairing gaps, it is still difficult to accurately identify and effectively repair complex gaps. Therefore, there are many problems that need to be solved in existing methods. The most critical issues include how to accurately and robustly identify gaps, how to define the optimal repair method, and how to optimally repair gaps to ensure the effectiveness of the model. Summary of the Invention
[0005] In order to solve the problems existing in the background technology, the present invention provides a method for repairing complex gaps in a three-dimensional model based on optimization.
[0006] The technical solution adopted in the present invention is:
[0007] The present invention provides a method for repairing complex gaps in a three-dimensional model based on optimization, comprising the following steps:
[0008] S1. Obtain the B-Rep model of the product to be inspected and repaired in the computer;
[0009] S2. Traverse all edges of the B-Rep model to obtain gap edges, construct a connection relationship graph of all gap edges based on the gap edges, search the connection relationship graph to obtain all ring structures, and process the ring structures to obtain all edge pairs that meet the conditions;
[0010] S3, sampling the edge pairs obtained in step S2, processing all the sampled points to obtain an overall optimization error including smoothness error, surface difference error, and gap scale error, and continuously optimizing the edge pairs based on the overall optimization error to finally obtain the patching surface equation;
[0011] S4. Repair the B-Rep model of the product to be repaired according to the repair surface equation obtained in step S3 to obtain a B-Rep model with correct geometric topology, which is then used to make the repaired product.
[0012] The products that need to be repaired include architectural design, mechanical design, medical equipment and other products.
[0013] The step S2 is specifically as follows:
[0014] S21. Traverse all edges in the B-Rep model, count the number of faces adjacent to each edge, and mark the edges with only one adjacent face as gap edges;
[0015] S22. For the gap edges marked in step S21, if the distance between an endpoint on any gap edge and an endpoint on any other gap edge is less than a preset connection threshold, mark the two gap edges as connected, search all gap edges marked as connected, and establish a connection relationship graph for all gap edges;
[0016] S23. Perform a depth-first search on the connection relationship graph of all gap edges obtained to find ring structures, and process and obtain the area of each ring structure. If the area of the ring structure is less than a preset single-ring structure gap threshold, the ring structure itself is a gap and is treated as a single-ring gap.
[0017] S24. For all ring structures whose areas are not less than the single-ring structure gap threshold in step S23, the gap area between every two ring structures is obtained. If the gap area is less than the double-ring structure gap threshold, a gap is formed between the two ring structures as a double-ring gap.
[0018] S25, matching any two gap edges in the single-ring gap obtained in step S23, obtaining a direction matching value and a distance matching value for each matching, comparing the direction matching value and the distance matching value with a preset direction threshold and a preset distance threshold, respectively, retaining two gap edges whose direction matching value is greater than the direction threshold and whose distance matching value is greater than the distance threshold to form a group of edge pairs;
[0019] S26. For the two ring structures in the dual-ring gap obtained in step S24, each gap edge of one ring structure is matched with all gap edges of the other ring structure, obtaining a direction matching value and a distance matching value for each matching. Two gap edges with a direction matching value greater than a direction threshold and a distance matching value greater than a distance threshold are retained to form a group of edge pairs.
[0020] S27. All edge pairs obtained from step S25 and step S26 eventually constitute all edge pairs that meet the conditions.
[0021] The step S3 is specifically as follows:
[0022] S31. Based on all edge pairs obtained in step S2, obtain the parameters of the faces that are adjacent to the two gap edges in each edge pair, and use the parameters of the faces that are adjacent to all edge pairs and the curve parameters of the edge as the curve and surface parameters of the edge pair;
[0023] S32. Based on the curve and surface parameters of the edge pair obtained in step S31, process each edge pair in the following manner:
[0024] Sampling the edge pairs and the faces adjacent to the edge pairs using curve and surface parameters to obtain a sampling point and its initial position, mapping the sampling points into three-dimensional space, processing the distance between each sampling point and its corresponding edge pair in the three-dimensional space, and obtaining a sampling step length for the next sampling based on the distance processing. Traversing and searching for the next sampling point according to the sampling step length until the traversal and sampling are completed, and constructing the initial surface equation of the faces adjacent to the edge pairs in the three-dimensional space based on all the sampling points;
[0025] S33. For each sampling point obtained in step S32, search for other sampling points in its neighborhood. Obtain the distance between the current sampling point and each of the other sampling points according to the surface equation. Record the other sampling points whose distance is less than a preset reference point threshold as reference points. Add all reference points to the neighborhood point set. Obtain the normal vector of the current sampling point according to the neighborhood point set extraction process. Perform prediction processing based on the normal vector of the current sampling point to obtain the predicted coordinates of the current point. The distance between the coordinates of the current sampling point and the predicted coordinates of the current sampling point is used as the smoothing error of the current sampling point.
[0026] S34, processing and obtaining the distance from the current position to the initial position of each sampling point, which is the surface difference error;
[0027] S35, processing to obtain the distance from each sampling point on one gap edge to the other gap edge in all edge pairs, which is the gap scale error;
[0028] S36, taking the average of the smoothing error, surface difference error, and gap scale error obtained in steps S33 to S35, and performing weighted summation on the averaged smoothing error, surface difference error, and gap scale error to obtain an overall optimization error;
[0029] S37. Repeat steps S33 to S37. Based on the overall optimization error obtained in step S36, the surface equation is continuously optimized using the gradient descent method to obtain the final patching surface equation.
[0030] The step S4 is specifically as follows:
[0031] S41, performing topological modification on the orientations of two gap edges in all edge pairs of the product to be repaired according to the repair surface curve equation obtained in step S3;
[0032] S42, performing geometric modification on all pairs of edges of the product to be repaired according to the repair surface curve equation obtained in step S3;
[0033] S43. Based on the repair surface curve equation obtained in step S3, all remaining edges of the product to be repaired that are adjacent to the gap edge in the edge pair are regenerated to obtain a repaired product.
[0034] The distance matching value in step S25 is set according to the following formula:
[0035]
[0036] In the formula, score is the matching score, N is the total number of sampling points on the line, i is the i-th sampling point, ∈1 is the distance threshold set according to experience, and x i is the i-th sampling point on one side of the edge pair, y i is the i-th sampling point on the other corresponding edge in the edge pair.
[0037] The sampling step length in step S32 is obtained by the following formula:
[0038] step(v i )=step*distance n (v i , edge)
[0039] In the formula, step() means the time between v i The sampling step size at , n represents the distance weight index set according to experience, v i Indicates the current sampling point, step indicates the initial sampling length set according to experience, distance(v i ,edge) represents the distance between the current sampling point and the gap, and edge represents the gap boundary line.
[0040] The normal vector of the sampling point in step S33 is obtained by processing according to the following formula:
[0041]
[0042] Where n represents the normal vector of the sampling point, v i represents the i-th point in the neighborhood, v0 represents the first point in the neighborhood, v m represents the last point in the neighborhood, v represents the coordinates of the sampling point, n i represents the normal vector of the i-th point in the neighborhood, and k represents the distance weight index set according to experience.
[0043] The predicted coordinates of the sampling points in step S33 are obtained by processing according to the following formula:
[0044]
[0045] Where p represents the predicted coordinate, n represents the normal vector of the sampling point, and v i represents the i-th point in the neighborhood, v0 represents the first point in the area, and v m Indicates the last point in the domain, α i Represents ∠v i v i-1 The angle of p, β i Represents ∠v i v i+1 The angle of p, p i represents the coordinates of the i-th point in the domain, and cot represents the trigonometric function.
[0046] The beneficial effects of the present invention are:
[0047] This invention uses an optimization method to repair complex gaps in the B_Rep model, resulting in an effective model that is beneficial for subsequent downstream applications. Furthermore, because the invention incorporates optimization methods into the repair process, it is possible to control the quality of complex gap repair in 3D models by setting a reasonable optimization error, ultimately achieving an optimal repair result.
[0048] The present invention first identifies gaps, then determines edges that are initially gaps by counting the number of faces adjacent to each edge. Connectivity analysis is then performed, in which an acceleration structure is introduced to accelerate the connectivity determination of a large number of boundaries. Furthermore, the present invention incorporates a ring structure during gap identification, enabling the identification of both single- and double-ring gaps. This prevents interference from other error types in gap detection and identification, thereby improving gap detection accuracy.
[0049] The present invention uses a surface smoothing error to control the smoothness of gap connections in the repaired model; a surface difference error to control the extent of surface changes during optimization, minimizing differences between the repaired model and the original model; and a gap scale error to ensure that gaps eventually disappear during the repair process. Furthermore, appropriate weights are set to influence the quality of the model repair. The three errors and weights employed in this invention ensure optimal quality of the repaired model, even while preserving the inherent flaws. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a flow chart of the method of the present invention;
[0051] Figure 2 It is a 3D CAD model data structure diagram;
[0052] Figure 3 Modify the schematic for the gap topology;
[0053] Figure 4 Figure 2 is the structural diagram of single-ring and multi-ring gap models. DETAILED DESCRIPTION
[0054] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present invention and are not intended to limit the present invention.
[0055] like Figure 1 As shown, the present invention includes the following steps:
[0056] S1. Obtain the B-Rep model of the product to be inspected and repaired in the computer.
[0057] The products that need to be inspected and repaired include architectural design, mechanical design, medical equipment and other products.
[0058] S2. Accurately identify gaps with complex structures based on the ring structure, traverse all edges of the B-Rep model to obtain gap edges, and then construct a connection relationship graph of all gap edges based on the gap edges. Search the connection relationship graph to obtain all ring structures, and process them according to the ring structures to obtain all qualified edge pairs.
[0059] Step S2 is specifically as follows:
[0060] S21. Traverse all edges in the B-Rep model, count the number of faces adjacent to each edge, and mark the edges with only one adjacent face as gap edges.
[0061] In specific implementation, the structure of the 3D CAD model is as follows Figure 2As shown, the model obtained from S1 yields multiple bodies. The coedges in the body are traversed according to the data structure. For each coedge, its partner object is recursively accessed until it is empty or a previously visited coedge is reached. During the traversal, the number of partner pointers visited is recorded. This number is the number of faces adjacent to the edge. If this number is 1, it is a gap edge and is marked.
[0062] S22. For the gap edges marked in step S21, when the distance between an endpoint on any gap edge and an endpoint on any other gap edge is less than a preset connection threshold, mark the two gap edges as connected, search all gap edges marked as connected, and establish a connection relationship graph for all gap edges.
[0063] In practice, a two-dimensional array is constructed, where each value represents whether two gap edges are connectable. For each coedge, the coordinates of its start and end points are obtained. All remaining gap edges are then traversed to check whether any of them have overlapping start or end points. If so, the two gap edges are connected, and the corresponding positions in the two-dimensional array are marked as connectable. The resulting two-dimensional array is the connection relationship graph.
[0064] S23. Perform a depth-first search on the connection relationship graph of all gap edges obtained to find the ring structure, and process to obtain the area of each ring structure. If the area of the ring structure is less than the preset single-ring structure gap threshold, the ring structure itself is a gap and is used as a single-ring gap.
[0065] In the specific implementation, a depth-first search is performed in the obtained connection relationship graph to obtain the gap edge information that can form a ring structure, that is, a series of COEDGEs. Uniform sampling is performed on all COEDGEs, and the sampling points are placed in an array in the order of connection. In order to calculate the area of the ring structure, it is necessary to connect the point set into multiple triangles. Based on the coordinates of the sampling points, a dynamic programming method is used to obtain a triangle connection method with the smallest area, and the total area of the connected triangles is calculated. If the area is less than the preset single-ring structure gap threshold, the ring structure itself can be determined as a gap.
[0066] S24. For all ring structures whose areas are not less than the single-ring structure gap threshold in step S23, obtain the gap area between every two ring structures. If the gap area is less than the double-ring structure gap threshold, a gap is formed between the two ring structures as a double-ring gap.
[0067] In the specific implementation, for all ring structures whose area in step S23 is not less than the gap threshold of the single ring structure, the area between each two ring structures is calculated according to the method in S23, by sampling points on the edges of the two ring structures and generating a triangular mesh model with the minimum area. If the sum of the triangle areas is less than the gap threshold of the double ring structure, a gap is formed between the two ring structures.
[0068] Figure 4 (a) is the model structure of a single ring gap. Figure 4 (b) in the figure is the model structure of the double-ring gap.
[0069] S25. Match any two gap edges in the single-ring gap obtained in step S23, obtain a direction matching value and a distance matching value for each match, compare the direction matching value and the distance matching value with a preset direction threshold and a preset distance threshold, respectively, and retain two gap edges whose direction matching value is greater than the direction threshold and whose distance matching value is greater than the distance threshold to form a group of edge pairs.
[0070] The distance matching value in step S25 is set according to the following formula:
[0071]
[0072] In the formula, score is the matching score, N is the total number of sampling points on the line, i is the i-th sampling point, ∈1 is the distance threshold set according to experience, and x i is the i-th sampling point on one side of the edge pair, y i is the i-th sampling point on the other corresponding edge in the edge pair.
[0073] S26. For the two ring structures in the double-ring gap obtained in step S24, each gap edge of one ring structure is matched with all gap edges of the other ring structure, and a direction matching value and a distance matching value are obtained for each matching. Two gap edges whose direction matching value is greater than the direction threshold and whose distance matching value is greater than the distance threshold are retained to form a group of edge pairs.
[0074] S27. All edge pairs obtained from step S25 and step S26 eventually constitute all edge pairs that meet the conditions.
[0075] In the specific implementation, steps S25 to S27 are as follows: for all the ring structures obtained in steps S23 and S24, which are combined together to form a ring structure with the same gap, sampling is performed on the ring structure, and for any two gap edges, the distance between the point between the two gap edges and the point on the opposite edge closest to this point is calculated, and the angle between the direction vectors of the two gap edges at their respective points is calculated; then, the matching score between the two edges is calculated, and the larger the matching score, the higher the matching degree. The group of edges with the highest matching degree is taken, and it is determined whether the distance and the angle are greater than the distance threshold and the direction threshold. If they are greater, the matching condition is not met and the matching ends. If the matching condition is met, the group with the highest matching degree is continued to be taken; finally, the process is repeated until the matching condition is no longer met, and all matching edge pairs are obtained.
[0076] S3. Sample the edge pairs obtained in step S2, process all the sampling points obtained by sampling to obtain an overall optimization error including smoothness error, surface difference error, and gap scale error, and continuously optimize the edge pairs based on the overall optimization error to finally obtain a high-quality patching surface equation.
[0077] Step S3 is specifically as follows:
[0078] S31. According to all edge pairs obtained in step S2, obtain the parameters of the faces that are adjacent to the two gap edges in each edge pair, and use the parameters of the faces that are adjacent to all edge pairs as the curve and surface parameters of the edge pairs.
[0079] In a specific implementation, the edge pair obtained in step S2 is two COEDGEs, and COEDGE can obtain EDGE and FACE information, and obtain CURVE and SURFACE information through EDGE and FACE, that is, the curve and surface parameters of the edge pair.
[0080] S32. Based on the curve and surface parameters of the edge pair obtained in step S31, process each edge pair in the following manner:
[0081] The curve and surface parameters are used to perform sampling on the edge pairs and the faces with adjacent edge pairs to obtain a sampling point and its initial position, and the sampling point is mapped to the three-dimensional space of the CAD model. The distance between each sampling point and its corresponding edge pair in the three-dimensional space is processed, and the sampling step length of the next sampling is obtained based on the distance processing. The next sampling point is traversed according to the sampling step length until the traversal and sampling are completed. The initial surface equation of the face with adjacent edge pairs in the three-dimensional space is constructed based on all the sampling points.
[0082] According to this sampling method, the sampling step size is small and the sampling density is large when the distance to the gap is close; the sampling step size is large and the sampling density is small when the distance to the gap is far.
[0083] The sampling step length in step S32 is obtained by processing according to the following formula:
[0084] step(v i )=step*distance n (v i , edge)
[0085] In the formula, step() means the time between v i The sampling step size at , n represents the distance weight index set according to experience, v i Indicates the current sampling point, step indicates the initial sampling length set according to experience, distance(v i ,edge) represents the distance between the current sampling point and the gap, and edge represents the gap boundary line.
[0086] S33. For each sampling point obtained in step S32, search for the remaining sampling points in its neighborhood. Obtain the distance between the current sampling point and each remaining sampling point according to the surface equation processing. Record the remaining sampling points whose distance is less than a preset reference point threshold as reference points. Then, add all reference points to the neighborhood point set. Obtain the normal vector of the current sampling point according to the neighborhood point set extraction processing. Perform prediction processing based on the normal vector of the current sampling point to obtain the predicted coordinates of the current point. The distance between the coordinates of the current sampling point and the predicted coordinates of the current sampling point is used as the smoothing error of the current sampling point. If the neighborhood point set is empty, the smoothing error of the current sampling point is recorded as 0.
[0087] The normal vector of the sampling point in step S33 is obtained by processing according to the following formula:
[0088]
[0089] In the formula, n represents the normal vector of the sampling point, represents, v represents the coordinates of the sampling point, n i represents the normal vector of the i-th point in the neighborhood, and k represents the distance weight index set according to experience.
[0090] The predicted coordinates of the sampling points in step S33 are obtained by processing according to the following formula:
[0091]
[0092] Where p represents the predicted coordinate, n represents the normal vector of the sampling point, and v i represents the i-th point in the neighborhood, v0 represents the first point in the area, and v m Indicates the last point in the domain, α i Indicates ∠V i V i-1 p represents the angle, β represents ∠V i V i+1The angle of p, p i represents the coordinates of the i-th point in the domain, and cot represents the trigonometric function.
[0093] S34: Process and obtain the distance from the current position to the initial position of each sampling point, which is the surface difference error.
[0094] S35. Process and obtain the distance from each sampling point on one gap edge to the other gap edge in all edge pairs, which is the gap scale error.
[0095] S36. Take the average values of the smoothing error, surface difference error and gap scale error obtained in steps S33 to S35 respectively. The smoothing error of 0 does not participate in the averaging calculation. The smoothing error, surface difference error and gap scale error after taking the average value are weighted summed to obtain the overall optimization error. In the specific implementation, the weights of the weighted summation are, from large to small, the weight of the gap scale error, the weight of the smoothing error and the weight of the surface difference error.
[0096] S37. Repeat steps S33 to S37. Based on the overall optimization error obtained in step S36, the surface equation is continuously optimized using the gradient descent method to obtain the final patching surface equation.
[0097] In the specific implementation, in the surface equation, the optimization parameters are determined according to the surface type. If it is an analytical surface such as a plane or cylinder, the optimized parameters are the parameters that define the surface. If it is a free-form surface, the optimization parameters are the control vertices. In order to ensure locality, some control vertices need to be selected and fixed and cannot be optimized. The distance between the control point and the gap is selected as the standard. The control vertices with a distance greater than the threshold are fixed, and the control vertices with a distance less than the optimization threshold need to be optimized; secondly, the coordinates of the point are expressed as a function of the optimization parameters; finally, the function of the error with respect to the optimization parameters can be obtained; finally, according to the overall optimization error, the gradient descent method is used to continuously optimize the surface equation, and the geometric parameters of the surface are modified until the error condition is met and the optimization is terminated.
[0098] S4. Repair the B-Rep model of the product to be repaired according to the repair surface equation obtained in step S3 to obtain a B-Rep model with correct geometric topology, which is then used to make the repaired product.
[0099] Step S4 is specifically as follows:
[0100] S41. Based on the repair surface equation obtained in step S3, topologically modify the orientations of two gap edges in all edge pairs of the product to be repaired.
[0101] In specific implementation, Figure 3As shown in the gap topology modification diagram, for each edge pair of the product to be repaired, construct a repaired gap curve between the two gap edges in the edge pair based on the patch surface equation. Delete the edges corresponding to the two gap edges in the edge pair and point them to the new edge. Align the coedge's partner to the corresponding coedge. Create new vertices for the two end points of the gap curve and change the starting points of the coedge and edge to the corresponding vertices, deleting the original points.
[0102] S42: According to the repair surface equation obtained in step S3, geometric modifications are performed on all pairs of edges of the product to be repaired.
[0103] The geometric modification refers to changing the geometric equation of the surface corresponding to the edge-to-edge relationship to the geometric equation obtained in step S3, so that the final surface can be smooth and tightly connected.
[0104] S43. Based on the repair surface equation obtained in step S3, all remaining edges of the product to be repaired that are adjacent to the gap edge in the edge pair are regenerated to obtain a repaired product.
[0105] In a specific implementation, all remaining edges that are adjacent to the gap edge in the edge pair are re-intersected and generated, and the geometric parameters are changed to achieve a repaired product.
[0106] This invention uses an optimization method to repair complex gaps in the B_Rep model, resulting in an effective model that is beneficial for subsequent downstream applications. Furthermore, because the invention incorporates optimization methods into the repair process, it is possible to control the quality of complex gap repair in 3D models by setting a reasonable optimization error, ultimately achieving an optimal repair result.
[0107] The present invention first identifies gaps, then determines edges that are initially gaps by counting the number of faces adjacent to each edge. Connectivity analysis is then performed, in which an acceleration structure is introduced to accelerate the connectivity determination of a large number of boundaries. Furthermore, the present invention incorporates a ring structure during gap identification, enabling the identification of both single- and double-ring gaps. This prevents interference from other error types in gap detection and identification, thereby improving gap detection accuracy.
[0108] The present invention uses a surface smoothing error to control the smoothness of gap connections in the repaired model; a surface difference error to control the extent of surface changes during optimization, minimizing differences between the repaired model and the original model; and a gap scale error to ensure that gaps eventually disappear during the repair process. Furthermore, appropriate weights are set to influence the quality of the model repair. The three errors and weights employed in this invention ensure optimal quality of the repaired model, even while preserving the inherent flaws.
[0109] The present invention proposes a gap recognition method based on a ring structure, which can identify complex gaps in single and double ring situations. Using a ring as a basis can more accurately identify gaps, eliminate the influence of other errors on gap recognition, and can identify complex gap situations.
[0110] This paper proposes an optimization-based method for repairing complex gaps in 3D models. This method can repair gap errors in 3D models, providing an effective 3D model for subsequent simulation and manufacturing applications. By optimizing smoothing errors, surface difference errors, and gap scale errors, the repaired model achieves high quality.
[0111] Finally, it should be noted that the above embodiments and explanations are intended only to illustrate the technical solutions of the present invention and are not intended to limit the present invention. It should be understood by those skilled in the art that modifications or equivalent substitutions to the technical solutions of the present invention may be made without departing from the spirit and scope of the technical solutions disclosed herein, and all such modifications or equivalent substitutions shall be encompassed within the scope of protection of the claims of the present invention.
Claims
1. A method for repairing complex gaps in a three-dimensional model based on optimization, characterized in that: Methods include: S1. Obtain the B-Rep model of the product to be inspected and repaired in the computer; S2. Traverse all edges of the B-Rep model to obtain gap edges, construct a connection relationship graph of all gap edges based on the gap edges, search the connection relationship graph to obtain all ring structures, and process the ring structures to obtain all edge pairs that meet the conditions; S3, sampling the edge pairs obtained in step S2, processing all the sampled points to obtain an overall optimization error including smoothness error, surface difference error, and gap scale error, and continuously optimizing the edge pairs based on the overall optimization error to finally obtain the patching surface equation; S4. Repair the B-Rep model of the product to be repaired according to the repair surface equation obtained in step S3 to obtain a B-Rep model with correct geometric topology, which is then used to produce the repaired product; The step S3 is specifically as follows: S31. Based on all edge pairs obtained in step S2, obtain the parameters of the faces that are adjacent to the two gap edges in each edge pair, and use the parameters of the faces that are adjacent to all edge pairs and the curve parameters of the edge as the curve and surface parameters of the edge pair; S32. Based on the curve and surface parameters of the edge pair obtained in step S31, process each edge pair in the following manner: Sampling the edge pairs and the faces adjacent to the edge pairs using curve and surface parameters to obtain a sampling point and its initial position, mapping the sampling points into three-dimensional space, processing the distance between each sampling point and its corresponding edge pair in the three-dimensional space, and obtaining a sampling step length for the next sampling based on the distance processing. Traversing and searching for the next sampling point according to the sampling step length until the traversal and sampling are completed, and constructing the initial surface equation of the faces adjacent to the edge pairs in the three-dimensional space based on all the sampling points; S33. For each sampling point obtained in step S32, search for other sampling points in its neighborhood. Obtain the distance between the current sampling point and each of the other sampling points according to the surface equation. Record the other sampling points whose distance is less than a preset reference point threshold as reference points. Add all reference points to the neighborhood point set. Obtain the normal vector of the current sampling point according to the neighborhood point set extraction process. Perform prediction processing based on the normal vector of the current sampling point to obtain the predicted coordinates of the current point. The distance between the coordinates of the current sampling point and the predicted coordinates of the current sampling point is used as the smoothing error of the current sampling point. S34, processing and obtaining the distance from the current position to the initial position of each sampling point, which is the surface difference error; S35, processing to obtain the distance from each sampling point on one gap edge to the other gap edge in all edge pairs, which is the gap scale error; S36, taking the average of the smoothing error, surface difference error, and gap scale error obtained in steps S33 to S35, and performing weighted summation on the averaged smoothing error, surface difference error, and gap scale error to obtain an overall optimization error; S37. Repeat steps S33 to S37. Based on the overall optimization error obtained in step S36, the surface equation is continuously optimized using the gradient descent method to obtain the final patching surface equation.
2. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 1, characterized in that: The step S2 is specifically as follows: S21. Traverse all edges in the B-Rep model, count the number of faces adjacent to each edge, and mark the edges with only one adjacent face as gap edges; S22. For the gap edges marked in step S21, if the distance between an endpoint on any gap edge and an endpoint on any other gap edge is less than a preset connection threshold, mark the two gap edges as connected, search all gap edges marked as connected, and establish a connection relationship graph for all gap edges; S23. Perform a depth-first search on the connection relationship graph of all gap edges obtained to find ring structures, and process and obtain the area of each ring structure. If the area of the ring structure is less than a preset single-ring structure gap threshold, the ring structure itself is a gap and is treated as a single-ring gap. S24. For all ring structures whose areas are not less than the single-ring structure gap threshold in step S23, the gap area between every two ring structures is obtained. If the gap area is less than the double-ring structure gap threshold, a gap is formed between the two ring structures as a double-ring gap. S25, matching any two gap edges in the single-ring gap obtained in step S23, obtaining a direction matching value and a distance matching value for each matching, comparing the direction matching value and the distance matching value with a preset direction threshold and a preset distance threshold, respectively, retaining two gap edges whose direction matching value is greater than the direction threshold and whose distance matching value is greater than the distance threshold to form a group of edge pairs; S26. For the two ring structures in the dual-ring gap obtained in step S24, each gap edge of one ring structure is matched with all gap edges of the other ring structure, obtaining a direction matching value and a distance matching value for each matching. Two gap edges with a direction matching value greater than a direction threshold and a distance matching value greater than a distance threshold are retained to form a group of edge pairs. S27. All edge pairs obtained from step S25 and step S26 eventually constitute all edge pairs that meet the conditions.
3. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 1, characterized in that: The step S4 is specifically as follows: S41, performing topological modification on the orientations of two gap edges in all edge pairs of the product to be repaired according to the repair surface curve equation obtained in step S3; S42, performing geometric modification on all pairs of edges of the product to be repaired according to the repair surface curve equation obtained in step S3; S43. Based on the repair surface curve equation obtained in step S3, all remaining edges of the product to be repaired that are adjacent to the gap edge in the edge pair are regenerated to obtain a repaired product.
4. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 2, characterized in that: The distance matching value in step S25 is set according to the following formula: In the formula, score is the matching score, N is the total number of sampling points on the line, i is the i-th sampling point, ∈1 is the distance threshold set according to experience, and x i is the i-th sampling point on one side of the edge pair, y i is the i-th sampling point on the other corresponding edge in the edge pair.
5. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 1, characterized in that: The sampling step length in step S32 is obtained by the following formula: step(v i )=step*distance n (v i ,edge) In the formula, step() means the time between v i The sampling step size at , n represents the distance weight index set according to experience, v i Indicates the current sampling point, step indicates the initial sampling length set according to experience, distance(v i ,edge) represents the distance between the current sampling point and the gap, and edge represents the gap boundary line.
6. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 1, characterized in that: The normal vector of the sampling point in step S33 is obtained by processing according to the following formula: Where n represents the normal vector of the sampling point, v i represents the i-th point in the neighborhood, v0 represents the first point in the neighborhood, v m represents the last point in the neighborhood, v represents the coordinates of the sampling point, n i represents the normal vector of the i-th point in the neighborhood, and k represents the distance weight index set according to experience.
7. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 1, characterized in that: The predicted coordinates of the sampling points in step S33 are obtained by processing according to the following formula: Where p represents the predicted coordinate, n represents the normal vector of the sampling point, and v i represents the i-th point in the neighborhood, v0 represents the first point in the area, and v m Indicates the last point in the domain, α i Represents ∠v i v i-1 p is the angle, β represents ∠v i v i+1 The angle of p, p i represents the coordinates of the i-th point in the domain, and cot represents the trigonometric function.
Citation Information
Patent Citations
Geometric repairing method for combined curved surface
CN108229081A
Curved surface defect repairing method for complex curved surface offset
CN115879220A