A method and apparatus for extracting intersection lines of 3D models based on MVP inverse transform

CN122574009APending Publication Date: 2026-08-14DALIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-19
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

尽管理论上可实现高精度,但在工程实践中存在以下突出问题:(1)由于浮点误差或退化情况(如共面、共边、接触但不穿透),导致交线拓扑断裂;(2)计算复杂度高,百万面级模型难以达到交互级性能;(3)拓扑拼接困难,需要复杂的边界修补与冗余消除

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122574009A_ABST
    Figure CN122574009A_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for extracting intersection lines of 3D models based on MVP inverse transform. The method includes: preprocessing a 3D mesh model; assigning different color identifiers to different models through a graphics rendering interface and rasterizing and rendering them to screen space; performing pixel-level analysis on the rendered image, detecting color abrupt change regions between adjacent pixels, and extracting candidate pixels for intersection lines; and restoring the candidate pixels to 3D spatial coordinates using the inverse transform of model-view-projection transformation based on their screen coordinates and corresponding depth values, thereby obtaining a set of intersection points or a continuous curve. This invention utilizes the parallel processing capabilities of GPUs to transform geometric intersection calculation into color difference detection and depth inversion in image space, avoiding the numerical instability and topological breakage problems of traditional methods, and achieving efficient and robust 3D model intersection line calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer graphics and 3D model processing technology, and in particular to a method and apparatus for extracting intersection lines of 3D models based on MVP inverse transform. Background Technology

[0002] Intersection Computation of 3D Models is one of the core problems in computer graphics, computer-aided design (CAD), and engineering simulation (CAE). This problem aims to determine the location and topological structure of the intersection lines between two or more 3D surface or mesh models in space, providing fundamental geometric information for tasks such as Boolean operations, assembly interference detection, collision analysis, geometric reconstruction, and visualization.

[0003] Traditional methods for calculating intersection lines are mainly based on geometric analysis and topological traversal. In triangular mesh models, a common practice is to screen candidate triangle pairs by establishing an acceleration structure (such as BVH, AABB tree, or kd tree) and then perform triangle-triangle intersection detection. Although high accuracy can be achieved in theory, the following prominent problems exist in engineering practice: (1) Topological breaks in intersection lines are caused by floating-point errors or degradation (such as coplanarity, shared edges, contact but not penetration); (2) High computational complexity makes it difficult for million-face-level models to achieve interactive performance; (3) Difficulty in topological stitching requires complex boundary repair and redundancy elimination. For parametric surfaces, recursive trimming or parametric domain subdivision methods also suffer from poor numerical stability and convergence failure for complex intersection lines.

[0004] With the development of GPU parallel computing and real-time rendering, researchers have attempted to leverage the visualization capabilities of GPUs to assist geometric calculations. However, existing image-space-based methods still have shortcomings in terms of accuracy of 3D coordinate reconstruction, continuity of intersection lines, and occlusion handling. Therefore, there is an urgent need for a method that can efficiently and robustly extract intersection lines from 3D models. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention provides a method and apparatus for extracting intersection lines of a three-dimensional model based on MVP inverse transform.

[0006] In a first aspect, the present invention provides a method for extracting intersection lines of a three-dimensional model based on MVP inverse transform, comprising: The input 3D mesh model is preprocessed to construct a standardized mesh data structure; Different color identifiers are assigned to different 3D models through the graphics rendering interface. Multiple models are projected onto the screen space using rasterization rendering and the rendering results are scanned according to a preset viewpoint or path. Pixel-level analysis is performed on the rendered color image to detect regions where color changes occur between adjacent pixels. Pixels with color changes are identified and extracted as candidate pixels for intersection lines. Based on the two-dimensional position of the candidate pixels of the intersection line in screen space and their corresponding depth values, the candidate pixels of the intersection line are restored to three-dimensional spatial coordinates by using the inverse transformation of model-view-projection transformation, so as to obtain the intersection point set or continuous curve of the three-dimensional model.

[0007] In one embodiment of the present invention, when assigning color identifiers to different 3D models through the graphics rendering interface, the assigned color identifiers are all different single pure colors, so that the pixel colors corresponding to different models have distinguishable differences in the color channels.

[0008] In one embodiment of the present invention, when detecting a color abrupt change region, the color difference between the current pixel and at least one neighboring pixel is compared. When the color difference exceeds a preset threshold, the current pixel is determined to be a candidate pixel for intersection.

[0009] In one embodiment of the present invention, the neighboring pixels include adjacent pixels in at least one of the directions of the right, lower right, and lower side of the current pixel.

[0010] In one embodiment of the present invention, the depth value is obtained from a depth buffer generated during the graphics rendering process, and the depth value represents the distance of the scene point corresponding to the pixel relative to the viewpoint.

[0011] In one embodiment of the present invention, after restoring the three-dimensional coordinates using inverse transformation, the method further includes performing connectivity analysis on the restored three-dimensional point set to generate a continuous three-dimensional intersection curve.

[0012] In one embodiment of the present invention, after the three-dimensional spatial coordinates are obtained, the method further includes: determining the triangular mesh surface where the candidate pixel of the intersection line is located, and calculating the centroid coordinate representation of the intersection point on the triangular mesh surface.

[0013] In one embodiment of the present invention, after obtaining the restored three-dimensional spatial coordinates, the validity of the candidate intersection points is further verified: if the distance between the restored three-dimensional spatial coordinates of two candidate intersection points corresponding to the same intersection line exceeds a preset error range, the two points are determined to be occlusions rather than true intersections, and they are removed from the intersection point set.

[0014] In one embodiment of the present invention, the preset viewpoint or path includes multiple different viewpoint directions; the steps of assigning different color identifiers to different 3D models through the graphics rendering interface, performing pixel-level analysis on the rendered color image, and restoring 3D coordinates using inverse transformation are performed on each viewpoint to obtain a set of candidate pixels for intersection lines under each viewpoint; and the restoration step further includes fusing the 3D point sets restored from multiple viewpoints to generate a complete 3D intersection curve.

