A universal parametric curve or surface self-intersection calculation method, device and storage medium

By subdividing curves or surfaces into sub-line segments or sub-faces, and using BVH structure to accelerate intersect judgment, combining the tracking method to calculate self-intersection points and self-intersection lines, the detection and calculation of curves and surface self-intersection problems in computer-aided design is solved. The problem of inefficiency achieves efficient and robust self-transmissing processing.

CN118569003BActive Publication Date: 2024-12-24ZHEJIANG UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411054668.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-12-24
Estimated Expiration
2044-08-02

AI Technical Summary

Technical Problem

In computer-aided design and manufacturing, curve and surface self-intersection problems lead to unexpected behaviors and erroneous results, especially in Boolean operations and CNC toolpath generation, it is difficult for the prior art to effectively detect and handle self-intersection situations.

Method used

The curve or surface is divided into sub-line segments or sub-face sheets by using a sub-division method, and the intersection judgment is accelerated using the BVH structure, and the self-intersection point and self-intersection line are calculated through the tracking method, which solves the detection and calculation efficiency of self-intersection problems. question.

Benefits of technology

It realizes efficient detection and calculation of parameter curves and surface self-intersection of various complexities and forms, and is suitable for complex situations such as multiple self-intersection points and self-intersection curves, improving the robustness and calculation efficiency of the algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569003B_ABST
    Figure CN118569003B_ABST
Patent Text Reader

Abstract

The present invention discloses a general parametric curve or surface self-intersection calculation method, device and storage medium, including: dividing the parameter domain of the parametric curve or parametric surface by an interval overlapping division method, constructing a BVH and realizing the subdivision of the parametric curve or parametric surface, thereby dividing the entire parametric curve or surface into a plurality of sub-segments or sub-faces, and then using a specific method to quickly traverse the BVH to detect self-intersections to find intersecting box pairs, then topologically reconstructing the intersecting box pairs, and finally using a tracking method to calculate self-intersection points and self-intersection lines. The method of the present invention can effectively process parametric curves or surfaces of various complexities and forms, and has wide applicability, high efficiency and sufficient robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer-aided design and manufacturing, and relates to a universal parameter curve or surface self-intersection calculation method, device and storage medium. Background Art

[0002] Computer-Aided Design And Manufacturing (CAD / CAM) plays an extremely important role in modern engineering, construction and manufacturing. By providing a digital design environment, it enables engineers, designers and creative personnel to design and develop in a faster, more accurate and more flexible way. The use of CAD / CAM is not limited to the traditional mechanical design field. It plays a key role in the fields of architecture, electronics, aerospace, automobiles, and medical treatment, and has become an indispensable core technology for modern engineering design.

[0003] A CAD kernel is a software component that implements the core functionality of CAD software. The CAD kernel provides a set of algorithms and data structures for processing geometric shapes, implementing geometric transformations, performing collision detection, and performing Boolean operations such as union, intersection, and difference. CAD kernels are usually object-oriented and have various classes and methods that can be used in a programming environment. CAD software developers can use CAD kernels to build their applications, thereby accelerating the development process and providing high-performance design and analysis capabilities.

[0004] In the CAD kernel, handling curve and surface self-intersections is an important issue because it can lead to unexpected behavior, especially when performing Boolean operations, cutting or other geometric operations. When a curve or surface has self-intersections in 2D or 3D space, it may lead to some challenges and problems: Unable to define unique parameters: A point on a curve or surface may have multiple parameter values ​​corresponding to it, which makes it difficult to accurately locate on the curve or surface; Geometric operation problems: Curve or surface self-intersections may lead to incorrect results when performing geometric operations (such as intersection detection, Boolean operations, etc.) because the intersection point may be double-counted or mistaken for two different points.

[0005] In the CAD kernel, Boolean operations support the construction of complex solid models from simple primitives. In order to convert the solid model into its boundary representation, an intersection algorithm is needed to handle the intersection of free-form surfaces. In existing intersection algorithms, it is usually assumed that the input surface has no self-intersection. However, in some cases, such as when the surface is an offset surface or a swept surface, we need to consider the possibility of self-intersection of the input surface.

[0006] CNC tool path generation is a technology widely used in computer-aided design and manufacturing (CAD / CAM). It is used to generate paths that control CNC machine tools to perform cutting operations so as to convert the designed geometric shapes into the tool trajectories required in the actual manufacturing process. Generating cutting paths by offset surfaces is an effective method, such as generating tool paths along the equidistant contours of offset surfaces. In the process of offset surface generation, self-intersections sometimes occur, which can cause problems in CNC tool path generation. For example, it may cause unexpected collisions of the tool during machining, affecting the machining quality and even damaging the workpiece or tool. Therefore, the detection and elimination of self-intersections in offset surfaces has long been an important issue in CNC tool path generation applications.

[0007] Based on this, the present invention proposes a universal method for calculating the self-intersection of a parametric curve or a parametric surface, which can effectively detect the self-intersection of a parametric curve or a parametric surface.

[0008] The parametric curve can be formally described as:

[0009]

[0010] in, represents the position on the parameter curve, , and represents the coordinates on the curve, represents the parameter value. Formula (1) represents a To coordinate points in space (3D parametric curve) Or coordinate points on a plane (2D parametric curve) On this basis, the curve self-intersection problem can be described as:

[0011]

[0012] in Indicates that there are two different parameter values ​​on the curve and Map to the same location All locations Generally speaking, It is a set of self-intersection points.

[0013] Parametric surfaces can be formally described as:

[0014]

[0015] in, represents the position on the parametric surface, , and represents the coordinates on the surface, and represents the parameter value. Formula (3) represents a To the coordinate point in space 's mapping.

[0016] On this basis, the surface self-intersection problem can be described as:

[0017]

