A method and system for collision detection and intersection contour extraction of triangular mesh models

The construction process of the triangular mesh model is optimized through the BVH binary tree and SAH algorithm, combined with the separation axis theorem and coplanar judgment, the efficiency and accuracy problems in the collision detection of the three-dimensional mesh model are solved, and efficient and accurate collision detection and intersection profile extraction are achieved.

CN119693583BActive Publication Date: 2025-07-11GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411647579.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-07-11
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 inconsistent performance when dealing with complex and variable scenarios, slow calculation speed, high memory consumption, and difficult to meet the requirements of real-time and accuracy.

Method used

The BVH binary tree data structure is used to optimize the construction process of the triangle mesh model with the SAH algorithm, and the intersection detection of the triangle shape and the intersection line generation are achieved through depth-first traversal and bounding box intersection detection, combined with the separation axis theorem and the judgment method of coplanar and non-coplanarity.

Benefits of technology

Improves the efficiency and accuracy of collision detection, and is suitable for static and dynamic changes in digital twin models, generates an ordered closed-loop profile, and supports subsequent repair and optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119693583B_ABST
    Figure CN119693583B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of triangular mesh models, and particularly to a method and system for collision detection and intersection contour extraction of triangular mesh models. The method accelerates the collision detection efficiency by constructing a model BVH hierarchical bounding volume binary tree data structure, reduces computational losses, and uses the intersection relationship between triangular meshes to construct an intersection line determination method. Finally, contour extraction is performed on the set of intersection lines to visually feedback the collision relationship. The purpose of the present invention is to solve the problems of poor detection efficiency and accuracy in virtual model collision detection and intersection contour extraction, making it more in line with the real world in digital twin simulation, and having 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 method and system for collision detection and intersection contour extraction of triangular mesh models. Background Art

[0002] With the rapid development of three-dimensional mesh model technology and the wide application of three-dimensional models in fields such as CAD / CAM and digital twin simulation, in order to be closer to and conform to the real world, collision detection between three-dimensional models has become indispensable. In digital twin simulation, collision detection is not only applied between three-dimensional models, but also between three-dimensional models and virtual sensors. Doing a good job in collision detection is an important part of realizing the simulation of the virtual world to the real world, which makes collision avoidance possible and further gives full play to the value of digital twins in aspects such as virtual production and virtual commissioning.

[0003] However, the existing technologies mainly have the following disadvantages when performing collision detection:

[0004] (1) When the spatial subdivision method is used to process different scenarios and objects with different shapes and complexities, it is difficult to maintain a relatively consistent detection efficiency. This is because this method relies on the hierarchical subdivision technology of the entire scene to achieve, resulting in inconsistent performance when facing complex and changeable scenes.

[0005] (2) When calculating the intersecting triangles and triangle intersection lines of three-dimensional mesh collisions, the existing technologies have problems such as slow calculation speed, large memory consumption, and high accuracy 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 object of the present invention is to propose a method for collision detection and intersection contour extraction of triangular mesh models, aiming to solve the problems of poor detection efficiency and accuracy in virtual model collision detection and intersection contour extraction, making it more in line with the real world in digital twin simulation, and having the effects of high efficiency, accuracy, and wide applicability.

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

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

[0009] A method for collision detection and intersection contour extraction of triangular mesh models includes the following steps:

[0010] S1. Construct a digital twin model:

[0011] Use 3D modeling software to establish a high-precision model composed of triangular meshes, which has two attribute data: vertex coordinates and vertex indices. At the same time, encapsulate the motion behavior to construct the digital twin of the workpiece.

[0012] S2. Construction of BVH data structure:

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

[0014] S3. BVH collision detection:

[0015] Based on the two BVH binary tree data structures constructed in S2, perform recursive traversal, and detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth-first traversal. Combine the intersection detection of the bounding boxes and recursive calls to optimize the efficiency.

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

[0017] After obtaining the leaf nodes of the two BBVH binary tree data structures in S3, perform pairwise intersection detection on the triangular meshes of the leaf nodes, determine whether two triangles intersect, and calculate the intersection point positions to form a set of intersection lines.

[0018] S5. Contour generation:

[0019] Process the set of intersection lines obtained in S4, traverse each edge and find the next edge that meets the conditions for sorting to generate a closed-loop contour.