[0015] Secondly, the present invention provides a three-dimensional model intersection line extraction device based on MVP inverse transform, comprising: The preprocessing module is used to preprocess the input 3D mesh model and construct a standardized mesh data structure. The rendering module is used to assign different color labels to different 3D models through the graphics rendering interface, project multiple models onto the screen space using rasterization rendering, and scan the rendering results according to a preset viewpoint or path. The pixel extraction module is used to perform pixel-level analysis on the rendered color image, detect areas where color changes occur between adjacent pixels, identify and extract pixels with color changes as candidate pixels for intersection lines. The coordinate restoration module is used to restore the intersection candidate pixels to three-dimensional spatial coordinates based on their two-dimensional positions in screen space and their corresponding depth values, using the inverse transformation of model-view-projection transformation, to obtain the intersection point set or continuous curve of the three-dimensional model.

[0016] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the methods described in the first aspect and any of its embodiments.

[0017] This invention transforms the geometric intersection problem into color discrimination and depth inversion in image space, and utilizes the highly parallel processing capabilities of GPUs to replace the traditional triangle pair traversal, which has the following beneficial effects: (1) High computational efficiency: GPU rasterization and pixel-level parallel processing can achieve real-time or interactive performance even for million-level triangle models.

[0018] (2) Strong numerical stability: It mainly utilizes GPU visualization information to minimize the computational requirements of geometric intersection. Only in necessary stages (such as the connectivity analysis stage) can precise geometric intersection be selectively used to perform fine calculations on the triangular facets where candidate intersection points are located, thereby providing higher numerical stability while ensuring efficiency, and naturally handling degenerate cases such as coplanarity and tangency.

[0019] (3) Topological integrity: Based on the color change detection of the pixel neighborhood, continuous pixel-level intersection lines can be obtained, and then continuous curves in three-dimensional space can be directly generated through MVP inverse transformation, without the need for complex topological repair.

[0020] (4) Simple to implement and versatile: The main calculations can be completed with only the standard graphics rendering pipeline, and it is easy to integrate into existing CAD / CAE / CG software.

[0021] (5) Rich output information: It not only provides the three-dimensional point set of the intersection line, but also outputs the centroid coordinates of the intersection point on the triangle, which is convenient for downstream Boolean operations, mesh splitting and other operations.

[0022] (6) Multi-view fusion enhancement: By calculating and fusing the intersection lines from multiple different viewpoints, the missing intersection lines caused by occlusion or depth discontinuity under a single viewpoint can be effectively overcome, and more complete and accurate three-dimensional intersection lines can be obtained. Attached Figure Description

[0023] The above and other objects, features, and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. In the drawings, several embodiments of the invention are illustrated by way of example and not limitation, and like or corresponding reference numerals denote like or corresponding parts wherein: Figure 1 This is a flowchart illustrating the implementation of the 3D model intersection line extraction method based on MVP inverse transform provided by this invention. Figure 2 This is a schematic diagram of the rendering results after assigning different color labels to different models in an embodiment of the present invention; Figure 3 This is a schematic diagram of the visualization results of the intersection lines extracted in an embodiment of the present invention. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0025] It should be understood that the terms "first," "second," "third," and "fourth," etc., in the claims, specification, and drawings of this invention are used to distinguish different objects, not to describe a specific order. "First," "second," "third," and "fourth," etc., also do not necessarily mean only one, but can also mean multiple. The terms "comprising" and "including" used in the specification and claims of this invention indicate the presence of the described features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof.

[0026] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0027] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0028] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0029] Figure 1 The overall flow of the method of the present invention is shown. This method utilizes the rasterization and depth buffering mechanisms of the GPU in the real-time rendering process, realizes the representation of different models in screen space through color differentiation, and achieves automatic extraction of intersection lines and 3D reconstruction based on pixel color changes and depth inversion.

[0030] Step 1: Model Preprocessing The input 3D mesh model undergoes normalization and topology cleanup to remove anomalous data such as duplicate vertices, degenerate patches, and isolated points, and a half-edge data structure or other normalized mesh data structure is constructed. The purpose of this step is to ensure the stability and consistency of the subsequent GPU rendering and spatial coordinate reconstruction process.

[0031] Step 2: Color Differentiation Rendering Using graphics rendering interfaces such as OpenGL, DirectX, or Vulkan, different 3D models to be intersected are each assigned a unique single solid color. For example, ... Figure 2 As shown, the two mesh models that need to be intersected are rendered as red (R=1, G=0, B=0) and green (R=0, G=1, B=0), respectively. Multiple models are projected onto screen space using the GPU's rasterization rendering pipeline, and the rendering results are scanned frame-by-frame according to a preset camera path (or manual interaction). To balance computational load and intersection accuracy, the color data from the rendering frame buffer can be read every preset number of frames (e.g., every 10 frames).

[0032] Step 3: Extraction of intersection pixels The rendered color image is analyzed at the pixel level to detect regions where color abruptly changes between adjacent pixels. This embodiment employs a parallel computing architecture (such as CUDA) to simultaneously read all pixels in the image. For each current pixel, the color information of its right, lower right, and lower adjacent pixels is read.

[0033] Color differences are calculated using the Euclidean distance formula:

[0034] in: This represents the color difference value between the current pixel and its neighboring pixels. It represents the red, green, and blue components of the current pixel (values ​​range from 0 to 1). It consists of the red, green, and blue components of adjacent pixels (values ​​ranging from 0 to 1).

[0035] If the color difference between the current pixel and any adjacent pixel is If the value exceeds a preset threshold T (e.g., T=0.3), the current pixel is marked as a candidate pixel for intersection, and the result image of the candidate pixel for intersection is output.

