Optimization-based three-dimensional model complex gap repairing method

By identifying and repairing complex gaps in the three-dimensional CAD model based on optimization, the accuracy and efficiency of gap identification and repair in the prior art are solved, and the efficient repair and effectiveness of the model are achieved.

CN119475461AActive Publication Date: 2025-02-18ZHEJIANG UNIV

Patent Information

Application Number
CN202411516094.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-18
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

It is difficult for the prior art to accurately identify and effectively repair complex gaps in three-dimensional CAD models, resulting in the impact of model effectiveness and accuracy, affecting subsequent simulation and processing applications.

Method used

Using an optimization-based method, by traversing the edges of the B-Rep model, the connection relationship diagram of the gap edges is constructed, the ring structure is identified, and the surface equation is obtained through sampling and optimization error adjustment, and the gap in the model is finally repaired.

Benefits of technology

Accurate identification and efficient repair of complex gaps are achieved, ensuring the correctness and effectiveness of the geometric topology of the model, and improving the efficiency and quality of subsequent applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119475461A_ABST
    Figure CN119475461A_ABST
Patent Text Reader

Abstract

The invention discloses a method for repairing a complex gap based on an optimization three-dimensional model. The method comprises the steps that a B-Rep model of a product needing to be repaired is obtained through modeling in a computer, then all edges of the B-Rep model are traversed to obtain gap edges, a connection relation graph of all the gap edges is constructed according to the gap edges, the connection relation graph is searched to obtain all ring structures, and the ring structures of the product needing to be repaired are obtained. The method comprises the following steps: processing according to a ring structure to obtain all edge pairs meeting conditions, sampling the obtained edge pairs, processing all sampling points obtained by sampling to obtain an overall optimization error of the edge pairs, and continuously optimizing the edge pairs according to the overall optimization error to finally obtain a repaired curved surface equation. And finally, repairing the B-Rep model of the to-be-repaired product according to the obtained repairing curved surface equation so as to manufacture a repaired product. According to the method for automatically repairing the complex gap based on optimization, the model repairing capability and effectiveness can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

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 a three-dimensional model 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, gap errors may occur in the model. This error may be caused by unrobust modeling operations, improper use of modeling operations, or model exchange between heterogeneous systems, which will undermine the effectiveness and accuracy of the model, and thus have a serious negative impact on subsequent applications such as simulation and processing.

[0003] Repairing gaps in models is crucial, but it also faces many challenges. First, the structure of the model at the gap may be extremely complex and the types of gaps may be diverse, making it difficult to automatically and accurately identify gap errors. Second, during the repair process, there is no single way to repair, and it is difficult to determine the optimal repair method so that the final model is consistent with the ideal state. Finally, both model gap identification and repair involve a large number of calculations, which increases complexity and time consumption, and it is difficult to ensure high efficiency.

[0004] The gap repair in commercial software is done manually by engineers, providing two operations: boundary movement and surface filling, which seriously affects efficiency. The commonly used repair method currently focuses on filling the surface at the gap, but due to the small size of the gap, the size of the filled surface is small, which will affect 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 the 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 complex gap repair method of a three-dimensional model based on optimization.

[0006] The technical solution adopted by 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 the 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 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 sampling points obtained by sampling to obtain an overall optimization error including smoothness error, surface difference error and gap scale error, and continuously optimizing the edge pairs according to the overall optimization error to finally obtain the repair 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, 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, the two gap edges are marked as connected, all gap edges marked as connected are searched, and a connection relationship graph of all gap edges is established;

[0016] S23, performing a depth-first search on the connection relationship graph of all gap edges obtained, searching for ring structures, and processing to 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 used as a single-ring gap;

[0017] S24, for all the ring structures whose areas are not less than the gap threshold of the single ring structure in step S23, the gap area is obtained between every two ring structures. If the gap area is less than the gap threshold of the double ring structure, 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 itself obtained in step S23, obtaining a direction matching value and a distance matching value each time, 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 values ​​are greater than the direction threshold and whose distance matching values ​​are greater than the distance threshold to form a group of edge pairs;

[0019] 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, and 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 finally constitute all edge pairs that meet the conditions.

[0021] The step S3 is specifically as follows:

[0022] S31, according to all the edge pairs obtained in step S2, obtain the parameters of the surface that is adjacent to the two gap edges in each edge pair, and use the parameters of the surface that is adjacent to all edge pairs and the curve parameters of the edge as the curve and surface parameters of the edge pair;

[0023] S32, according to the curve and surface parameters of the edge pair obtained in step S31, each edge pair is processed in the following manner:

[0024] Sampling the edge pairs and the faces with adjacent edge pairs by using curve and surface parameters to obtain a sampling point and its initial position, mapping the sampling point to the three-dimensional space, processing and obtaining the distance between each sampling point and its corresponding edge pair in the three-dimensional space, and obtaining the sampling step length of the next sampling according to the distance processing, traversing and searching for the next sampling point according to the sampling step length until the traversal sampling is completed, and constructing the initial surface equation of the faces with adjacent edge pairs in the three-dimensional space according to all the sampling points;

[0025] S33, for each sampling point obtained in step S32, searching for other sampling points in its neighborhood, obtaining the distance between the current sampling point and each other sampling point according to the surface equation processing, recording the other sampling points whose distance is less than the preset reference point threshold as reference points, and then including all reference points in the neighborhood point set, obtaining the normal vector of the current sampling point according to the neighborhood point set extraction processing, performing prediction processing according to the normal vector of the sampling point of the current point to obtain the predicted coordinates of the current point, and the distance between the coordinates of the current sampling point and the predicted coordinates of the current sampling point is used as the fairing 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, process and obtain the distance from each sampling point on one gap edge to another gap edge in all edge pairs, which is the gap scale error;

[0028] S36, taking average values ​​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, repeating steps S33 to S37, and according to the overall optimization error obtained in step S36, continuously optimizing the surface equation 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 edge pairs of the product to be repaired according to the repair surface curve equation obtained in step S3;

[0033] S43, according to 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 processing according to 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 length at , n represents the distance weight index set according to experience, v i represents the current sampling point, step represents the initial sampling length set according to experience, and 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, and 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 based on experience.

[0043] The predicted coordinates of the sampling points in step S33 are obtained by processing according to the following formula:

[0044]

[0045] In the formula, p represents the predicted coordinates, 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 neighborhood, and v m represents 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] The present invention repairs the complex gaps of the model based on the optimization method on the B_Rep model, and can obtain an effective model, which is beneficial to subsequent downstream applications. At the same time, since the present invention introduces the optimization method in the repair process, the quality of the complex gap repair of the three-dimensional model can be controlled by setting a reasonable optimization error, and finally an optimal repair result is obtained.

[0048] The present invention first identifies the gap, obtains the edges that are initially gaps by counting the number of faces adjacent to each edge, and performs connectivity analysis. In the connectivity analysis, an acceleration structure is introduced to accelerate the connectivity judgment of a large number of boundaries. At the same time, since the present invention introduces a ring structure in gap identification, single-ring and double-ring gaps can be identified, avoiding interference of other error types on gap detection and identification, and improving the accuracy of gap detection and identification.

[0049] The present invention controls the smoothness of the connection at the gap in the repaired model by setting the surface smoothing error; controls the change size of the surface during the optimization process by setting the surface difference error, so that the repaired model is less different from the original model; and ensures that the gap disappears in the repair process by setting the gap scale error. And the quality of model repair is affected by setting reasonable weights. The setting of the three errors and weights in the present invention makes the quality of the model after gap repair optimal under the premise of error repair. 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 shows the structure diagram of single-ring and multi-ring gap models. DETAILED DESCRIPTION

[0054] The present invention will be further described in detail below in conjunction with 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 used to limit the present invention.

[0055] like Figure 1 As shown, the present invention comprises 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 build 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 according to the ring structure 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 the specific implementation, the structure of the 3D CAD model is as follows: Figure 2As shown, multiple BODYs can be obtained from the model obtained in S1. The COEDGE in the BODY is traversed according to the data structure. For each COEDGE, its partner object is recursively accessed until it is empty or the visited COEDGE is accessed. During the traversal process, the number of partner pointers traversed is recorded. This number is the number of faces adjacent to the edge. If this number is 1, it is a gap edge and it 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 of all gap edges.

[0063] In the specific implementation, a two-dimensional array is constructed, and each value in the two-dimensional array represents whether two gap edges can be connected. For each COEDGE, the coordinates of its starting point and end point can be obtained, and all other gap edges are traversed to check whether the starting point or end point of the remaining gap edges coincides. If so, the two gap edges are connected, and the corresponding positions in the two-dimensional array are marked as connectable. The final two-dimensional array is the connection relationship diagram.

[0064] S23, performing a depth-first search on the connection relationship graph of all gap edges obtained, finding the ring structure, and processing 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 the 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. According to the coordinates of the sampling points, a triangle connection method with the smallest area is obtained through dynamic programming, 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 the ring structures whose areas are not less than the gap threshold of the single ring structure in step S23, process and obtain the gap area between every two ring structures. If the gap area is less than the gap threshold of the double ring structure, 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 is not less than the single-ring structure gap threshold in step S23, the area between every 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 double-ring structure gap threshold, 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, matching any two gap edges in the single-ring gap itself obtained in step S23, obtaining a direction matching value and a distance matching value each time, 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 values ​​are greater than the direction threshold and whose distance matching values ​​are 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 in the other ring structure, and a direction matching value and a distance matching value are obtained 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.