[0020] Preferably, in S2, it specifically includes the following steps:

[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 in all triangular mesh coordinates.

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

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

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

[0025] Among them, maxX, maxY, maxZ, minX, minY, and minZ are the maximum x, maximum y, maximum z, minimum x, minimum y, and minimum z among all triangular mesh coordinates;

[0026] S222. Traverse the x, y, and z axes to find the optimal splitting axis, and divide the range on the axis into 8 intervals as candidate splitting positions;

[0027] S223. For each candidate splitting point, place the triangles into the left region or the right region, and calculate the cost of selecting this splitting axis and splitting 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 is the cost of traversing a node, set as a constant 1; C I is the cost of intersecting a triangle, set as a constant 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 splitting point and axis with the minimum cost;

[0030] S224. Record the splitting point and axis with the minimum cost as the optimal splitting scheme;

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

[0032] Preferably, in S4, it specifically includes the following steps:

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

[0034] S42. Determine whether two triangles are coplanar: Determine whether two triangles are coplanar by checking if the dot product of the normal vectors of the planes where the two triangles lie 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, it is determined that the triangles intersect;

[0036] S44. If the two triangles are non - coplanar, respectively detect the number of intersection points of one triangle with the plane of the other triangle, and determine whether they intersect according to the number of intersection points.

[0037] Preferably, in S41, the method for detecting the number of intersection points of a triangle with the plane of another triangle includes:

[0038] S441. Use the dot product to determine whether the plane of one triangle is parallel to the side of another triangle: Check if 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;

[0039] 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;

[0040] 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.

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

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

[0043] n*P + d = 0

[0044] 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;

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

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

[0047] where P0 is the starting point and P1 is the ending 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 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 edge of the triangle in a loop, obtain the number of intersection points and the intersecting edges between this triangle and the plane of another triangle.

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

[0056] Build a digital twin model unit, which is used to use 3D modeling software to establish a high-precision model composed of triangular meshes, with two attribute data of vertex coordinates and vertex indices, and encapsulate the motion behavior at the same time, so as 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 segmented, 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] Triangular mesh intersection detection and intersection line formation unit, which is used to perform pairwise intersection detection on the triangular 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 triangular 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.

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

[0062] An enclosing box establishment subunit, configured to traverse each triangular mesh, establish an enclosing box for the entire high-precision model, and store the enclosing box data, including the maximum x, maximum y, maximum z, minimum x, minimum y, and minimum z among all triangular mesh coordinates;

[0063] A calculation subunit, configured to find an optimal splitting plane through the SAH algorithm to divide the triangles into two parts to minimize the cost of traversal and intersection, specifically including:

[0064] Calculate the surface area of the enclosing box of the entire high-precision model, and set the optimal cost to 1.25 times the cost of intersection of all the triangles under this 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 among all triangular mesh coordinates;

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

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

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

[0070] where C T is the cost of traversing a node, set to a constant of 1; C I is the cost of intersecting a triangle, set 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 splitting point and axis with the minimum cost;

[0071] Record the splitting point and axis with the minimum cost as the optimal splitting scheme;

[0072] Repeat the sub-unit to repeatedly calculate the sub-unit for the left and right child nodes after splitting until each leaf node contains only one triangular mesh.

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

[0074] An update module for updating 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 triangle is located;

[0075] A judgment module for judging whether two triangles are coplanar: judging whether two triangles are coplanar by whether the dot product of the normal vectors of the planes where the two triangles are located is 1;

[0076] A coplanar module for, if two triangles are coplanar, judging whether there is a separating axis using the separating axis theorem, and if there is no separating axis, judging that the triangles intersect;

[0077] A non-coplanar module for, if two triangles are non-coplanar, respectively detecting the number of intersection points of a triangle with the plane of another triangle, and determining whether they intersect according to the number of intersection points.

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

[0079] A parallel judgment sub-module for judging whether the plane of a triangle is parallel to the side of another triangle using the dot product: using whether the dot product of the normal vector of the plane parallel to a triangle and the direction vector of the side of another triangle is 0;

[0080] A collinear sub-module for, if parallel and the starting point of the side is on the plane, considering that this side is collinear with the plane, adding this side to the contour set and setting the number of intersection points to 2;

