Three-dimensional grid model processing method, computer equipment and storage medium
By adjusting the curvature of each vertex in the three-dimensional mesh model, the edge length of the mesh geometric surface is adjusted and the vertex translation process is performed, the problem of self-crossing phenomenon during the out-expansion of the three-dimensional mesh model is solved, and the density and regularity of the mesh are improved.
Patent Information
- Application Number
- CN202311096152.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2025-02-25
AI Technical Summary
The prior art is prone to self-crossing phenomenon in the process of extubation of the three-dimensional grid model, and there are limitations in efficiency and robustness, and there is a lack of effective solutions.
By obtaining the vertex curvature of each vertex in the mesh, adjusting the edge length of the mesh geometric panel, splitting the mesh with larger curvature and combining mesh with smaller curvature, and translating the vertices of the mesh along the direction pointed by the vertex normal vector to reduce the spatial range of the self-intersection area.
It effectively reduces the spatial range of self-intersection areas after the grid is expanded, improves the density and regularity of the grid, and improves the overall efficiency of the algorithm.
Smart Images

Figure CN119516144A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of medical image three-dimensional model processing, and in particular to a three-dimensional grid model processing method, computer equipment and storage medium. Background Art
[0002] With the rapid development of computer technology, computer-aided diagnosis and preoperative planning have gained greater attention and wider application in clinical practice. The three-dimensional information of the lesion is obtained through various imaging methods (such as CT, MRI, etc.), and the three-dimensional model of the lesion is obtained through a variety of computer image and graphics technologies. Compared with traditional two-dimensional image diagnosis, three-dimensional model imaging allows doctors to observe and understand the patient's lesion from multiple angles and in all directions, so as to diagnose, evaluate and treat the patient more accurately.
[0003] The mesh model is a flexible and efficient three-dimensional model that is widely used for lesion display and surgical planning. Mesh expansion is an important operation in mesh processing, which is of great significance for determining the clinical target area, planned target area, treatment area and treatment area of other types of lesions. However, mesh self-intersection is inevitable in the process of mesh expansion. The difficulty of this problem is how to extract the area on the surface after mesh expansion while ensuring that the shape does not change and maintaining the two-dimensional manifold properties of the mesh. The current mesh expansion method has certain limitations in efficiency and robustness.
[0004] With regard to the problem of self-intersection after expansion of three-dimensional mesh models in related technologies, no effective solution has been proposed so far. Summary of the invention
[0005] Based on this, it is necessary to provide a three-dimensional mesh model processing method, computer equipment and storage medium that can improve the self-intersection phenomenon after the three-dimensional mesh model is expanded in order to solve the above technical problems.
[0006] In a first aspect, the present application provides a three-dimensional mesh model processing method. The method comprises:
[0007] Acquire a three-dimensional grid model corresponding to the medical image; wherein the three-dimensional grid model is composed of a plurality of grids, and the outer surface of the three-dimensional grid model is enclosed by geometric facets of the grids;
[0008] Acquire the vertex curvature of each vertex in the mesh, and adjust the side length of the mesh geometric face according to the vertex curvature; wherein, the greater the vertex curvature of the mesh, the greater the probability that the side length of the mesh is shortened, and / or, the smaller the vertex curvature of the mesh, the greater the probability that the mesh is merged;
[0009] The vertices of the mesh are translated by a preset distance along the direction indicated by the vertex normal vector.
[0010] In one embodiment, adjusting the size of the mesh according to the vertex curvature includes:
[0011] Determine the ideal side length of the original side corresponding to the vertex according to the vertex curvature; wherein the greater the vertex curvature, the shorter the ideal side length;
[0012] Determining a first edge length threshold according to the ideal edge length of the original edge; wherein the first edge length threshold is greater than the ideal edge length; if the actual edge length of the original edge is greater than the first edge length threshold, dividing the original edge into two sub-edges, and forming a new geometric facet according to the two sub-edges and two vertices corresponding to the original edge; and / or,
[0013] A second edge length threshold is determined according to the ideal edge length of the original edge; wherein the second edge length threshold is smaller than the ideal edge length; if the actual edge length is smaller than the second edge length threshold, the original edge and the geometric patch where the original edge is located are deleted, and the two vertices corresponding to the original edge are merged.
[0014] In one of the embodiments, before translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes:
[0015] If the difference between the real vertex degree and the ideal vertex degree of the geometric patch of the mesh is reduced after exchanging the diagonals of the geometric patch, and the geometric patch is a convex quadrilateral, then the diagonals of the geometric patch are exchanged; wherein the real vertex degree is the number of vertices connected to the vertex, and the ideal vertex degree is determined based on the position of the vertex.
[0016] In one of the embodiments, before translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes:
[0017] A first vertex of the mesh is tangentially translated toward a second vertex; wherein the second vertex is a center point of a neighborhood of the first vertex.
[0018] In one embodiment, determining the second vertex includes:
[0019] Determine a third vertex connected to the first vertex;
[0020] Calculate the average area of the geometric patch where the edge determined by the first vertex and each of the third vertices is located, and calculate the total area of the polygon formed by the first vertex and all the third vertices;
[0021] Determining the weight of each third vertex according to the ratio of the average area of the geometric patch to the total area of the polygon;
[0022] The third vertex is processed by weighted averaging based on corresponding weights to obtain the second vertex.
[0023] In one embodiment, tangentially translating a first vertex of the mesh toward a second vertex includes:
[0024] The second vertex is translated by a specific distance along the normal vector of the first vertex; wherein the specific distance is equal to the projection length of the vector from the second vertex to the first vertex in the direction of the normal vector of the first vertex.
[0025] In one of the embodiments, before translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes:
[0026] Move the first vertex of the mesh to a fourth vertex; wherein the fourth vertex is the point closest to the first vertex.
[0027] In one of the embodiments, after translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes:
[0028] If there is a first geometric patch in the mesh whose minimum side length is less than a preset side length, deleting the minimum side of the first geometric patch and the geometric patch where the minimum side is located, and merging two vertices corresponding to the minimum side; and / or,
[0029] If there is a second geometric patch in the mesh whose maximum angle is greater than a preset angle, and if after exchanging the diagonals of the second geometric patch, the difference between the actual vertex degree and the ideal vertex degree of the geometric patch decreases, and the geometric patch is a convex quadrilateral, exchanging the diagonals of the geometric patch;
[0030] Among them, the preset side length is the minimum side length of the non-degenerate geometric facet, the preset angle is the maximum angle of the non-degenerate geometric facet; the real vertex degree is the number of vertices connected by the vertex, and the ideal vertex degree is determined based on the position of the vertex.
[0031] In one of the embodiments, after translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes:
[0032] Detecting a seed geometric facet in the three-dimensional mesh model; wherein the seed geometric facet is located on the outer surface of the three-dimensional mesh model, and the seed geometric facet is a non-self-intersecting geometric facet;
[0033] Performing region growing according to the seed geometric facets, retaining legal geometric facets according to the region growing results, and deleting the remaining geometric facets as illegal geometric facets; wherein the legal geometric facets include geometric facets located on the outer surface of the three-dimensional mesh model.
[0034] In one embodiment, performing region growing based on the seed geometric patch includes:
[0035] Generate a geometric facet queue according to the seed geometric facet, and set the attributes of the seed geometric facet to be legal;
[0036] Traversing the geometric facets in the geometric facet queue until the geometric facet queue is empty; wherein, if the adjacent geometric facet of the current geometric facet is not a self-intersecting geometric facet, adding the adjacent geometric facet to the geometric facet queue, and setting the attributes of the adjacent geometric facet to be legal;
[0037] The legal geometric patches are retained, and the remaining geometric patches are deleted as illegal geometric patches.
[0038] In one embodiment, detecting a seed geometric patch in the three-dimensional mesh model includes:
[0039] emitting rays from outside the three-dimensional mesh model to the three-dimensional mesh model;
[0040] The seed geometric patches are selected from the geometric patches that have intersection points with the ray.
[0041] In one embodiment, selecting a seed geometric facet from geometric faces that have intersections with the ray includes:
[0042] Acquire a geometric patch corresponding to the first intersection point, and if the geometric patch corresponding to the first intersection point is a non-self-intersecting geometric patch, use the geometric patch corresponding to the first intersection point as the seed geometric patch; and / or,
[0043] Acquire a geometric patch corresponding to the second intersection point, and if the geometric patch corresponding to the second intersection point is a non-self-intersecting geometric patch, use the geometric patch corresponding to the second intersection point as the seed geometric patch;
[0044] The first intersection point is the intersection point that is closest to the starting point of the ray among the intersection points corresponding to the ray, and the second intersection point is the intersection point that is farthest from the starting point of the ray among the intersection points corresponding to the ray.
[0045] In one of the embodiments, after deleting the remaining geometric patches as illegal geometric patches, the method further includes:
[0046] Acquire an edge located on an outer surface of the three-dimensional mesh model;
[0047] Connecting the edges of the outer surface end to end to form a plurality of closed loops;
[0048] The holes formed by the multiple closed loops are filled.
[0049] In one embodiment, filling the holes formed by the multiple closed loops includes:
[0050] Determining the type of the closed loop;
[0051] If the closed loop is of a hole type, filling the first hole formed by the closed loop;
[0052] If the closed loop is of a fracture type, multiple closed loops belonging to the same fracture structure are combined, and multiple groups of disconnected closed loops are merged into a second hole and then filled.
[0053] In one embodiment, determining the type of the closed loop includes:
[0054] If the closed loop is part of the corresponding fracture structure, determining that the closed loop belongs to the fracture type;
[0055] If the closed loop is not part of any fracture structure, then the closed loop is determined to be of the hole type;
[0056] Among them, when the loop distance between the closed loop and any other closed loop is less than a first preset value, and the closed loop is not connected to any other closed loop, the closed loop belongs to a part of the corresponding fracture structure; the loop distance is the distance between the nearest vertices between the two closed loops, and when the adjacent geometric faces of the two closed loops cannot be traversed to each other through regional growth, the two closed loops are not connected.
[0057] In one embodiment, combining multiple closed loops belonging to the same fracture structure and merging multiple groups of disconnected closed loops into a second hole includes:
[0058] The second hole is composed of a plurality of closed edges; for each vertex in the first closed edge, the point with the closest distance is found in each second closed edge to obtain a feature pair;
[0059] Filter legal feature pairs, and merge two points of the legal feature pairs; wherein the legal feature pairs will not cause the generation of self-intersecting facets after merging the two points.
[0060] In one embodiment, combining multiple closed loops belonging to the same fracture structure and merging multiple groups of disconnected closed loops into a second hole includes:
[0061] When the distance between two points in the feature pair is greater than a second preset value, the feature pair is determined to be illegal.
[0062] In one embodiment, filling the holes formed by the multiple closed loops includes:
[0063] Obtaining an edge line of the hole;
[0064] Based on the edge line of the hole, the hole is geometrically segmented in a recursive manner, and the geometric segmentation result obtained by each recursion is evaluated based on a preset index until the geometric segmentation result meets the preset index; wherein the preset index is used to evaluate the local area;
[0065] For any new geometric patch located in the hole area, if the side length of the new geometric patch is greater than the original geometric patch around the hole, insert new vertices into the new geometric patch and split the new geometric patch according to the new vertices;
[0066] The position of the new vertex is continuously moved in a direction that makes the energy function decrease until the energy function reaches a minimum value; wherein the energy function is determined according to the principal curvatures of all the inserted new vertices.
[0067] In one embodiment, translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector includes:
[0068] The vertices of the mesh are translated multiple times along the direction indicated by the vertex normal vector until the total translation distance reaches the preset distance.
[0069] In a second aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the first aspect are implemented.
[0070] In a third aspect, the present application further provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the first aspect are implemented.
[0071] The above-mentioned three-dimensional mesh model processing method, computer device and storage medium obtain the vertex curvature of each vertex in the mesh, adjust the side length of the mesh geometric facet according to the vertex curvature, so that the mesh geometric facet has a smaller side length and a higher density, and reduces the spatial range of the self-intersection area after the mesh is expanded; considering that the mesh shape mutation area is also the area with larger vertex curvature in the mesh, the normal vectors of the surrounding geometric facets change more dramatically, and self-intersection is prone to occur. Before the mesh is expanded, the side length of the mesh geometric facet is adjusted according to the vertex curvature, so that the mesh geometric facet has a smaller side length and a higher density, and reduces the spatial range of the self-intersection area after the mesh is expanded; further, the effect of splitting the mesh is achieved by shortening the side length of the mesh with larger vertex curvature, and the mesh with smaller vertex curvature is merged as much as possible, while ensuring the overall efficiency of the algorithm, it also improves the mesh's isotropy, regularity and facet quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 is a hardware structure block diagram of a terminal of a three-dimensional mesh model processing method in an embodiment;
[0073] Figure 2 is a flow chart of a method for processing a three-dimensional mesh model in one embodiment;
[0074] Figure 3 is a comparison diagram of a three-dimensional mesh model before and after preprocessing in one embodiment;
[0075] Figure 4 is a schematic diagram of the change process of geometric facets during preprocessing of a three-dimensional mesh model in an embodiment;
[0076] Figure 5 is a schematic diagram of the intersection and non-intersection of triangles in an embodiment;
[0077] Figure 6 is a schematic diagram of the principle of searching for a seed geometric facet in an embodiment;
[0078] Figure 7 is a schematic diagram of merging a vertex and a non-original vertex feature pair in one embodiment;
[0079] Figure 8 is a flow chart of a method for processing a three-dimensional mesh model in another embodiment;
[0080] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0081] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0082] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0083] The method embodiments provided in this application can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of a three-dimensional mesh model processing method according to an embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0084] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the three-dimensional mesh model processing in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0085] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0086] The three-dimensional grid model processing method provided in the present application can be applied to the field of medical image processing, such as image visualization, image segmentation, state analysis of human tissue, computational mechanics analysis and disease diagnosis. Among them, medical images can be collected by imaging systems, such as digital subtraction angiography (DSA), magnetic resonance imaging (MRI), magnetic resonance angiography (MRA), computed tomography (CT), computed tomography angiography (CTA), ultrasonic scanning (US), positron emission tomography (PET), single photon emission computed tomography (SPECT), SPECT-MR, CT-PET, CE-SPECT, DSA-MR, PET-MR, PET-US, SPECT-US, TMS-MR, US-CT, US-MR, X-ray-CT, X-ray-PET, X-ray-US, video-CT, video-US and / or similar one or more combinations. The target of the imaging scan can be a combination of one or more of an organ, a body, an object, a damaged part, a tumor, etc. In some embodiments, the target of the imaging scan can be a combination of one or more of the head, chest, abdomen, organ, bone, blood vessel, etc. In some embodiments, the target of the scan can be vascular tissue at one or more parts. In some embodiments, in a 3D medical image, the most minute resolvable element may be a voxel, and the 3D medical image may be composed of a series of 2D slices or 2D layers.
[0087] Related technologies propose a mesh expansion method based on distance field. This is an estimated implicit geometric representation method, which will inevitably lose information, especially the loss of high-frequency information (information in the area where the mesh shape changes suddenly). At the same time, even for low-frequency information, when the mesh density is very high, if the distance field resolution is insufficient, it will also cause a lot of information loss. The information loss of the distance field will be alleviated if its resolution (the number of voxels in the length, width and height directions of the volume data) is improved, but a distance field with too large a size will take up a long computing time and occupy more video memory resources. In addition, the expansion of the distance field also needs to go through the process of converting from the distance field to the mesh, which will again cause a loss of accuracy, and also face the problem of too large a distance field size and too long conversion time. Therefore, the method of realizing mesh expansion through distance field is suitable for models with few high-frequency features and medium or lower mesh density. Among them, the area where the mesh shape changes suddenly is also the area with large vertex curvature in the mesh. The greater the curvature of a vertex in the mesh, the more drastic the change of the geometric patch normal vector around the vertex, and the more likely it is to have self-intersection.
[0088] Based on the above analysis, in one embodiment, Figure 2 As shown, a three-dimensional mesh model processing method is provided, and the method is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:
[0089] Step S201, obtaining a three-dimensional mesh model corresponding to the medical image; wherein the three-dimensional mesh model is composed of a plurality of meshes, and the outer surface of the three-dimensional mesh model is enclosed by geometric facets of the meshes.
[0090] Medical images are obtained by scanning targets with an imaging system. The target of the imaging scan may be a combination of one or more of an organ, a body, an object, a damaged part, a tumor, etc. Furthermore, the target of the imaging scan may be a combination of one or more of the head, chest, abdomen, organs, bones, blood vessels, etc.
[0091] A three-dimensional mesh model is a simulation of a target shape in a medical image. A mesh can be understood as a geometric domain that approximates a polygon or a polyhedron. The mesh appears as a geometric patch on the outer surface of the three-dimensional mesh model, and geometric patches are enclosed to form a three-dimensional mesh model. The three-dimensional mesh model processing method provided in the present application is applicable to polygonal meshes, such as triangles, quadrilaterals, pentagons, hexagons, etc. Unless otherwise specified, the embodiments of the present application are introduced using triangular meshes (geometric patches are triangles) as an example.
[0092] Exemplarily, the user inputs the initial tumor grid in the terminal and sets the grid's expansion distance. In addition, the relevant parameters in the following steps or processes can also be set in the terminal.
[0093] Step S202, obtaining the vertex curvature of each vertex in the mesh, and adjusting the side length of the mesh geometric facet according to the vertex curvature; wherein, the greater the vertex curvature of the mesh, the greater the probability that the side length of the mesh is shortened, and / or, the smaller the vertex curvature of the mesh, the greater the probability that the mesh is merged.
[0094] This step provides the adjustment trend of the edge length of the geometric patch: for meshes with larger vertex curvature, try to split them; for meshes with smaller vertex curvature, try to merge them. By adaptively adjusting the edge length of the mesh geometric patch, the mesh density is finally adjusted, making the mesh distribution more uniform and reasonable. Figure 3 A comparison diagram of the three-dimensional mesh model before and after preprocessing corresponding to step S202 is given, as shown in FIG. Figure 3 As shown, Figure 3 (a) represents the initial 3D mesh model before 3D mesh model preprocessing. Figure 3 (b) represents the initial 3D mesh model after 3D mesh model preprocessing. It can be seen that the mesh area with larger curvature obtains greater refinement than the mesh area with smaller curvature.
[0095] Step S203: translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector.
[0096] The three-dimensional grid model is expanded outward, and the expanded three-dimensional grid model is finally output. The expanded three-dimensional grid model can be used as a reference for the clinical target area, the planned target area, and even the treatment area. For example, the user inputs the tumor grid to be expanded in the terminal and sets the expansion distance at the same time. In addition, the user can add other grid operations in the terminal input so that the grid is close to the reference range expected by the user, which can greatly reduce the burden on the user to manually outline the clinical target area, the planned target area, and even the treatment area.
[0097] Optionally, the vertices of the mesh are translated multiple times along the direction indicated by the vertex normal vector until the total translation distance reaches a preset distance. If the expansion distance is too long, a single large-distance expansion operation can be split into multiple short-distance expansion operations to reduce the large-scale holes and breaks caused by the large-distance expansion.
[0098] In the above steps S201 to S203, considering that the area with sudden changes in mesh shape is also the area with large vertex curvature in the mesh, the normal vectors of the surrounding geometric patches change more dramatically, and self-intersection is prone to occur. Before the mesh is expanded, the side length of the mesh geometric patches is adjusted according to the vertex curvature, so that the mesh geometric patches have smaller side lengths and higher density, and the spatial range of the self-intersection area after the mesh is expanded is reduced; further, the side length of the mesh with larger vertex curvature is shortened to achieve the effect of splitting the mesh, and the mesh with smaller vertex curvature is merged as much as possible, which ensures the overall efficiency of the algorithm while also improving the mesh's isotropy, regularity and patch quality.
[0099] The following embodiments will introduce the preprocessing before mesh expansion. Before introducing the mesh preprocessing method, the method of initializing the ideal side length is first introduced. The calculation formula is as follows:
[0100]
[0101]
[0102] Among them, v i Represents a vertex in a three-dimensional mesh model, L(v i ) is the vertex v i The ideal side length, k i For vertex v i The maximum absolute curvature, ε is the error tolerance factor, H i For vertex v i The mean curvature, K i For vertex v iGaussian curvature. After calculating the ideal side length of the vertex, the ideal side length of any side is the smaller value of the ideal side lengths of its two vertices. In order to ensure that the mesh is not over-subdivided or insufficiently refined, the user can specify the ideal minimum / maximum side length. When the ideal side length calculated by curvature of any side is not in this range, the ideal side length of the side takes the set value. After completing the ideal side length initialization, the three mesh preprocessing methods provided in the following embodiments can be executed to adjust the size of the mesh according to the vertex curvature. Accordingly, Figure 4 A schematic diagram of the change process of geometric patches during the preprocessing of a three-dimensional mesh model is given, which corresponds to the following embodiments respectively.
[0103] (1) Splitting: In one embodiment, the ideal edge length of the original edge corresponding to the vertex is determined based on the vertex curvature; wherein, the greater the vertex curvature, the shorter the ideal edge length; a first edge length threshold is determined based on the ideal edge length of the original edge; wherein, the first edge length threshold is greater than the ideal edge length; if the actual edge length of the original edge is greater than the first edge length threshold, the original edge is split into two sub-edges, and a new geometric facet is formed based on the two sub-edges and the two vertices corresponding to the original edge.
[0104] refer to Figure 4 In (a), for example, the first edge length threshold = ideal edge length × 4 / 3. Traverse all edges of the grid. If the length of an edge is greater than 4 / 3 of the ideal edge length, perform a split operation, that is, split the edge from the midpoint into two sub-edges, and the two sub-edges form new triangles with the two vertices of the original edge.
[0105] (2) Merging: In one embodiment, a second edge length threshold is determined based on the ideal edge length of the original edge; wherein the second edge length threshold is smaller than the ideal edge length; if the actual edge length is smaller than the second edge length threshold, the original edge and the geometric facet where the original edge is located are deleted, and the two vertices corresponding to the original edge are merged.
[0106] refer to Figure 4 In (b), for example, the second edge length threshold = ideal edge length × 4 / 5. Traverse all edges of the mesh. If the length of an edge is less than 4 / 5 of the ideal length of the edge, a merge operation is performed, that is, the edge and the two triangles where the edge is located are deleted, and the two vertices are merged into the midpoint of the edge.
[0107] (3) Split + Merge: In one embodiment, all edges in the three-dimensional mesh model are traversed and the splitting step and the merging step are performed.
[0108] In one embodiment, a grid preprocessing method different from the above embodiment is also provided.
[0109] (4) Flipping: In one embodiment, before translating the vertices of the mesh by a preset distance in the direction indicated by the vertex normal vector, the method further includes: if after exchanging the diagonals of the geometric facets of the mesh, the difference between the real vertex degree and the ideal vertex degree of the geometric facets decreases, and the geometric facets are convex quadrilaterals, then exchanging the diagonals of the geometric facets; wherein the real vertex degree is the number of vertices connected to the vertex, and the ideal vertex degree is determined based on the position of the vertex.
[0110] The number of vertices connected to each vertex is called the vertex degree (Valence value). Assume that the ideal vertex degree of a boundary vertex is 4 and the ideal vertex degree of a non-boundary vertex is 6. Figure 4 (c) in the figure traverses all edges of the mesh. If swapping the diagonal of the quadrilateral on the edge can reduce the difference between the degree of the four vertices of the quadrilateral and the ideal degree, and the quadrilateral is a convex quadrilateral, then perform a flip operation, that is, swap the diagonal of the quadrilateral. This setting can reduce narrow and long geometric patches or geometric patches with large internal angles, making the internal angles of the geometric patches approach 60 degrees, and finally making the mesh as a whole approach an equilateral triangle mesh.
[0111] (5) Vertex tangential translation: In one embodiment, before translating the vertex of the mesh by a preset distance in the direction indicated by the vertex normal vector, the method also includes: tangentially translating the first vertex of the mesh toward the second vertex; wherein the second vertex is the center point of the adjacent area of the first vertex.
[0112] This setting can reduce narrow and long geometric faces or geometric faces with large internal angles, making the internal angles of the geometric faces approach 60 degrees, and ultimately making the overall mesh approach an equilateral triangle mesh.
[0113] Exemplarily, all vertices of the mesh are traversed. First, the second vertex is determined. The third vertex connected to the first vertex is determined; the average area of the geometric facet where the edge determined by the first vertex and each third vertex is located is calculated, and the total area of the polygon composed of the first vertex and all third vertices is calculated; the weight of each third vertex is determined according to the ratio of the average area of the geometric facet to the total area of the polygon; the third vertex is weighted averaged based on the corresponding weight to obtain the second vertex. The calculation formula of the second vertex is as follows:
[0114]
[0115] Among them, g i is the second vertex, v i is the current vertex (equivalent to the first vertex), N(v i ) is the vertex v i The set of connected vertices, v j Belong to N(v i )(equivalent to the third vertex), Aij It is the average area of the geometric patch where the edge determined by vertex i and vertex j is located.
[0116] Then, the first vertex of the mesh is translated tangentially to the second vertex. The second vertex is translated along the normal vector of the first vertex by a specific distance; wherein the specific distance is equal to the projection length of the vector from the second vertex to the first vertex in the direction of the normal vector of the first vertex. The calculation formula for the tangential translation of the first vertex to the second vertex is as follows:
[0117] p′ i =g i +nn T (p i -g i )
[0118] Among them, p i is the first vertex, p′ i To transform the vertex p i The vertex obtained after tangential translation, n is the vertex p i The current normal vector, n T is the transformation rank of n.
[0119] (6) Translation of the nearest vertex: In one embodiment, before translating the vertex of the mesh by a preset distance in the direction indicated by the vertex normal vector, the method also includes: moving the first vertex of the mesh to the fourth vertex; wherein the fourth vertex is the point closest to the first vertex.
[0120] For example, after performing the above-mentioned vertex tangential translation step, all vertices of the mesh are traversed again to find the nearest vertex of each vertex in the original mesh, and the vertex is translated to the nearest vertex. In this way, the three-dimensional mesh model is consistent with the original shape, avoiding affecting the mesh shape when optimizing the mesh quality.
[0121] It can be understood that the above six grid preprocessing methods can be freely superimposed and combined.
[0122] When a 3D mesh model is expanded, the normal vectors of all vertices are calculated, and then all vertices are translated by a specified distance in the direction of the normal vector. After the vertices are translated irregularly, some degenerate triangles may be generated. To solve this problem, the expanded mesh needs to be post-processed. The following embodiment will introduce the post-processing of the mesh expansion.
[0123] (1) Merging: In one embodiment, after translating the vertices of the mesh by a preset distance in the direction indicated by the vertex normal vector, the method further includes: if there is a first geometric patch in the mesh whose minimum edge length is less than a preset edge length, deleting the minimum edge of the first geometric patch and the geometric patch where the minimum edge is located, and merging the two vertices corresponding to the minimum edge. The preset edge length is the minimum edge length of the non-degenerate geometric patch.
[0124] Exemplarily, the minimum side length of a non-degenerate triangle is set (i.e., a preset side length), and then the degenerate triangles are detected and deleted. First, the minimum side detection is performed. Traverse each edge, and if the minimum side length of the edge is less than the set minimum side length, the edge is merged, that is, the minimum side of the triangle where the edge is located and the triangle where the minimum side is located are deleted, and the two vertices corresponding to the minimum side are merged.
[0125] (2) Flipping: In one embodiment, after translating the vertices of the mesh by a preset distance in the direction indicated by the vertex normal vector, the method further includes: if there is a second geometric patch in the mesh whose maximum angle is greater than the preset angle, and if the difference between the real vertex degree and the ideal vertex degree of the geometric patch decreases after exchanging the diagonal of the second geometric patch, and the geometric patch is a convex quadrilateral, then exchanging the diagonal of the geometric patch. The preset angle is the maximum angle of the non-degenerate geometric patch. The real vertex degree is the number of vertices connected to the vertex, and the ideal vertex degree is determined based on the position of the vertex.
[0126] Exemplarily, the maximum angle of the non-degenerate triangle is set (i.e., a preset angle), and then the maximum angle detection is performed. Each triangle is traversed, and if the maximum angle of the triangle is greater than the set maximum angle, the side corresponding to the maximum angle is flipped, that is, the diagonals of the quadrilateral are swapped.
[0127] (3) Merge + Flip: In one embodiment, the merging step is performed on all edge traversals in the three-dimensional mesh model, and the merging step is performed on triangle traversals. This arrangement achieves the effect of vertex coordinate offset and degenerate triangle removal.
[0128] The following embodiment will introduce the region growing of the expanded three-dimensional grid model.
[0129] In one embodiment, region growing is performed based on geometric patches of a mesh, including: identifying legal geometric patches in a three-dimensional mesh model; wherein the legal geometric patches do not include self-intersecting geometric patches and geometric patches located inside the three-dimensional mesh model; and region growing is performed based on at least some of the legal geometric patches.
[0130] After the 3D mesh model is expanded, there will be three types of geometric faces: (1) legal geometric faces located on the outer surface of the 3D mesh model; (2) illegal geometric faces located inside the 3D mesh model; and (3) self-intersecting geometric faces that are legal in some areas but illegal in others.
[0131] Among them, a self-intersecting geometric patch refers to a geometric patch that intersects with at least one other geometric patch. Self-intersecting geometric patches are special in that they may have some local regions that are legal and some that are illegal. When searching for legal geometric patches by traversal, it is necessary to avoid using self-intersecting geometric patches for region growing, otherwise illegal geometric patches will be mistakenly judged as legal. In this embodiment, by identifying self-intersecting geometric patches and illegal geometric patches, these two types of geometric patches can be filtered out to obtain legal geometric patches and implement legal region growing.
[0132] In one embodiment, a self-intersecting patch detection method is provided, comprising the following steps:
[0133] Step S301, constructing a binary space partition tree (BSP) corresponding to the three-dimensional mesh model; wherein the binary space partition tree includes a plurality of leaf nodes, each leaf node is composed of a bounding box, and each bounding box includes at least part of a triangular face.
[0134] Exemplarily, determine whether the number of triangles contained in the current bounding box is greater than the preset maximum number of triangles, and whether the number of layers of the current bounding box is less than the preset maximum number of layers of the spatial binary tree; if so, use a bisection plane to divide the current bounding box into two sub-bounding boxes; wherein the bisection plane passes through the center point of the current bounding box, the normal vector of the bisection plane points in the direction of the longest side of the current bounding box, and the number of layers of the two sub-bounding boxes is equal to the number of layers of the current bounding box plus one; respectively use the two sub-bounding boxes as the current bounding boxes, and return to the above-mentioned determination step to continue execution.
[0135] Optionally, the maximum number of levels of the spatial binary tree is greater than log2m / n, where m is the total number of triangles and n is the maximum number of triangles allowed to be contained in each bounding box.
[0136] The method of obtaining the initial bounding box is as follows: Calculate the maximum xyz coordinate and the minimum xyz coordinate of the grid in the 3D grid model, use these 6 coordinate planes to form an initial bounding box containing all triangles, and set the number of layers of the initial bounding box to 0.
[0137] Step S302: Perform a pairwise self-intersection check on the triangles contained in each bounding box.
[0138] Exemplarily, for two adjacent triangular facets sharing a common edge, it is determined that the two adjacent triangular facets do not intersect; and / or, for two adjacent triangular facets sharing a common vertex but not a common edge, it is determined that the two adjacent triangular facets intersect if and only if the two adjacent triangular facets have an intersection point other than a common vertex.
[0139] For a non-adjacent first triangular facet and a second triangular facet, calculate the distances between each pair of vertices from the first triangular facet to the second triangular facet; wherein each pair of vertex distances carries a sign; determine whether the signs of each pair of vertex distances are the same; if so, determine that the first triangular facet and the second triangular facet do not intersect; if not, determine whether the first line segment and the second line segment overlap; wherein the first line segment is the intersection line of the plane where the first triangular facet and the second triangular facet are located, and the second line segment is the intersection line of the plane where the second triangular facet and the first triangular facet are located; if so, determine that the first triangular facet and the second triangular facet intersect; if not, determine that the first triangular facet and the second triangular facet do not intersect.
[0140] For ease of understanding, Figure 5 A schematic diagram of the intersecting and non-intersecting triangles is given, such as Figure 5 As shown, taking triangles T1 and T2 as an example, this embodiment is further introduced.
[0141] First, calculate the signed distances from the three vertices of triangle T1 to triangle T2. If the signs of the three distances are all positive or all negative, then the two must not intersect, such as Figure 5 As shown in (a) and (b) in . If the three distances are Figure 5 As shown in (c) and (d) in the figure, it means that the two triangles are coplanar and a two-dimensional plane triangle intersection test is required. If the three distances do not meet the above conditions, proceed to the next step.
[0142] Then, the signed distances of the three vertices of triangle T2 to triangle T1 are calculated. The analysis method of the result is the same as the previous one.
[0143] Next, assume that the intersection line of the triangle planes T1 and T2 is L12, and the intersection line of the triangle planes T2 and T1 is L21, and determine whether L12 and L21 overlap. If there is overlap, the two triangles intersect, such as Figure 5 As shown in (f) in ; if there is no overlap, the two do not intersect, such as Figure 5 As shown in (e) in .
[0144] In one embodiment, after translating the vertices of the mesh by a preset distance in the direction indicated by the vertex normal vector, the method also includes: detecting seed geometric patches in the three-dimensional mesh model; wherein the seed geometric patches are located on the outer surface of the three-dimensional mesh model, and the seed geometric patches are non-self-intersecting geometric patches; performing region growing based on the seed geometric patches, and retaining legal geometric patches based on the region growing results, and deleting the remaining geometric patches as illegal geometric patches; wherein the legal geometric patches include geometric patches located on the outer surface of the three-dimensional mesh model.
[0145] In this embodiment, the formation of self-intersecting geometric faces is avoided through legal region growth. Therefore, what is grown is a mesh region located outside after the three-dimensional mesh model is expanded. The mesh region contains non-self-intersecting faces located outside and local regions located outside of the self-intersecting faces.
[0146] Among them, performing region growth according to the seed geometric patches includes: generating a geometric patch queue according to the seed geometric patches, and setting the attributes of the seed geometric patches to be legal; traversing the geometric patches in the geometric patch queue until the geometric patch queue is empty; wherein, when the adjacent geometric patches of the current geometric patch are not self-intersecting geometric patches, adding the adjacent geometric patches to the geometric patch queue and setting the attributes of the adjacent geometric patches to be legal; retaining the legal geometric patches, and deleting the remaining geometric patches as illegal geometric patches.
[0147] For example, the following will take a triangular face as an example to give the growth steps of the legal region:
[0148] Step S401, defining a queue of triangles to be processed;
[0149] Step S402, setting the attributes of whether the triangles are legal and whether they have been traversed, and initializing all triangles as illegal and not traversed;
[0150] Step S403, setting the seed geometric facet as a legal triangle facet and adding it to a queue of triangle faces to be processed;
[0151] Step S404, taking out a triangle from the triangle queue as the current triangle;
[0152] Step S405, determining whether the current triangle has been traversed; if so, executing step S409; if not, executing step S406;
[0153] Step S406, setting the traversal attribute of the current triangle patch to traversed;
[0154] Step S407, determining whether the adjacent triangles of the current triangle are self-intersecting triangles; if not, executing step S408; if yes, executing step S409;
[0155] Step S408, adding the adjacent triangles of the current triangle to the queue of to-be-processed triangles, and setting them as legal triangles;
[0156] Step S409, determining whether the queue of triangles to be processed is empty; if not, returning to step S404; if so, executing step S410;
[0157] Step S410, deleting all illegal triangles.
[0158] Through this embodiment, ungrown triangles and self-intersecting triangles can be deleted.
[0159] In one embodiment, detecting seed geometric facets in a three-dimensional mesh model includes: emitting rays from outside the three-dimensional mesh model to the three-dimensional mesh model; and selecting seed geometric facets from geometric facets having intersection points with the rays.
[0160] For ease of understanding, Figure 6 The schematic diagram of the principle of finding seed geometric patches is given. Figure 6 (a) shows the line segments and facets of the self-intersecting mesh model. To facilitate the visualization of the internal structure of the self-intersecting mesh model, Figure 6 (b) Only the line segments of the self-intersecting mesh model are shown.
[0161] In this embodiment, a certain point outside the self-intersecting mesh model is used as the ray starting point, and a ray cluster is emitted to the self-intersecting mesh model. The geometric facets (or tangent geometric facets) that each ray penetrates for the first time and the geometric facets (or tangent geometric facets) that each ray penetrates for the last time have at least a portion of the area located on the outer surface of the self-intersecting mesh model, which is temporarily referred to as a candidate seed geometric facet. If the candidate seed geometric facet is a non-self-intersecting geometric facet, the entire geometric facet is located on the outer surface of the self-intersecting mesh model and can be regarded as a seed point.
[0162] You can choose parallel ray clusters. You can also choose non-parallel ray clusters, that is, to emit rays from all directions toward the self-intersecting mesh model as much as possible, which can ensure that as much geometric facet information as possible on the outer surface of the self-intersecting mesh model is collected, thereby enhancing the robustness of the algorithm. Since this method does not involve geometric facet segmentation, it is not necessary to accurately calculate the coordinates of the intersection points between each geometric facet. At the same time, the judgment of whether there is an intersection between geometric faces allows a bias towards the conclusion of the intersection, without forcing a precise judgment, thereby minimizing or even avoiding abnormal problems caused by floating-point calculation errors.
[0163] Furthermore, an embodiment of screening seed geometric patches from geometric patches having intersection points with rays will be given below.
[0164] Optionally, a geometric patch corresponding to the first intersection is obtained. If the geometric patch corresponding to the first intersection is a non-self-intersecting geometric patch, the geometric patch corresponding to the first intersection is used as a seed geometric patch; wherein the first intersection is the intersection point that is closest to the starting point of the ray among the intersection points corresponding to the ray. In this embodiment, in order to simplify the algorithm, only the geometric patch that penetrates the three-dimensional mesh model for the first time can be selected as a candidate seed geometric patch.
[0165] Optionally, a geometric patch corresponding to the second intersection is obtained. If the geometric patch corresponding to the second intersection is a non-self-intersecting geometric patch, the geometric patch corresponding to the second intersection is used as a seed geometric patch; wherein the second intersection is the intersection point farthest from the starting point of the ray among the intersection points corresponding to the ray. In this embodiment, in order to simplify the algorithm, only the geometric patch that passes through the three-dimensional mesh model for the last time can be selected as a candidate seed geometric patch.
[0166] Optionally, obtain the geometric patch corresponding to the first intersection point, and if the geometric patch corresponding to the first intersection point is a non-self-intersecting geometric patch, use the geometric patch corresponding to the first intersection point as a seed geometric patch; obtain the geometric patch corresponding to the second intersection point, and if the geometric patch corresponding to the second intersection point is a non-self-intersecting geometric patch, use the geometric patch corresponding to the second intersection point as a seed geometric patch; wherein the first intersection point is the intersection point closest to the starting point of the ray among the intersection points corresponding to the ray, and the second intersection point is the intersection point farthest from the starting point of the ray among the intersection points corresponding to the ray. In this embodiment, the geometric patch that penetrates the three-dimensional mesh model for the first time and the geometric patch that passes out of the three-dimensional mesh model for the last time can be selected as candidate seed geometric patches.
[0167] The following will take triangular geometric patches as an example to further introduce the above method of finding seed geometric patches.
[0168] Step S501, for a self-intersecting mesh model, find 5 starting points outside it and distinguish and emit 5 parallel rays. Among them, the 5 starting points can be points outside the bounding box of the self-intersecting mesh model. The bounding box is calculated by calculating the maximum xyz coordinate and the minimum xyz coordinate of the mesh in the three-dimensional mesh model, and using these 6 coordinate planes to form an initial bounding box containing all triangular facets.
[0169] Step S502: for each ray, determine whether the ray has an intersection with all the triangular facets of the self-intersecting mesh model. If there is an intersection, save the intersection and its corresponding triangular facet. Figure 6, ray 1 has no intersection with the self-intersecting mesh model; ray 2 has two intersections with the self-intersecting mesh model, both of which are located on the external triangles; ray 3 has four intersections with the self-intersecting mesh model, the first intersection is located on the external triangle, the last intersection is located on the self-intersecting triangle, and the remaining intersections are located on the internal triangles; ray 4 has four intersections with the self-intersecting mesh model, and the first and last intersections are located on the external triangles, and the remaining intersections are located on the internal triangles; ray 5 has four intersections with the self-intersecting mesh model, the first intersection is located on the self-intersecting triangle, the last intersection is on the external triangle, and the remaining intersections are located on the internal triangles. It can be seen that the first intersection and the last intersection cannot be located on the internal triangle.
[0170] Step S503: for rays with intersections, perform depth sorting on the intersection sets corresponding to the rays to obtain a sorted intersection set. The depth sorting method is as follows: for all intersections in the intersection set, calculate the distance between them and the starting point of the ray, and arrange the intersections in ascending order of distance.
[0171] Step S504: For rays with intersections, the first and last points in the sorted intersection set correspond to the first and last intersections, respectively, and the triangles where the two intersections are located are obtained as candidate seed triangles. Then, it is determined whether the two triangles are self-intersecting triangles. If not, the triangles are added to the seed triangle set.
[0172] In one embodiment, after deleting the remaining geometric faces as illegal geometric faces, the method further includes: obtaining edges located on the outer surface of the three-dimensional mesh model; connecting the edges of the outer surface end to end to form multiple closed loops; and filling holes formed by the multiple closed loops.
[0173] In combination with the above-mentioned embodiment, by projecting the seed geometric patches, deleting illegal geometric patches will cause holes in the three-dimensional mesh model. It is only necessary to fill the holes in the mesh to obtain a closed two-dimensional manifold mesh.
[0174] Among them, the holes formed by multiple closed loops are filled, including: judging the type of the closed loop; if the closed loop is a hole type, filling the first hole formed by the closed loop; if the closed loop is a fracture type, combining multiple closed loops belonging to the same fracture structure, and merging multiple groups of unconnected closed loops into a second hole before filling.
[0175] Different repair methods are provided for holes and breaks. Taking a triangle as an example, first, find the boundary edges and connect the boundary edges (edges that are only located in one triangle in the mesh) end to end to form multiple closed loops; then, distinguish whether the closed loops belong to holes or breaks, and combine the closed loops belonging to the same break into a group; then, merge multiple groups of disconnected closed loops of the break into multiple holes; finally, fill all the holes.
[0176] The following is an introduction to determining the type of closed circuit.
[0177] In one embodiment, if a closed loop is part of a corresponding fracture structure, the closed loop is determined to be of a fracture type; if a closed loop is not part of any fracture structure, the closed loop is determined to be of a hole type; wherein, when the loop distance between a closed loop and any other closed loop is less than a first preset value, and the closed loop is not connected to any other closed loop, the closed loop is part of the corresponding fracture structure; the loop distance is the distance between the nearest vertices of two closed loops, and when adjacent geometric faces of two closed loops cannot be traversed to each other through regional growth, the two closed loops are not connected.
[0178] In this embodiment, in order to distinguish whether a closed loop is a hole or a fracture, the concepts of loop connectivity and loop distance are proposed for auxiliary judgment for the closed curve composed of the mesh edge lines. Then, the distance between holes is used to divide the holes into two cases: hole closed curves and fracture closed curves, so that mesh repair can be performed according to different situations.
[0179] Furthermore, multiple closed loops belonging to the same fracture structure are combined, and multiple groups of unconnected closed loops are merged into a second hole, including: the second hole is composed of a number of closed edges; for each vertex in the first closed edge, the point with the closest distance is found in each second closed edge to obtain a feature pair; legal feature pairs are screened, and the two points of the legal feature pairs are merged; wherein, after the legal feature pairs are merged, no self-intersecting facets will be generated.
[0180] When repairing a fracture, the fracture closed curve is closed by merging vertices, and the fracture closed curve is converted into multiple hole closed curves.
[0181] In one embodiment, assuming that a fracture consists of a closed edge B1 and a closed edge B2, merging multiple groups of disconnected closed loops into a second hole includes:
[0182] Step S601, preprocessing to find feature pairs. Traverse the B1 vertices, and for each B1 vertex, find the nearest point in B2, save the distance between the two, and the two points form a feature pair. This nearest point may be a point on the edge of B2, or it may be a vertex on B2. Then traverse the B2 vertices and repeat the above operation. Sort the feature pairs according to the rule that the smaller the distance, the higher the priority.
[0183] Step S602, looping and connecting legal feature pairs. Select the one with the highest priority from the feature pairs, and determine whether the feature pair is legal. If it is legal, merge the vertices. After the vertices are merged, delete the two merged vertices from the feature pair, and the other feature pairs remain unchanged. This process is looped until no feature pairs can be legally connected. The following will introduce the merging of feature pairs and the legality of feature pairs.
[0184] Feature pair merging refers to the process of merging two vertices into the same vertex. There are two possibilities for this operation: ① Merging the B1 edge vertex with the B2 edge vertex; ② Merging a vertex with a non-vertex on another closed edge line. The former is a special case of the latter, so here we take ② as an example to describe the feature pair merging process.
[0185] For ease of understanding, Figure 7 A schematic diagram of merging vertex and non-original vertex feature pairs is given, such as Figure 7 As shown in the figure, v1 is the nearest point of v0, and this point is not the original vertex. First, use v1 to split the triangle where it is located into two sub-triangles, and calculate the coordinates of v0 and v1 after merging according to the formula. Then set the coordinates of v0 to v′, and all vertices connected to v1 are connected to v0. Finally, delete the isolated v1 point. The calculation formula is as follows, where λ represents the weight, so that the merged vertex is biased towards v0 or v1. Generally, λ is set to 0.5.
[0186] v′=λv0+(1-λ)v1
[0187] The legality of a feature pair means that the newly generated or modified triangular facets will not intersect with other mesh facets when the feature pair is merged. This application assumes that the newly generated or modified triangular facets will not intersect with the unmodified triangular facets. Therefore, the legality of a feature pair is only related to whether the modified or newly generated triangular facets after merging the feature pair intersect with the previously generated or modified triangular facets. At the same time, in order to speed up the judgment, this process is accelerated using a spatial binary tree, that is, the triangular facets to be judged are only judged with the triangular facets located at the same leaf node.
[0188] Optionally, the number of broken closed edge curves can be greater than or equal to 2, where the number of closed edge curves is assumed to be n. The process is similar to the above, but there are differences in finding feature points. For any vertex on the closed edge curve B1, when finding its feature pair, it is necessary to calculate it with the closed edge curves B1, B2, ..., Bn in sequence.
[0189] Optionally, another method for determining whether a feature pair is legal includes: when the distance between two points in the feature pair is greater than a second preset value, the feature pair is determined to be illegal. In order to ensure the robustness of the step of converting fractures into holes, an indicator of a feature pair distance threshold may be added. When the distance of the feature pair is greater than the threshold, it is considered an illegal feature pair.
[0190] Through the above process, the fracture is converted into a plurality of holes. Then, all holes in the current grid are repaired. In one embodiment, the holes formed by a plurality of closed loops are filled, including:
[0191] Step S701, hole edge line confirmation: obtaining the hole edge line.
[0192] Step S702, hole triangulation: based on the edge lines of the holes, the holes are geometrically segmented in a recursive manner, and the geometric segmentation results obtained by each recursion are evaluated based on preset indicators until the geometric segmentation results meet the preset indicators; wherein the preset indicators are used to evaluate the local area.
[0193] A bottom-up (local to global) recursive optimization method can be used to reduce the generation of narrow triangles. Based on the principle that local optimization is equivalent to global optimization of hole subdivision, each recursion should be able to make the local area optimal. As shown in the following formula, w i,j It is the sum of the quality evaluation parameters of the triangle face when the triangulation result formed by the hole point from the i-th point to the j-th point is optimal. φ(i,m,j) is the quality evaluation parameter of the triangle face formed by vertices i, j, and k.
[0194]
[0195] Step S703, triangulation network refinement: for any new geometric patch located in the hole area, if the side length of the new geometric patch is greater than the original geometric patch around the hole, new vertices are inserted into the new geometric patch and the new geometric patch is split according to the new vertices.
[0196] By inserting new vertices, the triangular facets in the hole area of the mesh are refined. For the new triangular facets in the hole area, if their side length is much longer than the original triangular facets around the hole, new vertices are inserted into the inside of the new triangular facets and the triangular facets are split into three sub-triangular facets using the vertices. Then, by exchanging the diagonals of the quadrilaterals, the mesh is made to satisfy the spatial Delaunay property, and finally the density and side length of the new triangular facets in the hole area are close to those of the original mesh near the hole.
[0197] Step S704, triangular network optimization: continuously moving the positions of new vertices in a direction that decreases the energy function until the energy function reaches a minimum value; wherein the energy function is determined according to the principal curvatures of all the inserted new vertices.
[0198] This process minimizes the set energy function by moving the positions of the newly added vertices. As shown in the following formula, the energy function is set to the sum of the squares of the principal curvatures of all new vertices, and the optimization target is the vertex curvature.
[0199]
[0200] Among them, Num is the number of all vertices in the mesh area to be optimized, k 1n and k 2n is the principal curvature of any vertex on the mesh area to be optimized. The curvature in three-dimensional space reflects the degree of curvature at any position. The greater the curvature of any vertex, the greater the curvature of the area adjacent to the vertex, and the greater the change in the normal vector of the face near the point. Therefore, when the energy function is minimum, the normal vector between the hole triangle and the original triangle around the hole changes little, and the mesh presents a smooth characteristic.
[0201] In one embodiment, taking a triangular face as an example, Figure 8 A flowchart of another 3D mesh model processing method is given. Figure 8 As shown, the process includes the following steps:
[0202] Step S801, obtaining a three-dimensional mesh model to be expanded and expansion distance parameters;
[0203] Step S802, preprocessing the three-dimensional mesh model based on vertex curvature;
[0204] Step S803, offsetting each vertex of the preprocessed three-dimensional mesh model by a specified outward expansion distance in the direction of the normal vector, and deleting degenerate triangles;
[0205] Step S804, performing self-intersection facet detection;
[0206] Step S805, using parallel rays to find a set of geometric facets located on the outer surface of the three-dimensional mesh model;
[0207] Step S806, using the geometric face set as a seed point to perform face region growth;
[0208] Step S807, deleting the ungrown facets and self-intersecting facets;
[0209] Step S808, filling holes in the three-dimensional mesh model;
[0210] Step S809, outputting the three-dimensional mesh model with the holes filled.
[0211] In this embodiment, first, the entire mesh, especially the area with large curvature, is further subdivided to effectively reduce the spatial range of the self-intersection area after expansion. Then, the triangular facets of the outer surface of the mesh are obtained by a multi-angle ray projection method, and the outer surface of the mesh containing holes and fractures is obtained by a regional growing algorithm. Next, the hole and fracture distinction method proposed in this application is used to classify the two, and all fractures are converted into holes. Finally, all the holes in the mesh are repaired to obtain a closed two-dimensional manifold mesh. The above steps do not involve complex geometric operations, have low requirements on the accuracy of geometric operations, and have good efficiency and robustness. Specific examples related to the above steps have been introduced in the above embodiments, and will not be repeated in this embodiment.
[0212] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0213] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a three-dimensional mesh model processing method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0214] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0215] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of any of the above method embodiments when executing the computer program.
[0216] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are implemented.
[0217] In one embodiment, a computer program product is provided, including a computer program, which implements the steps of any of the above method embodiments when executed by a processor.
[0218] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0219] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0220] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0221] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A three-dimensional mesh model processing method, characterized in that: include: Acquire a three-dimensional grid model corresponding to the medical image; wherein the three-dimensional grid model is composed of a plurality of grids, and the outer surface of the three-dimensional grid model is enclosed by geometric facets of the grids; Acquire the vertex curvature of each vertex in the mesh, and adjust the side length of the mesh geometric face according to the vertex curvature; wherein, the greater the vertex curvature of the mesh, the greater the probability that the side length of the mesh is shortened, and / or, the smaller the vertex curvature of the mesh, the greater the probability that the mesh is merged; The vertices of the mesh are translated by a preset distance along the direction indicated by the vertex normal vector.
2. The three-dimensional mesh model processing method according to claim 1, characterized in that: Adjusting the size of the mesh according to the vertex curvature includes: Determine the ideal side length of the original side corresponding to the vertex according to the vertex curvature; wherein the greater the vertex curvature, the shorter the ideal side length; Determining a first edge length threshold according to the ideal edge length of the original edge; wherein the first edge length threshold is greater than the ideal edge length; if the actual edge length of the original edge is greater than the first edge length threshold, dividing the original edge into two sub-edges, and forming a new geometric facet according to the two sub-edges and two vertices corresponding to the original edge; and / or, A second edge length threshold is determined according to the ideal edge length of the original edge; wherein the second edge length threshold is smaller than the ideal edge length; if the actual edge length is smaller than the second edge length threshold, the original edge and the geometric patch where the original edge is located are deleted, and the two vertices corresponding to the original edge are merged.
3. The three-dimensional mesh model processing method according to claim 1, characterized in that: Before translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes: If the difference between the real vertex degree and the ideal vertex degree of the geometric patch of the mesh is reduced after exchanging the diagonals of the geometric patch, and the geometric patch is a convex quadrilateral, then the diagonals of the geometric patch are exchanged; wherein the real vertex degree is the number of vertices connected to the vertex, and the ideal vertex degree is determined based on the position of the vertex.
4. The three-dimensional mesh model processing method according to claim 1, characterized in that: Before translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes: A first vertex of the mesh is tangentially translated toward a second vertex; wherein the second vertex is a center point of a neighborhood of the first vertex.
5. The three-dimensional mesh model processing method according to claim 4, characterized in that: Determining the second vertex includes: Determine a third vertex connected to the first vertex; Calculate the average area of the geometric patch where the edge determined by the first vertex and each of the third vertices is located, and calculate the total area of the polygon formed by the first vertex and all the third vertices; Determining the weight of each third vertex according to the ratio of the average area of the geometric patch to the total area of the polygon; The third vertex is processed by weighted averaging based on corresponding weights to obtain the second vertex.
6. The three-dimensional mesh model processing method according to claim 5, characterized in that: Tangentially translating a first vertex of the mesh toward a second vertex includes: The second vertex is translated by a specific distance along the normal vector of the first vertex; wherein the specific distance is equal to the projection length of the vector from the second vertex to the first vertex in the direction of the normal vector of the first vertex.
7. The three-dimensional mesh model processing method according to claim 1, characterized in that: Before translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes: Move the first vertex of the mesh to a fourth vertex; wherein the fourth vertex is the point closest to the first vertex.
8. The three-dimensional mesh model processing method according to claim 1, characterized in that: After translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes: If there is a first geometric patch in the mesh whose minimum side length is less than a preset side length, deleting the minimum side of the first geometric patch and the geometric patch where the minimum side is located, and merging two vertices corresponding to the minimum side; and / or, If there is a second geometric patch in the mesh whose maximum angle is greater than a preset angle, and if after exchanging the diagonals of the second geometric patch, the difference between the actual vertex degree and the ideal vertex degree of the geometric patch decreases, and the geometric patch is a convex quadrilateral, exchanging the diagonals of the geometric patch; Among them, the preset side length is the minimum side length of the non-degenerate geometric facet, the preset angle is the maximum angle of the non-degenerate geometric facet; the real vertex degree is the number of vertices connected by the vertex, and the ideal vertex degree is determined based on the position of the vertex.
9. The three-dimensional mesh model processing method according to claim 1, characterized in that: After translating the vertices of the mesh by a preset distance along the direction indicated by the vertex normal vector, the method further includes: Detecting a seed geometric facet in the three-dimensional mesh model; wherein the seed geometric facet is located on the outer surface of the three-dimensional mesh model, and the seed geometric facet is a non-self-intersecting geometric facet; Performing region growing according to the seed geometric facets, retaining legal geometric facets according to the region growing results, and deleting the remaining geometric facets as illegal geometric facets; wherein the legal geometric facets include geometric facets located on the outer surface of the three-dimensional mesh model.
10. The three-dimensional mesh model processing method according to claim 9, characterized in that: Performing region growing according to the seed geometry patch includes: Generate a geometric facet queue according to the seed geometric facet, and set the attributes of the seed geometric facet to be legal; Traversing the geometric facets in the geometric facet queue until the geometric facet queue is empty; wherein, if the adjacent geometric facet of the current geometric facet is not a self-intersecting geometric facet, adding the adjacent geometric facet to the geometric facet queue, and setting the attributes of the adjacent geometric facet to be legal; The legal geometric patches are retained, and the remaining geometric patches are deleted as illegal geometric patches.
11. The three-dimensional mesh model processing method according to claim 9, characterized in that: Detecting a seed geometric facet in the three-dimensional mesh model includes: emitting rays from outside the three-dimensional mesh model to the three-dimensional mesh model; The seed geometric patches are selected from the geometric patches that have intersection points with the ray.
12. The three-dimensional mesh model processing method according to claim 11, characterized in that: Screening seed geometric faces from geometric faces that have intersection points with the ray, including: Acquire a geometric patch corresponding to the first intersection point, and if the geometric patch corresponding to the first intersection point is a non-self-intersecting geometric patch, use the geometric patch corresponding to the first intersection point as the seed geometric patch; and / or, Acquire a geometric patch corresponding to the second intersection point, and if the geometric patch corresponding to the second intersection point is a non-self-intersecting geometric patch, use the geometric patch corresponding to the second intersection point as the seed geometric patch; The first intersection point is the intersection point that is closest to the starting point of the ray among the intersection points corresponding to the ray, and the second intersection point is the intersection point that is farthest from the starting point of the ray among the intersection points corresponding to the ray.
13. The three-dimensional mesh model processing method according to claim 9, characterized in that: After deleting the remaining geometric patches as illegal geometric patches, the method further includes: Acquire an edge located on an outer surface of the three-dimensional mesh model; Connecting the edges of the outer surface end to end to form a plurality of closed loops; The holes formed by the multiple closed loops are filled.
14. The three-dimensional mesh model processing method according to claim 13, characterized in that: Filling the holes formed by the multiple closed loops includes: Determining the type of the closed loop; If the closed loop is of a hole type, filling the first hole formed by the closed loop; If the closed loop is of a fracture type, multiple closed loops belonging to the same fracture structure are combined, and multiple groups of disconnected closed loops are merged into a second hole and then filled.
15. The three-dimensional mesh model processing method according to claim 14, characterized in that: Determining the type of the closed loop includes: If the closed loop is part of the corresponding fracture structure, determining that the closed loop belongs to the fracture type; If the closed loop is not part of any fracture structure, then the closed loop is determined to be of the hole type; Among them, when the loop distance between the closed loop and any other closed loop is less than a first preset value, and the closed loop is not connected to any other closed loop, the closed loop belongs to a part of the corresponding fracture structure; the loop distance is the distance between the nearest vertices between the two closed loops, and when the adjacent geometric faces of the two closed loops cannot be traversed to each other through regional growth, the two closed loops are not connected.
16. The three-dimensional mesh model processing method according to claim 14, characterized in that: Combine multiple closed loops belonging to the same fracture structure, and merge multiple groups of disconnected closed loops into the second hole, including: The second hole is composed of a plurality of closed edges; for each vertex in the first closed edge, the point with the closest distance is found in each second closed edge to obtain a feature pair; Filter legal feature pairs, and merge two points of the legal feature pairs; wherein the legal feature pairs will not cause the generation of self-intersecting facets after merging the two points.
17. The three-dimensional mesh model processing method according to claim 16, characterized in that: Combine multiple closed loops belonging to the same fracture structure, and merge multiple groups of disconnected closed loops into the second hole, including: When the distance between two points in the feature pair is greater than a second preset value, the feature pair is determined to be illegal.
18. The three-dimensional mesh model processing method according to claim 13, characterized in that: Filling the holes formed by the multiple closed loops includes: Obtaining an edge line of the hole; Based on the edge line of the hole, the hole is geometrically segmented in a recursive manner, and the geometric segmentation result obtained by each recursion is evaluated based on a preset index until the geometric segmentation result meets the preset index; wherein the preset index is used to evaluate the local area; For any new geometric patch located in the hole area, if the side length of the new geometric patch is greater than the original geometric patch around the hole, insert new vertices into the new geometric patch and split the new geometric patch according to the new vertices; The position of the new vertex is continuously moved in a direction that makes the energy function decrease until the energy function reaches a minimum value; wherein the energy function is determined according to the principal curvatures of all the inserted new vertices.
19. The three-dimensional mesh model processing method according to claim 1, characterized in that: The vertices of the mesh are translated by a preset distance along the direction indicated by the vertex normal vector, including: The vertices of the mesh are translated multiple times along the direction indicated by the vertex normal vector until the total translation distance reaches the preset distance.
20. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 19 are implemented.
21. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 19 are implemented.
Citation Information
Cited By
Product integral forming automatic optimization method applied to 3D printing
CN120191027A
Quadrilateral grid lightweight method and system, storage medium and equipment
CN121437810A