[0018] in Indicates that there are two different parameter points on the surface and Map to the same location All surface locations Generally speaking, It is a set of self-intersecting curves and self-intersecting points. It is worth noting that the algorithm used in the present invention can act on any parametric curve or surface, as long as the parametric curve or surface can calculate the self-intersecting points from the given parameter points. To space coordinates 's mapping. Summary of the invention

[0019] The purpose of the present invention is to provide a general parameter curve and surface self-intersection calculation method in view of the deficiencies in the prior art. The method is mainly based on the idea of ​​subdivision, dividing the entire curve or surface into sub-segments or sub-faces, and converting the self-intersection problem into the intersection problem of non-adjacent sub-segments or sub-faces on the same curve or surface. In order to accelerate the intersection judgment of these sub-segments and sub-faces and avoid the algorithm efficiency problems caused by brute force search, the present invention uses the BVH structure to accelerate the intersection judgment. Traditional BVH is usually constructed by binary division, but this construction assumes that the input curve or surface has no self-intersection, and its division is usually non-overlapping, which will cause the algorithm to be unable to judge the self-intersection on the division boundary. On this basis, the present invention proposes a tracking-based method to realize the calculation of the final self-intersection line.

[0020] The technical solution adopted by the present invention is as follows:

[0021] A general method for calculating the self-intersection of a parametric curve or a surface comprises: dividing the parameter domain of the parametric curve or the parametric surface by an interval overlapping partitioning method, constructing a BVH and realizing the subdivision of the parametric curve or the parametric surface, thereby dividing the entire parametric curve or the surface into a plurality of sub-segments or sub-faces, then using a specific method to quickly traverse the BVH to detect self-intersections to find intersecting box pairs, then topologically reconstructing the intersecting box pairs, and finally using a tracking method to calculate the self-intersection points and self-intersection lines.

[0022] The bounding box hierarchy (BVH) used in the present invention uses an axis-aligned bounding box (AABB). In addition to the bounding box, each BVH node also stores information such as the parameter domain, explicit storage of the parameter domain size, and leaf node labels. BVH uses a ternary tree structure, and each BVH node has three pointers to child nodes. In the self-intersection of a curve, the parameter domain is one-dimensional, including the minimum and maximum values ​​of the parameter domain; in the self-intersection of a surface, the parameter domain is two-dimensional, including and In addition, the present invention uses a key-value mapping table as a data structure of the division method to record the corresponding relationship before and after the parameter domain length is divided.

[0023] On this basis, the present invention provides the construction process of curve self-intersection and surface self-intersection BVH respectively, which mainly includes three parts: initialization process: initialize BVH nodes according to the length or size of the parameter domain and allocate memory for them; leaf node judgment process: check whether the node is a leaf node, and set the leaf node mark according to the length or size of the parameter domain; BVH construction process: recursively construct the BVH tree, obtain the domain length of the child node according to the partition table, call the initialization process to initialize the child node, and then calculate the parameter domain according to the domain length of the child node, call the leaf node judgment process to determine whether the current node is a leaf node, and then recursively call the BVH construction process for the three child nodes of the current node.

[0024] On the basis of the completion of the BVH structure, the bounding box of the leaf node is calculated by sampling on the curve or surface. The process is to calculate the sampling step on the surface according to the input sampling number, starting from the minimum parameter value, walking the sampling step on the curve or surface each time, and calculating the coordinates of the point on the curve at the corresponding parameter, and then updating the bounding box parameters according to the coordinates of this point. The bottom-up BVH bounding box construction process is recursive. The recursion will start from the root node of the BVH, first recursively construct the bounding box of the child node until the child node is a leaf node; then merge the bounding boxes of all child nodes together as the bounding box of this node.

[0025] After the BVH bounding box is constructed, the BVH is traversed to find the self-intersecting areas. The traversal process includes checking the legitimacy of the BVH nodes, determining whether the AABB bounding boxes intersect, and recursively performing intersection traversal. The traversal will start from the root node of the BVH, first recursively perform self-intersection traversal on the three child nodes of the current node, and then determine the overlap of the bounding boxes of the three child nodes: for the two child nodes whose bounding boxes overlap, perform intersection traversal; for the two child nodes whose bounding boxes do not overlap, prune the BVH tree without any processing. During the intersection traversal, the three child nodes of the larger parameter domain node and another node are used each time for recursive intersection traversal until both nodes are leaf nodes. If the bounding boxes of two leaf nodes overlap, this indicates that a pair of intersecting boxes has been found.

[0026] After finding the intersecting box pairs of leaf nodes, topology reconstruction will be performed. Its purpose is to connect all adjacent curve segments and surface patches to form a large curve and surface, so that the step size can be correctly calculated when the marching method is used to solve the self-intersection points and self-intersection curves.

[0027] Finally, the self-intersection problem is solved by the curve and surface intersection algorithm, including using the Newton iteration method to find the starting point and the tracking method to calculate a series of points on the intersection line. Finally, all the result points are fitted into a B-spline curve. The whole process mainly relies on BVH technology and numerical calculation methods to solve the self-intersection problem of curves and surfaces.

[0028] Compared with the prior art, the beneficial effects of the present invention are:

[0029] (1) The curve or surface self-intersection calculation method proposed in the present invention has wide applicability. The method is suitable for processing parametric curves or surfaces of various complexities and forms, including but not limited to polynomial curves, Bezier curves, NURBS curves and various surface models.

[0030] (2) The curve or surface self-intersection calculation method proposed in the present invention has remarkable efficiency. By cleverly modifying the BVH, the method enables the curve or surface self-intersection problem to be solved using a mature curve or surface intersection algorithm, thereby enabling the self-intersection algorithm to achieve almost the same computational efficiency as the existing curve or surface intersection algorithm.

[0031] (3) The curve or surface self-intersection calculation method proposed in the present invention is sufficiently robust and can stably handle complex situations such as multiple self-intersection points and self-intersection curves, similar self-intersection points and self-intersection curves, and circular self-intersection curves. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 Schematic diagram of curve and surface division using the binary method;

