Triangular mesh model collision detection and intersection contour extraction method and system

By using BVH binary tree and SAH algorithms to optimize the BVH construction process in the collision detection of three-dimensional grid models, the problems of poor detection efficiency and accuracy in the existing technology are solved, and efficient and accurate collision detection and contour extraction are achieved.

CN119693583AActive Publication Date: 2025-03-25GUANGDONG UNIV OF TECH

Patent Information

Application Number
CN202411647579.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-03-25
Estimated Expiration
2044-11-18

AI Technical Summary

Technical Problem

The prior art has problems of poor detection efficiency and accuracy in the collision detection of three-dimensional grid models. Especially when dealing with complex scenes and high-complex objects, it is difficult to maintain consistent detection efficiency, and the calculation speed is slow, memory consumption is large, and the accuracy requirements are high.

Method used

The BVH binary tree data structure and SAH algorithm are used to optimize the construction process of BVH binary tree, and the intersection relationship between leaf nodes is detected through deep priority traversal, and the intersection detection and recursive call optimization efficiency of bounding boxes are combined.

Benefits of technology

The speed of collision detection is significantly improved, the calculation complexity is reduced, efficient and accurate collision detection is achieved, and an orderly closed-loop profile is generated, enhancing the applicability and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119693583A_ABST
    Figure CN119693583A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of triangular mesh models, in particular to a triangular mesh model collision detection and intersection contour extraction method and system, and the method accelerates the collision detection efficiency through constructing a model BVH hierarchical bounding volume binary tree data structure, reduces the calculation loss, and improves the calculation efficiency. And constructing an intersection line judgment method by using an intersection relationship between the triangular meshes, and finally performing contour extraction on an intersection line set to intuitively feed back a collision relationship. The invention aims to solve the problem of poor detection efficiency and precision during virtual model collision detection and intersection contour extraction, so that the digital twin simulation is more in line with the real world, and the method has the effects of high efficiency, accuracy and wide applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of triangular mesh models, and in particular to a triangular mesh model collision detection and intersection contour extraction method and system. Background Art

[0002] With the rapid development of 3D mesh model technology and the widespread application of 3D models in CAD / CAM, digital twin simulation and other fields, collision detection between 3D models has become indispensable in order to be closer to and more consistent with the real world. In digital twin simulation, collision detection is not only applied between 3D models, but also between 3D models and virtual sensors. Good collision detection is an important part of realizing the simulation of the real world in the virtual world. It makes collision avoidance possible, thereby giving full play to the value of digital twins in virtual production, virtual debugging and other aspects.

[0003] However, the existing technology has the following main disadvantages when performing collision detection:

[0004] (1) The spatial partitioning method has difficulty maintaining consistent detection efficiency when dealing with different scenes and objects of different shapes and complexities. This is because the method relies on the hierarchical partitioning technology of the entire scene, which results in different performances when facing complex and changing scenes.

[0005] (2) When calculating the intersecting triangles and triangle intersection lines of a three-dimensional mesh collision, the existing technology has problems such as slow calculation speed, large memory consumption, and high precision requirements. These problems limit the further improvement of collision detection technology in terms of real-time performance and accuracy. Summary of the invention

[0006] One of the purposes of the present invention is to propose a method for collision detection and intersection contour extraction of a triangular mesh model, aiming to solve the problems of poor detection efficiency and accuracy in virtual model collision detection and intersection contour extraction, so that the digital twin simulation is more in line with the real world, with high efficiency, accuracy and wide applicability.

[0007] Another object of the present invention is to propose a triangular mesh model collision detection and intersection contour extraction method, which adopts a triangular mesh model collision detection and intersection contour extraction method as described above, has the advantages of high precision, high efficiency, flexibility and scalability, and has collision detection, intersection contour extraction, model feature extraction, visualization and interaction and a wide range of application functions.

[0008] To achieve this object, the present invention adopts the following technical solutions:

[0009] A triangular mesh model collision detection and intersection contour extraction method comprises the following steps:

[0010] S1. Build a digital twin model:

[0011] Use 3D modeling software to build a high-precision model consisting of triangular meshes, which has two attribute data: vertex coordinates and vertex indexes, and encapsulates motion behaviors to build a digital twin of the workpiece;

[0012] S2. BVH data structure construction:

[0013] Construct a BVH binary tree data structure for each high-precision model, and use the SAH algorithm to optimize the construction process of the BVH binary tree data structure, wherein the BVH binary tree data structure includes a root node, child nodes and leaf nodes, the root node stores the bounding box data of the high-precision model, the child node stores the segmented bounding box data, and the leaf node stores the vertex coordinates and vertex index of the high-precision model;

[0014] S3. BVH collision detection:

[0015] Based on the two BVH binary tree data structures built by S2, recursive traversal is performed to detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal, and the intersection detection of bounding boxes and recursive calls are combined to optimize efficiency;

[0016] S4. Triangular mesh intersection detection and intersection line formation:

[0017] After obtaining the leaf nodes of two BBVH binary tree data structures in S3, two-by-two intersection detection is performed on the triangular meshes of the leaf nodes to determine whether the two triangles intersect, and the intersection position is calculated to form an intersection line set;

[0018] S5. Contour generation:

[0019] The intersection line set obtained by S4 is processed, each edge is traversed and the next edge that meets the conditions is found and sorted to generate a closed loop contour.

[0020] Preferably, in S2, the following steps are specifically included:

[0021] S21, traverse each triangular mesh, establish the bounding box of the entire high-precision model and store the bounding box data, including the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangular mesh coordinates;

[0022] S22. Use the SAH algorithm to find the best splitting plane and divide the triangle into two parts to minimize the cost of traversal and intersection, including:

[0023] S221. Calculate the surface area of ​​the entire high-precision model bounding box and set the optimal cost to 1.25 times the cost of the intersection of all triangles under the node. The calculation formula is as follows:

[0024] Area=2*[(maxX-minX)*(maxY-minY)+(maxZ-minZ)*(maxY-minY)+(maxX-minX)*(maxZ-minZ)]