[0074] S27. All edge pairs obtained from step S25 and step S26 finally 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 that is 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 continues to be taken; finally, the process is repeated until the matching condition is not 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 according to 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, according to the curve and surface parameters of the edge pair obtained in step S31, each edge pair is processed in the following manner:

[0081] A sampling point and its initial position are obtained by sampling the edge pairs and the faces with adjacent edge pairs using curve and surface parameters, and the sampling points are 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 obtained, and the sampling step length of the next sampling is obtained according to the distance processing. The next sampling point is traversed according to the sampling step length until the traversal and sampling are completed, and the initial surface equation of the faces with adjacent edge pairs in the three-dimensional space is constructed according to all sampling points.

[0082] According to this sampling method, when the distance to the gap is close, the sampling step is small and the sampling density is large; when the distance to the gap is far, the sampling step is large and the sampling density is small.

[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 length at , n represents the distance weight index set according to experience, v i represents the current sampling point, step represents the initial sampling length set according to experience, and 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 other sampling points in its neighborhood, obtain the distance between the current sampling point and each other sampling point according to the surface equation processing, record the other sampling points whose distance is less than the preset reference point threshold as reference points, then add all the reference points into the neighborhood point set, obtain the normal vector of the current sampling point according to the neighborhood point set extraction processing, perform prediction processing according to the normal vector of the sampling point of the current point to obtain the predicted coordinates of the current point, and use the distance between the coordinates of the current sampling point and the predicted coordinates of the current sampling point as the smoothing error of the current sampling point. If the domain 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 based on experience.

[0090] The predicted coordinates of the sampling points in step S33 are obtained by processing according to the following formula:

[0091]

[0092] In the formula, p represents the predicted coordinates, 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 neighborhood, and v m represents the last point in the domain, α i Indicates ∠V i V i-1 p is the angle, β is the angle of ∠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 another 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 weighted sum of the averaged smoothing error, surface difference error and gap scale error is performed 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, repeating steps S33 to S37, and according to the overall optimization error obtained in step S36, continuously optimizing the surface equation 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 a cylinder, the optimization parameters are the parameters that define the surface. If it is a free surface, the optimization parameters are the control vertices. In order to ensure locality, it is necessary to select some control vertices to be 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 points 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. According to the repair surface equation obtained in step S3, topological modification is performed on 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 all edge pairs of the product to be repaired, construct the repair gap curve between the two gap edges in the edge pair according to the repair surface equation, delete the EDGE corresponding to the two gap edges in the edge pair and point to the new EDGE. Point the partner of COEDGE to the corresponding COEDGE. Create the VERTEX of the two end points of the gap curve, change the starting point of COEDGE and EDGE to the corresponding VERTEX, and delete the original point.

[0102] S42: According to the repair surface equation obtained in step S3, geometric modifications are performed on all edge pairs 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 pair to the geometric equation obtained in step S3, so that the final surface can be smooth and tightly connected.

[0104] S43, according to the repair surface equation obtained in step S3, regenerate all the remaining edges of the product to be repaired that are adjacent to the gap edges in the edge pair, so as 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 geometric parameters are changed to achieve a repaired product.

[0106] The present invention repairs the complex gaps of the model based on the optimization method on the B_Rep model, and can obtain an effective model, which is beneficial to subsequent downstream applications. At the same time, since the present invention introduces the optimization method in the repair process, the quality of the complex gap repair of the three-dimensional model can be controlled by setting a reasonable optimization error, and finally an optimal repair result is obtained.

[0107] The present invention first identifies the gap, obtains the edges that are initially gaps by counting the number of faces adjacent to each edge, and performs connectivity analysis. In the connectivity analysis, an acceleration structure is introduced to accelerate the connectivity judgment of a large number of boundaries. At the same time, since the present invention introduces a ring structure in gap identification, single-ring and double-ring gaps can be identified, avoiding interference of other error types on gap detection and identification, and improving the accuracy of gap detection and identification.

[0108] The present invention controls the smoothness of the connection at the gap in the repaired model by setting the surface smoothing error; controls the change size of the surface during the optimization process by setting the surface difference error, so that the repaired model is less different from the original model; and ensures that the gap disappears in the repair process by setting the gap scale error. And the quality of model repair is affected by setting reasonable weights. The setting of the three errors and weights in the present invention makes the quality of the model after gap repair optimal under the premise of error repair.

[0109] The present invention proposes a gap recognition method based on a ring structure, which can recognize complex gaps in single-ring and double-ring situations. Using the ring as the basis can more accurately recognize gaps, eliminate the influence of other errors on gap recognition, and can recognize complex gap situations.

[0110] The present invention proposes a complex gap repair method for a three-dimensional model based on optimization, which can repair gap errors in the three-dimensional model and provide an effective three-dimensional model for subsequent simulation and manufacturing applications. Through the smoothing error, surface difference error and gap scale error, the repaired model has a higher quality.

[0111] Finally, it should be noted that the above embodiments and explanations are only used to illustrate the technical solution of the present invention rather than to limit it. Those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope disclosed in the technical solution of the present invention, which should be included in the scope of protection of the claims of the present invention.

Claims

1. A complex gap repair method for 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 the 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 the ring structures to obtain all edge pairs that meet the conditions. S3, sampling the edge pairs obtained in step S2, processing 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 optimizing the edge pairs according to the overall optimization error to finally obtain the repair 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 make the repaired product.

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, 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, the two gap edges are marked as connected, all gap edges marked as connected are searched, and a connection relationship graph of all gap edges is established; S23, performing a depth-first search on the connection relationship graph of all gap edges obtained, searching for ring structures, and processing to 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 used as a single-ring gap; S24, for all the ring structures whose areas are not less than the gap threshold of the single ring structure in step S23, the gap area is obtained between every two ring structures. If the gap area is less than the gap threshold of the double ring structure, 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 itself obtained in step S23, obtaining a direction matching value and a distance matching value each time, 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 values ​​are greater than the direction threshold and whose distance matching values ​​are greater than the distance threshold to form a group of edge pairs; 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, and 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 finally 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 S3 is specifically as follows: S31, according to all the edge pairs obtained in step S2, obtain the parameters of the surface that is adjacent to the two gap edges in each edge pair, and use the parameters of the surface that is adjacent to all edge pairs and the curve parameters of the edge as the curve and surface parameters of the edge pair; S32, according to the curve and surface parameters of the edge pair obtained in step S31, each edge pair is processed in the following manner: Sampling the edge pairs and the faces with adjacent edge pairs by using curve and surface parameters to obtain a sampling point and its initial position, mapping the sampling point to the three-dimensional space, processing and obtaining the distance between each sampling point and its corresponding edge pair in the three-dimensional space, and obtaining the sampling step length of the next sampling according to the distance processing, traversing and searching for the next sampling point according to the sampling step length until the traversal sampling is completed, and constructing the initial surface equation of the faces with adjacent edge pairs in the three-dimensional space according to all the sampling points; S33, for each sampling point obtained in step S32, searching for other sampling points in its neighborhood, obtaining the distance between the current sampling point and each other sampling point according to the surface equation processing, recording the other sampling points whose distance is less than the preset reference point threshold as reference points, and then including all reference points in the neighborhood point set, obtaining the normal vector of the current sampling point according to the neighborhood point set extraction processing, performing prediction processing according to the normal vector of the sampling point of the current point to obtain the predicted coordinates of the current point, and the distance between the coordinates of the current sampling point and the predicted coordinates of the current sampling point is used as the fairing 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, process and obtain the distance from each sampling point on one gap edge to another gap edge in all edge pairs, which is the gap scale error; S36, taking average values ​​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, repeating steps S33 to S37, and according to the overall optimization error obtained in step S36, continuously optimizing the surface equation using the gradient descent method to obtain the final patching surface equation.

4. 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 edge pairs of the product to be repaired according to the repair surface curve equation obtained in step S3; S43, according to 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.

5. 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.

6. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 3, characterized in that: The sampling step length in step S32 is obtained by processing according to 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 length at , n represents the distance weight index set according to experience, v i represents the current sampling point, step represents the initial sampling length set according to experience, and distance(v i , edge) represents the distance between the current sampling point and the gap, and edge represents the gap boundary line.

7. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 3, 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, and 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 based on experience.

8. The method for repairing complex gaps in a three-dimensional model based on optimization according to claim 3, characterized in that: The predicted coordinates of the sampling points in step S33 are obtained by processing according to the following formula: In the formula, p represents the predicted coordinates, 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 neighborhood, and v m represents 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.

Citation Information

Patent Citations

  • Geometric repairing method for combined curved surface

    CN108229081A

  • Curved surface defect repairing method for complex curved surface offset

    CN115879220A

  • Three-dimensional model gap repairing method and device based on triangular surface, equipment and medium

    CN116091365A

  • Automatic repairing method, device and equipment for automobile modeling geometric model

    CN117313243A

Cited By

  • Simulation model stitching method and system and vehicle body curved surface model stitching method

    CN119720394A