[0033] Figure 2 Schematic diagram of a simple solution to the common boundary created by the dichotomy;

[0034] Figure 3 It is a schematic diagram of curve and surface division actually used in the present invention;

[0035] Figure 4 Process diagram of constructing BVH for self-intersecting curves;

[0036] Figure 5 Diagram of the process of constructing a BVH for a self-intersecting surface;

[0037] Figure 6 Process diagram of BVH traversal for self-intersecting curves;

[0038] Figure 7 Process diagram of BVH traversal for self-intersecting surfaces;

[0039] Figure 8 Schematic diagram of the tasks completed for topology reconstruction;

[0040] Fig. 9 A schematic diagram of the intersection of a surface patch and multiple non-adjacent surface patches;

[0041] Fig.10 A schematic diagram of a surface intersecting with itself to form a self-intersecting curve;

[0042] Fig.11 A schematic diagram of a surface intersecting with itself to form a closed self-intersecting curve;

[0043] Fig.12 A schematic diagram of a surface intersecting itself to form two close self-intersecting curves;

[0044] Fig.13 A schematic diagram of a surface intersecting itself to form two long-distance short self-intersecting curves;

[0045] Fig.14 It is a schematic diagram of a curve intersecting itself to form a self-intersection point;

[0046] Fig.15 It is a schematic diagram of a curve intersecting with itself to form multiple self-intersection points;

[0047] Fig.16 It is a schematic diagram of a curve intersecting itself, forming two close self-intersection points;

[0048] Fig.17 A schematic diagram of a self-intersection of a polyline, forming a self-intersection point with three parameters mapped to the same point;

[0049] Fig.18A flow chart comparing self-intersection calculation and intersection calculation; DETAILED DESCRIPTION

[0050] The present invention proposes a method for calculating the self-intersection of curves and surfaces. The following describes the scheme of the present invention in detail from the basic principle of the algorithm, BVH construction, BVH traversal, topology reconstruction, and calculation of self-intersection points and self-intersection lines. The first four parts complete the problem transformation from surface self-intersection calculation to surface intersection calculation, which is also the focus of the present invention. The contributions of the present invention can be summarized as follows:

[0051] (1) Regarding the self-intersection problem of curves and surfaces: This paper proposes a general curve and surface self-intersection solution framework. The parameter domain of parametric curves and surfaces is divided by a special partitioning method, and this partitioning method is applied to BVH to achieve curve and surface subdivision. Then, a special method is used to traverse the BVH to detect self-intersections to find intersecting box pairs. After that, the topology of the intersecting box pairs is reconstructed, and finally the self-intersection points and self-intersection lines are calculated by tracking. In this way, the detection of self-intersections of curves and surfaces and the rapid calculation of self-intersection points and self-intersection curves are achieved.

[0052] (2) For the parameter domain partitioning method of parametric curves and surfaces, the present invention proposes an "interval overlap" partitioning method, which adds an intermediate interval area on the basis of the binary division method, and adds an additional area that partially overlaps with the other areas. This solves the self-intersection detection problem on adjacent boundaries of the binary division method and reduces the performance consumption caused by the parameter domain partitioning.

[0053] (3) For the "interval overlap" partitioning method, the present invention provides a storage method for the partitioning method, and applies the partitioning method to the data structure and construction process of the curve self-intersection BVH and the surface self-intersection BVH. The partition of the parameter domain and the construction of the BVH structure are completed from top to bottom by constructing a ternary tree and storing the parameter domain at each node of the tree, and then the bounding box of each leaf node is calculated, and finally the bounding box of each non-leaf node is calculated from bottom to top. In this way, the construction of the BVH and the subdivision of the parameter curve and surface are quickly completed.

[0054] (4) For the BVH structure based on the "interval overlap" partitioning method, the present invention provides a "self-intersection intersection" BVH traversal algorithm. The three child nodes of each non-leaf node are recursively self-intersection traversed, and the three child nodes are intersected to check the self-intersection and intersection of the three child nodes. For each pair of leaf nodes, check whether their bounding boxes intersect, and record the parameter domains and bounding boxes of all intersecting leaf nodes. In this way, fast BVH traversal and search for intersecting box pairs are achieved.

[0055] (5) For all the intersecting box pairs, the present invention provides a topology reconstruction algorithm. The parameter domains of all intersecting box pairs are constructed into a graph, and all adjacent parameter domains are connected together through a breadth-first traversal algorithm. Then, a complete parameter domain is constructed based on the connection information, so as to achieve the correct selection of the step size when the subsequent tracking method is used for intersection line calculation.

[0056] (6) For the calculation of self-intersection points and self-intersection lines, the present invention uses the Newton iteration method to find the starting point of the tracking method in the surface intersection and the intersection point in the curve intersection, and uses the tracking method to calculate the intersection line in the surface intersection. By replacing the BVH construction and traversal process in the curve or surface intersection algorithm with the self-intersection BVH construction and traversal process in steps (2) to (4), the curve or surface intersection algorithm is used to calculate the curve or surface self-intersection problem. The following is a further detailed description of the technical solution of the present invention in conjunction with the accompanying drawings and specific examples, which are divided into five sections 1 to 5:

[0057] 1. Basic principles of the algorithm

[0058] The main idea of ​​the curve and surface self-intersection algorithm in the present invention is as follows: based on the idea of ​​subdivision, the entire curve or surface is divided into several sub-segments or sub-patches, and then the self-intersection problem of the curve and surface is converted into the intersection problem of two non-adjacent sub-segments or sub-patches on the same curve or surface, so that the self-intersection problem can be solved using the intersection algorithm.