[0081] An intersection point judgment sub-module for, if not parallel, calculating whether there is an intersection point between the plane and the side, and obtaining the position ratio of the intersection point on the side using the plane equation and the parametric equation of the intersection point line segment.

[0082] Preferably, the specific implementation process of the intersection point judgment sub-module is:

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

[0084] n*P + d = 0

[0085] 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;

[0086] The parametric equation for 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 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:

[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 efficiency of collision detection: 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 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, providing 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 the construction of the BVH data structure in the method for collision detection and intersection contour extraction of a triangular mesh model according to the present invention;

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

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

[0105] Figure 5 It is a separating axis schematic diagram of the intersection detection and intersection line of the triangular mesh in the method for collision detection and intersection contour extraction of a triangular mesh model according to the present invention. Specific embodiments

[0106] The technical solution of the present invention will be further described below in conjunction with the accompanying drawings and through specific embodiments.

[0107] A method for collision detection and intersection contour extraction of a triangular mesh model includes the following steps:

[0108] S1. Construct a digital twin model:

[0109] Using 3D modeling software, a high-precision model composed of triangular meshes is established, which has two attribute data of vertex coordinates and vertex indices, and at the same time encapsulates the motion behavior to construct a digital twin of the workpiece;

[0110] Specifically, first obtain the 3D data of the object from the actual physical world, which can be achieved through means such as 3D scanning and CAD modeling. Then use 3D modeling software (such as 3D Max, Maya, etc.) to construct the obtained 3D data into a high-precision triangular mesh model. The model should include 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 attributes (such as mass, inertia, etc.), motion constraints (such as joint constraints, collision constraints, etc.) and dynamic simulation algorithms (such as physical engines) to the model to realize the dynamic simulation of the model in the virtual environment.

[0111] S2. Construction of the BVH data structure:

[0112] 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, where 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 divided bounding box data, and the leaf nodes store the vertex coordinates and vertex indices of the high-precision model;

[0113] S3, BVH Collision Detection:

[0114] Based on the two BVH binary tree data structures constructed in S2, perform recursive traversal, and detect the intersection relationship between the leaf nodes of the two BVH binary tree data structures through depth - first traversal. Combine the intersection detection of bounding boxes and recursive calls to optimize the efficiency;

[0115] S4, Triangle Mesh Intersection Detection and Intersection Line Formation:

[0116] After obtaining the leaf nodes of the two BBVH binary tree data structures in S3, perform pairwise intersection detection on the triangular meshes of the leaf nodes, determine whether two triangles intersect, calculate the intersection point positions, and form an intersection line set;

[0117] S5, Contour Generation:

[0118] Process the intersection line set obtained in S4, traverse each edge and find the next eligible edge for sorting to generate a closed - loop contour.

[0119] The intersection line set obtained in S4 is essentially the contour data, but the order of the set cannot form a closed loop because the set is unordered and does not ensure that the end point of an element is the start point of the next element. To generate a closed - loop contour, the intersection line set needs to be processed by traversing each edge and finding the next eligible edge for sorting.

[0120] In summary, the present invention proposes a method for triangle mesh digital twin model collision detection and intersection edge contour extraction. It uses the BVH hierarchical bounding volume binary tree data structure to accelerate the collision detection efficiency, and optimizes the node splitting strategy through the SAH algorithm, improving the detection accuracy and efficiency. At the same time, it constructs an intersection line determination method using the intersection relationship between triangle meshes and extracts the intersection edge contour data to intuitively feedback the collision relationship. The present invention has 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. Enhance accuracy: Adopt the separating axis theorem and the judgment methods for coplanarity and non - coplanarity to ensure the accuracy of triangle mesh intersection detection, avoiding false positives and false negatives.

[0124] 3. Wide applicability: This method is not only applicable to the collision detection of static objects, but also can be applied to digital twin models with dynamic changes, showing wide applicability.

[0125] 4. Strong contour extraction ability: By processing the set of intersection lines, it can generate an ordered closed-loop contour, providing strong support for subsequent repair or optimization.

[0126] For further illustration, in S2, it specifically includes the following steps:

[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 in all triangular mesh coordinates;

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

[0129] S221. Calculate the surface area of the bounding box of the entire high-precision model, and set the best cost as 1.25 times the cost of intersection of all triangles under this 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 in all triangular mesh coordinates;

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

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

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

[0135] where C T is the cost of traversing a node, set as a constant of 1; C ITo obtain the cost of intersecting a triangle, it is set 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 splitting point and axis with the minimum cost;

[0136] S224. Record the splitting point and axis with the minimum cost as the optimal splitting scheme;

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

[0138] The main purpose of the SAH algorithm is to find the best splitting plane to divide a set of triangle bounding box data into two parts, thereby minimizing the cost of traversal and intersection. Due to selecting different splitting positions, by trying different axes and splitting points, an optimal splitting scheme is finally found. Taking the number of times of traversing nodes and the number of triangles as the cost, the cost of traversal and intersection calculation is minimized to the greatest extent during splitting, so the performance efficiency will be further improved.

[0139] For further explanation, in S4, it specifically includes the following steps:

[0140] 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;

[0141] S42. Determine whether the two triangles are coplanar: Use whether the dot product of the normal vectors of the planes where the two triangles are located is 1 to determine whether the two triangles are coplanar;

[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, then determine that the triangles intersect;

[0143] S44. If the two triangles are non - coplanar, respectively detect the number of intersection points of a triangle with the plane of the other triangle, and determine whether they intersect according to the number of intersection points.

[0144] For further explanation, in S41, the method for detecting the number of intersection points of a triangle with the plane of the other triangle includes:

[0145] S441. Use the dot product to determine whether the plane of a 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;

[0146] S442. If parallel and the starting point of the edge lies on the plane, the edge is considered collinear with the plane, added to the contour set, and the intersection point count is set to 2;

[0147] S443. If not parallel, calculate whether there is an intersection point between the plane and the edge, and obtain the position ratio of the intersection point on the edge using the plane equation and the parametric equation of the intersection point segment.

[0148] For further explanation, in S443, the formula for calculating whether there is an intersection point between the plane and the edge 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 of the perpendicular distance from the plane to the origin;

[0152] S4432. The parametric equation of the intersection point 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 intersection point 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 edge, 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 looping through each edge of the triangle, obtain the number of intersection points and the intersecting edges 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 attributes of two triangles, including calculating the projection boundaries of the three vertices of the two triangles on the other side using the dot product respectively (the dot product of the vertex vector and the edge vector), and the plane definition where the triangles are located, to prepare for the subsequent separating axis determination.

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

[0164] (1) First, discuss the case where two triangles are coplanar: Determine whether two triangles are coplanar by using the dot product of the normal vectors of the planes where the two triangles are located. If the dot product is 1, use the separating axis theorem to determine whether there is a separating axis. Loop through each side of the two triangles and use this side as the projection axis of the other triangle. By comparing whether the projection boundaries of the original triangle on this side overlap with the projection boundaries of the other triangle, if there is an overlap, it proves that there is no separating axis in this projection direction and they intersect; otherwise, they do not intersect. It is not until the traversal is completed that it can be determined whether the two coplanar triangles intersect. As Figure 5 shown, if there is no separating axis, it means the triangles intersect. However, coplanar triangles do not meet the requirement of supporting the output of the intersecting edge because this edge is not a contour. Only when two triangles intersect at a certain angle is it an intersecting contour.

[0165] (2) Then, handle the non-coplanar case. Respectively detect the number of intersection points between a triangle and the plane of the other triangle. A triangle has 3 sides, and check one by one whether they intersect with the plane.

[0166] First, use the dot product to determine whether the plane of one triangle is parallel to the edge of the other 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, then it is on the plane), then it is considered that this edge is collinear with the plane, and this edge can be directly added to the contour set, and the number of intersection points is set to 2;

[0167] Conversely, if they are not parallel, then calculate whether there is an intersection point between the plane and the edge. Use the plane equation and the parametric equation of the intersecting point line segment to obtain the parameter t, which represents the position ratio of the intersection point on the edge.

[0168] A triangular mesh model collision detection and intersecting contour extraction system adopts a triangular mesh model collision detection and intersecting contour extraction method as described above, including:

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

[0170] BVH data structure construction unit, which is used to construct 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 segmented bounding box data, and the leaf nodes store the vertex coordinates and vertex indices of the high-precision model;

[0171] BVH collision detection unit, which is used to perform recursive traversal based on two BVH binary tree data structures constructed by the BVH data structure construction unit, and 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;

[0172] 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, determine whether two triangles intersect, calculate the intersection point positions, and form an intersection line set;

[0173] 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 eligible edge for sorting to generate a closed-loop contour.

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

[0175] For further explanation, the BVH data structure construction unit specifically includes:

[0176] Bounding box establishment sub-unit, which is used to traverse each triangle 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 in all triangle mesh coordinates;

[0177] Calculation sub-unit, which 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 including:

[0178] Calculate the surface area of the bounding box of the entire high-precision model, and set the best cost to 1.25 times the cost of intersection of all triangle numbers under this 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 among all triangular mesh coordinates;

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

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

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

[0184] Where C T is the cost of traversing a node, set to a constant of 1; C I is the cost of intersecting a triangle, set 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 splitting point and axis with the minimum cost;

[0185] Record the splitting point and axis with the minimum cost as the optimal splitting scheme;

[0186] Repeat the subunit to repeatedly calculate the subunit for the left and right child nodes after splitting until each leaf node contains only one triangular mesh.

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

[0188] An update module for updating 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;

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

[0190] A coplanar module, used to, if two triangles are coplanar, use the separating axis theorem to judge whether there is a separating axis, and if there is no separating axis, judge that the triangles intersect;

[0191] A non-coplanar module, used to, if two triangles are non-coplanar, respectively detect the number of intersection points of a triangle with the plane of another triangle, and determine whether they intersect according to the number of intersection points.

[0192] Further explanation, the non-coplanar module specifically includes:

[0193] A parallel judgment sub-module, used to use the dot product to judge whether the plane of one triangle is parallel to the side of another 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 another triangle is 0;

[0194] A collinear sub-module, used to, if it is parallel and the starting point of the side is on the plane, consider that this side is collinear with the plane, add the side to the contour set, and set the number of intersection points to 2;

[0195] An intersection point judgment sub-module, used to, if it is 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.

[0196] Further explanation, the specific implementation process of the intersection point judgment sub-module is as follows:

[0197] The plane equation is expressed as:

[0198] n*P + d = 0

[0199] 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;

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

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

[0202] Where, P0 is the starting point and P1 is the ending point;

[0203] 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:

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

[0205] After calculating the intersection ratio t, if t=0, the intersection is the starting point, if t=1, the intersection is the end point, and if t=0, the intersection is the end point. <t<1则交点在起点与终点之间,其余表示没有交点,求的交点占边的比例后,交点的计算方式如下:

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

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

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

[0209] 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.

[0210] The technical principle of the present invention is described above in conjunction with specific embodiments. These descriptions are only for explaining the principle of the present invention and cannot be interpreted as limiting the scope of protection of the present invention in any way. Based on the explanations herein, those skilled in the art can associate other specific embodiments of the present invention without creative work, and these equivalent variations or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A method for triangle mesh model collision detection and intersection contour extraction, characterized in that It includes the following steps: S1. Construct a digital twin model: Use 3D modeling software to establish a high-precision model composed of triangular meshes, which has two attribute data, namely vertex coordinates and vertex indices, and encapsulate the motion behavior to construct the workpiece digital twin; S2. Construct the BVH data structure: 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. 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 nodes store the bounding box data after being segmented, and the leaf nodes store the vertex coordinates and vertex indices of the high-precision model; S3. BVH collision detection: Based on the two BVH binary tree data structures constructed in S2, perform recursive traversal, and 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; S4. Triangular mesh intersection detection and intersection line formation: After obtaining the leaf nodes of the two BBVH binary tree data structures in S3, perform pairwise intersection detection on the triangular meshes of the leaf nodes, determine whether two triangles intersect, and calculate the intersection point positions to form an intersection line set; S5. Contour generation: Process the intersection line set obtained in S4, traverse each edge and find the next edge that meets the conditions for sorting to generate a closed-loop contour.

2. The method for triangle mesh model collision detection and intersection contour extraction according to claim 1, characterized in that, In S2, it specifically includes the following steps: 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 in all triangular mesh coordinates; S22. Through the SAH algorithm, find the optimal splitting plane to divide the triangle into two parts to minimize the cost of traversal and intersection. Specifically, it includes: S221. Calculate the surface area of the bounding box of the entire high-precision model, and set the optimal cost to 1.25 times the cost of intersection of all the triangles under this 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 in all triangular mesh coordinates; S222. Traverse the x, y, and z axes to find the optimal splitting axis, divide the range on the axis into 8 intervals as candidate splitting positions; S223. For each candidate splitting point, place the triangle into the left region or the right region, and calculate the cost of selecting this splitting axis and splitting point. The calculation formula is as follows: Cost = C T + C I *(P L + P R + N L + N R ) Among which C T is the cost of traversing a node, set to a constant of 1; C I is the cost of intersecting a triangle, set 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, and after iteration, record the splitting point and axis of the minimum cost; S224. Record the splitting point and axis with the minimum cost as the optimal splitting scheme; S23. Repeat S22 for the left and right child nodes after splitting until each leaf node contains only one triangular mesh.

3. A method for triangle mesh model collision detection and intersection contour extraction according to claim 1, characterized in that, In S4, it specifically includes the following steps: 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 checking 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, it is determined that the triangles intersect; S44. If the two triangles are non-coplanar, respectively detect the number of intersection points of a triangle with the plane of the other triangle, and determine whether they intersect according to the number of intersection points.

4. A method for triangle mesh model collision detection and intersection contour extraction according to claim 3, characterized in that, In S41, the method for detecting the number of intersection points of a triangle with 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 method for triangle mesh model collision detection and intersection contour extraction 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 with 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, with two attribute data of vertex coordinates and vertex indices, and encapsulate the motion behavior at the same time to construct a workpiece digital twin; BVH data structure construction unit, which is used to construct 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 divided bounding box data, and the leaf nodes store the vertex coordinates and vertex indices of the high-precision model; 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, and 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; 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, determine whether two triangles intersect, calculate the intersection point positions, and form an intersection line set; 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 eligible edge for sorting to 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: Bounding box establishment sub-unit, which is used to traverse each triangle 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 in all triangle mesh coordinates; Calculation sub-unit, which 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 bounding box of the entire high-precision model, and set the best cost to 1.25 times the cost of intersection of all the triangles under this 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 in all triangle mesh coordinates; Traverse the x, y, and z axes to find the best splitting axis, divide the range on the axis into 8 intervals as candidate splitting positions; For each candidate splitting point, put the triangle into the left area or the right area, and calculate the cost of selecting this splitting axis and splitting point. The calculation formula is as follows: Cost=C T +C I *(P L +P R +N L +N R ) Where C T is the cost of traversing a node, set to a constant of 1; C I is the cost of intersecting a triangle, set 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, and after iteration, record the splitting point and axis of the minimum cost; Record the splitting point and axis with the minimum cost as the optimal splitting scheme; Repeat sub-unit, which is used to repeat the calculation sub-unit for the left and right child nodes after splitting until each leaf node contains only one triangle mesh.

8. A system for triangle mesh model collision detection and intersection contour extraction according to claim 7, characterized in that, The triangle mesh intersection detection and intersection line formation unit specifically includes: An update module for updating the properties 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; A judgment module for judging whether two triangles are coplanar: judging whether two triangles are coplanar by whether the dot product of the normal vectors of the planes where the two triangles are located is 1; A coplanar module for, if two triangles are coplanar, using the separating axis theorem to judge whether there is a separating axis, and if there is no separating axis, judging that the triangles intersect; A non-coplanar module for, if two triangles are non-coplanar, respectively detecting the number of intersection points of a triangle with the plane of another triangle, and determining whether they intersect according to the number of intersection points.

9. A triangle mesh model collision detection and intersection contour extraction system according to claim 8, characterized in that, The non-coplanar module specifically includes: A parallel judgment sub-module for using the dot product to judge 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 direction vector of the side of another triangle is 0; A collinear sub-module for, if it is parallel and the starting point of the side is on the plane, considering that this side is collinear with the plane, adding this side to the contour set, and setting the number of intersection points to 2; An intersection point judgment sub-module for, if it is not parallel, calculating whether there is an intersection point between the plane and the side, and obtaining the position ratio of the intersection point on the side using the plane equation and the parametric equation of the intersection point line segment.

10. A triangle mesh model collision detection and intersection contour extraction system according to claim 9, characterized in that, The specific implementation process of the intersection point judgment sub-module is as follows: The equation of the plane 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; 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; 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)) 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, and the rest indicates that 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 After looping through each side of the triangle, the number of intersection points of the triangle with the plane of another triangle and the intersecting sides 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