A method, apparatus, electronic device, and storage medium for fast calculation of the directed distance field from point cloud to STL mesh of blood vessel wall.
By using a non-recursive binary tree traversal algorithm that generates the tree on the CPU and sends it to the GPU, the directed distance calculation from the point cloud to the STL mesh of the blood vessel wall is optimized, solving the problem of high computational complexity in the existing technology and realizing efficient biomechanical analysis.
Patent Information
- Application Number
- CN202610173133.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-06
- Publication Date
- 2026-05-26
AI Technical Summary
Calculating the directed distance field from point cloud to STL mesh of blood vessel wall is highly complex, and existing algorithms are inefficient, making it difficult to meet the needs of medical image analysis and biomechanical computation.
A non-recursive binary tree is constructed, tree nodes are stored in a linear array, and the binary tree is generated on the CPU and then sent to the GPU for multi-threaded traversal. Combined with memory pre-allocation and non-recursive traversal algorithms, the directed distance calculation from point cloud to blood vessel wall STL mesh is optimized.
It significantly improves the computational efficiency of the directed distance field from point cloud to blood vessel wall STL mesh, enabling fast computation and efficient biomechanical analysis.
Smart Images

Figure CN122089832A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical image processing, specifically relating to a fast calculation method, device, electronic device, and storage medium for the directed distance field from point cloud to STL mesh of blood vessel wall. Background Technology
[0002] Extracting and constructing STL meshes of blood vessels from 3D medical images is a routine operation in medical image analysis. However, STL meshes are surface meshes, and dynamic analysis of blood and blood vessels requires volume meshes inside the blood vessels or a large number of particles filling the blood vessels. To obtain the volume mesh or filling particles, it is necessary to calculate the directed distances from the spatial point cloud to the blood vessel wall. Since the distance from each point to the blood vessel wall is the minimum of its distances to all triangular units in the blood vessel STL mesh, and the number of triangular units is enormous, calculating the directed distance from a single point to the blood vessel wall is already quite complex and requires the design of special algorithms. Therefore, the computational complexity of the directed distance field from all points in the point cloud to the blood vessel wall needs to be increased by several orders of magnitude. It is necessary to reconstruct and optimize the algorithm based on the single-point directed distance algorithm and implement the algorithm on high-performance heterogeneous computing devices such as GPUs. Summary of the Invention
[0003] This invention addresses the problems existing in the prior art by providing a method, apparatus, electronic device, and storage medium for rapid calculation of the directed distance field from point cloud to blood vessel wall STL mesh. This method can achieve rapid calculation of the directed distance field from spatial point cloud to blood vessel wall, improve the generation speed of spatial mesh or spatial particles, and enhance the efficiency of biodynamic analysis.
[0004] To address the above technical problems, this invention provides the following technical solution: a fast method for calculating the directed distance field from a point cloud to a blood vessel wall STL mesh, comprising the following steps:
[0005] S1. Read the STL file of the blood vessel wall and establish vertex and triangular unit indices;
[0006] S2, Calculate the pseudo-outer normal of the triangular element;
[0007] S3. Design a directed distance algorithm from any point in the design space to an STL mesh, including data structures and calculation methods;
[0008] S4. Improvement and deployment of the algorithm on GPU devices: On the CPU side, a binary tree linear array with stack depth is constructed and recorded in a non-recursive manner. After being transferred to the GPU, the GPU memory is pre-allocated according to the stack depth and a multi-threaded non-recursive traversal is started. At the same time, the distance calculation from the point to the triangular unit is performed.
[0009] S5. Apply the single-point directed distance algorithm to the directed distance field of large-scale point cloud to blood vessel wall STL mesh.
[0010] Furthermore, the aforementioned step S1 includes the following sub-steps:
[0011] S101. Read the STL file of the blood vessel wall to obtain the vertex coordinate array of each triangular unit, arranged in the inherent order of the file;
[0012] S102. Remove duplicate coordinates, reorder the vertices to obtain the vertex index sequence and the triangular unit index sequence corresponding to the vertex indexes.
[0013] Furthermore, in the aforementioned step S3, the data structure is to construct a binary tree, classifying the triangular units of the STL mesh level by level. Each level corresponds to a node in the binary tree, containing a portion of the triangular units of the STL mesh. Each node has two child nodes, left and right. The left and right child nodes divide the set of triangular units corresponding to the current node into two subclasses. Each subclass can define a minimum sphere containing its corresponding set of triangular units.
[0014] Furthermore, in the aforementioned step S3, each node of the binary tree contains four pieces of information: a left pointer—pointing to the left child node, a left sphere—recording the center coordinates and radius of the left subclass, a right pointer—pointing to the right child node, and a right sphere—recording the center coordinates and radius of the right subclass.
[0015] Furthermore, in the aforementioned fast calculation method for the directed distance field from the point cloud to the STL mesh of the blood vessel wall, if the node is a leaf node, its left pointer is set to null, and its right pointer points to the unique triangular unit corresponding to the subclass.
[0016] Furthermore, step 3 described above includes the following sub-steps:
[0017] S301, Set the distance from the point to the STL grid to infinity, i.e. ,
[0018] S302. Traverse the binary tree starting from the root node;
[0019] S303. If the current node is not a leaf node, calculate the distance from the point to the left sphere of the current node. and the distance from the point to the right sphere of the previous node. ;like Then, the following two conditional operations will be executed sequentially: when Continue traversing the left child node of the current node, when Continue traversing the right child nodes of the current node;
[0020] like Then, the following two conditional operations will be executed sequentially: when Continue traversing the right child nodes of the current node, when... Continue traversing the left child nodes of the current node;
[0021] If the current node is a leaf node, calculate the distance from the node to the triangular unit corresponding to its right child. ,like Then update And record the current triangular unit. The closest unit at present;
[0022] After completing the binary tree traversal, based on the triangular unit... The pseudo-outer normal is used to determine whether the point is located inside or outside the STL mesh, and the directed distance is obtained as the directed distance from the point to the STL mesh.
[0023] Furthermore, step S4 described above specifically involves: storing binary tree nodes using a linear array; constructing the binary tree on the CPU using a non-recursive method, while simultaneously recording the stack depth required for traversing the binary tree; sending the binary tree node array to the GPU; designing the GPU memory space required for multi-threaded binary tree traversal according to the stack depth; sending the vertex index, triangular unit index, and pseudo-outer normal of the triangular unit to the GPU; and designing a non-recursive binary tree traversal program and a distance calculation program from a spatial point to a specified triangular unit on the GPU.
[0024] Another aspect of the present invention provides an electronic device, comprising:
[0025] Memory, which stores computer-readable instructions;
[0026] The processor reads computer-readable instructions stored in the memory to execute the fast calculation method for the directed distance field from the point cloud to the STL mesh of the blood vessel wall as described in the present invention.
[0027] The present invention also provides a computer-readable storage medium storing computer-readable instructions, which, when executed by a computer's processor, cause the computer to perform the fast calculation method for the directed distance field from the point cloud to the STL mesh of the blood vessel wall as described in the present invention.
[0028] Compared with the prior art, the beneficial technical effects of the present invention using the above technical solution are as follows:
[0029] The fast computation method for the directed distance field from point cloud to blood vessel wall STL mesh provided in this application starts with the directed distance from a single point to the blood vessel wall STL mesh. It transforms the calculation of the directed distance from a single point to the STL mesh into a binary tree traversal. The binary tree is constructed non-recursively, tree nodes are stored using a linear array, and the depth of the auxiliary stack is estimated, allowing the binary tree generated on the CPU to be directly sent to the GPU for use. When performing binary tree search on the GPU, the non-recursive traversal method strictly controls memory overhead. When performing threaded search, the GPU-side algorithm achieves near-linear scalability, significantly improving the computational efficiency of the directed distance field from point cloud to blood vessel wall STL mesh. Attached Figure Description
[0030] Figure 1 This is a schematic diagram illustrating the application environment of the technical solution provided in one embodiment of this application.
[0031] Figure 2 This is a flowchart of a fast calculation method for the directed distance field from point cloud to blood vessel wall STL mesh provided in an embodiment of this application.
[0032] Figure 3 This is a structural block diagram of a device for rapidly calculating the directed distance field from point cloud to blood vessel wall STL mesh, provided in an embodiment of this application.
[0033] Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application.
[0034] Figure 5 This is a schematic diagram illustrating the calculation of the pseudo-outer normal of the triangular element in this application.
[0035] Figure 6 The figure shows the distribution of blood vessels inside and outside the vessel obtained by the method of this application. In the figure, (a) is a schematic diagram of the STL grid of the blood vessel, (b) is a schematic diagram of the particles inside the blood vessel, and (c) is a schematic diagram of the particles outside the blood vessel. Detailed Implementation
[0036] To better understand the technical content of the present invention, specific embodiments are described below in conjunction with the accompanying drawings.
[0037] In this invention, various aspects of the invention are described with reference to the accompanying drawings, in which numerous illustrative embodiments are shown. Embodiments of the invention are not limited to those depicted in the drawings. It should be understood that the invention is implemented through any of the various concepts and embodiments described above, as well as the concepts and embodiments described in detail below, because the concepts and embodiments disclosed herein are not limited to any particular implementation. Furthermore, some aspects of the invention disclosed may be used alone or in any suitable combination with other aspects of the invention disclosed.
[0038] Figure 1 This is a schematic diagram illustrating the application environment of the technical solution provided in one embodiment of this application. The environment includes a network 110 and a computer device 120. The network 110 can be a communication medium of various connection types capable of providing communication links between servers 120, such as a wired communication link or a wireless communication link. The computer device 120 can be a server, a server cluster, or other device with computing capabilities, and is not specifically limited here.
[0039] Figure 2 This is a flowchart illustrating a fast method for calculating the directed distance field from a point cloud to a blood vessel wall STL mesh, according to an embodiment of this application. Specific steps include:
[0040] S1. Read the vessel wall STL file and establish vertex and triangular unit indices. Specifically, read the coordinates of each vertex sequentially according to the order of the triangular units in the vessel wall STL file, and number each vertex according to the reading order. Sort the sequence of tuples consisting of vertices and vertex numbers in ascending order of vertex coordinates. At this point, duplicate vertex coordinates in the new sequence have been grouped together. Number the vertices in the new sequence a second time in ascending order, where vertices with duplicate coordinates have the same second number value. The deduplicated second number and its corresponding vertex coordinate are now the vertex index. Perform a second sorting on the sequence of tuples consisting of vertices, vertex numbers, and vertex second numbers in ascending order of vertex numbers. The vertex coordinates return to their original order, and the vertex number is now the triangular unit index.
[0041] S2, such as Figure 5 As shown, the pseudo-outer normal of a triangular element is calculated. Specifically, a triangular element should only have a definite outer normal, and at any point in space... The distance to a certain triangular element is closely related to the outward normal of that triangular element, that is, when point... When the projection of the plane containing the triangular element lies inside the triangular element, its distance to the triangular element is equal to... The distance to its own projection. However, due to the point shown in the figure below... In the triangular unit The projection of the plane must fall on one of the seven regions from region I to region VII. When the projection falls on region II-region IV, the point... To the triangular unit For point The distance to the edge; at this point, the edge needs to be defined. , as well as The pseudo-outer normal; when the projection falls on region V-region VII, point To the triangular unit For point The distance to the vertex; at this point, the vertex needs to be defined. , , The pseudo-outer normal is defined as the normalized unit vector of the sum of the outer normals of the two triangular elements containing the edge, since the STL mesh of the blood vessel is strictly closed and each edge is shared by two triangular elements. Similarly, since vertices of the blood vessel STL mesh are shared by multiple triangular elements, the pseudo-outer normal of a vertex is defined as the normalized unit vector of the weighted average sum of the outer normals of all the triangular elements containing the vertex, where the weights are the angle values in the triangular element corresponding to the vertex.
[0042] S3. Design a directed distance algorithm from any point in space to an STL mesh, including the data structure and calculation method. The data structure is a binary tree that classifies the triangular cells of the STL mesh level by level. Each level corresponds to a node in the binary tree, containing a subset of the triangular cells of the STL mesh. Each node has two child nodes, left and right. The left and right child nodes divide the set of triangular cells corresponding to the current node into two subclasses. Each subclass can define a minimum sphere containing its corresponding set of triangular cells.
[0043] Specifically, starting from the root node, the binary tree and its generation algorithm are designed according to recursive logic. First, the triangular units are numbered, and a sequence of tuples, Triangle, consisting of the triangular units and their numbers, is constructed as an auxiliary array. The binary tree generation function is denoted as:
[0044] Tree_generation(Node, Sphere, Triangle, head, tail)
[0045] Here, Node is a node of the binary tree, which stores the left sphere (Node.Sphere_l), right sphere (Node.Sphere_l), left pointer (Node.ptr_l), and right pointer (Node.ptr_r) corresponding to the node; Sphere is the sphere structure to be calculated passed to the generator function; Node corresponds to all triangular units numbered from head to tail-1.
[0046] When tail – head > 1, calculate the geometric center of all triangular units corresponding to the Node, and use it as the center of the Sphere; calculate the distance from all vertices of all triangular units corresponding to the Node to the center of the Sphere, and take the shortest distance as the radius of the Sphere. Compare the spans of all triangular units corresponding to the Node in the x, y, and z coordinate dimensions, and sort the [head, tail-1] segment of the Triangle array from smallest to largest according to the dimension with the smallest span. Take middle = (head + tail) / 2 as the dividing line between the left and right classes. Generate the left node Node_l, and set Node.ptr_l to point to Node_l, and then recursively call the function:
[0047] Tree_generation(Node_l, Node.Sphere_l, Triangle, head, mid). Generates the right node Node_r, sets Node.ptr_r to point to Node_r, and then recursively calls the function:
[0048] Tree_generation(Node_r, Node.Sphere_r, Triangle, mid, tail).
[0049] Each node in a binary tree contains four pieces of information: a left pointer pointing to the left child node, a left sphere recording the center coordinates and radius of the left child node, a right pointer pointing to the right child node, and a right sphere recording the center coordinates and radius of the right child node. If the node is a leaf node, its left pointer is set to null, and its right pointer points to the unique triangular unit corresponding to its child node.
[0050] Preferably, step 3 includes the following sub-steps:
[0051] S301, Set the distance from the point to the STL grid to infinity, i.e. ,
[0052] S302. Traverse the binary tree starting from the root node;
[0053] S303. If the current node is not a leaf node, calculate the distance from the point to the left sphere of the current node. and the distance from the point to the right sphere of the previous node. ;like Then, the following two conditional operations will be executed sequentially: when Continue traversing the left child node of the current node, when Continue traversing the right child nodes of the current node;
[0054] like Then, the following two conditional operations will be executed sequentially: when Continue traversing the right child nodes of the current node, when... Continue traversing the left child nodes of the current node;
[0055] If the current node is a leaf node, calculate the distance from the node to the triangular unit corresponding to its right child. ,like Then update And record the current triangular unit. The closest unit at present;
[0056] After completing the binary tree traversal, based on the triangular unit... The pseudo-outer normal is used to determine whether the point is located inside or outside the STL mesh, and the directed distance is obtained as the directed distance from the point to the STL mesh.
[0057] S4. Algorithm Improvement and Deployment on GPU Devices: On the CPU side, a binary tree linear array with stack depth is constructed and recorded in a non-recursive manner. After being transferred to the GPU, GPU memory is pre-allocated according to the stack depth and multi-threaded non-recursive traversal is started, while single-point directed distance calculation is performed.
[0058] To achieve parallel computation from point cloud to STL mesh of blood vessel wall, a binary tree must be constructed on the GPU, and the traversal algorithm must be performed on the GPU. Since the GPU's global memory is only suitable for storing linear arrays, the nodes of the binary tree need to be stored as one-dimensional arrays. Here, each node stores the array indices (index_l, index_r) of the left and right spheres. Furthermore, the GPU can only implement recursive calls through dynamic parallelism, but dynamic parallelism is inefficient and has a huge implicit memory overhead. Therefore, in terms of algorithm structure, the generation and traversal of the binary tree are implemented non-recursively. Specifically, an auxiliary stack is first applied on the CPU to generate the binary tree non-recursively and record the stack depth. Then, the binary tree nodes stored as one-dimensional arrays are sent to the GPU for later use. The improved algorithm is as follows:
[0059] First, number the triangular elements, construct a binary tuple sequence Triangle consisting of triangular elements and their numbers as an auxiliary array, and set a root sphere Sphere_root. Secondly, initialize the node array Nodal of the binary tree, preset the length of the node array to Nodal_length = 1024, and set the current node index to Nodal_index = 0. Then initialize the auxiliary stack stack. Each element of the auxiliary stack is a five-tuple, namely 1) pre_index: the general array index of the parent node. When pre_index = 0, the current node is the root node. When pre_index < 0, the current node is the left child node of the parent node, and the actual index of the parent node is -pre_index - 1. When pre_index > 0, the current node is the right child node of the parent node, and the actual index of the parent node is pre_index - 1. 2) index: the array index of the current node. 3) head: the starting number of the triangular element corresponding to the current node. 4) tail: the termination number of the triangular element corresponding to the current node + 1. 5) tag: the traversal auxiliary tag. Store the auxiliary stack in a one-dimensional array, and preset the length of the stack array to stack_length = 64. The first element of the auxiliary stack is: stack[0].pre_index = 0, stack[0].index = 0, stack[0].head = 0, stack[0].tail = the total number of triangular elements, stack[0].tag = 0. Set the initial stack depth to depth = 0 and the maximum stack depth to max_depth = 0;
[0060] When depth is less than 0, enter the loop body:
[0061] If max_depth < depth, then update max_depth = depth.
[0062] If stack[depth].tag = 2, then pop the current element and depth--.
[0063] If stack[depth].tag < 2 and stack[depth].tail - stack[depth].head = 1, then the current node is a leaf node. Set the index of the left child node of the current node to -1, and set the index of the right child node of the current node to the number of Triangle[stack[depth].head]. Calculate the centroid and circumcircle radius of the triangular element corresponding to this number. Based on the value of the generalized index of the parent node, determine whether the current node is the left or right child node of the parent node, and write the centroid coordinates and circumcircle radius into the left or right sphere of the parent node of the current node accordingly. Then set stack[depth].tag = 2.
[0064] If `stack[depth].tag=0`, then based on the value of the parent node's generalized index, determine whether the current node is the left or right child of the parent node, and calculate the geometric center of all triangular units corresponding to the current node as the left or right sphere center of the parent node. Calculate the distance from all vertices of all triangular units corresponding to the current node to the aforementioned sphere center, and take the shortest distance as the radius of the left or right sphere of the parent node. Compare the spans of all triangular units corresponding to the current node in the x, y, and z coordinate dimensions, and sort the `[stack[depth].head, stack[depth].tail-1]` segments of the `Triangle` array from smallest to largest according to the dimension with the smallest span. Take `middle = (stack[depth].head + stack[depth].tail) / 2` as the dividing line between the left and right classes. Let `Nodal_index = Nodal_index + 1`, and set it as the index of the left child node of the current node: `Nodal[stack[depth]].index_l = Nodal_index`. When the node array is insufficient, its length is doubled and updated accordingly. The left child node information is pushed onto the auxiliary stack `depth++`, and when the auxiliary stack array is insufficient, its length is doubled and updated accordingly. The new element pushed onto the stack is set as follows: `stack[depth].pre_index = -stack[depth-1].index-1`, `stack[depth].index = Nodal_index`.
[0065] stack[depth].head=stack[depth-1].head,
[0066] stack[depth].tail=middle,
[0067] stack[depth].tag=0. Update the auxiliary tag of the current node stack[depth-1].tag=1.
[0068] If `stack[depth].tag=1`, then `middle = (stack[depth].head + stack[depth].tail) / 2` is used as the boundary between the left and right classes. Let `Nodal_index = Nodal_index + 1`, setting it as the index of the right child node of the current node: `Nodal[stack[depth]].index_r = Nodal_index`. When the node array length is insufficient, the length of the node array is doubled to update its length. The right child node information is pushed onto the auxiliary stack `depth++`, and when the auxiliary stack array length is insufficient, its length is doubled to update its length. The new element pushed onto the stack is set as follows:
[0069] stack[depth].pre_index=stack[depth-1].index+1, stack[depth].index=Nodal_index,
[0070] stack[depth].head=middle,
[0071] stack[depth].tail=stack[depth-1].tail,
[0072] stack[depth].tag=0. Update the auxiliary tag of the current node stack[depth-1].tag=2.
[0073] Return to the beginning of the loop.
[0074] When depth < 0, the auxiliary stack space can be released after exiting the loop. Let Nodal_length = Nodal_index to obtain a binary tree node array Nodal of length Nodal_length. This array is sent to the GPU to calculate the directed distance from a point in space to the blood vessel STL mesh. The maximum stack depth max_depth is used to set the size of the auxiliary stack on the GPU for the next computation.
[0075] The arrays of vertex indices, triangulation element indices, and pseudo-outer normals of the triangulation elements of the STL mesh are sent to the GPU for use in the next step of calculation.
[0076] Preferably, in step S4, the directed distance calculation of a single point includes a traversal algorithm for searching a binary tree in a non-recursive manner on the GPU, and an algorithm for calculating the distance from a single point to a specific triangular unit on the GPU.
[0077] For ease of explanation, we will first detail the algorithm for calculating the distance from any point P in space to the triangular element numbered i. This algorithm takes the coordinates of point P and the coordinates of the three vertices A, B, and C of triangular element i (assuming the inherent order of the three vertices is ABC) as input. It returns the type of the nearest geometry to point P (type), the distance from point P to triangular element i (dist), and the barycentric coordinates of the nearest point on triangular element i to P (barycentric). The geometry includes vertices A, B, and C, edges AB, BC, and CA, and triangular element i itself, totaling seven types. The calculation process is as follows:
[0078] if and Then type is vertex A, dist= ,barycentric= ,return.
[0079] if and Then type is vertex B, dist= ,barycentric= ,return.
[0080] if and Then type is vertex C, dist= barycentric= ,return.
[0081] Calculate the outward normal of triangular element i ,as well as , .
[0082] if( and and Then the type is edge AB, and the boundary-centric value is... dist= ,return.
[0083] if( and and Then the type is edge BC, and the boundary-centric value is... dist= ,return.
[0084] if( and and Then the type is edge CA, and the boundary-centric value is... dist= ,return.
[0085] At this point, type is the triangular unit i itself, barycentric= dist= ,return.
[0086] The following details a non-recursive binary tree traversal algorithm on a GPU.
[0087] On the GPU, an index array `array_i` and a label array `array_t` are allocated as two auxiliary stacks for performing binary tree traversal search. Both stacks have a length of `array_length = (max_depth + 1) * blockDim * gridDim`, where `blockDim` and `gridDim` are the GPU's built-in block size and grid size, respectively, representing the scale of multi-threaded parallel computation. The current thread ID `gid` is obtained from a GPU built-in function. The starting position of the index array corresponding to `gid` is `stack_i = array_i + gid * blockDim * gridDim`, and the starting position of the label array corresponding to `gid` is `stack_t = array_t + gid * blockDim * gridDim`. The method for allocating the directed distance from any point P in the computation space of thread `gid` to the STL grid of the blood vessel wall on the GPU is as follows:
[0088] First, set the distance from point P to the STL grid to dist= Set stack_i[0]=0, stack_t[0]=0, and set the initial stack depth to depth=0.
[0089] When depth Entering the circulation body at 0:
[0090] If stack_t[depth]=2, then the current element is popped from the stack by depth--.
[0091] If stack_t[depth] < 2 and the left subtree of the current node Nodal[stack_i[depth]].left = -1, it means that the leaf node has been searched, that is, the triangular unit with the number i = Nodal[stack_i[depth]].right. At this time, call the above distance algorithm from point P to triangular unit i to obtain the current distance dist(P, i), type(P, i), and barycentric(P, i). If dist(P, i) < dist, then let dist = dist(P, i), and save or update the corresponding type value and barycentric value with the current value, and record triangle_id = i.
[0092] If stack_t[depth] = 0, then calculate the distance d_l from point P to the left spherical surface of the current node, that is, the distance from point P to the center of the left spherical surface minus the radius of the left spherical surface. Similarly, calculate the distance d_r from point P to the right spherical surface of the current node. When d_l < d_r, if d_l < dist, then update the current label stack_t[depth] = (d_r < dist)? -1:2, push the left child node of the current node into the auxiliary stack depth++, and let stack_t[depth] = 0, stack_i[depth] = Nodal[stack_i[depth - 1]].left; otherwise update the current label stack_t[depth] = 2. If there is still d_r < dist, then push the right child node of the current node into the auxiliary stack depth++, and let stack_t[depth] = 0, stack_i[depth] = Nodal[stack_i[depth - 1]].right. When d_r < d_l, if d_r < dist, then update the current label stack_t[depth] = (d_l < dist)? 1:2, push the right child node of the current node into the auxiliary stack depth++, and let stack_t[depth] = 0, stack_i[depth] = Nodal[stack_i[depth - 1]].right; otherwise update the current label stack_t[depth] = 2. If there is still d_l < dist, then push the left child node of the current node into the auxiliary stack depth++, and let stack_t[depth] = 0, stack_i[depth] = Nodal[stack_i[depth - 1]].left.
[0093] If stack_t[depth] = -1, then update the current label stack_t[depth] = 2, push the right child of the current node onto the auxiliary stack depth++, set stack_t[depth] = 0, and stack_i[depth] = Nodal[stack_i[depth-1]].right.
[0094] If stack_t[depth]=1, then update the current label stack_t[depth]=2, push the left child of the current node onto the auxiliary stack depth++, set stack_t[depth]=0, and stack_i[depth]=Nodal[stack_i[depth-1]].left.
[0095] Return to the beginning of the loop.
[0096] When depth < 0, after exiting the loop, triangle_id is the number of the nearest triangular cell to point P. Based on the searched values of type, dist, and barycentric, the directed distance from point P to the STL mesh can be calculated using the following steps.
[0097] First, select the pseudo-outer normal of the triangle element numbered triangle_id based on the value of type. That is, when type is a vertex, the corresponding vertex pseudo-outer normal is selected; when type is an edge, the corresponding edge pseudo-outer normal is selected; and when type is the triangle element itself, the intrinsic outer normal of the triangle element is selected. Let the vertex coordinates of the triangle element with the number triangle_id be A, B, C, in their intrinsic order, and barycentric= ,calculate If sign < 0, then P is located inside the STL grid with a directed distance of -dist; otherwise, P is located outside the STL grid with a directed distance of dist.
[0098] S5. Applying the single-point directed distance algorithm to the directed distance field from a large-scale point cloud to a vessel wall STL mesh. After determining the vessel's STL file and ensuring the STL mesh's connectivity and watertightness, the algorithm described above can be used to generate the STL mesh's vertex indices, triangular element indices, pseudo-outer normals of the triangular elements, and a binary tree node array. These are then sent to a GPU device to implement a parallel computation method for the point cloud to STL mesh directed distance field on the GPU. This method only requires the point cloud as input to the GPU to quickly calculate all directed distances from it to the STL mesh. As an application example of the algorithm, based on the given 3D dimensions of the vessel STL mesh, and with appropriate point cloud spacing... A 3D point cloud array uniformly distributed on a rectangular grid is generated and sent to the GPU. After selecting appropriate GPU block size (BlockDim) and grid size (gridDim), the algorithm is called through a simple GPU kernel function to mark points with a directed distance less than 0 as particles inside the blood vessel (0), and points with a directed distance greater than 0 and less than 0 as particles inside the blood vessel (0). The points are marked as extravascular particles (1), which can quickly obtain such as Figure 6 The diagram shows the particle distribution inside and outside the blood vessel. In the figure, (a) shows the STL mesh of the blood vessel, (b) shows the particles inside the blood vessel, and (c) shows the particles outside the blood vessel. The obtained particle distribution can be used for biomechanical calculations and analyses related to blood vessels.
[0099] The fast calculation method for the directed distance field from point cloud to blood vessel wall STL mesh provided in this application starts with the directed distance from a single point to the blood vessel wall STL mesh. It transforms the calculation of the directed distance from a single point to the STL mesh into a binary tree traversal. The binary tree is constructed non-recursively, tree nodes are stored using a linear array, and the depth of the auxiliary stack is estimated, allowing the binary tree generated on the CPU to be directly sent to the GPU for use. When performing binary tree search on the GPU, the non-recursive traversal method strictly controls memory overhead. When performing threaded search, the GPU-side algorithm achieves near-linear scalability, greatly improving the calculation efficiency of the directed distance field from point cloud to blood vessel wall STL mesh. This method can be widely used in medical image analysis and biomechanical calculations and analysis related to blood vessels.
[0100] The following describes an embodiment of the apparatus of this application, which can be used to execute the fast calculation method of the directed distance field from the point cloud to the STL mesh of the blood vessel wall in the above embodiments of this application. Figure 3 A schematic diagram illustrates the structure of a fast calculation device for the directed distance field from point cloud to blood vessel wall STL mesh provided in an embodiment of this application. For example... Figure 3 As shown, one embodiment of this application provides a fast calculation device for the directed distance field from point cloud to blood vessel wall STL mesh, comprising:
[0101] The blood vessel wall STL file parsing and indexing module 310 reads STL mesh data and generates vertex and triangular unit indices.
[0102] The pseudo-normal calculation module 320 for triangular elements calculates the pseudo-outer normal of all triangular elements in the STL mesh based on the vertices, edges, and the element itself.
[0103] Binary tree design module 330 designs binary trees and their generation algorithms according to recursive logic;
[0104] Binary Tree Improvement and Deployment Module 340 improves the data structure of binary trees to adapt to GPU devices, generates binary trees in a non-recursive manner, and sends the generated binary tree node array and other auxiliary arrays to the GPU to prepare for fast calculation of directed distances.
[0105] The single-point directed distance calculation module 350 searches the binary tree in a non-recursive manner on the GPU side to find the nearest triangular cell from the single point to the STL mesh, and calculates the directed distance from the single point to this triangular cell.
[0106] The algorithm application module 360 applies the single-point directed distance algorithm to a large-scale point cloud to blood vessel wall STL mesh directed distance field calculation instance through GPU multi-threaded parallelism.
[0107] The specific implementation process of the functions and roles of each module / unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0108] It is understood that these modules can be implemented through hardware, software, or a combination of both. When implemented in hardware, these modules can be implemented as one or more hardware modules, such as one or more application-specific integrated circuits (ASICs). When implemented in software, these modules can be implemented as one or more computer programs that execute on one or more processors.
[0109] The following is for reference. Figure 4 This application describes an electronic device 400 provided in one embodiment. Figure 4 The electronic device 400 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0110] like Figure 4 As shown, the electronic device 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 402 or programs loaded from storage section 408 into random access memory (RAM). The RAM 403 also stores various programs and data required for system operation. The CPU 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output interface 405 (I / O interface) is also connected to the bus 404.
[0111] The following components are connected to the input / output interface 405: an input section 606 including a keyboard, mouse, etc.; an output section 407 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a local area network card, modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the input / output interface 405 as needed. A removable medium 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 410 as needed so that computer programs read from it can be installed into the storage section 408 as needed.
[0112] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by central processing unit 401, it performs various functions defined in the system of this application.
[0113] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this application.
[0114] In an exemplary embodiment of this application, a computer-readable storage medium is also provided, on which computer-readable instructions are stored, which, when executed by a computer's processor, cause the computer to perform the methods described in the above method embodiments.
[0115] According to one embodiment of this application, a program product for implementing the methods in the above-described method embodiments is also provided. This program product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of this invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0116] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0117] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0118] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0119] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0120] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0121] Furthermore, although the steps of the method in this application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0122] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this application.
[0123] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention filed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the appended claims.
Claims
1. A method for fast computation of point cloud to vessel wall STL mesh directed distance field, characterized in that, The steps are as follows: S1, read the blood vessel wall STL file, establish vertex index and triangular unit index; S2, calculate the pseudo outer normal of the triangular unit; S3, design a directed distance algorithm from a space point to the STL grid, including data structure and calculation method; S4, improvement and deployment of the algorithm on the GPU device: build a binary tree linear array with non-recursive method on the CPU side and record the stack depth, transfer to the GPU, pre-allocate memory according to the stack depth and start multi-thread non-recursive traversal, and execute the single-point directed distance algorithm at the same time; S5, apply the single-point directed distance algorithm to the large-scale point cloud to the blood vessel wall STL grid directed distance field.
2. The method of claim 1, wherein, Step S1 includes the following sub-steps: S101, read the blood vessel wall STL file to obtain the vertex coordinate array of each triangular unit arranged in the inherent order in the file; S102, remove duplicate coordinates, reorder the vertices, and obtain the vertex index sequence and the triangular unit index sequence corresponding to the vertex index.
3. The method of claim 1, wherein, In step S3, the data structure is to construct a binary tree, which classifies the triangular units of the STL grid level by level, each level corresponds to a node of the binary tree, and each node contains a part of the triangular units of the STL grid, each node has left and right two child nodes, and the left and right child nodes divide the triangular unit set corresponding to the current node into left and right two subclasses, and each subclass can define a minimum sphere containing the triangular unit set corresponding thereto.
4. The method of claim 3, wherein, In step S3, each node of the binary tree contains four information: left pointer pointing to left child node, left sphere recording center coordinates of left subclass and radius of left subclass, right pointer pointing to right child node, and right sphere recording center coordinates of right subclass and radius of right subclass.
5. The method of claim 3, wherein, If the node is a leaf node, the left pointer is empty, and the right pointer points to the unique triangular unit corresponding to the subclass.
6. The fast calculation method of point cloud to blood vessel wall STL grid directed distance field according to claim 3, characterized in that, Step 3 includes the following sub-steps: S301, set the distance from the point to the STL mesh to infinity, that is , S302, traverse the binary tree from the root node; S303, if the current node is not a leaf node, then calculate the distance from the point to the left sphere of the current node and the distance from the point to the right sphere of the previous node ; if , then perform the following two conditional operations in sequence: continue traversing the left child node of the current node when ; and continue traversing the right child node of the current node when ; If then the following two conditional operations are performed in sequence: continue traversing the right child node of the current node when and continue traversing the left child node of the current node when . If the current node is a leaf node, then calculate the distance from the point to the triangle element corresponding to its right child , if , then update , and record the current triangle element as the closest element so far; After the completion of the binary tree traversal, according to the pseudo-outward normal of the triangular element , it is judged whether the point is located on the inside or outside of the STL grid to obtain a directed distance as the directed distance from the point to the STL grid.
7. The method of claim 3, wherein, Step S4 is specifically: store the binary tree nodes in a linear array, build the binary tree in a non-recursive way on the CPU side, and record the stack depth required for traversing the binary tree at the same time; send the binary tree node array to the GPU side, design the memory space required for multi-thread binary tree traversal on the GPU side according to the stack depth, send the vertex index, triangular unit index and pseudo outer normal of the triangular unit to the GPU side, and design a non-recursive traversal binary tree program and a space point to specified triangular unit distance calculation program on the GPU side.
8. An electronic device, comprising: It comprises: A memory storing computer readable instructions; A processor reading the computer readable instructions stored in the memory to execute the fast calculation method of point cloud to blood vessel wall STL grid directed distance field according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, It has computer readable instructions stored thereon, which, when executed by a processor of a computer, enable the computer to execute the fast calculation method of point cloud to blood vessel wall STL grid directed distance field according to any one of claims 1-7.