[0059] First consider a simple partition such as Figure 1 As shown in (a), when the curve is divided into Divided into two smaller parts hour, The self-crossing can be achieved through and The recursive self-intersection of and However, this simple division will cause a problem: due to and Adjacent, when and When calculating the intersection of two curves, their connection points are usually used as the intersection point calculation results. For two curve segments, checking whether they are smoothly connected or partially intersecting at a common point usually does not cause a large performance overhead. However, when this approach is extended to surfaces, such as Figure 1 As shown in (b), two surface patches are determined and Whether they are smoothly connected or locally intersecting along their common boundaries is computationally expensive. Traditional subdivision-based algorithms usually recursively subdivide the surface into smaller and smaller patches along the common boundaries, which incurs a significant performance overhead.

[0060] A simple remedy is to add a single edge surface that covers the common boundary curve. Perform a self-intersection test, such as Figure 2 As shown in (b) in the figure. Under this division, two things need to be guaranteed: each part is self-intersection checked, and each two parts are intersected. At the same time, it is necessary to ensure that the intersection check of any two adjacent parts should be replaced by a self-intersection check of a large surface. In this way, and The intersection calculation is replaced by At the same time, since any two sub-faces need to be intersected, it is also necessary to perform and The intersection calculation.

[0061] In order to more conveniently use BVH to represent the partitioning process and reduce the performance overhead caused by the difference operation on the surface, the surface can be Divided into three parts , the partition is implemented as Figure 3 As shown in (b). Under this division and Not directly adjacent, but slightly separated so that and The intersection calculation can be performed directly. The spaced-apart surface patches are represented using the symbol Sub-patch Covering at the same time as well as and Under this division, the surface The self-intersection calculation can be converted into Perform a recursive self-intersection calculation, and The intersection calculation.

[0062] Recursively subdividing the surface into three smaller parts means that each non-leaf node of the BVH structure will have three child nodes: left child node, middle child node and right child node, which are responsible for recursive self-intersection. At the same time, when performing intersection calculations, the difference operation can be implicitly expressed by restricting the parameter domain of the subtree without constructing an additional BVH structure, which will be explained in detail in Section 3.

[0063] 2.BVH data structure and construction process

[0064] 2.1 Background knowledge

[0065] 2.1.1 Bounding Volume Hierarchy

[0066] A bounding volume is a simple geometric shape that is used to approximate or enclose a more complex object or collection so that operations can be performed more efficiently in calculations. In computer graphics, bounding volumes are often used to accelerate tasks such as collision detection, visibility testing, and spatial partitioning. Some commonly used bounding volumes in computer graphics include: Bounding Box uses a rectangle or cube to represent the bounding range of an object or a collection of objects; Bounding Sphere uses a three-dimensional sphere to represent the bounding range of an object or a collection of objects, which is usually defined by calculating the center and radius of the object or collection of objects; Bounding Cone uses a three-dimensional cone to represent the bounding range of an object or a collection of objects. This bounding volume can provide a more compact approximate shape in some graphics applications; Bounding Cylinder uses a three-dimensional cylinder to approximate the bounding object, which is used to accelerate collision detection and other geometric calculations in some applications; Bounding Frustum: Use a three-dimensional cone to approximate the bounding object, which is usually used to represent the camera's frustum, which is used to eliminate objects that are not in the frustum and improve rendering performance. An axis-aligned bounding box (AABB) is a special bounding box whose sides are parallel to the coordinate axes, which makes the testing and calculation of axis-aligned bounding boxes simpler because you only need to check the minimum and maximum values ​​on each coordinate axis; an oriented bounding box (OBB) is another bounding box whose sides can be rotated in any direction. It can enclose objects more compactly, but the calculation is more complicated than AABB.

[0067] Bounding Volume Hierarchy (BVH) is a data structure widely used in computer graphics, computer games, and ray tracing. The main purpose of BVH is to accelerate the calculation of searching for objects in space, collision detection, and ray tracing. BVH usually consists of a tree structure, where each node represents a bounding volume, and the leaf nodes contain the actual objects or geometric shapes. This hierarchical structure makes it more efficient to quickly locate and process objects in the scene.

[0068] 2.1.2 Key-value mapping

[0069] Key Value Mapping is a data structure or abstract data type that establishes a mapping relationship from a unique key to the corresponding value. In this structure, each key uniquely identifies a value, allowing the value associated with it to be accessed and manipulated through the key. This mapping relationship is often called a dictionary, map, or associative array. The data structure that implements this mapping relationship varies in different programming languages. Some common implementations include:

[0070] Hash table: Use hash functions to map keys to a location in memory for fast insertion, search, and deletion operations. In C++, std::unordered_map is a key-value mapping based on a hash table.

[0071] Red-black tree: Maintains ordered key-value pairs through a self-balancing binary search tree. In C++, std::map and std::multimap are associative containers implemented based on red-black trees.

[0072] Array or list: Use an array or list to store key-value pairs, and use linear search to find the value corresponding to the key. This implementation is relatively slow, but it is still useful in some specific scenarios.

[0073] 2.2 Explanation of symbols

[0074] In the self-intersection algorithm of the present invention, the axis-aligned bounding box (AABB) is used as the bounding volume used by the bounding volume hierarchy (BVH). At the same time, in each BVH node, in addition to the bounding volume, other information is also stored: including a parameter domain, explicit storage of the parameter domain size, and leaf node marking. Since the BVH used in the present invention is a ternary tree, the BVH node also includes three pointers to child nodes. In addition, since the parameter domain in the curve is one-dimensional and the parameter domain in the surface is two-dimensional, the two have different attribute values ​​in the "explicit storage of the parameter domain size" and "parameter domain", which is explained in the application field in the following table. The symbols used in the construction process of BVH are as follows:

[0075]

[0076] It should be noted that , is the parameter domain in the curve self-intersection BVH node subitems; , , , is the parameter domain in the surface self-intersection BVH node In addition, "." will be used below to indicate access to node attributes, such as the symbol " " indicates accessing the parameter domain of the node "node".