[0025] Where maxX, maxY, maxZ, minX, minY and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangle mesh coordinates;

[0026] S222, traverse the x, y, and z axes to find the best segmentation axis, and divide the range on the axis into 8 intervals as candidate segmentation positions;

[0027] S223. For each candidate segmentation point, place the triangle in the left area or the right area, and calculate the cost of selecting the segmentation axis and the segmentation point. The calculation formula is as follows:

[0028] Cost = C T +C I *(P L +P R +N L +N R )

[0029] Among them C T The cost of traversing a node is set to a constant of 1; C I To find the cost of intersecting a triangle, set it to a constant of 1.25; P L is the ratio of the surface area of ​​the left subtree to the total surface area; P R is the ratio of the surface area of ​​the right subtree to the total surface area; N L is the number of triangles in the left subtree; N R is the number of triangles in the right subtree. After iteration, record the split point and axis with the minimum cost;

[0030] S224, recording the segmentation point and axis with the minimum cost as the optimal segmentation solution;

[0031] S23. Repeat S22 for the split left and right child nodes until each leaf node contains only one triangle mesh.

[0032] Preferably, in S4, the following steps are specifically included:

[0033] S41, updating the attributes of the two triangles, including using the dot product to respectively calculate the projection boundaries of the three vertices of the two triangles on the other side and the plane definition where the triangles are located;

[0034] S42, determining whether the two triangles are coplanar: determining whether the two triangles are coplanar by determining whether the dot product of the normal vectors of the plane where the two triangles are located is 1;

[0035] S43. If the two triangles are coplanar, use the separating axis theorem to determine whether there is a separating axis. If there is no separating axis, determine that the triangles intersect.

[0036] S44. If the two triangles are not coplanar, the number of intersections between the two triangles and the plane of another triangle is detected respectively, and whether they intersect is determined based on the number of intersections.

[0037] Preferably, in S41, the method for detecting the number of intersections between a triangle and another triangle plane includes:

[0038] S441, using the dot product to determine whether the plane of a triangle is parallel to the side of another triangle: using whether the dot product of the normal vector of the plane parallel to one triangle and the side direction vector of another triangle is 0;

[0039] S442, if they are parallel and the starting point of the edge is on the plane, the edge is considered to be colinear with the plane, the edge is added to the contour set, and the number of intersections is set to 2;

[0040] S443. If they are not parallel, calculate whether there is an intersection between the plane and the edge, and use the plane equation and the parameterized equation of the intersection line segment to obtain the position ratio of the intersection on the edge.

[0041] Preferably, in S443, the formula for calculating whether there is an intersection between the plane and the edge is:

[0042] S4431, the plane equation is expressed as:

[0043] n*P+d=0

[0044] Where n is the plane normal vector, P is an arbitrary point on the plane, and d is a constant representing the negative value of the vertical distance from the plane to the origin;

[0045] S4432. The parametric equation of the intersection point and line segment is expressed as:

[0046] P(t)=P0+t*(P1-P0)

[0047] Among them, P0 is the starting point and P1 is the end point;

[0048] S4433. Substitute the parametric equation of the intersection point line segment into the plane equation to solve for t, and determine the position of the intersection point according to the value of t:

[0049] t=(-n*P0+d) / (n*(P1-P0))

[0050] After calculating the intersection point ratio t, if t = 0, the intersection point is the starting point; if t = 1, the intersection point is the ending point; if 0 < t < 1, the intersection point is between the starting point and the ending point; otherwise, it means there is no intersection point. After obtaining the ratio of the intersection point to the edge, the calculation method of the intersection point is as follows:

[0051] P(x) = dir(x) * t + P0

[0052] P(y) = dir(y) * t + P0

[0053] P(z) = dir(z) * t + P0

[0054] S4435. After traversing each side of the triangle in a loop, obtain the number of intersection points between the triangle and the plane of another triangle and the intersecting edges.

[0055] A triangle mesh model collision detection and intersection contour extraction system, which adopts a triangle mesh model collision detection and intersection contour extraction method as described above, including:

[0056] Build a digital twin model unit, which is used to use 3D modeling software to establish a high-precision model composed of triangle meshes, with two attribute data of vertex coordinates and vertex indices, and at the same time encapsulate the motion behavior to build a workpiece digital twin;

[0057] BVH data structure construction unit, which is used to build a BVH binary tree data structure for each high-precision model, and optimize the construction process of the BVH binary tree data structure by using the SAH algorithm. The BVH binary tree data structure includes a root node, child nodes, and leaf nodes. The root node stores the bounding box data of the high-precision model structure, the child nodes store the bounding box data after being split, and the leaf nodes store the vertex coordinates and vertex indices of the high-precision model;

[0058] BVH collision detection unit, which is used to perform recursive traversal based on the two BVH binary tree data structures constructed by the BVH data structure construction unit, detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal, and optimize the efficiency by combining the intersection detection of the bounding boxes and recursive calls;

[0059] Triangle mesh intersection detection and intersection line formation unit, which is used to perform pairwise intersection detection on the triangle meshes of the leaf nodes after the BVH collision detection unit obtains the leaf nodes of the two BBVH binary tree data structures, judge whether two triangles intersect, calculate the intersection point positions, and form an intersection line set;

[0060] Contour generation unit, which is used to process the intersection line set obtained by the triangle mesh intersection detection and intersection line formation unit, traverse each edge and find the next edge that meets the conditions for sorting to generate a closed-loop contour.

[0061] Preferably, the BVH data structure construction unit specifically includes:

[0062] The bounding box establishment subunit is used to traverse each triangular mesh, establish the bounding box of the entire high-precision model and store the bounding box data, including the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangular mesh coordinates;

[0063] The calculation subunit is used to find the best splitting plane through the SAH algorithm to divide the triangle into two parts to minimize the cost of traversal and intersection. Specifically, it includes:

[0064] Calculate the surface area of ​​the entire high-precision model bounding box and set the optimal cost to 1.25 times the cost of the intersection of all triangles under the node. The calculation formula is as follows:

[0065] Area=2*[(maxX-minX)*(maxY-minY)+(maxZ-minZ)*(maxY-minY)+(maxX-minX)*(maxZ-minZ)]

[0066] Where maxX, maxY, maxZ, minX, minY and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangle mesh coordinates;

[0067] Traverse the x, y, and z axes to find the best split axis, and divide the range on the axis into 8 intervals as candidate split positions;

[0068] For each candidate segmentation point, place the triangle in the left or right region and calculate the cost of selecting the segmentation axis and segmentation point. The calculation formula is as follows:

[0069] Cost = C T +C I *(P L +P R +N L +N R )

[0070] Among them C T The cost of traversing a node is set to a constant of 1; C I To find the cost of intersecting a triangle, set it to a constant of 1.25; P L is the ratio of the surface area of ​​the left subtree to the total surface area; P R is the ratio of the surface area of ​​the right subtree to the total surface area; N L is the number of triangles in the left subtree; N R is the number of triangles in the right subtree. After iteration, record the split point and axis with the minimum cost;

[0071] Record the segmentation point and axis with the minimum cost as the optimal segmentation solution;

[0072] The repeating sub-unit is used to repeatedly calculate the sub-units for the split left and right child nodes until each leaf node contains only one triangle mesh.

[0073] Preferably, the triangular mesh intersection detection and intersection line formation unit specifically includes:

[0074] An update module is used to update the properties of two triangles, including using dot products to calculate the projection boundaries of the three vertices of the two triangles on the other side and the definition of the plane where the triangles are located;

[0075] A judgment module is used to judge whether two triangles are coplanar: whether the dot product of the normal vectors of the plane where the two triangles are located is 1 to judge whether the two triangles are coplanar;

[0076] The coplanar module is used to determine whether there is a separating axis using the separating axis theorem if two triangles are coplanar, and if there is no separating axis, it is determined that the triangles intersect;

[0077] The non-coplanar module is used to detect the number of intersections between the two triangles and the plane of another triangle if the two triangles are not coplanar, and determine whether they intersect based on the number of intersections.

[0078] Preferably, the non-coplanar module specifically includes:

[0079] The parallel judgment submodule is used to use the dot product to judge whether the plane of a triangle is parallel to the side of another triangle: whether the dot product of the plane normal vector of a triangle parallel to the side direction vector of another triangle is 0;

[0080] The colinear submodule is used to consider that if the edges are parallel and the starting point of the edge is on the plane, the edge is added to the contour set, and the number of intersections is set to 2;

[0081] The intersection judgment submodule is used to calculate whether there is an intersection between the plane and the edge if they are not parallel, and use the plane equation and the parameterized equation of the intersection line segment to obtain the position ratio of the intersection on the edge.

[0082] Preferably, the specific implementation process of the intersection judgment submodule is as follows:

[0083] The equation of the plane is expressed as:

[0084] n*P+d=0

[0085] Where n is the plane normal vector, P is an arbitrary point on the plane, and d is a constant representing the negative value of the vertical distance from the plane to the origin;

[0086] The equation for parameterizing the intersection point line segment is expressed as:

[0087] P(t) = P0 + t * (P1 - P0)

[0088] where P0 is the starting point and P1 is the ending point;

[0089] Substitute the parameterization equation of the intersection point line segment into the plane equation to solve for t, and determine the position of the intersection point according to the value of t:

[0090] t = (-n * P0 + d) / (n * (P1 - P0))

[0091] After calculating the intersection point ratio t, if t = 0, the intersection point is the starting point; if t = 1, the intersection point is the ending point; if 0 < t < 1, the intersection point is between the starting point and the ending point; otherwise, it means there is no intersection point. After obtaining the ratio of the intersection point to the edge, the calculation method of the intersection point is as follows:

[0092] P(x) = dir(x) * t + P0

[0093] P(y) = dir(y) * t + P0

[0094] P(z) = dir(z) * t + P0

[0095] After traversing each edge of the triangle in a loop, the number of intersection points and the intersecting edges between this triangle and the plane of another triangle are obtained.

[0096] One of the technical solutions in the above technical solutions has the following beneficial effects:

[0097] 1. Improve the collision detection efficiency: By adopting the SAH algorithm to optimize the construction process of the BVH binary tree data structure, the speed of collision detection is significantly improved, the computational complexity is reduced, and efficient collision detection is achieved.

[0098] 2. Enhance the accuracy: By using the separating axis theorem and the judgment methods of coplanarity and non-coplanarity, the accuracy of triangle mesh intersection detection is ensured, and false positives and false negatives are avoided.

[0099] 3. Wide applicability: It is not only applicable to the collision detection of static objects, but also can be applied to digital twin models with dynamic changes, and has wide applicability.

[0100] 4. Strong contour extraction ability: By processing the intersection line set, an ordered closed-loop contour can be generated, which provides strong support for subsequent repair or optimization. Brief Description of the Drawings

[0101] Figure 1 is a schematic flow chart of a method for collision detection and intersection contour extraction of a triangular mesh model of the present invention;

[0102] Figure 2 It is a schematic diagram of constructing a BVH data structure in a triangular mesh model collision detection and intersection contour extraction method of the present invention;

[0103] Figure 3 It is a detection schematic diagram of BVH collision detection in a triangular mesh model collision detection and intersection contour extraction method of the present invention;

[0104] Figure 4 It is a schematic diagram of triangular mesh intersection detection and intersection line formation in a triangular mesh model collision detection and intersection contour extraction method of the present invention;

[0105] Figure 5 It is a schematic diagram of separation axes of triangular mesh intersection detection and intersection lines in a triangular mesh model collision detection and intersection contour extraction method of the present invention. DETAILED DESCRIPTION

[0106] The technical solution of the present invention is further described below with reference to the accompanying drawings and through specific implementation methods.

[0107] A triangular mesh model collision detection and intersection contour extraction method comprises the following steps:

[0108] S1. Build a digital twin model:

[0109] Use 3D modeling software to build a high-precision model consisting of triangular meshes, which has two attribute data: vertex coordinates and vertex indexes, and encapsulates motion behaviors to build a digital twin of the workpiece;

[0110] Specifically, first obtain the three-dimensional data of the object from the actual physical world, which can be achieved through three-dimensional scanning, CAD modeling, etc. Then use three-dimensional modeling software (such as 3D Max, Maya, etc.) to build the acquired three-dimensional data into a high-precision triangular mesh model. The model should contain attribute data such as vertex coordinates and vertex indices. Then encapsulate the motion behavior of the constructed triangular mesh model to form a digital twin. This includes adding physical properties (such as mass, inertia, etc.), motion constraints (such as joint constraints, collision constraints, etc.) and dynamic simulation algorithms (such as physics engines) to the model to achieve dynamic simulation of the model in a virtual environment.

[0111] S2. BVH data structure construction:

[0112] Constructing a BVH binary tree data structure for each high-precision model, and using the SAH algorithm to optimize the construction process of the BVH binary tree data structure, wherein the BVH binary tree data structure includes a root node, child nodes, and leaf nodes, the root node stores the bounding box data of the high-precision model, the child node stores the segmented bounding box data, and the leaf node stores the vertex coordinates and vertex indexes of the high-precision model;

[0113] S3, BVH collision detection:

[0114] Based on the two BVH binary tree data structures built by S2, recursive traversal is performed to detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal, and the intersection detection of bounding boxes and recursive calls are combined to optimize efficiency;

[0115] S4. Triangular mesh intersection detection and intersection line formation:

[0116] After obtaining the leaf nodes of two BBVH binary tree data structures in S3, two-by-two intersection detection is performed on the triangular meshes of the leaf nodes to determine whether the two triangles intersect, and the intersection position is calculated to form an intersection line set;

[0117] S5. Contour generation:

[0118] The intersection line set obtained by S4 is processed, each edge is traversed and the next edge that meets the conditions is found and sorted to generate a closed loop contour.

[0119] In S4, we get the intersection line set, which is essentially the contour data. However, the sequential arrangement of the set cannot form a closed loop because the set is disordered and the end point of an element is not the starting point of the next element. In order to generate a closed loop contour, we need to process the intersection line set, traverse each edge and find the next edge that meets the conditions and sort them.

[0120] In summary, the present invention proposes a method for collision detection and intersection edge contour extraction of a triangular mesh digital twin model, which uses a BVH hierarchical bounding volume binary tree data structure to accelerate the efficiency of collision detection, and optimizes the node segmentation strategy through the SAH algorithm to improve the detection accuracy and efficiency. At the same time, the intersection relationship between triangular meshes is used to construct an intersection line determination method, and the intersection edge contour data is extracted to intuitively feedback the collision relationship. The present invention has a high application value in digital twin simulation, and can achieve accurate and efficient virtual model collision detection and intersection contour extraction.

[0121] Therefore, this method has the following beneficial effects:

[0122] 1. Improve collision detection efficiency: By using the SAH algorithm to optimize the construction process of the BVH binary tree data structure, the speed of collision detection is significantly improved, the computational complexity is reduced, and efficient collision detection is achieved.

[0123] 2. Enhanced accuracy: The separation axis theorem and the coplanar and non-coplanar judgment method are used to ensure the accuracy of triangular mesh intersection detection and avoid false positives and missed positives.

[0124] 3. Wide applicability: This method is not only suitable for collision detection of static objects, but can also be applied to dynamically changing digital twin models, and has wide applicability.

[0125] 4. Strong contour extraction capability: By processing the intersection line set, an ordered closed-loop contour can be generated, providing strong support for subsequent repair or optimization.

[0126] To further illustrate, in S2, the following steps are specifically included:

[0127] S21, traverse each triangular mesh, establish the bounding box of the entire high-precision model and store the bounding box data, including the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangular mesh coordinates;

[0128] S22. Use the SAH algorithm to find the best splitting plane and divide the triangle into two parts to minimize the cost of traversal and intersection, including:

[0129] S221. Calculate the surface area of ​​the entire high-precision model bounding box and set the optimal cost to 1.25 times the cost of the intersection of all triangles under the node. The calculation formula is as follows:

[0130] Area=2*[(maxX-minX)*(maxY-minY)+(maxZ-minZ)*(maxY-minY)+(maxX-minX)*(maxZ-minZ)]

[0131] Where maxX, maxY, maxZ, minX, minY and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangle mesh coordinates;

[0132] S222, traverse the x, y, and z axes to find the best segmentation axis, and divide the range on the axis into 8 intervals as candidate segmentation positions;

[0133] S223. For each candidate segmentation point, place the triangle in the left area or the right area, and calculate the cost of selecting the segmentation axis and the segmentation point. The calculation formula is as follows:

[0134] Cost = C T +C I *(P L +P R +N L +N R )

[0135] Among them C T The cost of traversing a node is set to a constant of 1; C ITo find the cost of intersecting a triangle, set it to a constant of 1.25; P L is the ratio of the surface area of ​​the left subtree to the total surface area; P R is the ratio of the surface area of ​​the right subtree to the total surface area; N L is the number of triangles in the left subtree; N R is the number of triangles in the right subtree. After iteration, record the split point and axis with the minimum cost;

[0136] S224, recording the segmentation point and axis with the minimum cost as the optimal segmentation solution;

[0137] S23. Repeat S22 for the split left and right child nodes until each leaf node contains only one triangle mesh.

[0138] The main purpose of the SAH algorithm is to find the best splitting plane and divide a set of triangle bounding box data into two parts, so as to minimize the cost of traversal and intersection. Due to the selection of different splitting positions, through the trial of different axes and splitting points, an optimal splitting solution is finally found, with the number of node traversals and the number of triangles as the cost, which minimizes the cost of traversal and intersection calculation during splitting, so it will further improve performance efficiency.

[0139] To further illustrate, in S4, the following steps are specifically included:

[0140] S41, updating the attributes of the two triangles, including using the dot product to respectively calculate the projection boundaries of the three vertices of the two triangles on the other side and the plane definition where the triangles are located;