[0036] In this embodiment, only the current pixel is compared with its neighboring pixels in the right, lower right, and lower directions, rather than all eight neighborhood directions. The reasons for this design are as follows: First, during pixel-by-pixel parallel traversal, a color abrupt change edge will be detected once by each of its two adjacent pixels. Checking all directions would generate duplicate candidate pixel pairs, increasing the computational overhead for subsequent deduplication. Checking only the right, lower right, and lower directions (i.e., the half-neighborhood towards the lower right corner of the image) ensures that each edge is detected only once, while also preventing any horizontal, vertical, or diagonal abrupt changes from being missed. This is because a change in the left direction is necessarily detected by the right side of the left pixel, a change in the upper direction is necessarily detected by the lower side of the upper pixel, and a change in the upper left direction is necessarily detected by the lower right side of the upper left pixel. Second, GPU threads typically access pixels in row-major order. Checking pixels in the right and next row has better cache locality, which is beneficial for improving parallel processing efficiency. Therefore, the three directions used in this embodiment represent a preferred balance between computational efficiency and detection completeness. In other embodiments, more directions can be added as needed, all falling within the scope of this invention.

[0037] Step 4: 3D coordinate reconstruction 4.1 Constructing screen space coordinates Based on the screen coordinates (u,v) of the candidate pixels of the intersection line and their corresponding depth values (Read from the depth buffer, normalized to [0,1]), constructing a screen space coordinate representation. Simultaneously, use OpenGL's frame buffer object (FBO) to obtain the triangular mesh information where the pixel is located.

[0038] 4.2 MVP Inverse Transformation to Restore 3D Coordinates By utilizing the inverse transformation relationship between view transformation and projection transformation used in the rendering process, the spatial coordinates are inversely calculated into the actual position in 3D space. The depth buffer is obtained by storing the scene's depth information in a depth buffer (z-buffer) during GPU rendering; this depth information represents the distance of a pixel relative to the viewpoint. For each intersection candidate pixel, its 3D coordinate reconstruction process incorporates the pixel's depth value for inverse transformation. The formula for calculating the scaling factor of the homogeneous coordinates in the clipping space is:

[0039] in, The scaling factor for the homogeneous coordinates of the clipping space. The normalized depth value read from the depth buffer, ranging from 0 to 1. The near clipping plane distance set during rendering. The distance to the far clipping plane is set for rendering.

[0040] Then, construct the clipping space coordinates. ,in It is obtained by inverse viewport transformation from screen coordinates and depth values.

[0041] The complete model-view-projection inverse transformation formula is as follows:

[0042] Where M, V, and P are the model matrix, view matrix, and projection matrix, respectively; These are their inverse matrices; The coordinates in the clipping space are [-w, w]; w is the homogeneous coordinate scaling factor calculated in step 4.2. These are the coordinates of the restored model space.

[0043] In this invention, since the preprocessing in step 1 has placed the 3D mesh model in the world coordinate system, and the color rendering in step 2 does not apply any additional model transformation to the model (i.e., the model matrix M is the identity matrix), therefore... The above formula simplifies to:

[0044] Obtained world space coordinates These are the three-dimensional coordinates of the intersection point. If other implementations require independent rotation, translation, or scaling of the model, simply multiply by the left component during the inverse transformation. This is a direct equivalent substitution of the present invention.