[0077] The leaf node mapping table will also be used in the BVH construction algorithm , is a key-value mapping table. Due to the special self-intersecting BVH, there will be repeated leaf nodes in the leaf node layer. In order to avoid repeated sampling when calculating the bounding box, it is necessary to use To complete the mapping from the parameter domain to the set of repeated BVH leaf nodes. The key is the parameter domain , the value is a collection of BVH node pointers In the implementation of the present invention, the std::map container in C++ is used as the data structure constituting the leaf node mapping table.

[0078] Since the self-intersection algorithm of the present invention adopts a special BVH partitioning method, it is necessary to store the corresponding partitioning method. Now, the relevant data structure of the partitioning table is described. The description of some symbols is as follows:

[0079]

[0080] The above items constitute the nodes of the partition table. is a key-value mapping table, whose key is the length of the parameter domain before the division, and whose value is the node formed by each item in the above table. It should be noted that in the following we will use the symbol "[key]" to represent the access The key is the node corresponding to the "key", and the symbol "." is used to access the items in the node. For example Indicates that the length is When the parameter domain is divided The length of the region.

[0081] In the implementation of the present invention, the std::map container in C++ is used as the data structure for constituting the partition table. At the same time, the following table shows the data structure used in the present invention. The relevant parameters need to be explained. Other parameters may be adopted in different applications and requirements.

[0082]

[0083] 2.3 Construction of BVH

[0084] The construction of BVH is mainly divided into three parts. First, the parameter domain is divided from top to bottom, and the BVH tree structure is constructed at the same time. Then the bounding boxes of all leaf nodes are calculated, which completes the sampling on the surface and curve. Finally, the bounding boxes of all nodes are constructed from bottom to top. Most of the processes of curve self-intersection and surface self-intersection are similar, but because the parameter domain of the curve is one-dimensional and the parameter domain of the surface is two-dimensional, there are some differences in the calculation process of the two. The following will describe the BVH construction process of curve self-intersection and surface self-intersection separately.

[0085] 2.3.1 Self-intersection of a curve

[0086] In the first part, we will complete the division of the curve parameter domain and the construction of the BVH used for the curve self-intersection. The construction process will be carried out recursively. The BVH construction algorithm also needs to use two sub-processes, namely initializing the BVH node (Init) and determining whether the BVH node is a leaf node (Determine). The construction process is as follows Figure 4 shown.

[0087] During the initialization process, the parameter field length of the node will be passed in. The process will apply for memory for a node, write the parameter field length of the node into the node's data, and return the pointer of the node. If the input length is invalid, the process will directly return a null pointer. The process is described in pseudo code as follows:

[0088]

[0089] In the process of judging the leaf node, a leaf node pointer will be passed in. The process will check whether the parameter field length of a leaf node is 1 and mark the leaf node of the node. Set to the correct value. At the same time, add the leaf node pointer to the leaf node mapping table The correct key in the set. If the input node pointer is invalid, the process will not do anything. The pseudo code of this process is as follows:

[0090]

[0091] The process of constructing a self-intersecting BVH of a curve is mainly to use the domain length of the current node to query the partition table To obtain the domain lengths of its three child nodes, call the Init procedure to initialize the child nodes, then calculate the parameter domain of the child nodes based on the domain length of the current node, and call the Determine procedure to set the correct value for the leaf node tag of the child node, and complete the leaf node mapping table For use in calculating the bounding box. Then, the Generate process is recursively called on the three child nodes of the current node to complete the construction of the BVH.

[0092]

[0093] In the second part, the bounding box calculation for all leaf nodes will be completed. The process is as follows: First, the sampling step length on the surface is calculated according to the input sampling number, starting from the minimum parameter value, each time the sampling step length is walked on the curve, and the coordinates of the point on the curve at the corresponding parameter are calculated, and then the bounding box parameters are updated according to the coordinates of this point. Finally, the leaf node mapping table is used to calculate the bounding box parameters. Set the bounding box of the leaf nodes of the same parameter domain in the BVH.

[0094] In addition, since this part can be calculated in parallel, multithreading or GPU can be used for calculation. The implementation of the present invention adopts OpenMP technology for parallel acceleration. OpenMP (Open Multi-Processing) is an application programming interface (API) for parallel programming, which allows programmers to write parallel programs using shared memory. Through OpenMP, serial code can be easily converted into parallel code to fully utilize the performance of multi-core processors and shared memory systems.

[0095] Non-Uniform Rational B-Splines (NURBS) are widely used in the field of Computer Aided Design (CAD) due to their flexibility, accuracy, and efficient representation and operation of curves and surfaces. Therefore, the present invention uses NURBS as parameter curve mapping.

[0096] A NURBS curve of order p is defined as:

[0097]

[0098] in It means that the node vector is defined as The length of the knot vector of the B-spline basis function on is ,generally ,and ; Represents the control points of the parametric curve. The number of control points is ; Represents the weight of each control point. The calculation of B-spline basis function can be performed recursively:

[0099]

[0100] The calculation process of the bounding box of a leaf node is described as follows using pseudo code. The algorithm will use the symbol Indicates that the parameters Calculate coordinates on a NURBS curve:

[0101]

[0102] In the third part, we will complete the construction process of the self-intersecting BVH bounding box of the curve from bottom to top. The construction is also recursive. First, recursively construct the bounding box of the child node until the child node is a leaf node or empty. Then merge the bounding boxes of all child nodes together as the bounding box of this node, which is described in pseudo code as follows:

[0103]

[0104] 2.3.2 Surface Self-Intersection

[0105] In the first part, we will complete the partitioning of the surface parameter domain and the construction of the BVH used for the surface self-intersection. Similar to the curve self-intersection, the construction process also requires an initialization process (Init) and a leaf node determination process (Determine). The construction process is as follows Figure 5 shown.