[0141] S42, determining whether the two triangles are coplanar: determining whether the two triangles are coplanar by using whether the dot product of the normal vectors of the plane where the two triangles are located is 1;

[0142] S43. If the two triangles are coplanar, use the separating axis theorem to determine whether there is a separating axis. If there is no separating axis, determine that the triangles intersect.

[0143] S44. If the two triangles are not coplanar, the number of intersections between the two triangles and the plane of another triangle is detected respectively, and whether they intersect is determined based on the number of intersections.

[0144] To further illustrate, in S41, the method for detecting the number of intersections between a triangle and another triangle plane includes:

[0145] S441, using the dot product to determine whether the plane of a triangle is parallel to the side of another triangle: using whether the dot product of the normal vector of the plane parallel to one triangle and the side direction vector of another triangle is 0;

[0146] S442. If it is parallel and the starting point of the side lies on the plane, then this side is considered collinear with the plane. Add this side to the contour set and set the number of intersection points to 2;

[0147] S443. If it is not parallel, then calculate whether there is an intersection point between the plane and the side, and use the plane equation and the parametric equation of the intersecting point line segment to obtain the position ratio of the intersection point on the side.

[0148] For further explanation, in S443, the formula for calculating whether there is an intersection point between the plane and the side is:

[0149] S4431. The plane equation is expressed as:

[0150] n*P + d = 0

[0151] where n is the plane normal vector, P is any point on the plane, and d is a constant representing the negative value of the perpendicular distance from the plane to the origin;

[0152] S4432. The parametric equation of the intersecting point line segment is expressed as:

[0153] P(t) = P0 + t*(P1 - P0)

[0154] where P0 is the starting point and P1 is the ending point;

[0155] S4433. Substitute the parametric equation of the intersecting point line segment into the plane equation to solve for t, and determine the position of the intersection point according to the value of t:

[0156] t = (-n*P0 + d) / (n*(P1 - P0))

[0157] After calculating the intersection point ratio t, if t = 0, the intersection point is the starting point; if t = 1, the intersection point is the ending point; if 0 < t < 1, the intersection point is between the starting point and the ending point; otherwise, it means there is no intersection point. After obtaining the ratio of the intersection point on the side, the calculation method of the intersection point is as follows:

[0158] P(x) = dir(x)*t + P0

[0159] P(y) = dir(y)*t + P0

[0160] P(z) = dir(z)*t + P0

[0161] S4435. After traversing each side of the triangle in a loop, obtain the number of intersection points and the intersecting sides of this triangle with the plane of another triangle.

[0162] After obtaining two leaf nodes of two BVH trees in S3, pairwise intersection detection is performed on the triangular meshes of the leaf nodes in sequence. When determining whether two triangles intersect, the judgment steps are as Figure 4As shown, first update the two triangle attributes, including using the dot product to calculate the projection boundaries of the three vertices of the two triangles on the other side (vertex vector multiplied by the edge vector) and the plane definition of the triangles, in preparation for the subsequent separation axis definition.

[0163] The intersection detection of triangles is divided into two cases: coplanar and non-coplanar.

[0164] (1) First, we discuss the case where two triangles are coplanar: We determine whether the two triangles are coplanar by checking whether the dot product of the normal vectors of the plane where the two triangles lie is 1. We use the separating axis theorem to determine whether there is a separating axis. We loop through the edges of the two triangles and use that edge as the projection axis of the other triangle. We compare the projection boundary of the original triangle on that edge with the projection boundary of the other triangle to see if they overlap. If they overlap, it proves that there is no separating axis in that projection direction, and vice versa. We cannot determine whether the two coplanar triangles intersect until the traversal is complete. Figure 5 As shown, if there is no separation axis, it means that the triangles intersect, but coplanar triangles do not support the output of intersection edges because the edge is not a contour. Only when two triangles intersect at a certain angle can they have an intersection contour.

[0165] (2) Next, deal with the non-coplanar situation and detect the number of intersections between the triangle and another triangular plane. The triangle has three sides, and check whether they intersect with the plane one by one.

[0166] First, use the dot product to determine whether the plane of one triangle is parallel to the edge of another triangle (the dot product of the normal vector of the parallel plane and the direction vector of the edge is 0). If they are parallel and the starting point of the edge is on the plane (calculate the distance between the plane and the starting point of the edge, if it is 0, it is on the plane), then this edge is considered to be colinear with the plane, and the edge can be directly added to the contour set, and the number of intersections is set to 2;

[0167] On the contrary, if they are not parallel, calculate whether there is an intersection between the plane and the edge, and use the plane equation and the parameterized equation of the intersection line segment to obtain the parameter t, which represents the position ratio of the intersection on the edge.

[0168] A triangular mesh model collision detection and intersection contour extraction system, using the triangular mesh model collision detection and intersection contour extraction method as described above, comprising:

[0169] Constructing a digital twin model unit, which is used to use 3D modeling software to build a high-precision model consisting of a triangular mesh, with two attribute data: vertex coordinates and vertex index, and encapsulate motion behavior, so as to build a digital twin of the workpiece;

[0170] A BVH data structure construction unit is used to construct a BVH binary tree data structure for each high-precision model, and use a SAH algorithm to optimize the construction process of the BVH binary tree data structure, wherein the BVH binary tree data structure includes a root node, child nodes and leaf nodes, the root node stores the bounding box data of the high-precision model, the child node stores the segmented bounding box data, and the leaf node stores the vertex coordinates and vertex index of the high-precision model;

[0171] The BVH collision detection unit is used to recursively traverse the two BVH binary tree data structures constructed based on the BVH data structure construction unit, detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal, and combine the intersection detection of the bounding box and recursive calls to optimize efficiency;

[0172] The triangle mesh intersection detection and intersection line formation unit is used to perform a pairwise intersection detection on the triangle meshes of the leaf nodes after the BVH collision detection unit obtains the leaf nodes of the two BBVH binary tree data structures, determine whether the two triangles intersect, and calculate the intersection position to form an intersection line set;