[0045] 4.3 Occlusion Removal (Verification of Candidate Intersection Validity) Since adjacent color-changing pixels in screen space may originate from occlusion edges of the model rather than actual intersections, it is necessary to eliminate false intersections. Specifically, for two pixels that constitute candidate intersection pairs in screen space, if their reconstructed 3D coordinates... and Distance between ( If a preset error threshold is set (e.g., 0.1% of the model's bounding box size), then these two points are determined to be pseudo-intersections caused by occlusion, and they are removed from the intersection point set. Here... This represents the three-dimensional Euclidean distance.

[0046] 4.4 Calculation of barycenter coordinates The three-dimensional coordinates of the intersection point obtained in step 4.2 are projected onto a two-dimensional plane parallel to the triangular facet, eliminating errors perpendicular to the triangular facet. The intersection point is represented as the weighted sum of the three vertices of the triangle by calculating the centroid coordinates of the projected point on the triangular facet. , in, The projection point (3D coordinates) of the intersection point. These are the coordinates (3D vectors) of the three vertices of the triangular facet. Let the coordinates of the centroid of the intersection point on the triangle plane be (i.e., the weight coefficients of each vertex), satisfying... .

[0047] The coordinates of the centroid can be calculated using the area coordinate method: , in, Let be the areas of the smaller triangles formed by the intersection points and the sides of the main triangle, respectively. This represents the total area of ​​the triangular facet. The centroid coordinates indicate the relative position of the intersection point within the triangle, and can be used for subsequent Boolean operations, mesh partitioning, and other processing.

[0048] Below the formula, add: "In this embodiment, the area of ​​the triangle is calculated using the cross product of vectors:" The area of ​​the small triangle can be deduced similarly.

[0049] 4.5 Generate continuous intersection curves Connectivity analysis is performed on the reconstructed 3D intersection point set. This step provides two optional methods: (1) Connect the discrete intersection points into a continuous 3D intersection curve based on the spatial proximity relationship between points and the original pixel adjacency relationship; (2) Utilize the triangular facet pair information corresponding to the candidate intersection point pair to perform precise geometric intersection calculation on each pair of triangular facets to obtain precise intersection segments, and then connect these intersection segments into a continuous 3D intersection curve according to the spatial adjacency relationship. This method can obtain higher numerical accuracy, and is especially suitable for scenarios with extremely high requirements for intersection quality. The final intersection visualization result is as follows: Figure 3 As shown (the intersection line in the figure is highlighted in green).

[0050] In practical applications, when the intersection line of two models is obscured by themselves from certain viewpoints (for example, when a sphere intersects a cube, the intersection line may be obscured by the front surface of the sphere from a certain direction), it is difficult to obtain the complete intersection line from a single viewpoint. Therefore, this invention provides a multi-view fusion implementation method.

[0051] Specifically, in step 2, the preset camera path includes multiple different viewpoints (e.g., setting a camera position every 30 degrees around the Y-axis, for a total of 12 viewpoints). Steps 2 to 4 are repeated for each viewpoint to obtain the candidate pixel set of the intersection line under each viewpoint, and the 3D point set under each viewpoint is obtained through MVP inverse transformation. Since the point sets obtained under different viewpoints will have overlapping areas, step 4 also includes fusing the 3D point sets obtained from multiple viewpoints: first, all points are transformed to the same world coordinate system; second, duplicate points are removed by spatial mesh partitioning (e.g., the voxel size is 0.5% of the model bounding box size); finally, the connectivity analysis is re-performed on the fused point set to generate a more complete and continuous 3D intersection line curve.

[0052] This multi-view fusion strategy can overcome the occlusion problem under a single viewpoint and is suitable for intersection line extraction of complex models, such as intersection detection of internal engine parts and calculation of medical interfaces of human bones and organs.

[0053] The three-dimensional model intersection calculation method provided in this application has the advantages of fast calculation speed, strong robustness and easy implementation due to the use of GPU parallel rasterization and MVP inverse transformation.

[0054] The following describes each scene in detail with reference to the specific steps of the present invention (preprocessing, color rendering, intersection pixel extraction, MVP inverse transform restoration, centroid coordinate calculation, occlusion culling, multi-view fusion, etc.).

[0055] (1) Boolean operations in CAD software Scenario requirement: In CAD software such as SolidWorks and AutoCAD, users need to perform union, difference, or intersection operations on two solid models. The core of this is accurately calculating the intersection line between the two models, then trimming and recombining the mesh along the intersection line.

[0056] How this application scheme is applied: Step 1 (Preprocessing): Load the triangular meshes of Model A and Model B respectively, perform normal unification (ensuring all facet normals face outwards) and topology cleanup (removing duplicate vertices and zero-area faces), and construct a half-edge data structure to provide stable and non-redundant mesh data for subsequent GPU rendering and spatial reconstruction. For NURBS surfaces commonly found in CAD models, they can be discretized into triangular meshes before being input into this scheme.

[0057] Step 2 (Color Differentiation Rendering): Create an off-screen framebuffer object (FBO) in the software's graphics backend (e.g., OpenGL). Render model A as pure red (RGB:1,0,0) and model B as pure green (0,1,0). Set camera parameters: Use orthographic projection (to avoid perspective distortion), and select the camera direction in the opposite direction of the longest axis of the model's bounding box (e.g., looking down along the Z-axis) to ensure the intersection line projection area is maximized. To improve the integrity of the intersection line, multi-view blending can be enabled: render sequentially from the six directions +X, -X, +Y, -Y, +Z, and -Z, executing steps 2-4 independently for each direction.

[0058] Step 3 (Intersection Pixel Extraction): For the rendered image of each viewpoint, launch the CUDA kernel to traverse all pixels in parallel. For each pixel, check the colors of its three adjacent pixels to the right, bottom right, and bottom. Calculate the color difference ΔC. If ΔC > 0.2 (the threshold can be adjusted according to the model complexity), then mark the pixel as a candidate intersection pixel. All candidate pixels constitute the intersection pixel set for that viewpoint.

[0059] Step 4 (3D Coordinate Reconstruction): For each candidate pixel, read the normalized depth value from the depth buffer. Calculate the homogeneous coordinate scaling factor w using the formula, and then use (V) - ¹P - ¹) Matrix transformation yields world coordinates. Occlusion culling is then performed: for adjacent candidate pixels, if the reconstructed 3D spatial distance is greater than 0.5% of the model bounding box diagonal, it is considered an occluded pseudo-point and discarded. The remaining points are reliable intersection points. Centroid coordinates are used for calculation: the triangle face ID of each pixel is recorded using the FBO, the 3D point is projected onto the triangle plane, and the centroid coordinates (α1, α2, α3) are calculated using area coordinates. These centroid coordinates can be directly used for subsequent mesh trimming—for example, in the difference operation, the triangles of model B are segmented along the intersection line, and the triangles inside the intersection line are deleted.

[0060] Fusion and Output: The intersection point set obtained from the six perspectives is uniformly transformed to the world coordinate system. Duplicate points are removed by spatial grid hashing (voxel side length is set to 0.1% of the model size), and then connectivity analysis (based on KD-tree nearest neighbor search) is performed to connect them into a smooth 3D closed curve. Finally, the intersection curve is output to the CAD kernel to complete Boolean operations.

[0061] Technical benefits: Traditional geometric intersection methods take several minutes to process models with millions of faces, and are prone to broken intersection lines due to coplanarity and tiny gaps. This solution utilizes GPU parallel rendering, with a total rendering + pixel processing time of less than 0.5 seconds for six perspectives, resulting in continuous and complete intersection lines, significantly improving the CAD interactive experience.

[0062] (2) Support generation and model decomposition in 3D printing Scenario Requirements: When printing FDM 3D models, if the model has overhanging structures exceeding 45°, supports need to be added. The first step in support generation is to calculate the intersection line between the model and the support plane (usually the build platform plane) to determine the attachment profile of the support pillars. Additionally, for large models exceeding the printing area, they need to be cut into multiple pieces; the intersection line of the cut surfaces determines the segmentation boundaries.

[0063] How this application scheme is applied: Step 1 (Preprocessing): Import the model to be printed (STL format), perform normalization and topology cleanup. The support plane can be discretized into an extremely thin square flat mesh (side length greater than the model projection, thickness negligible), or the mathematical plane equations can be directly used in subsequent rendering (the plane needs to be rendered as a semi-transparent mesh). For model splitting, the user defines a cutting plane (or a more complex freeform surface), discretizes it into a fine triangular mesh as the second model.

[0064] Step 2 (Color Differentiation Rendering): Render the model in red and the supporting plane / cutting plane in blue. The camera uses orthographic projection, with its direction perpendicular to the supporting plane (e.g., downwards along the positive Z-axis). Since the supporting plane is a single facet, the intersection of the model and the plane will appear as a sudden change in color from red to blue in the rendered color image.

[0065] Step 3 (Intersection Pixel Extraction): Similar to the CAD scene, detect pixels with color abrupt changes in parallel. There is a special case here: when the model surface is almost parallel to the supporting plane (such as the bottom of the plane), the color abrupt change region may be relatively wide. Therefore, the color difference threshold can be appropriately lowered (e.g., T=0.1), and sub-pixel edge detection can be enabled: perform local gradient calculations on candidate pixel regions to refine the edges to a single pixel width.

[0066] Step 4 (3D Coordinate Reconstruction): For each intersection pixel, reconstruct the 3D coordinates using the depth value and inverse MVP transformation. Note: The support plane is a thin plate, and its depth value may fluctuate slightly; median filtering can be used for smoothing. The reconstructed 3D points are the bottom attachment points of the support pillars. Using the centroid coordinates, the precise position of each point on the model triangle can be determined, which is used to generate custom supports (such as the branching points of tree-like supports). For model splitting, the reconstructed intersection lines are the segmentation boundaries. Projecting them onto the cutting plane forms a closed contour, and then the original model is divided into two independent parts along the contour.

[0067] Technical Benefits: This solution avoids the approximate method of calculating the model's horizontal projection and then offsetting it, directly obtaining the accurate intersection contour. For complex hollow models, the accuracy of intersection calculation is improved to over 99%, and the support generation time is reduced by 80%. Multi-view fusion can be used for multi-plane cutting during model splitting, ensuring the integrity of the intersection lines of the segmented surfaces.

[0068] (3) Real-time collision detection and physics feedback in game development Scenario requirement: In action games, when a weapon (sword, bullet) hits an enemy's body, it is necessary to calculate the intersection line (i.e., cutting line) between the weapon model and the enemy model in real time to determine the hit range, damage area, and generate cutting effects (such as knife marks, bloodstains, and severed limbs).

[0069] How this application scheme is applied: Step 1 (Preprocessing): The weapon model (such as the blade) and the enemy body model (such as the torso) may change their position and pose every frame during runtime, but the mesh topology remains unchanged. Therefore, only one preprocessing step, such as normalization, needs to be performed during game loading, and the vertex positions can be directly transformed during runtime.

[0070] Step 2 (Color-Differentiated Rendering): In the game rendering thread, create an additional low-resolution rendering target (e.g., 512×512 pixels, much lower than the screen resolution, to improve speed). Render weapons as cyan and enemies as magenta. The camera uses perspective projection and shares the view frustum with the main game camera (to avoid extra calculations), but a separate orthographic camera can also be used to target the impact area. To improve performance, only the bounding box region of the injured area can be rendered (through view frustum clipping).

[0071] Step 3 (Intersection Pixel Extraction): Due to the game's requirement for extremely low latency (<5ms), this solution uses a computation shader to perform pixel detection directly on the GPU: inputting color and depth textures, and outputting a buffer storing the screen coordinates of intersection pixels. When detecting abrupt color changes in the neighborhood, a simple sum of absolute differences (SAD) is used for a fast approximation instead of Euclidean distance to reduce computation. The threshold is set to 0.3.

[0072] Step 4 (3D Coordinate Reconstruction): For each intersection pixel, quickly reconstruct the 3D point using the inverse of the view projection matrix of the current frame. Since both weapon and enemy models are dynamic, the latest MVP matrix needs to be obtained in real time. Perform occlusion culling: If the distance between the reconstructed 3D points of adjacent pixels is greater than twice the weapon thickness, it is considered to be due to a depth fracture caused by the weapon part behind the enemy and should be culled. The remaining set of points is the valid intersection line. Finally, a continuous curve is generated through connectivity analysis. The game engine calculates the damage coefficient based on the length and number of points of the intersection line (e.g., line length > 10cm triggers a critical hit effect) and generates a particle system (bloodstains, sparks) at the intersection line location. To achieve dynamic cutting, the intersection line can be accurately mapped onto the triangle of the enemy model using the centroid coordinate information, cutting the mesh in real time and generating the fracture surface.

[0073] Technical Effects: Traditional physics engines can only return a single collision point or a simple normal, failing to obtain a complete contact curve. This solution provides rich intersection geometry information, enabling realistic blade marks and cutting effects in games, with a single-frame processing time controlled within 3-5ms (512×512 resolution), meeting the 60fps requirement.

[0074] (4) Organ segmentation and surgical planning in medical image processing Scenario requirement: In preoperative planning, surgeons need to determine the interface between the tumor and surrounding normal organs (such as liver tumors and liver, brain tumors and brain tissue) in order to design the resection range. The three-dimensional organ model reconstructed by CT or MRI is usually a high-precision triangular mesh (millions of faces).

[0075] How this application scheme is applied: Step 1 (Preprocessing): Load the tumor mesh and organ mesh, and perform normalization. Medical models often contain small fragmented surfaces or self-intersections, requiring topology cleaning (e.g., using Blender's repair tool). Construct a half-edge data structure for subsequent centroid coordinate lookup.

[0076] Step 2 (Color Differentiation Rendering): Create an off-screen renderer on the professional graphics card of the medical imaging workstation. Tumors are rendered in red, and organs are rendered in semi-transparent green (semi-transparency aids in visual verification, but intersection detection is still based on opaque color markings; semi-transparency is only for display). Since organs and tumors may be completely enclosed or partially enclosed, occlusion is inevitable from a single viewpoint; therefore, multi-view fusion must be used. Preset camera path: around the model center, with a fixed elevation angle of 30° and an azimuth angle of one viewpoint every 30°, for a total of 12 views. Each viewpoint is rendered independently.

[0077] Step 3 (Intersection Pixel Extraction): For each viewpoint image, CUDA is used to detect color abrupt changes in parallel. To improve the sub-pixel accuracy of medical intersections, after detecting candidate pixels, a second interpolation (Sobel gradient combined with bilinear interpolation) can be performed in the local region to refine the intersection position to the sub-pixel level.

[0078] Step 4 (3D Coordinate Reconstruction): A set of 3D points is reconstructed for each viewpoint. All 12 viewpoint point sets are unified to the world coordinate system, and duplicate points are removed using voxel filtering (voxel size is set to the spatial dimensions corresponding to the image resolution, e.g., 1mm). Connectivity analysis is then performed to generate the intersection line (i.e., the interface contour) of a closed triangular mesh surface. Using barycentric coordinates, the intersection points can be precisely mapped onto the triangles of the organ model, thus generating a smooth cutting surface. This intersection surface is output to the surgical navigation system, allowing doctors to visually observe the relative positions of tumors, blood vessels, and nerves in AR / VR.

[0079] Technical Results: Traditional medical image segmentation typically relies on voxel-level thresholding or region growing, making it difficult to accurately extract the intersection lines of surfaces. This solution directly calculates the intersection lines on a high-precision mesh, and multi-view fusion completely solves the problem of internal organ occlusion. The computation time (12 views, 1024×1024 resolution per view) is approximately 2 seconds, far faster than manual delineation. Test cases have verified that the intersection line error is less than 0.2mm.

[0080] (5) Workpiece grasping and collision avoidance in robot vision Scenario requirements: When an industrial robot grasps a workpiece, it is necessary to calculate the intersection line between the robotic arm (gripper) and the workpiece to determine whether penetration or interference occurs; in addition, it is also necessary to calculate the intersection line between the robotic arm and surrounding obstacles for obstacle avoidance.

[0081] How this application scheme is applied: Step 1 (Preprocessing): Load the robot model (especially the gripper) and the workpiece model (reconstructed in real-time by a 3D vision sensor). Since the workpiece position may change every frame, but the model itself is static, preprocessing only needs to be performed once. For the incomplete mesh reconstructed in real-time by the sensor, smoothing and hole filling are required before input.

[0082] Step 2 (Color Differentiation Rendering): Use a virtual camera integrated with the robot control system, whose intrinsic and extrinsic parameters are calibrated to match the observation camera in the actual scene. Render the robotic arm in blue and the workpiece in orange. Since robot control is extremely sensitive to latency (<10ms), the rendering resolution can be reduced to 640×480, and anti-aliasing can be turned off. The camera can be set to perspective projection with a 60° field of view.

[0083] Step 3 (Intersection Pixel Extraction): Use a lightweight pixel comparison kernel function on the GPU to compare only the right and bottom directions (saving approximately 30% of computation). Set the threshold to 0.2. Simultaneously, perform a fast depth consistency check: if a pixel is marked as a candidate but its neighborhood depth difference is too large (>0.1 times the far plane), skip it to reduce occlusion misjudgments.

[0084] Step 4 (3D Coordinate Reconstruction): For each valid candidate pixel, a 3D point is obtained through inverse transformation using the known view projection matrix. These points represent the contact line between the gripper and the workpiece. If the contact line length exceeds a threshold (e.g., 2cm), it indicates that the gripper has penetrated the workpiece, and the system issues a warning and stops moving. For obstacle avoidance, the intersection line between the robot and the obstacle is calculated; if the intersection line exists, an emergency stop is triggered. Simultaneously, the intersection point can be projected onto the robot's motion plane to correct the path in real time.

[0085] Technical Results: This solution runs entirely on the GPU, with a single-frame processing time of <5ms (640×480 resolution), meeting the real-time requirements of high-speed sorting robots. Compared to traditional bounding box-based coarse collision detection, this solution provides accurate penetration depth and location information, enabling flexible grasping and adaptive obstacle avoidance.

[0086] (6) Fluid-solid interaction in film and television special effects Scenario Requirements: In film special effects, the interaction between water flow and rocks, and between waves and ship hulls, is frequently simulated. Each frame, a new triangular mesh (representing the water surface) is generated through physical simulation. The intersection of the water surface mesh and the solid mesh needs to be calculated to determine the location and intensity of water splashes.

[0087] How this application scheme is applied: Step 1 (Preprocessing): The solid model (rock, hull) is static and only requires one preprocessing step. The water surface mesh is regenerated every frame, but the topology is similar, so simple normal unification can be performed every frame (water surface mesh normals facing upwards).

[0088] Step 2 (Color-Differentiated Rendering): For performance reasons, only the water surface mesh can be rendered, while the solid mesh serves as a reference depth (it doesn't display color but participates in the depth buffer). A more general approach is to render the water surface as cyan and the solid mesh as brown. The camera is set to perspective projection, following the viewpoint of the splashing water (e.g., the bow of a ship). Due to the drastic changes in the water surface mesh, offline multi-view fusion is not suitable; therefore, a dynamic single-view is used, but some visibility of intersection lines is provided by relying on the refraction and reflection of light on the water surface itself.

[0089] Step 3 (Intersection Pixel Extraction): Similar to the game scene, quickly detect color abrupt changes. To capture subtle wave edges, the rendering resolution can be increased to 1920×1080, and the threshold can be set as low as 0.1.

[0090] Step 4 (3D Coordinate Reconstruction): For each intersection pixel, reconstruct the 3D point. Since there may be multiple overlapping layers at the intersection of the water surface and the solid (the water surface may be above or below the solid), occlusion culling is required: retain the intersection point closest to the camera. The reconstructed point set generates a series of curve segments through connectivity analysis. These curve segments are passed to the particle system, generating different numbers and sizes of water splash particles based on the curve length and curvature. The particle emission direction is the curve normal direction (obtained by calculating the cross product of the triangular face normal using the barycentric coordinates).

[0091] Technical Effects: In traditional special effects production, water splash generation is usually based on random areas or manually placed emitters, lacking realistic interaction with geometry. This solution automatically and in real-time calculates precise contact lines, making the water splash effect more natural and realistic. The single-frame calculation time is approximately 15ms (1920×1080), which can meet the needs of offline rendering or real-time preview.

[0092] In the specific implementation of each of the above scenarios, the core steps of this invention are followed, and parameters such as rendering resolution, threshold, and number of viewpoints are adjusted according to the characteristics of the scenario. Those skilled in the art should understand that these examples do not limit the scope of protection of this invention; all scenarios that utilize the method of this invention for calculating the intersection lines of 3D models fall within the scope of protection of the claims of this invention.

[0093] To more clearly illustrate the technical solution of the present invention and to ensure that those skilled in the art can implement the present invention based on the documents in this application, a complete numerical implementation example from input to output is provided below.

[0094] Calculate the intersection of a sphere model and a cube model.

[0095] Sphere model: The center of the sphere is located at the world coordinate origin (0,0,0), and the radius R=1.0. The triangular mesh contains approximately 5000 triangles, and the vertex coordinates satisfy x²+y²+z²=1.

[0096] Cube model: Centered at world coordinates (0,0,0.5), side length L=2.0, i.e., x∈[-1,1], y∈[-1,1], z∈[0,1]. The triangular mesh contains 12 triangles (two triangles per face).

[0097] Given that the true intersection of two models lies on a circle in the z=0.5 plane, with center (0,0,0.5) and radius [missing information]. .

[0098] Step 1 – Model Preprocessing: Load the STL files of both models, perform normalization and topology cleanup, and remove duplicate vertices (tolerance 1e-6, i.e., distance less than 10). 6 (The vertices are considered repeated) and degenerate triangles. Construct a half-side data structure. After preprocessing, the sphere has approximately 2502 vertices and the cube has 8 vertices.

[0099] Step 2 – Color Differentiation Rendering: An off-screen FBO is created using OpenGL at a resolution of 1920×1080. The sphere is rendered as pure red (1,0,0), and the cube as pure green (0,1,0). Camera parameters: viewpoint (5,5,5), target point (0,0,0.25), up direction (0,1,0); perspective projection, near clipping plane 0.1, far clipping plane 10.0. This calculation is performed in detail using the first viewpoint (azimuth angle 45°).

[0100] Step 3 – Intersection Pixel Extraction: At screen coordinates (960, 540), the current pixel color is (1, 0, 0), and the right pixel color is (0, 1, 0) at (961, 540). Calculate... Pixels larger than the threshold of 0.2 were marked as candidate pixels. Approximately 1800 candidate pixels were detected in total.

[0101] Step 4 – 3D coordinate reconstruction (taking (960, 540) as an example): Depth value: =0.65.

[0102] Screen coordinates to clip space: x_ndc=2 960 / 1920-1=0, y_ndc=2 540 / 1080-1=0, z_clip=2 0.65-1=0.3.

[0103] Calculate w: w=(2×0.1×10) / (10+0.1-(2×10-0.1)×(2×0.65-1))=2.0 / (10.1-19.9×0.3)=2.0 / 4.13≈0.484.

[0104] Inverse MVP Transformation: Based on the aforementioned camera parameters (viewpoint, target point, near and far clipping planes, etc.), those skilled in the art can construct the corresponding projection matrix P and view matrix V, and calculate their inverse matrices. Multiply the clip space homogeneous coordinates (0.0, 0.0, 0.3, 0.484) by the left. You can then obtain the world coordinates (0.866, 0.000, 0.500).

[0105] Occlusion culling: adjacent pixel pairs with a distance of 0.0096 < ε = 0.05 are retained.

[0106] Centroid coordinates: corresponding to the triangle vertices (0.860, 0.020, 0.510), (0.870, -0.010, 0.495), (0.850, 0.015, 0.505), the centroid coordinates are calculated to be (0.42, 0.35, 0.23).

[0107] Connectivity analysis: Connect all candidate points according to their adjacency to obtain a closed curve.

[0108] Multi-view fusion (optional): Four views are calculated separately around the Y-axis at 90° intervals, resulting in a fused point set of approximately 2000 points, completely covering the circular intersection line. Results validation: The average radius of the intersection line points is 0.8665, the standard deviation is 0.0021, and the length is 5.443, consistent with theoretical values. Single-view fusion takes approximately 3.3ms, and the total time for four-view fusion is less than 20ms, a 17-fold improvement over traditional geometric methods (approximately 350ms).

[0109] Through the detailed numerical calculations above, those skilled in the art can clearly understand the specific implementation of each step of the present invention, and can apply the present invention to various practical scenarios without creative effort.

[0110] Based on the same inventive concept, this invention also provides a three-dimensional model intersection line extraction device based on MVP inverse transform, comprising: The preprocessing module is used to preprocess the input 3D mesh model and construct a standardized mesh data structure. The rendering module is used to assign different color labels to different 3D models through the graphics rendering interface, project multiple models onto the screen space using rasterization rendering, and scan the rendering results according to a preset viewpoint or path. The pixel extraction module is used to perform pixel-level analysis on the rendered color image, detect areas where color changes occur between adjacent pixels, identify and extract pixels with color changes as candidate pixels for intersection lines. The coordinate restoration module is used to restore the intersection candidate pixels to three-dimensional spatial coordinates based on their two-dimensional positions in screen space and their corresponding depth values, using the inverse transformation of model-view-projection transformation, to obtain the intersection point set or continuous curve of the three-dimensional model.

[0111] The coordinate restoration module is also used to: determine the triangular mesh surface where the candidate pixel of the intersection line is located, and calculate the centroid coordinate representation of the intersection point on the triangular mesh surface.

[0112] The specific working principles of each module correspond one-to-one with the aforementioned method steps, and will not be repeated here. This device can be integrated into graphics workstations, game consoles, or any device with GPU computing capabilities.

[0113] The present invention also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the methods described in any of the preceding claims. The storage medium may be ROM, RAM, magnetic disk, optical disk, or any other form of non-transitory computer-readable medium.

[0114] This invention transforms the three-dimensional geometric intersection problem into color abrupt change detection and depth inversion in image space, making full use of the parallel rasterization capability and depth buffer information of the GPU, and has the following significant advantages: Efficiency: It avoids the O(NlogN) or even O(N²) triangle pair traversal in traditional methods. The computational complexity is only related to the screen resolution, making it particularly efficient for complex models.

[0115] Robustness: It does not rely on precise floating-point geometric calculations and is naturally immune to numerically sensitive conditions such as coplanarity, tangency, and minor degradation. The intersection line is topologically complete and continuous.

[0116] Ease of implementation: Based on standard graphics pipelines, no need to customize complex geometric data structures, and easy to integrate into existing software.

[0117] Rich output: It can simultaneously obtain the 3D point set of the intersection line, the continuous curve, and the centroid coordinates, directly supporting downstream CAD operations (such as Boolean operations and mesh division).

[0118] Multi-view integrity: By fusing multiple views, the occlusion problem under a single view is solved, ensuring that the intersection lines of complex models are extracted completely.

[0119] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for extracting intersection lines of a 3D model based on MVP inverse transform, characterized in that, Includes the following steps: The input 3D mesh model is preprocessed to construct a standardized mesh data structure; Different color identifiers are assigned to different 3D models through the graphics rendering interface. Multiple models are projected onto the screen space using rasterization rendering and the rendering results are scanned according to a preset viewpoint or path. Pixel-level analysis is performed on the rendered color image to detect regions where color changes occur between adjacent pixels. Pixels with color changes are identified and extracted as candidate pixels for intersection lines. Based on the two-dimensional position of the candidate pixels of the intersection line in screen space and their corresponding depth values, the candidate pixels of the intersection line are restored to three-dimensional spatial coordinates by using the inverse transformation of model-view-projection transformation, so as to obtain the intersection point set or continuous curve of the three-dimensional model.

2. The method according to claim 1, characterized in that, When assigning color identifiers to different 3D models through the graphics rendering interface, the assigned color identifiers are all different single pure colors, so that the pixel colors corresponding to different models have distinguishable differences in the color channels.

3. The method according to claim 1, characterized in that, When detecting regions where color changes abruptly between adjacent pixels, the color difference between the current pixel and at least one neighboring pixel is compared. When the color difference exceeds a preset threshold, the current pixel is determined to be a candidate pixel for the intersection line.

4. The method according to claim 3, characterized in that, The neighboring pixels include adjacent pixels in at least one of the following directions: right, lower right, and lower.

5. The method according to claim 1, characterized in that, The depth value is obtained from the depth buffer generated during the graphics rendering process, and the depth value represents the distance of the scene point corresponding to the pixel relative to the viewpoint.

6. The method according to claim 1, characterized in that, After restoring the three-dimensional coordinates using inverse transformation, the process also includes connectivity analysis of the restored three-dimensional point set to generate continuous three-dimensional intersection curves.

7. The method according to claim 1, characterized in that, After obtaining the three-dimensional spatial coordinates, the process also includes: determining the triangular mesh surface where the candidate pixels of the intersection line are located, and calculating the centroid coordinate representation of the intersection point on the triangular mesh surface.

8. The method according to claim 1, characterized in that, After obtaining the restored three-dimensional spatial coordinates, the validity of the candidate intersection points is verified: if the distance between the restored three-dimensional spatial coordinates of two candidate intersection points corresponding to the same intersection line exceeds the preset error range, the two points are determined to be occluded rather than truly intersecting, and they are removed from the intersection point set.

9. The method according to claim 1, characterized in that, The preset viewpoint or path includes multiple different viewpoint directions; the steps of assigning different color labels to different 3D models through the graphics rendering interface, performing pixel-level analysis on the rendered color image, and restoring 3D coordinates using inverse transformation are performed on each viewpoint to obtain a set of candidate pixels for intersection lines under each viewpoint. Furthermore, restoring the candidate pixels of the intersection line to three-dimensional spatial coordinates also includes fusing the three-dimensional point sets obtained from multiple perspectives to generate a complete three-dimensional intersection line curve.

10. A device for extracting intersection lines of a three-dimensional model based on MVP inverse transform, characterized in that, include: The preprocessing module is used to preprocess the input 3D mesh model and construct a standardized mesh data structure. The rendering module is used to assign different color labels to different 3D models through the graphics rendering interface, project multiple models onto the screen space using rasterization rendering, and scan the rendering results according to a preset viewpoint or path. The pixel extraction module is used to perform pixel-level analysis on the rendered color image, detect areas where color changes occur between adjacent pixels, identify and extract pixels with color changes as candidate pixels for intersection lines. The coordinate restoration module is used to restore the intersection candidate pixels to three-dimensional spatial coordinates based on their two-dimensional positions in screen space and their corresponding depth values, using the inverse transformation of model-view-projection transformation, to obtain the intersection point set or continuous curve of the three-dimensional model.