[0106] In surface self-intersection, the process of initializing the BVH nodes is similar to the process of initializing the BVH nodes in curve self-intersection, but because the parameter domain of the surface is two-dimensional, it is necessary to use and Recorded separately in Direction and The length of the parameter field in the direction, and you need to use Record the size of the parameter domain and the process of initializing the surface self-intersection nodes using pseudo code as follows:

[0107]

[0108] The algorithm for determining leaf nodes in surface self-intersection is basically the same as that for curve self-intersection. The only difference is that the determination condition is changed from the length of the parameter domain (one-dimensional) to the size of the domain (two-dimensional). The pseudo code for determining leaf nodes is as follows:

[0109]

[0110] Similar to the self-intersection of a curve, a recursive process will be used to complete the construction of the BVH. However, unlike the BVH of the self-intersection of a curve, the division of the parameter domain will be performed alternately in two directions, and each division will be performed on the longer edge. The division process is described in pseudo code as follows:

[0111]

[0112] In the second part, the bounding boxes of all leaf nodes will be calculated. The calculation process is similar to the calculation process of the leaf node bounding box in the curve self-intersection, but because the parameter domain of the surface is two-dimensional, the calculation of the sampling step and the walking will be performed in two directions. Similar to the curve self-intersection, the present invention uses NURBS as the parameter surface mapping and adopts OpenMP technology for parallel acceleration.

[0113] A NURBS surface of order p in the u direction and order q in the v direction is defined as:

[0114]

[0115] in Indicated in The direction is defined at the node vector as The B-spline basis function on has a length of ; Indicated in The direction is defined at the node vector as The B-spline basis function on has a length of ; represents a network of control points; Represents the weight of each control point. The calculation process of B-spline basis function is the same as that of NURBS curve.

[0116] The calculation process of the bounding box of a leaf node is described as follows using pseudo code. The algorithm will use the symbol Indicates that the parameter Calculate coordinates on a NURBS surface:

[0117]

[0118] In the third part, we will complete the bottom-up construction process of the surface self-intersection BVH bounding box. This process is exactly the same as Algorithm 2-5 in curve self-intersection, so we will not repeat it here.

[0119] 3.BVH traversal and self-intersection algorithm

[0120] In Section 2, we completed the construction of the BVH required for calculating curve self-intersection and surface self-intersection. On this basis, we can find the self-intersection area by traversing the BVH. Since the BVH structure of curve self-intersection is the same as that of surface self-intersection, the BVH traversal process described below is applicable to both curve self-intersection and surface self-intersection.

[0121] According to the description of the algorithm in Section 1, in the process of calculating self-intersection, the self-intersection calculation will be recursively performed on the child nodes, and the intersection of three non-adjacent regions will be calculated, which will be manifested in the algorithm as two parts: self-intersection and intersection.

[0122] The following will first describe the intersection part. The intersection traversal process will accept two BVH node pointers and two parameter domains as parameter domain restrictions for the subtree with these two BVH nodes as roots. The parameter domain restrictions will be passed down as the recursion proceeds. During the intersection traversal process, the algorithm always keeps one node fixed and uses the three child nodes of another node to recursively perform intersection traversal. First, the algorithm will check the legality of the input. If any BVH node pointer is a null pointer, the algorithm will not perform any operation. Then, the algorithm will check whether the AABB bounding boxes stored in the current two BVH nodes intersect. If the bounding boxes in the two BVH nodes do not intersect, it means that the nodes in the BVH subtree with these two nodes as roots will not intersect. At this time, the algorithm will return directly to implement the pruning of the BVH tree. Otherwise, the algorithm will use the three child nodes of the larger node to recursively intersect with another node. In order to ensure that the larger node is divided each time recursively, the algorithm will compare the size of the parameter domains stored in the node. For the self-intersection of the curve, the comparison is ; For surface self-intersection, the comparison is The traversal process of curves and surfaces is as follows Figure 6 and Figure 7 shown.

[0123] When the two current nodes are both leaf nodes, the traversal ends. At this time, the algorithm will check whether the parameter domains of the two nodes are in the corresponding restricted parameter domains. If the check passes, it means that the algorithm has found a pair of leaf nodes that may intersect, and then the algorithm inserts the parameter domains corresponding to the pair of leaf nodes into the intersection table. It is a hash table, and its main purpose is to remove duplicates for intersection pairs. The pseudo code description of the intersection traversal process is as follows:

[0124]

[0125] Next, we will describe the self-intersection part, starting from the parameter curve Or parametric surface Starting from the BVH root node, the self-intersection traversal process is first recursively called for the three child nodes of the current node, and the recursion stops when the child node is a null pointer or a leaf node. Then, the intersection of the three parts is calculated. Here, the algorithm will calculate the parameter restrictions and pass them as parameters for the intersection process. It is worth noting that for intersection pairs that do not require parameter domain restrictions, the original parameter domain will be passed directly. The pseudo code description of the self-intersection traversal process is as follows:

[0126]

[0127] 4. Topology Reconstruction

[0128] In the algorithm in Section 3, we can get all the curve segments and surface patches that need to be intersected. In this section, we will perform topological reconstruction on these curve segments and surface patches. The task of topological reconstruction is to connect all adjacent curve segments and surface patches to obtain a large curve and surface. The reason for this step is to correctly calculate the marching step length when using the marching method to solve the self-intersection points and self-intersection curves. The tasks that need to be completed in topological reconstruction are as follows: Figure 8 shown.

[0129] In the process of topology reconstruction, a topology reconstruction table is needed. The relevant data structure of the topology reconstruction table is explained below. The meanings of some symbols are as follows:

[0130]

[0131] The above items constitute the nodes of the topology reconstruction table. is a key-value mapping table, whose key is a parameter domain and whose value is the node formed by each item in the above table. It should be noted that due to the different dimensions of the parameter domains of curves and surfaces, the partition table There are differences in the actual implementation of curve self-intersection and surface self-intersection, but the algorithm flow is roughly the same.