[0173] The contour generation unit is used to process the intersection line set obtained by the triangle mesh intersection detection and intersection line formation unit, traverse each edge and find the next edge that meets the conditions for sorting, and generate a closed-loop contour.

[0174] This system has the advantages of high precision, high efficiency, flexibility and scalability, and has collision detection, intersection contour extraction, model feature extraction, visualization and interaction, as well as a wide range of application functions.

[0175] To further illustrate, the BVH data structure construction unit specifically includes:

[0176] The bounding box establishment subunit is used to traverse each triangular mesh, establish the bounding box of the entire high-precision model and store the bounding box data, including the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangular mesh coordinates;

[0177] The calculation subunit is used to find the best splitting plane through the SAH algorithm to divide the triangle into two parts to minimize the cost of traversal and intersection. Specifically, it includes:

[0178] Calculate the surface area of ​​the entire high-precision model bounding box and set the optimal cost to 1.25 times the cost of the intersection of all triangles under the node. The calculation formula is as follows:

[0179] Area=2*[(maxX-minX)*(maxY-minY)+(maxZ-minZ)*(maxY-minY)+(maxX-minX)*(maxZ-minZ)]

[0180] Where maxX, maxY, maxZ, minX, minY and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangle mesh coordinates;

[0181] Traverse the x, y, and z axes to find the best split axis, and divide the range on the axis into 8 intervals as candidate split positions;

[0182] For each candidate segmentation point, place the triangle in the left or right region and calculate the cost of selecting the segmentation axis and segmentation point. The calculation formula is as follows:

[0183] Cost = C T +C I *(P L +P R +N L +N R )

[0184] Among them C T The cost of traversing a node is set to a constant of 1; C I To find the cost of intersecting a triangle, set it to a constant of 1.25; P L is the ratio of the surface area of ​​the left subtree to the total surface area; P R is the ratio of the surface area of ​​the right subtree to the total surface area; N L is the number of triangles in the left subtree; N R is the number of triangles in the right subtree. After iteration, record the split point and axis with the minimum cost;

[0185] Record the segmentation point and axis with the minimum cost as the optimal segmentation solution;

[0186] The repeating sub-unit is used to repeatedly calculate the sub-units for the split left and right child nodes until each leaf node contains only one triangle mesh.

[0187] To further illustrate, the triangular mesh intersection detection and intersection line formation unit specifically includes:

[0188] An update module is used to update the properties of two triangles, including using dot products to calculate the projection boundaries of the three vertices of the two triangles on the other side and the definition of the plane where the triangles are located;

[0189] A judgment module is used to judge whether two triangles are coplanar: whether the dot product of the normal vectors of the plane where the two triangles are located is 1 to judge whether the two triangles are coplanar;

[0190] The coplanar module is used to determine whether there is a separating axis using the separating axis theorem if two triangles are coplanar, and if there is no separating axis, it is determined that the triangles intersect;

[0191] The non-coplanar module is used to detect the number of intersections between the two triangles and the plane of another triangle if the two triangles are not coplanar, and determine whether they intersect based on the number of intersections.

[0192] To further illustrate, the non-coplanar module specifically includes:

[0193] The parallel judgment submodule is used to use the dot product to judge whether the plane of a triangle is parallel to the side of another triangle: whether the dot product of the plane normal vector of a triangle parallel to the side direction vector of another triangle is 0;

[0194] The colinear submodule is used to consider that if the edges are parallel and the starting point of the edge is on the plane, the edge is added to the contour set, and the number of intersections is set to 2;

[0195] The intersection judgment submodule is used to calculate whether there is an intersection between the plane and the edge if they are not parallel, and use the plane equation and the parameterized equation of the intersection line segment to obtain the position ratio of the intersection on the edge.

[0196] To further illustrate, the specific implementation process of the intersection judgment submodule is as follows:

[0197] The plane equation is expressed as:

[0198] n*P+d=0

[0199] Where n is the plane normal vector, P is an arbitrary point on the plane, and d is a constant representing the negative value of the vertical distance from the plane to the origin;

[0200] The parametric equation of the intersection point line segment is expressed as:

[0201] P(t)=P0+t*(P1-P0)

[0202] Among them, P0 is the starting point and P1 is the end point;

[0203] Substitute the parametric equation of the intersection point segment into the plane equation to solve for t, and determine the position of the intersection point based on the value of t:

[0204] t=(-n*P0+d) / (n*(P1-P0))

[0205] After calculating the intersection point ratio t, if t = 0, the intersection point is the starting point; if t = 1, the intersection point is the ending point; if 0 < t < 1, the intersection point is between the starting point and the ending point; otherwise, it means there is no intersection point. After obtaining the ratio of the intersection point to the edge, the calculation method of the intersection point is as follows:

[0206] P(x) = dir(x) * t + P0

[0207] P(y) = dir(y) * t + P0

[0208] P(z) = dir(z) * t + P0

[0209] After traversing each edge of the triangle in a loop, the number of intersection points and the intersecting edges between this triangle and the plane of another triangle are obtained.

[0210] The technical principle of the present invention has been described above in combination with specific embodiments. These descriptions are only for explaining the principle of the present invention and cannot be construed as any limitation to the protection scope of the present invention in any way. Based on the explanations herein, those skilled in the art can联想到 other specific embodiments of the present invention without creative efforts, and these equivalent variations or substitutions are all included within the scope defined by the claims of this application. It should be noted that the expression "联想到" in the original Chinese is a bit ambiguous. A more accurate expression might be "conceive of" or "come up with" in English. The above translation is based on the literal meaning. If a more accurate semantic translation is required, it can be adjusted according to the specific context.

Claims

