NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization
The NURBS multi-surface collaborative G1 continuity method, which optimizes the control point positions, solves the problems of low automation and quality defects in multi-surface connections, and achieves efficient and accurate surface continuity improvement, which is applicable to industrial design in automotive, aerospace and shipbuilding industries.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINAN IND SOFTWARE TECHNOLOGY CO LTD
- Filing Date
- 2026-01-23
- Publication Date
- 2026-06-09
AI Technical Summary
Existing CAD software has a low degree of automation in multi-surface collaborative connection scenarios, relies on manual adjustments which leads to surface quality defects, and does not effectively improve continuity under over-constraint conditions, affecting the aerodynamic performance and processing feasibility of industrial products.
By employing a NURBS-based multi-surface collaborative G1 continuity enhancement method based on control point location optimization, and utilizing the Python OCC library and a multi-algorithm parallel optimization framework, the control point coordinates are automatically optimized to achieve efficient continuity matching and quality improvement of multi-surface boundaries.
It achieves efficient and accurate improvement of multi-surface continuity, reduces manual dependence, avoids surface quality defects, and is suitable for high-quality surface modeling needs in fields such as automotive, aerospace and shipbuilding.
Smart Images

Figure CN122176248A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics technology, specifically to a NURBS multi-surface collaborative G1 continuity enhancement method based on control point position optimization. Background Technology
[0002] In the field of digital design of modern industrial products, high-end manufacturing scenarios such as automotive body panels, aerospace structural components, and ship skins place stringent requirements on the surface quality of 3D models: the surfaces must not only have high smoothness and high gloss, but also ensure a high level of continuity at the junctions of multiple surfaces in order to meet the comprehensive needs of aerodynamic performance, aesthetic appearance, and manufacturing processes.
[0003] The continuity between surfaces is a core indicator for measuring the surface quality of industrial products. Among them, G2-level curvature continuity has become a key requirement for mainstream high-end industrial design. In the existing technology, the surface continuity levels are defined as follows: G0 (positional continuity) means that adjacent surfaces achieve geometric position coincidence at the boundary; G1 (tangential continuity) means that, based on G0 continuity, the normal directions of adjacent surfaces at the boundary are consistent, achieving a smooth transition; G2 (curvature continuity) means that, based on G1 continuity, the curvature values of adjacent surfaces at the boundary are the same, ensuring that there are no visual abrupt changes in the transition.
[0004] While mainstream CAD software (such as CATIA, Siemens NX, Creo, etc.) provides basic surface continuity matching tools, they still have significant limitations in scenarios involving the collaborative connection of multiple surfaces: First, for intermediate working surfaces surrounded by multiple reference surfaces, existing tools cannot achieve a specified level of boundary continuity through a single automated operation. Designers must manually adjust control points or surface parameters based on experience, which is cumbersome and time-consuming. Second, manual adjustments can easily lead to surface quality defects. Even if the continuity requirements are met at the boundary, singularities, local wrinkles, and other problems may occur inside the surface, affecting the aerodynamic performance and manufacturing feasibility of the product. Third, when the working surface connects to two or more reference surfaces simultaneously, the boundary constraints are prone to over-constraint. Existing software usually approximates the continuity requirements by increasing the surface order or span, which leads to an increase in surface degrees of freedom and a decrease in controllability, thereby reducing the overall modeling quality and efficiency.
[0005] Furthermore, industrial product design must balance "design accuracy" and "manufacturing feasibility": low-quality connecting surfaces increase mold processing difficulty and production scrap rate, while the traditional "design-verification-correction" cycle consumes significant manpower and time. Therefore, how to optimize the control point positions of intermediate working surfaces through automation and intelligence while preserving the core attributes of the original surfaces, and achieve precise improvement in the continuity level of multi-surface boundaries, while avoiding internal quality defects, has become a key technical requirement for solving the pain points of high-quality surface modeling in high-end industrial products and improving the level of automation in digital design. Summary of the Invention
[0006] To address the aforementioned technical issues, a NURBS multi-surface collaborative G1 continuity enhancement method based on control point location optimization is provided. This technical solution resolves the technical problems existing in multi-surface collaborative connection scenarios, such as low automation, excessive reliance on human experience, easy generation of quality defects in surfaces, and poor continuity level enhancement under over-constraint conditions.
[0007] To achieve the above objectives, the technical solution adopted in this invention is: a NURBS multi-surface collaborative G1 continuity enhancement method based on control point position optimization, wherein the enhancement steps are as follows:
[0008] S1. Model Reading: Reads STEP format CAD models. For scenarios in industrial settings where multiple reference surfaces connect to intermediate working surfaces, sets connection reference surfaces in the four-parameter boundary directions of the working surfaces as optimization benchmarks.
[0009] S2. Parameter Extraction and Translation: After traversing the model through topological exploration, extract key information such as the target working surface number, order, and control point coordinates, retain the remaining parameters, and save them as a JSON file;
[0010] S3. Surface Reconstruction: Reconstruct the surface based on the extracted NURBS surface core parameters, retain the parameterization range and topology of the original surface, and ensure that the boundary position and curvature trend of the reconstructed surface are consistent with the original model.
[0011] S4. Boundary Sampling and Matching: The four-parameter boundaries of the reconstructed working surface and the reference surface are uniformly sampled. Through spatial position comparison, the boundaries of each working surface are accurately matched with the corresponding boundaries of the reference surface to form the boundary matching pairs required for continuity analysis.
[0012] S5. Continuity error detection: For each set of boundary matching pairs, perform boundary sampling to obtain the sampling point position, normal vector and curvature parameters. By comparing and calculating the parameter differences, generate a continuity error term to quantify the degree of boundary matching.
[0013] S6. Construction of the objective function: Using the spatial coordinates of the control points as the optimization variables, the error terms obtained in step S5 are introduced to construct the optimization system. Weighting factors are added to balance the contribution of each error term to form the overall objective function.
[0014] S7. Parallel optimization and solution using multiple algorithms: Call optimization algorithms to build a parallel computing framework, try multiple optimization strategies, retain better intermediate results during the iteration process, until the optimal control point coordinate numerical solution is obtained and saved;
[0015] S8. Result Output: Based on the optimal solution, the surface is reconstructed, and the continuity of each boundary is checked. If the single-sided error is within the allowable tolerance, it is considered to have reached the specified continuity level. The optimized surface model is exported as STEP format, and the result output and visualization are completed to carry out the overall optimization process.
[0016] Preferably, in step S1, the STEP format CAD model file to be optimized and the project program file are stored in the same directory. The model file contains a surface to be optimized surrounded by four reference surfaces. The import path of the model file is pre-configured in the main function, and the STEP model import interface in the PythonOCC library is called to complete the reading operation of the STEP format model file.
[0017] Preferably, the parameter extraction and translation in step S2 includes:
[0018] Based on the read model file data, the working surface is set as the starting point of the loop traversal and all surfaces are traversed.
[0019] The model surface in the input project program is a NURBS surface patch, which provides control capabilities through control points, weight factors, and node vectors. A NURBS surface of order p in the u direction and order q in the v direction is defined as follows:
[0020]
[0021] in, This forms a (n+1)×(m+1) control point grid; With each control point The associated weighting factors are here. It degenerates to 1, thus transforming into a regular B-spline surface; , These are the p-th and q-th order B-spline basis functions defined on the node vectors U and V, respectively; , These are node vectors, monotonically non-decreasing sequences of real numbers, and define the "piecewise" behavior of the parameter domain and basis functions.
[0022] In the Alias industrial surface construction tool, the core parameters are concentrated on the number of control points, order, and node span. Reading the surface model data actually obtains the order of U and V and the number of control points in the U and V directions, while the number of node spans is retained. The built-in loop structure obtains the spatial coordinates of the control points in the three-dimensional physical field. The extracted parameter information is stored in the parameter dictionary, written to the preset nurbs_simplified.json file, exported, and saved in the current same-level directory.
[0023] Preferably, the surface reconstruction in step S3 includes:
[0024] Based on the PythonOCC geometry engine, the pre-stored NURBS surface core geometric data is read from the preset nurbs_simplified.json file, automatically converted into a standard data format compatible with the PythonOCC library, and then reconstructed to obtain a NURBS surface that can be directly used for geometric analysis, surface visualization and subsequent CAD modeling operations;
[0025] The principle of generating node vectors in the u and v directions based on the extracted parameter information during surface reconstruction is as follows: For a p-th degree B-spline curve, it is defined by the following three elements:
[0026] n+1 control points: ;
[0027] Node vectors: ,satisfy ;
[0028] B-spline basis functions: Defined by the Cox-de Boor recursive formula, the parametric equation of the curve is:
[0029]
[0030] B-spline basis functions The domain is determined by the node sequence, according to the Cox-de Boor recurrence relation:
[0031]
[0032]
[0033] To make the basis functions arrive Both are defined, and the node indices need to range from 0 to... Therefore, the number of nodes is ,Right now Therefore That is, the number of nodes = the number of control points + the number of times + 1;
[0034] To ensure the curve passes through the first and last control points, clamping conditions need to be applied:
[0035]
[0036] This is achieved by making the endpoint nodes have repeatability. Implementation, that is:
[0037]
[0038]
[0039] The number of remaining internal nodes is These nodes are evenly distributed in the interval (0,1), and we have:
[0040]
[0041] Therefore, the complete node vector can be represented as:
[0042] .
[0043] Preferably, the boundary sampling and matching in step S4 includes:
[0044] Based on the reconstructed Geom_BsplineSurface object, the target working surface is first identified and all its parameter boundaries are extracted, namely the four parameter boundaries Umin, Umax, Vmin, and Vmax. Then, uniform sampling is performed on each parameter boundary of the working surface to obtain the three-dimensional spatial coordinate information of each sampling point. At the same time, uniform sampling processing of the same specification is performed on all types of boundaries of all reference surfaces to synchronously obtain the spatial position information of the sampling points of the reference surface bread boundaries.
[0045] By comparing and analyzing the sampling point position information of the working surface parameter boundary and the reference bread boundary, and taking the minimum sum of displacement differences of all pairs of sampling points to be matched as the core judgment criterion, the reference bread boundary that matches the current parameter boundary of the working surface is selected.
[0046] The mathematical principle of this method is based on the topological mapping and minimum distance optimization of the geometric relationship between surfaces. It establishes the correspondence by calculating the minimum Euclidean distance between the boundary curves of two surfaces: Let the working surface... There are 4 boundary curves, each of which can be represented by a parametric equation: Similarly, refer to the surface The four boundaries are: ;
[0047] In practical calculations, the boundary curves are discretized into a set of points, and each boundary is uniformly sampled: the sampled point set of the k-th boundary of the working surface is... ,in This is the number of sampling points; the set of sampling points for the l-th boundary of the reference surface is:
[0048]
[0049] in It is the number of sampling points;
[0050] For any pair of boundaries The spacing is approximated by the sum of the distances between sampling points, i.e., by the discrete approximation of the one-way Hausdorff distance:
[0051]
[0052] The algorithm iterates through all possible boundary combinations to find the pair with the minimum distance:
[0053]
[0054] Minimum distance value:
[0055]
[0056] This yields the boundary of the matching pair.
[0057] Preferably, the continuity error detection in step S5 includes:
[0058] Based on the boundary matching pairs output by the boundary matching module, a synchronous uniform sampling operation is performed on each boundary matching pair to extract three core geometric information items: the three-dimensional spatial coordinates, normal vector, and curvature of each sampling point. Then, the corresponding error is calculated according to detection rules for different continuity levels.
[0059] G0 continuity error: The G0 error, which characterizes the continuity of position, is obtained by calculating the difference in position coordinates between matching sampling point pairs.
[0060] G1 continuity error: The G1 error, which characterizes tangential continuity, is obtained by calculating the dot product of the matching sampling points with the normal vector and converting the dot product result into the included angle.
[0061] G2 continuity error: The G2 error, which characterizes the continuity of curvature, is obtained by calculating the curvature difference between the matched sampling point pairs.
[0062] After calculating the error of a single sampling point pair, the errors of all sampling points on the boundary matching pair are summed and averaged. The average value of each error is compared with the preset tolerance threshold to determine whether the boundary matching pair meets the specified continuity level requirements. The detection process is performed on all boundary matching pairs, and finally the complete continuity information of each boundary matching pair is output.
[0063] Preferably, the optimization of the objective function construction in step S6 includes:
[0064] Based on the continuity error data output in step S5, all continuity errors of the four parameter boundaries of the working surface are extracted through a loop structure, namely the G0 continuity error, G1 continuity error and G2 continuity error of each boundary. After accumulating all error terms, the initial target error function to be optimized is constructed.
[0065] Preferably, the parallel optimization solution using multiple algorithms in step S7 includes:
[0066] By using various optimization algorithms, we attempted to optimize the overall objective function and built a multi-algorithm parallel optimization program framework. The core implementation steps of this framework are as follows: select three optimization algorithms, namely CG, BFGS, and L-BFGS-B, independently configure the maximum number of iterations and the convergence tolerance for each algorithm, and attempt to optimize the objective function in parallel based on these three algorithms.
[0067] Preferably, the output of step S8 includes:
[0068] The NURBS surface core parameter data stored in the preset JSON file is parsed and reconstructed to generate a three-dimensional geometric surface that can be used for geometric verification. Then, the three-dimensional geometric surface is converted into a STEP format file that conforms to the industry standard to achieve compatibility and interaction with various CAD software. The surface visualization function is configured to intuitively verify the reconstruction accuracy and geometric shape effect of the surface.
[0069] Preferably, the specific implementation process for outputting the results is as follows: by loading and reading the optimized NURBS surface parameter JSON file, the reconstruction operation of the target working surface is completed, and the reconstructed surface is converted into a Brep geometry surface; while exporting the Brep geometry surface as a STEP format file, the visualization analysis of the surface geometric properties is carried out simultaneously to intuitively verify the continuity and morphological rationality of the optimized surface.
[0070] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0071] 1. High degree of automation, significantly reducing reliance on manual labor: Through the integrated design of the entire process from model import, parameter extraction, boundary matching to optimization verification, no manual intervention is required for surface fine-tuning and continuity matching. This effectively avoids the excessive reliance on designer experience in traditional methods and significantly improves the efficiency and consistency of multi-surface connection design.
[0072] 2. Controllable surface quality and precise improvement in continuity: The design adopts the principle of "optimizing only the coordinates of control points while keeping the surface order and node span unchanged" to avoid the decrease in controllability caused by redundancy of surface degrees of freedom; combined with multi-boundary collaborative error modeling and optimization, the continuity level of the working surface and the four-boundary reference surface can be accurately improved, while avoiding quality defects such as singularities and local wrinkles, ensuring the smoothness and smoothness of high-quality surfaces.
[0073] 3. Strong optimization stability and wide applicability: By building a multi-algorithm parallel computing framework and retaining intermediate optimization results, the risk of failure of a single algorithm optimization is effectively reduced, and the reliability of the process is improved; it is compatible with STEP format CAD models and general industrial scenarios, and can meet the high-quality surface modeling needs of the automotive, aerospace, and shipbuilding industries, with outstanding practicality and versatility.
[0074] 4. Excellent compatibility and adaptation to industrial design processes: The optimized model supports exporting to STEP format, which can be directly connected to mainstream CAD software without additional format conversion; parameter information is stored in a JSON database, which facilitates subsequent access and traceability, perfectly meeting the needs of the entire industrial "design-verification-production" process and reducing the cost of technology implementation. Attached Figure Description
[0075] Figure 1 This is a flowchart of the multi-surface continuity collaborative optimization method of the present invention;
[0076] Figure 2 This is an example of the original surface after continuity optimization (shown as a zebra stripe).
[0077] Figure 3 A schematic diagram of Example 1 for multi-surface collaborative G1 continuity optimization (including comparison of original / optimized surfaces);
[0078] Figure 4 Schematic diagram of Example 2 for multi-surface collaborative G1 continuity optimization (including comparison of original / optimized surfaces);
[0079] Figure 5 Schematic diagram of Example 3 for multi-surface collaborative G1 continuity optimization (including comparison of original / optimized surfaces);
[0080] Figure 6 Schematic diagram of Example 4 for multi-surface collaborative G1 continuity optimization (including comparison of original / optimized surfaces). Detailed Implementation
[0081] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.
[0082] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention.
[0083] The implementation of the multi-surface collaborative continuity optimization code described in this invention depends on the following software, hardware, and technical environment:
[0084] Hardware configuration: Processor model no lower than Intel Core i7 series, memory capacity no less than 16GB; graphics card has no special performance requirements, just enough to meet the basic needs of normal graphics rendering and data processing.
[0085] Software environment: The system uses a 64-bit Linux Ubuntu 20.04 operating system, which is compatible with mainstream CAD software such as CATIA and Autodesk Alias, and can realize the complete import and export functions of STEP format models.
[0086] Technical approach: The programming language used is Python 3.9 or later.
[0087] Data preparation: The CAD model to be optimized needs to be exported in advance to STEP format (preferably the industrially common STEP AP203 or AP214 sub-format), and the geometric parameters and topological information of the surface must be complete and without missing information during export to meet the needs of subsequent parameter extraction and surface reconstruction.
[0088] The multi-surface collaborative continuity optimization code of this invention adopts a modular architecture design, which is divided into several core functional modules. The core structure is set as a class definition segment. Sub-functions that implement various core processing functions are encapsulated in this class structure, supporting unified calls after class instantiation. The main function can call all sub-functions in the class as needed by instantiating this class, and realize the complete multi-surface collaborative optimization processing flow in a chain.
[0089] Standardized data exchange between functional modules is achieved through a JSON parameter database. The entire code project is configured with clearly defined input and output ports, and all types of data in the intermediate processing are transmitted and stored in JSON format. The overall architecture and data flow details are as follows:
[0090] Functional Breakdown: This code contains 8 core functional parts, which are divided into the following logical flow: model import, surface parameter extraction and JSON data translation, surface reconstruction, boundary sampling and matching, continuity error detection and analysis, optimization objective function construction, multi-algorithm parallel optimization solution, and result output.
[0091] Data flow: First, the model import module reads the STEP format CAD model file to be optimized, extracts and outputs the basic surface information. This basic surface information is then passed to the surface parameter extraction and JSON data translation module. After translation processing, a JSON parameter database is generated and saved locally, providing unified data support for subsequent intermediate processes such as surface reconstruction, boundary sampling and matching, continuity error detection and analysis, and optimization objective function construction. After the multi-algorithm parallel optimization solution module completes its calculations, it outputs the numerical solution of the optimized working surface control point coordinates. After the numerical solution is evaluated and meets the preset optimization requirements, it replaces the original control point coordinate data of the working surface and integrates it with the parameter data of each reference surface to generate a new JSON parameter file. Finally, the result output module reads the new JSON parameter file, completes the export and visualization of the optimized surface model, and forms a complete closed-loop data flow.
[0092] Module Interaction: Each module progresses according to the logic of "input-processing-output", forming a complete closed loop for multi-surface optimization. Among them, only the surface parameter extraction and JSON data translation module and the result output module are implemented as independent program blocks. The remaining core modules are all encapsulated in a preset class as sub-functions. This class can be directly called through the main function to realize the fully automated operation from model import to result visualization, improving optimization efficiency and ease of operation.
[0093] This section, in conjunction with the specific implementation steps of this invention, elaborates on the technical logic flow of each core functional module in the functional division. To protect core confidential information, only the key logic of the code operation of necessary core functions is described, supplemented by relevant theories to verify the scientific validity and feasibility of the algorithm logic.
[0094] S1, Model Import
[0095] First, the STEP format CAD model file to be optimized and the project program file should be stored in the same directory. The model file contains a surface to be optimized surrounded by four reference surfaces. Then, the import path of the model file is pre-configured in the main function, and the STEP model import interface in the PythonOCC library is called to complete the reading operation of the STEP format model file.
[0096] S2. Surface parameter extraction and JSON data translation
[0097] Based on the read model file data, the working surface is set as the starting point of the loop traversal and all surfaces are traversed.
[0098] The model surfaces in the input project program are NURBS surface patches, which provide very fine shape control through control points, weight factors, and node vectors. These parameters are very helpful for converting STEP models into objects that the program project can recognize. A NURBS surface with p-order u-direction and q-order v-direction is defined as follows:
[0099]
[0100] in, : Forms a (n+1)×(m+1) control point grid;
[0101] : With each control point The associated weighting factors are here. It degenerates to 1, thus transforming into a regular B-spline surface;
[0102] , These are the p-th and q-th order B-spline basis functions defined on the nodal vectors U and V, respectively.
[0103] , : Node vector, a monotonically non-decreasing sequence of real numbers, defining the "piecewise" behavior of the parameter field and basis functions.
[0104] In the Alias industrial surface construction tool, the core parameters mainly focus on the number of control points, order, and node span. Therefore, when reading the surface model data in the program, the actual process is to obtain the order of U and V and the number of control points in the U and V directions, while the number of node spans is retained. The built-in loop structure obtains the spatial coordinates of the control points in the three-dimensional physical field. The extracted parameter information is stored in the parameter dictionary and finally written into the preset nurbs_simplified.json file, exported and saved in the current same-level directory.
[0105] S3, Surface Reconstruction
[0106] Based on the PythonOCC geometry engine, the pre-stored NURBS surface core geometric data is read from the preset nurbs_simplified.json file, automatically converted into a standard data format that is compatible with the PythonOCC library, and then reconstructed to obtain a NURBS surface (i.e., Geom_BsplineSurface object) that can be directly used for geometric analysis, surface visualization and subsequent CAD modeling operations.
[0107] The principle of generating node vectors in the u and v directions based on the extracted parameter information during surface reconstruction is as follows: For a p-th degree B-spline curve, it is defined by the following three elements:
[0108] n+1 control points: ;
[0109] Node vectors: ,satisfy ;
[0110] B-spline basis functions: Defined by the Cox-de Boor recursive formula, the parametric equation of the curve is:
[0111]
[0112] B-spline basis functions The domain is determined by the node sequence. According to the Cox-de Boor recurrence relation:
[0113]
[0114]
[0115] To make the basis functions arrive Both are defined, and the node indices need to range from 0 to... Therefore, the number of nodes is ,Right now Therefore That is, the number of nodes = the number of control points + the number of times + 1;
[0116] To ensure the curve passes through the first and last control points, clamping conditions need to be applied:
[0117]
[0118] This is achieved by making the endpoint nodes have repeatability. Implementation, that is , The remaining number of internal nodes is These nodes are evenly distributed in the interval (0,1), and we have:
[0119]
[0120] Therefore, the complete node vector can be represented as:
[0121] .
[0122] S4, Boundary Sampling and Matching
[0123] Based on the reconstructed Geom_BsplineSurface object, we first define the target working surface and extract all its parameter boundaries, namely the four parameter boundaries Umin, Umax, Vmin, and Vmax. Then, we perform uniform sampling on each parameter boundary of the working surface to obtain the three-dimensional spatial coordinate information of each sampling point. At the same time, we perform uniform sampling processing of the same specifications on all types of boundaries of all reference surfaces to synchronously obtain the spatial position information of the sampling points of the reference surface bread boundaries.
[0124] By comparing and analyzing the sampling point position information of the working surface parameter boundary and the reference bread boundary, and taking the minimum sum of displacement differences of all pairs of sampling points to be matched as the core judgment criterion, the reference bread boundary that matches the current parameter boundary of the working surface is selected.
[0125] The mathematical principle of this method is based on the topological mapping and minimum distance optimization of the geometric relationship between surfaces. It establishes the correspondence by calculating the minimum Euclidean distance between the boundary curves of two surfaces: Let the working surface... There are 4 boundary curves, each of which can be represented by a parametric equation: Similarly, refer to the surface The four boundaries are: ;
[0126] In practical calculations, the boundary curves are discretized into a set of points; uniform sampling is performed on each boundary: the sampling point set of the k-th boundary of the working surface is... ,in This is the number of sampling points; the set of sampling points for the l-th boundary of the reference surface is:
[0127] in It represents the number of sampling points.
[0128] For any pair of boundaries The spacing is approximated by the sum of the distances between sampling points, i.e., by the discrete approximation of the one-way Hausdorff distance:
[0129]
[0130] The algorithm iterates through all possible boundary combinations to find the pair with the minimum distance:
[0131]
[0132] Minimum distance value:
[0133]
[0134] This yields the boundary of the matching pair.
[0135] S5. Continuity Error Detection and Analysis
[0136] This function is based on the boundary matching pairs output by the boundary matching module. First, it performs a synchronous uniform sampling operation on each boundary matching pair to extract three core geometric information items: the three-dimensional spatial coordinates, normal vector, and curvature of each sampling point. Then, it calculates the corresponding error according to the detection rules for different continuity levels.
[0137] G0 continuity error: The G0 error, which characterizes the continuity of position, is obtained by calculating the difference in position coordinates between matching sampling point pairs.
[0138] G1 continuity error: The G1 error, which characterizes tangential continuity, is obtained by calculating the dot product of the matching sampling points with the normal vector and converting the dot product result into the included angle.
[0139] G2 continuity error: The G2 error, which characterizes the continuity of curvature, is obtained by calculating the curvature difference between matched sampling point pairs.
[0140] After calculating the error of a single sampling point pair, the errors of all sampling points on the boundary matching pair are summed and averaged. The average value of each error is compared with the preset tolerance threshold to determine whether the boundary matching pair meets the specified continuity level requirement. The above detection process is performed on all boundary matching pairs, and finally the complete continuity information of each boundary matching pair is output.
[0141] In actual implementation, the following three technical details need to be given special attention:
[0142] 1. Adaptation of Forward and Reverse Sampling Parameter Order: After converting the STEP model into a Geom_BsplineSurface object recognizable by the OCC library, the sampling parameter order of boundary matching pairs may be inconsistent. For example, if the Umin boundary of the working surface matches the Umin boundary of the reference surface 1, although sampling is performed uniformly on both boundaries according to the parameter order "(Umin, Vmin) to (Umin, Vmax)", in actual modeling scenarios, the matching sampling point pairs may have reverse parameter coordinate matching. Therefore, before calculating the G0 continuity error, it is necessary to consider both "forward" and "reverse" matching cases in advance, calculate the Euclidean distance of the matching sampling point pairs based on the two cases, and then take the average of all Euclidean distances to obtain the error detection result that can accurately reflect the G0 continuity. This forward and reverse order adaptation logic is also applicable to the subsequent detection process of G1 and G2 continuity errors.
[0143] Set working surface The matching boundary is Reference surface Matching boundary Uniform sampling is performed on the two boundaries, with N+1 sampling points. Forward and reverse sampling are performed separately. The Euclidean distance between pairs of matched sampling points is then calculated.
[0144]
[0145] Then, the average distance is calculated based on the Euclidean distances of all point pairs, resulting in the G0 error term. Each of the forward and reverse processes yields a G0 error term. Considering the uncertainty of the parameter direction, the final G0 continuity error should be the minimum of the two matching cases: ;
[0146] 2. Correction of Normal Vector Direction: Since the internal encapsulation logic of the OCC embedded function is not publicly available, directly calling this function to extract the normal vector information of the surface boundary sampling points may result in deviations in the normal vector reading direction (either positive or negative). If the normal vector directions of two sets of matched sampling points are opposite, their dot product result will be negative, but the geometrically tangent plane actually possesses continuity. Therefore, when calculating the G1 continuity error, it is necessary to perform a post-processing operation of taking the absolute value of the normal vector dot product result, and then convert the processed dot product value into an angle. This normal vector direction correction logic is also applicable to the subsequent G2 continuity error detection process.
[0147] G1 continuity (tangent continuity) requires that two surfaces have the same tangent plane at their common boundary. Mathematically, this is represented as: Let the working surface... and reference surface At the matching point At that point, the directions of their normal vectors are consistent: That is, the unit normal vector should satisfy .
[0148] Because the internal implementation of OCC may produce inconsistencies in the direction of the normal vectors (after normalization), the two sets of normal vectors actually obtained may satisfy:
[0149]
[0150] in The direction factor is unknown, meaning the two sets of normal vectors are collinear but their orientation cannot be determined. Therefore, a correction is needed when calculating the dot product.
[0151]
[0152] Based on this, we further consider the case where the absolute value of the dot product of the normal vectors is not 1, that is: ;
[0153] At this point, the range of output angle change becomes The G1 continuity error is defined as the error at a single pair of sampling points. The average normal angle between all pairs of sampling points on the matching boundary is then obtained as the G1 continuity error term.
[0154] 3. Targeted processing of curvature difference for G2 continuity error: When calculating the G2 continuity error, a differentiated processing method is required for the curvature difference calculation based on the normal vector dot product result: If the normal vector dot product result is negative, the absolute values of the curvature values of the two sets of sampling points are first taken, and then the curvature difference is calculated; if the normal vector dot product result is positive, the difference between the curvature values of the two sets of sampling points is directly calculated. Through this differentiated processing, the obtained calculation result can accurately characterize the continuous change characteristics of curvature, that is, effectively reflect the G2 continuity error.
[0155] G2 continuity (curvature continuity) requires that two surfaces have the same normal curvature at their common boundary. Mathematically, G2 continuity is represented as: Let the working surface... and reference surface At the matching point P, the normal curvature along the common tangent direction t is equal: However, normal curvature is a signed quantity, and its sign is determined by the direction of the normal vector. If the normal vector is reversed, the absolute value of the normal curvature remains the same, then we have...
[0156]
[0157] Let the curvature values of the working surface and the reference surface at the sampling point at the matching boundary be respectively... , Let the dot product of the normal vectors at that point be... Let's discuss the different scenarios:
[0158] When the normal vectors are in the same direction, that is At this point, the normal vectors are in the same direction, and the curvature signs are defined in the same way. Therefore, the difference can be directly calculated as follows:
[0159]
[0160] When the normal vector is reversed, that is At this point, the normal vectors are in opposite directions, and the curvature signs are defined in opposite ways. The curvature of the reference surface should have the opposite sign.
[0161]
[0162] Combining the two cases above, the curvature difference can be uniformly expressed as:
[0163]
[0164] Among them, if , ; , At this point, the continuity error of G2 is represented by the absolute value of the curvature difference, and the absolute error is:
[0165]
[0166] The average value is calculated based on the absolute difference in curvature of all sampling point pairs at the matching boundary, thus obtaining a measure of the G2 continuity error.
[0167] S6. Optimize the objective function construction
[0168] Based on the continuous error data output by S5 (continuity error detection and analysis module), the continuous errors of the four parameter boundaries (Umin, Umax, Vmin, Vmax) of the working surface are extracted through a loop structure, namely the G0 continuous error, G1 continuous error and G2 continuous error of each boundary. After accumulating all the above error terms, the initial target error function to be optimized is constructed.
[0169] In the actual process of writing and implementing program code, the following three key technical factors need to be considered comprehensively:
[0170] Deformation constraint factors: It is expected that the deformation of the surface after optimization will remain within a reasonable range compared with that before optimization, so as to avoid excessive deformation of the surface and ensure that the original geometric features of the surface are not destroyed;
[0171] Continuity priority factor: Surface continuity has a clear hierarchy priority. The implementation of G1 continuity must be based on G0 continuity, and the implementation of G2 continuity must be based on G1 continuity. The hierarchy cannot be reversed.
[0172] Optimization effect constraints: The optimization effect of G2 continuity is actually limited by the optimization result of G1 continuity, and it is difficult to achieve the ideal G2 optimization effect when G1 continuity is not met.
[0173] Based on the above three considerations, the initial objective error function to be optimized is adjusted as follows:
[0174] A new surface deformation error term has been added to constrain the deformation during the surface optimization process;
[0175] Configure corresponding weight factors for each error term to adapt to the continuity priority and actual optimization needs;
[0176] The G2 continuity error term is removed, and only the G1 continuity is taken as the core optimization objective.
[0177] In summary, the final overall objective function can be expressed as follows:
[0178]
[0179] in, : Coordinates of sampling point i on the working surface / reference surface;
[0180] : The unit normal vector of sampling point i on the working surface / reference surface;
[0181] Compared with the original working surface, the optimized surface shows the coordinate components of each control point j and their corresponding coordinate component values.
[0182] Shape penalty sparsity coefficient.
[0183] S7. Parallel optimization solution using multiple algorithms
[0184] This paper employs multiple optimization algorithms to attempt to optimize the overall objective function described above, and establishes a multi-algorithm parallel optimization framework. The core implementation of this framework involves selecting three optimization algorithms—CG, BFGS, and L-BFGS-B—and independently configuring the maximum number of iterations and convergence tolerance for each algorithm. Based on these three algorithms, a parallel optimization solution for the objective function is then attempted.
[0185] The CG algorithm is an iterative algorithm that approximates the solution step by step using conjugate directions. It is suitable for solving large sparse linear systems of equations. .
[0186] For a given initial approximate solution Calculate the residual ,like ,but If the solution is exact, proceed to the iteration step.
[0187] The conjugate direction is determined by the residual. and the previous direction Generate, where the initial direction The subsequent direction is satisfied. The conjugate coefficient .
[0188] Along direction Search for the optimal step size To minimize the quadratic function The formula for calculating the step size is: Subsequently, the (k+1)th approximate solution is updated to The residual amount is updated synchronously. .
[0189] The BFGS algorithm is a quasi-Newton method specifically designed for solving unconstrained optimization problems. Its core objective is to minimize the objective function. The essence of BFGS is to construct an inverse approximation of the Hessian matrix using gradient information and iteratively optimize the approximation through "rank update".
[0190] Its core logic can be summarized as follows:
[0191] 1. Let the initial point be... Calculate the initial gradient Initial Hessian inverse approximation ;
[0192] 2. Search for the optimal step size in the opposite direction of the gradient. Update parameters The step size It is usually determined through line search (such as the Armijo criterion) to ensure 3. Calculate the gradient at the new point. And define gradient difference and parameter difference 4. Utilizing quasi-Newtonian conditions (Ensure that the approximate Hessian inverse is consistent with the true Hessian inverse in the direction of gradient difference), and iteratively optimize using the classic update formula of BFGS:
[0193] : .
[0194] The L-BFGS-B algorithm is a finite-memory improved version of the BFGS algorithm, specifically designed for solving unconstrained optimization problems with variable boundary constraints. Its core objective is to efficiently and stably minimize the objective function in large-scale, high-dimensional scenarios. Its essence is to approximate the inverse of the Hessian matrix using limited historical iteration information, and to ensure, through projection operations, that the solution after each iteration lies within the feasible region of the variables (i.e., ,in Let it be the lower bound vector. (The upper bound vector).
[0195] Its core logic can be summarized as follows:
[0196] 1. Search for the optimal step size in the opposite direction of the gradient. Update parameters The step size This is typically determined through a line search to ensure... ;
[0197] 2. Calculate the gradient at the new point. And define gradient difference and parameter difference ;
[0198] 3. Standard BFGS stores the complete rank update formula. Hessian inverse matrix L-BFGS-B only stores the data from the first k iterations. and ( , To determine the memory depth (typically 10-20), the current Hessian inverse approximation is calculated iteratively using a recursive formula. Memory requirements from Reduce to This greatly improves the scalability of high-dimensional problems.
[0199] Its approximate formula is:
[0200] ,
[0201] Where H0 = I (the initial Hessian inverse approximation is the identity matrix);
[0202] After each iteration, if If a variable exceeds its upper or lower bound l or u, it needs to be adjusted back to the feasible region through a projection operation: .
[0203] This multi-algorithm parallel optimization framework has the following three significant advantages:
[0204] The algorithms are highly independent and the process is highly stable: the three optimization algorithms adopt a parallel operation mode, which is independent of each other and does not interfere with each other. The failure of a single algorithm will not affect the optimization attempts of other algorithms, effectively ensuring the smooth progress of the overall optimization process.
[0205] Flexible parameter configuration and wide adaptability: The maximum number of iterations and convergence tolerance of each algorithm can be set as needed, which can flexibly balance the optimization quality of surface continuity and the solution time cost according to the needs of actual engineering scenarios.
[0206] Reliable results retention with no blank output: The optimization results of each algorithm are saved synchronously in real time. Even if the global optimization attempt of a certain algorithm fails to achieve the expected results, the coordinates of the control points of the working surface that are not fully optimized can be stored in the output JSON file, ensuring that there are valid results output after the optimization solution program finishes running.
[0207] S8. Result Output
[0208] First, the core parameter data of the NURBS surface stored in the preset JSON file is parsed and reconstructed to generate a three-dimensional geometric surface that can be used for geometric verification. Then, the three-dimensional geometric surface is converted into a STEP format file that conforms to industry standards to achieve compatibility and interaction with various CAD software. At the same time, the surface visualization function is configured to intuitively verify the reconstruction accuracy and geometric shape effect of the surface.
[0209] The specific implementation process is as follows: By loading and reading the optimized NURBS surface parameter JSON file, the reconstruction operation of the target working surface is completed, and the reconstructed surface is converted into a Brep geometry surface. While exporting the Brep geometry surface as a STEP format file (for subsequent CAD processes), the visualization analysis of the surface geometry characteristics is carried out simultaneously to intuitively verify the continuity and morphological rationality of the optimized surface.
[0210] The technical solution of the present invention has been verified by a large number of experimental cases, which shows that optimizing the G1 continuity while ensuring the G0 continuity between the working surface and the surrounding surface has significant technical advantages.
[0211] The specific verification process is as follows: First, multiple STEP format CAD surface model files meeting the S1 technical requirements are constructed and imported into the project program of this invention to perform G1 continuity optimization. Then, the effectiveness of the technical solution of this invention is verified through comparative analysis of the original and optimized surfaces. Some initial surface models are extracted from the surface of a car body to verify the universality of the algorithm program in professional engineering fields. The optimized surface models are imported into the Alias professional CAD software for continuity testing. The test results show that they meet the preset continuity level requirements, further confirming the professionalism and reliability of the algorithm process of this invention.
[0212] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.
Claims
1. A NURBS multi-surface collaborative G1 continuity enhancement method based on control point position optimization, characterized in that, The upgrade steps are as follows: S1. Model Reading: Reads STEP format CAD models. For scenarios in industrial settings where multiple reference surfaces connect to intermediate working surfaces, sets connection reference surfaces in the four-parameter boundary directions of the working surfaces as optimization benchmarks. S2. Parameter Extraction and Translation: After traversing the model through topological exploration, extract key information such as the target working surface number, order, and control point coordinates, retain the remaining parameters, and save them as a JSON file; S3. Surface Reconstruction: Reconstruct the surface based on the extracted NURBS surface core parameters, retain the parameterization range and topology of the original surface, and ensure that the boundary position and curvature trend of the reconstructed surface are consistent with the original model. S4. Boundary Sampling and Matching: The four-parameter boundaries of the reconstructed working surface and the reference surface are uniformly sampled. Through spatial position comparison, the boundaries of each working surface are accurately matched with the corresponding boundaries of the reference surface to form the boundary matching pairs required for continuity analysis. S5. Continuity error detection: For each set of boundary matching pairs, perform boundary sampling to obtain the sampling point position, normal vector and curvature parameters. By comparing and calculating the parameter differences, generate a continuity error term to quantify the degree of boundary matching. S6. Construction of the objective function: Using the spatial coordinates of the control points as the optimization variables, the error terms obtained in step S5 are introduced to construct the optimization system. Weighting factors are added to balance the contribution of each error term to form the overall objective function. S7. Parallel optimization and solution using multiple algorithms: Call optimization algorithms to build a parallel computing framework, try multiple optimization strategies, retain better intermediate results during the iteration process, until the optimal control point coordinate numerical solution is obtained and saved; S8. Result Output: Based on the optimal solution, the surface is reconstructed, and the continuity of each boundary is checked. If the single-sided error is within the allowable tolerance, it is considered to have reached the specified continuity level. The optimized surface model is exported as STEP format, and the result output and visualization are completed to carry out the overall optimization process.
2. The NURBS multi-surface collaborative G1 continuity enhancement method based on control point position optimization according to claim 1, characterized in that: In step S1, the STEP format CAD model file to be optimized and the project program file are stored in the same directory. The model file contains a surface to be optimized surrounded by four reference surfaces. The import path of the model file is pre-configured in the main function, and the STEP model import interface in the PythonOCC library is called to complete the reading operation of the STEP format model file.
3. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, The parameter extraction and translation in step S2 includes: Based on the read model file data, the working surface is set as the starting point of the loop traversal and all surfaces are traversed. The model surface in the input project program is a NURBS surface patch, which provides control capabilities through control points, weight factors, and node vectors. A NURBS surface of order p in the u direction and order q in the v direction is defined as follows: in, This forms a (n+1)×(m+1) control point grid; With each control point The associated weighting factors are here. It degenerates to 1, thus transforming into a regular B-spline surface; , These are the p-th and q-th order B-spline basis functions defined on the node vectors U and V, respectively; , These are node vectors, monotonically non-decreasing sequences of real numbers, and define the "piecewise" behavior of the parameter field and basis functions; In the Alias industrial surface construction tool, the core parameters are concentrated on the number of control points, order, and node span. Reading the surface model data actually obtains the order of U and V and the number of control points in the U and V directions, while the number of node spans is retained. The built-in loop structure obtains the spatial coordinates of the control points in the three-dimensional physical field. The extracted parameter information is stored in the parameter dictionary, written to the preset nurbs_simplified.json file, exported, and saved in the current same-level directory.
4. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, The surface reconstruction in step S3 includes: Based on the PythonOCC geometry engine, the pre-stored NURBS surface core geometric data is read from the preset nurbs_simplified.json file, automatically converted into a standard data format compatible with the PythonOCC library, and then reconstructed to obtain a NURBS surface that can be directly used for geometric analysis, surface visualization and subsequent CAD modeling operations; The principle of generating node vectors in the u and v directions based on the extracted parameter information during surface reconstruction is as follows: For a p-th degree B-spline curve, it is defined by the following three elements: n+1 control points: ; Node vectors: ,satisfy ; B-spline basis functions: Defined by the Cox-de Boor recursive formula, the parametric equation of the curve is: B-spline basis functions The domain is determined by the node sequence, according to the Cox-de Boor recurrence relation: To make the basis functions arrive Both are defined, and the node indices need to range from 0 to... Therefore, the number of nodes is ,Right now Therefore That is, the number of nodes = the number of control points + the number of times + 1; To ensure the curve passes through the first and last control points, clamping conditions need to be applied: This is achieved by making the endpoint nodes have repeatability. Implementation, that is: The number of remaining internal nodes is These nodes are evenly distributed in the interval (0,1), and we have: Therefore, the complete node vector can be represented as: 。 5. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, Step S4, including boundary sampling and matching, includes: Based on the reconstructed Geom_BsplineSurface object, the target working surface is first identified and all its parameter boundaries are extracted, namely the four parameter boundaries Umin, Umax, Vmin, and Vmax. Then, uniform sampling is performed on each parameter boundary of the working surface to obtain the three-dimensional spatial coordinate information of each sampling point. At the same time, uniform sampling processing of the same specification is performed on all types of boundaries of all reference surfaces to synchronously obtain the spatial position information of the sampling points of the reference surface bread boundaries. By comparing and analyzing the sampling point position information of the working surface parameter boundary and the reference bread boundary, and taking the minimum sum of displacement differences of all pairs of sampling points to be matched as the core judgment criterion, the reference bread boundary that matches the current parameter boundary of the working surface is selected. The mathematical principle of this method is based on the topological mapping and minimum distance optimization of the geometric relationship between surfaces. It establishes the correspondence by calculating the minimum Euclidean distance between the boundary curves of two surfaces: Let the working surface... There are 4 boundary curves, each of which can be represented by a parametric equation: Similarly, refer to the surface The four boundaries are: ; In practical calculations, the boundary curves are discretized into a set of points, and each boundary is uniformly sampled: the sampled point set of the k-th boundary of the working surface is... ,in This is the number of sampling points; the set of sampling points for the l-th boundary of the reference surface is: in It is the number of sampling points; For any pair of boundaries The spacing is approximated by the sum of the distances between sampling points, i.e., by the discrete approximation of the one-way Hausdorff distance: The algorithm iterates through all possible boundary combinations to find the pair with the minimum distance: Minimum distance value: This yields the boundary of the matching pair.
6. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, The continuity error detection in step S5 includes: Based on the boundary matching pairs output by the boundary matching module, a synchronous uniform sampling operation is performed on each boundary matching pair to extract three core geometric information items: the three-dimensional spatial coordinates, normal vector, and curvature of each sampling point. Then, the corresponding error is calculated according to detection rules for different continuity levels. G0 continuity error: The G0 error, which characterizes the continuity of position, is obtained by calculating the difference in position coordinates between matching sampling point pairs. G1 continuity error: The G1 error, which characterizes tangential continuity, is obtained by calculating the dot product of the matching sampling points with the normal vector and converting the dot product result into the included angle. G2 continuity error: The G2 error, which characterizes the continuity of curvature, is obtained by calculating the curvature difference between the matched sampling point pairs. After calculating the error of a single sampling point pair, the errors of all sampling points on the boundary matching pair are summed and averaged. The average value of each error is compared with the preset tolerance threshold to determine whether the boundary matching pair meets the specified continuity level requirements. The detection process is performed on all boundary matching pairs, and finally the complete continuity information of each boundary matching pair is output.
7. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, The optimization of the objective function construction in step S6 includes: Based on the continuity error data output in step S5, all continuity errors of the four parameter boundaries of the working surface are extracted through a loop structure, namely the G0 continuity error, G1 continuity error and G2 continuity error of each boundary. After accumulating all error terms, the initial target error function to be optimized is constructed.
8. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, The parallel optimization solution using multiple algorithms in step S7 includes: By using various optimization algorithms, we attempted to optimize the overall objective function and built a multi-algorithm parallel optimization program framework. The core implementation steps of this framework are as follows: select three optimization algorithms, namely CG, BFGS, and L-BFGS-B, independently configure the maximum number of iterations and the convergence tolerance for each algorithm, and attempt to optimize the objective function in parallel based on these three algorithms.
9. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 1, characterized in that, The output of step S8 includes: The NURBS surface core parameter data stored in the preset JSON file is parsed and reconstructed to generate a three-dimensional geometric surface that can be used for geometric verification. Then, the three-dimensional geometric surface is converted into a STEP format file that conforms to the industry standard to achieve compatibility and interaction with various CAD software. The surface visualization function is configured to intuitively verify the reconstruction accuracy and geometric shape effect of the surface.
10. The NURBS multi-surface collaborative G1 continuity improvement method based on control point position optimization according to claim 9, characterized in that, The specific implementation process for the output results is as follows: By loading and reading the optimized NURBS surface parameter JSON file, the reconstruction operation of the target working surface is completed, and the reconstructed surface is converted into a Brep geometry surface; while exporting the Brep geometry surface as a STEP format file, the visualization analysis of the surface geometric properties is carried out simultaneously to intuitively verify the continuity and morphological rationality of the optimized surface.