[0132] First, you need to initialize the topology reconstruction table The main process is as follows: For the intersection table obtained in Section 3 For each pair of parameter domains in , use them as the key value of the topology reconstruction table, and add the corresponding parameter domain to the set of intersection parameter domains of the corresponding key value. Then, for each item in the topology reconstruction table, take out its key as the current parameter domain, and check whether the neighbors around the current parameter domain are in the topology reconstruction table. If so, the parameter domain of this neighbor will be added to the set of neighbor parameter domains of the corresponding key value of the current parameter domain in the topology reconstruction table. It should be noted that the neighbor node check in curve self-intersection and surface self-intersection requires different neighbor node data to be checked due to the different parameter domain dimensions.

[0133]

[0134] After completing the construction of the topology reconstruction table, you can use the topology reconstruction table to rebuild the topology relationship. The algorithm will traverse the topology reconstruction table once to ensure that each element in the topology reconstruction table will be processed. For each element in the topology reconstruction table, the algorithm will first check the legitimacy of the element, that is, to ensure that the elements that have been processed will not be processed again. Then, if the element passes the legitimacy check, then add the element to the stack Then a round of parameter domain connection operation is performed.

[0135] In each round of connection, first from the stack A parameter field pops up as the parameter field currently being processed , and and the currently joined parameter domain A copy of joint.

[0136] Then we use the topology reconstruction table to query all There are intersecting parameter domains. In these parameter domains, find all the intersecting parameter domain sets that are currently being processed. Parameter domains that have adjacent relationships and add these parameter domains to the set Then according to the set Calculate the complete parameter domain after all the parameter domains are combined and use it to update Here we mainly consider the case of one surface patch or curve segment and multiple surface patches or curve segments, such as Fig. 9 As shown, Parameter domains that have intersecting relationships cannot be added directly to In the case of expansion.

[0137] if and Overlap, indicating Processing will cause the current parameter domain union to fail. In this case, we put Put on stack Otherwise, we use the copy parameter domain to update the current parameter domain and All parameter fields of neighbor nodes that have not been processed are placed into the stack middle.

[0138] Each stack When it is empty, it means that a join has been completed. In this case, the parameter fields that have been connected are placed in the result set, and all temporary variables are reset for the next join. The algorithm is described in pseudo code as follows:

[0139]

[0140]

[0141] 5. Calculation of self-intersection points and self-intersection lines

[0142] The focus of the present invention is to transform the self-intersection problem of curves and surfaces into an intersection problem, and no additional optimization is performed on the calculation of self-intersection points and self-intersection curves. There are currently many calculation methods for curve intersection and surface intersection. In this section, the calculation method of intersection points and intersection lines used in the present invention is briefly introduced from a methodological perspective. In the present invention, the tracking method is mainly used to solve the intersection problem, and the BVH technology is used to calculate the starting point in the tracking method. The flow of the surface intersection algorithm using the tracking method is introduced as follows:

[0143] 1). Construct the BVH used for the intersection problem: Due to the different dimensions of the parameter domain, the BVH structure constructed for the intersection of curves and surfaces is different. For curve intersection, the BVH is a binary tree, while the surface intersection uses a quadtree. In the BVH of the intersection problem, each partition of the parameter domain will no longer use the partitioning method of the specified length in the self-intersection, but will use a uniform and non-overlapping partitioning. The depth of the BVH is determined by the parameters passed in.

[0144] 2). Traverse the intersection problem BVH to find the intersecting box pairs: Traverse the BVH constructed by two curves or surfaces. The traversal will start from the root nodes of the two BVHs. If the bounding boxes of the two nodes intersect, then all their child nodes will enter the next round of intersection determination; otherwise, it means that the subtrees with the two nodes as roots do not intersect, and the algorithm will prune. Until the determination reaches the leaf node layer, all the intersection box pairs are obtained.

[0145] 3). Perform Newton iteration on each pair of boxes to find the starting point: Use the intersecting pair of boxes as the starting point. Usually, the coordinate point corresponding to the midpoint of the parameter domain in the two boxes is used as the starting point of the iteration, and the Newton iteration method or other numerical calculation methods are used to calculate the starting point. At the same time, it is necessary to exclude unusable starting points, including points outside the parameter domain, points already in the result set, tangent points, degenerate points, etc. At the same time, for the robustness of the algorithm, if a starting point is close to a degenerate point, then this starting point will also be excluded. It should be noted that the curve intersection problem has been solved in this step, and the starting point found by the Newton iteration method is the intersection point of the curve intersection problem.

[0146] 4). Use the tracking method to calculate a series of points on the intersection line: After calculating a starting point, the tracking method can be used to calculate a series of points on the intersection line. The basic idea of ​​the tracking method is to start from a starting point, walk a specified step length along a certain direction of travel to find the next point on the intersection line, and keep repeating this cycle until you return to the starting point (the intersection line is a ring), or go out of the parameter domain limit.

[0147] 5). Fit all result points into a B-spline curve: In step 4), a series of intersection points will be obtained. At the end of the algorithm, these intersection points will be fitted into a B-spline curve. The fitting can usually be achieved through the least squares method or other mathematical optimization methods. It should be noted that steps 3) to 5) are usually performed together to ensure that the newly found starting point is not on the intersection line that has been calculated.

[0148] To solve the self-intersection problem using the intersection algorithm, we only need to replace steps 1) and 2) of the above process with the self-intersection BVH construction algorithm in Section 2 and the self-intersection BVH traversal algorithm in Section 3, and we can also get the intersection box pairs. Although the BVH used by the intersection algorithm and the BVH used by the self-intersection algorithm have different structures at the high level, they have the same structure at the leaf node level.

[0149] It should be noted that according to the BVH partitioning method used in Section 2 of the present invention, its leaf nodes are 128*128 grids, which is the same as the leaf node structure of the intersecting BVH using an 8-layer full quadtree. If intersecting BVHs of different depths are used, the partitioning method in Section 2 needs to be modified.