1. A triangular mesh model collision detection and intersection contour extraction method, characterized in that: The following steps are involved: S1. Build a digital twin model: Use 3D modeling software to build a high-precision model consisting of triangular meshes, which has two attribute data: vertex coordinates and vertex indexes, and encapsulates motion behaviors to build a digital twin of the workpiece; S2. BVH data structure construction: Constructing a BVH binary tree data structure for each high-precision model, and using the SAH algorithm to optimize the construction process of the BVH binary tree data structure, wherein the BVH binary tree data structure includes a root node, child nodes, and leaf nodes, the root node stores the bounding box data of the high-precision model, the child node stores the segmented bounding box data, and the leaf node stores the vertex coordinates and vertex indexes of the high-precision model; S3, BVH collision detection: Based on the two BVH binary tree data structures built by S2, recursive traversal is performed to detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal, and the intersection detection of bounding boxes and recursive calls are combined to optimize efficiency; S4. Triangular mesh intersection detection and intersection line formation: After obtaining the leaf nodes of two BBVH binary tree data structures in S3, two-by-two intersection detection is performed on the triangular meshes of the leaf nodes to determine whether the two triangles intersect, and the intersection position is calculated to form an intersection line set; S5. Contour generation: The intersection line set obtained by S4 is processed, each edge is traversed and the next edge that meets the conditions is found and sorted to generate a closed loop contour.

2. A triangular mesh model collision detection and intersection contour extraction method according to claim 1, characterized in that: In S2, the following steps are specifically included: S21, traverse each triangular mesh, establish the bounding box of the entire high-precision model and store the bounding box data, including the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangular mesh coordinates; S22. Use the SAH algorithm to find the best splitting plane and divide the triangle into two parts to minimize the cost of traversal and intersection, including: S221. Calculate the surface area of ​​the entire high-precision model bounding box and set the optimal cost to 1.25 times the cost of the intersection of all triangles under the node. The calculation formula is as follows: Area=2*[(maxX-minX)*(maxY-minY)+(maxZ-minZ)*(maxY-minY)+(maxX-minX)*(maxZ-minZ)] Where maxX, maxY, maxZ, minX, minY and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangle mesh coordinates; S222, traverse the x, y, and z axes to find the best segmentation axis, and divide the range on the axis into 8 intervals as candidate segmentation positions; S223. For each candidate segmentation point, place the triangle in the left area or the right area, and calculate the cost of selecting the segmentation axis and the segmentation point. The calculation formula is as follows: Cost=C T +C I *(P L +P R +N L +N R ) Among them C T The cost of traversing a node is set to a constant of 1; C I To find the cost of intersecting a triangle, set it to a constant of 1.25; P L is the ratio of the surface area of ​​the left subtree to the total surface area; P R is the ratio of the surface area of ​​the right subtree to the total surface area; N L is the number of triangles in the left subtree; N R is the number of triangles in the right subtree. After iteration, record the split point and axis with the minimum cost; S224, recording the segmentation point and axis with the minimum cost as the optimal segmentation solution; S23. Repeat S22 for the split left and right child nodes until each leaf node contains only one triangle mesh.

3. A triangular mesh model collision detection and intersection contour extraction method according to claim 1, characterized in that: In s4, the following steps are specifically included: S41. Update the attributes of two triangles, including calculating the projection boundaries of the three vertices of the two triangles on the other side respectively using the dot product, and the plane definition where the triangles are located; S42. Determine whether the two triangles are coplanar: determine whether the two triangles are coplanar by whether the dot product of the normal vectors of the planes where the two triangles are located is 1; S43. If the two triangles are coplanar, use the separating axis theorem to determine whether there is a separating axis. If there is no separating axis, determine that the triangles intersect; S44. If the two triangles are not coplanar, respectively detect the number of intersection points of a triangle and the plane of the other triangle, and determine whether they intersect according to the number of intersection points.

4. A triangular mesh model collision detection and intersection contour extraction method according to claim 3, characterized in that: In S41, the method for detecting the number of intersection points of a triangle and the plane of the other triangle includes: S441. Use the dot product to determine whether the plane of one triangle is parallel to the side of the other triangle: use whether the dot product of the normal vector of the plane parallel to one triangle and the direction vector of the side of the other triangle is 0; S442. If they are parallel and the starting point of the side is on the plane, it is considered that this side is collinear with the plane, add this side to the contour set, and set the number of intersection points to 2; S443. If they are not parallel, calculate whether there is an intersection point between the plane and the side, and use the plane equation and the parametric equation of the intersection point line segment to obtain the position ratio of the intersection point on the side.

5. A triangular mesh model collision detection and intersection contour extraction method according to claim 4, characterized in that: In S443, the formula for calculating whether there is an intersection point between the plane and the side is: S4431. The plane equation is expressed as: n*P + d = 0 where n is the normal vector of the plane, P is any point on the plane, and d is a constant representing the negative value of the perpendicular distance from the plane to the origin; S4432. The parametric equation of the intersection point line segment is expressed as: P(t) = P0 + t*(P1 - P0) where P0 is the starting point and P1 is the ending point; S4433. Substitute the parametric equation of the intersection point line segment into the plane equation to solve for t, and determine the position of the intersection point according to the value of t: t = (-n*P0 + d) / (n*(P1 - P0)) S4434. After calculating the intersection point ratio t, if t = 0, the intersection point is the starting point; if t = 1, the intersection point is the ending point; if 0 < t < 1, the intersection point is between the starting point and the ending point; otherwise, it means there is no intersection point. After obtaining the ratio of the intersection point to the side, the calculation method of the intersection point is as follows: P(x) = dir(x)*t + P0 P(y) = dir(y)*t + P0 P(z) = dir(z)*t + P0 S4435. After looping through each side of the triangle, obtain the number of intersection points of the triangle and the plane of the other triangle and the intersecting sides.