[0150] The results of some self-crossing calculation examples using the method of the present invention are as follows: Figures 10 to 17 It can be seen that the method of the present invention can effectively process parameter curves or surfaces of various complexities and forms, and has wide applicability, high efficiency and sufficient robustness.

[0151] According to a specific embodiment of the present invention, there is also provided an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the aforementioned methods when executing the program.

[0152] According to a specific embodiment of the present invention, there is further provided a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any of the above methods are implemented.

[0153] The foregoing description of specific exemplary embodiments of the present invention is for the purpose of illustration and demonstration. These descriptions are not intended to limit the present invention to the precise form disclosed, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Obviously, the present invention is not limited to the above-mentioned specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. The purpose of selecting and describing exemplary embodiments is to explain the specific principles of the present invention and its practical application, so that those skilled in the art can realize and utilize various different exemplary embodiments of the present invention and various different options and changes. The scope of the present invention is intended to be limited by the claims and their equivalents.

Claims

1. A general method for calculating the self-intersection of a parametric curve or surface, characterized in that: The invention is used for generating numerical control tool paths. When generating numerical control tool paths along the equidistant contour of an offset surface, the self-intersection is detected in the offset surface generation process, including: dividing the parameter domain of a parametric curve or a parametric surface by an interval overlapping partitioning method, constructing a BVH and realizing the subdivision of the parametric curve or the parametric surface, thereby dividing the entire parametric curve or the surface into a number of sub-segments or sub-faces, and then traversing the BVH to detect self-intersections to find intersecting box pairs, and then topologically reconstructing the intersecting box pairs, and finally calculating the self-intersection points and self-intersection lines by a tracking method; wherein, the adopted BVH uses an axis-aligned bounding box (AABB), and each BVH node, in addition to the bounding box, also stores the parameter domain, explicit storage of the parameter domain size, and leaf node markings. The BVH adopts a ternary tree structure, and each BVH node has three pointers to child nodes; on the basis of the completion of the BVH structure, the calculation of the leaf node bounding box is realized by sampling on the curve or surface, and multi-threading or GPU is used for calculation.

2. The general parametric curve or surface self-intersection calculation method according to claim 1, characterized in that: The overlapping interval division method is to add an intermediate interval area on the basis of the dichotomy method, and to add an additional area that partially overlaps with other areas.

3. The general parametric curve or surface self-intersection calculation method according to claim 1, characterized in that: In the case of a curve self-intersection, the parameter domain is one-dimensional, including the minimum and maximum values ​​of the parameter domain; in the case of a surface self-intersection, the parameter domain is two-dimensional, including and The minimum and maximum values ​​in the direction use a key-value mapping table as the data structure of the division method to record the corresponding relationship before and after the parameter domain length is divided.

4. The general parametric curve or surface self-intersection calculation method according to claim 1, characterized in that: The BVH construction method includes: Initialization process: Initialize the BVH node according to the length or size of the parameter domain and allocate memory for it; Leaf node determination process: Check whether the node is a leaf node and set the leaf node mark according to the length or size of the parameter domain; The process of building a BVH is as follows: recursively build a BVH ternary tree, store the parameter domain at each node of the tree, complete the partition of the parameter domain and the construction of the BVH structure from top to bottom, obtain the domain length of the child node according to the partition table, call the initialization process to initialize the child node, and then calculate the parameter domain according to the domain length of the child node, call the leaf node judgment process to determine whether the current node is a leaf node, calculate the bounding box of each leaf node, and finally calculate the bounding box of each non-leaf node from bottom to top, and recursively call the construction of BVH for the three child nodes of the current node.

5. The general parametric curve or surface self-intersection calculation method according to claim 1, characterized in that: The traversal of BVH is specifically as follows: recursively perform self-intersection traversal on the three child nodes of each non-leaf node, and perform intersection traversal on the three child nodes to check the self-intersection and intersection of the three child nodes. For each pair of leaf nodes, check whether their bounding boxes intersect, and record the parameter domains and bounding boxes of all intersecting leaf nodes.

6. The general method for calculating the self-intersection of a parametric curve or surface according to claim 5, characterized in that: The traversal starts from the root node of the BVH. First, the three child nodes of the current node are recursively self-intersected. Then, the overlap of the bounding boxes of the three child nodes is determined: for the two child nodes whose bounding boxes overlap, an intersection traversal is performed; for the two child nodes whose bounding boxes do not overlap, the BVH tree is pruned without any processing; during the intersection traversal, the three child nodes of the node with the larger parameter domain and another node are used each time for recursive intersection traversal until both nodes are leaf nodes; if the bounding boxes of two leaf nodes overlap, they are a pair of intersection boxes.

7. The universal parametric curve or surface self-intersection calculation method according to claim 1, characterized in that: After finding the intersecting box pairs of leaf nodes, topology reconstruction is performed. The parameter domains of all intersecting box pairs are connected together through a breadth-first traversal algorithm, and then a complete parameter domain is constructed based on the connection information, thereby connecting all adjacent curve segments and surface patches.

8. The universal parametric curve or surface self-intersection calculation method according to claim 1, characterized in that: After topology reconstruction, the intersection algorithm of parametric curves or surfaces is adopted, and the Newton iteration method is used to find the starting point of the tracking method in the surface intersection or the intersection point in the curve intersection, and the tracking method is used to calculate the intersection line in the surface intersection.

9. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

10. A computer-readable storage medium storing computer-executable instructions, wherein the instructions are used to implement the method according to any one of claims 1 to 8 when executed.

Citation Information

Patent Citations

  • GPU-based NURBS curved surface parallel intersection method and device, and storage medium

    CN117115393A

  • Quasi-monte carlo light transport simulation by efficient ray tracing

    US20090167763A1

  • Accelerated ray tracing using shallow bounding volume hierarchies

    US20100053162A1

  • Apparatus and method for biased BVH traversal path

    US20230298127A1