6. A triangular mesh model collision detection and intersection contour extraction system, characterized in that: Adopt a method for triangle mesh model collision detection and intersecting contour extraction as described in any one of claims 1 - 5, including: Construct a digital twin model unit for using 3D modeling software to establish a high-precision model composed of triangular meshes, which has two attribute data of vertex coordinates and vertex indices, and encapsulates motion behaviors at the same time, so as to construct a workpiece digital twin; A BVH data structure construction unit is used to construct a BVH binary tree data structure for each high-precision model, and use a SAH algorithm to optimize the construction process of the BVH binary tree data structure, wherein the BVH binary tree data structure includes a root node, child nodes, and leaf nodes, the root node stores the bounding box data of the high-precision model, the child node stores the segmented bounding box data, and the leaf node stores the vertex coordinates and vertex indexes of the high-precision model; The BVH collision detection unit is used to recursively traverse the two BVH binary tree data structures constructed based on the BVH data structure construction unit, detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal, and combine the intersection detection of the bounding box and recursive calls to optimize efficiency; The triangle mesh intersection detection and intersection line formation unit is used to perform a pairwise intersection detection on the triangle meshes of the leaf nodes after the BVH collision detection unit obtains the leaf nodes of the two BBVH binary tree data structures, determine whether the two triangles intersect, and calculate the intersection position to form an intersection line set; The contour generation unit is used to process the intersection line set obtained by the triangle mesh intersection detection and intersection line formation unit, traverse each edge and find the next edge that meets the conditions for sorting, and generate a closed-loop contour.

7. A triangular mesh model collision detection and intersection contour extraction system according to claim 6, characterized in that: The BVH data structure construction unit specifically includes: The bounding box establishment subunit is used to traverse each triangular mesh, establish the bounding box of the entire high-precision model and store the bounding box data, including the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangular mesh coordinates; The calculation subunit is used to find the best splitting plane through the SAH algorithm to divide the triangle into two parts to minimize the cost of traversal and intersection. Specifically, it includes: Calculate the surface area of ​​the entire high-precision model bounding box and set the optimal cost to 1.25 times the cost of the intersection of all triangles under the node. The calculation formula is as follows: Area=2*[(maxX-minX)*(maxY-minY)+(maxZ-minZ)*(maxY-minY)+(maxX-minX)*(maxZ-minZ)] Where maxX, maxY, maxZ, minX, minY and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y and minimum z of all triangle mesh coordinates; Traverse the x, y, and z axes to find the best split axis, and divide the range on the axis into 8 intervals as candidate split positions; For each candidate segmentation point, place the triangle in the left or right region and calculate the cost of selecting the segmentation axis and segmentation point. The calculation formula is as follows: Cost=C T +C I *(P L +P R +N L +N R ) Among them C T The cost of traversing a node is set to a constant of 1; C I To find the cost of intersecting a triangle, set it to a constant of 1.25; P L is the ratio of the surface area of ​​the left subtree to the total surface area; P R is the ratio of the surface area of ​​the right subtree to the total surface area; N L is the number of triangles in the left subtree; N R is the number of triangles in the right subtree. After iteration, record the split point and axis with the minimum cost; Record the segmentation point and axis with the minimum cost as the optimal segmentation solution; The repeating sub-unit is used to repeatedly calculate the sub-units for the split left and right child nodes until each leaf node contains only one triangle mesh.

8. A triangular mesh model collision detection and intersection contour extraction system according to claim 7, characterized in that: The triangular mesh intersection detection and intersection line formation unit specifically includes: An update module is used to update the properties of two triangles, including using dot products to calculate the projection boundaries of the three vertices of the two triangles on the other side and the definition of the plane where the triangles are located; A judgment module is used to judge whether two triangles are coplanar: whether the dot product of the normal vectors of the plane where the two triangles are located is 1 to judge whether the two triangles are coplanar; The coplanar module is used to determine whether there is a separating axis using the separating axis theorem if two triangles are coplanar, and if there is no separating axis, it is determined that the triangles intersect; The non-coplanar module is used to detect the number of intersections between the two triangles and the plane of another triangle if the two triangles are not coplanar, and determine whether they intersect based on the number of intersections.

9. A triangular mesh model collision detection and intersection contour extraction system according to claim 8, characterized in that: The non-coplanar module specifically includes: The parallel judgment submodule is used to use the dot product to judge whether the plane of a triangle is parallel to the side of another triangle: whether the dot product of the plane normal vector of a triangle parallel to the side direction vector of another triangle is 0; The colinear submodule is used to consider that if the edges are parallel and the starting point of the edge is on the plane, the edge is added to the contour set, and the number of intersections is set to 2; The intersection judgment submodule is used to calculate whether there is an intersection between the plane and the edge if they are not parallel, and use the plane equation and the parameterized equation of the intersection line segment to obtain the position ratio of the intersection on the edge.

10. A triangular mesh model collision detection and intersection contour extraction system according to claim 9, characterized in that: The specific implementation process of the intersection judgment submodule is as follows: The equation of the plane is expressed as: n*P+d=0 Where n is the plane normal vector, P is an arbitrary point on the plane, and d is a constant representing the negative value of the perpendicular distance from the plane to the origin; The equation for the parameterization of the intersection point line segment is expressed as: P(t)=P0+t*(P1-P0) Among them, P0 is the starting point and P1 is the end point; Substitute the parametric equation of the intersection line segment into the plane equation to solve for t, and determine the position of the intersection point based on the value of t: t=(-n*P0+d) / (n*(P1-P0)) After calculating the intersection ratio t, if t=0, the intersection is the starting point, if t=1, the intersection is the end point, if 0<t<1, the intersection is between the starting point and the end point, and the rest indicates no intersection. After finding the ratio of the intersection to the edge, the intersection is calculated as follows: P(x)=dir(x)*t+P0 P(y)=dir(y)*t+P0 P(z)=dir(z)*t+P0 After looping through each edge of the triangle, the number of intersection points and intersection edges between the triangle and another triangle plane are obtained.

Citation Information

Patent Citations

  • Flexible scene continuous collision detection method based on continuous normal cone remover

    CN102393827A

  • Self collision detection method based on triangle mesh deformation body

    CN102609992A

  • GPU bounding box collision detection method

    CN106875492A

  • Method, device, medium and equipment for generating model profile grid with holes in real time

    CN114170385A

  • Customizable fineness three-dimensional model voxelization method based on grid segmentation and BVH

    CN118365837A

Cited By

  • Grid pickup method and related equipment

    CN120233926A