Hole triangle mesh generation method, device, equipment and storage medium
By projecting the hole boundary vertices of the three-dimensional model into the two-dimensional image space and generating a quadrilateral mesh, the problem of time-consuming generation of three-dimensional hole mesh and inability to express the shape of the object is solved, and efficient triangle mesh generation and shape expression are achieved.
Patent Information
- Application Number
- CN202210141629.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-16
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2042-02-16
AI Technical Summary
In the prior art, the generation of three-dimensional hole mesh has problems such as time-consuming, generation of wrong topological spaces, and inability to express the shape of the object well.
By projecting the hole boundary vertices of the three-dimensional model to the two-dimensional image space, a quadrilateral mesh is formed in the image space, and the projected vertices of the three-dimensional model vertices in the image space are obtained. Then, a hole triangle mesh is generated based on the quadrilateral mesh and projected vertices, and the mesh position is repaired using the Poisson equation.
It reduces the dimension of grid generation, improves the efficiency of triangle mesh generation, simplifies the complexity of the algorithm, and enables the repaired triangle mesh to better express the shape of the object.
Smart Images

Figure CN114445595B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of three-dimensional model repair, and in particular to a method, device, computer equipment and storage medium for generating a hole triangle mesh. Background Art
[0002] The existing methods for filling three-dimensional holes can be roughly divided into two categories: voxel-based methods and triangle-based methods. Among them, the voxel-based method first converts the mesh model into a series of voxel units, and then fills the holes in the voxel space. The voxel-based method has a good effect on filling holes, especially complex holes. Furthermore, the triangle-based method can directly operate the triangle surface to repair the hole, which is simple and fast.
[0003] The above two hole-filling methods are mainly divided into two steps. The first step is to generate a triangular mesh of the hole; the second step is to adjust the position of the mesh vertices so that the repaired mesh can better express the shape of the object. However, both of the above methods have defects. The voxel-based hole-filling method is time-consuming and generates an incorrect topological space. The triangular face repaired by the triangular face-filling method cannot well express the shape of the object. Summary of the invention
[0004] The purpose of the embodiments of the present application is to propose a method, device, equipment and storage medium for generating a three-dimensional model hole triangular mesh, so as to solve the technical problems in the prior art of three-dimensional hole mesh generation, such as time-consuming, erroneous topological space generation and inability to express the shape of the object well.
[0005] In order to solve the above technical problems, an embodiment of the present application provides a method for generating a triangular mesh of a hole in a three-dimensional model, the generation method comprising: obtaining the hole boundary vertices of the three-dimensional model and projecting the hole boundary to the image space; forming a quadrilateral mesh in the image space to obtain the projection vertices of the vertices inside the hole boundary of the three-dimensional model in the image space; and generating the hole triangular mesh based on the quadrilateral mesh and the projection vertices.
[0006] Among them, forming a quadrilateral grid in the image space to obtain the projection vertices of the vertices of the three-dimensional model in the image space further includes: determining the preset side length value of the grid according to the resolution of the image; generating a first straight line every preset side length value along the first direction; generating a second straight line every preset side length value along the second direction, wherein the first direction is perpendicular to the second direction; and obtaining the projection vertices of the vertices of the three-dimensional model in the image space according to the intersection points of all the first straight lines and all the second straight lines.
[0007] Among them, after the hole triangular mesh is generated according to the quadrilateral mesh and the projection vertices, it further includes: calculating the initial position coordinates of all the projection vertices in the three-dimensional space respectively to obtain the position of the hole triangular mesh; using Poisson's equation to calculate the positions of all the hole triangular meshes respectively to repair the position of the hole triangular mesh.
[0008] Among them, the use of Poisson's equation to calculate the positions of all the hole triangular meshes respectively to repair the positions of the hole triangular meshes further includes: calculating the divergence values of all the vertices of the hole triangular meshes; calculating the gradient values of each vertex of the hole triangular meshes according to the divergence values; determining the sparse matrix of the discrete Poisson equation to initialize the divergence values of each vertex of the hole triangular mesh according to the divergence values of the hole boundary and the boundary vertices; constructing a guided vector field; calculating the new coordinate values of each vertex in the hole triangular mesh according to the Poisson equation; and repairing the position of the hole triangular mesh according to the new coordinate values.
[0009] Among them, the construction of the guidance vector field further includes: obtaining the original normal vector of each triangle in the hole triangular mesh; using the harmonic equation to calculate the normal vector of each vertex of each triangle in the hole triangular mesh, so as to obtain a new normal vector of each triangle; and forming the guidance vector field with the new normal vectors of the triangles in the hole triangular mesh.
[0010] Among them, after using the harmonic equation to calculate the normal vector of each vertex of each triangle in the hole triangular mesh to obtain the new normal vector of each triangle, and before the new normal vectors of the triangles in the hole triangular mesh form the guide vector field, it further includes: calculating a rotation matrix based on the original normal vector and the new normal vector; calculating new coordinate values of each vertex of the triangle in the hole triangular mesh based on the rotation matrix.
[0011] Wherein, the Poisson equation is expressed as: Where f represents an unknown scalar function, represents the Laplace operator, h represents the guide vector field, divh represents the divergence of the guide vector field, and f* represents the definition in scalar function on Ω, Ω represents the set of all vertices of the mesh, Represents the set of all boundary vertices on the boundary of the hole.
[0012] In order to solve the above technical problems, an embodiment of the present application also provides a three-dimensional model hole triangular mesh generation device, the generation device comprising: a projection module, which obtains the hole boundary vertices of the three-dimensional model and projects the hole boundary to the image space; a quadrilateral mesh formation module, which is used to form a quadrilateral mesh in the image space and obtain the projection vertices of the vertices inside the hole boundary of the three-dimensional model in the image space; and a generation module, which is used to generate the hole triangular mesh based on the quadrilateral mesh and the projection vertices.
[0013] In order to solve the above-mentioned technical problems, an embodiment of the present application also provides a computer device, which adopts the technical solution described below: the computer device includes a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of the method for generating a triangular mesh of holes in a three-dimensional model as described above when executing the computer-readable instructions.
[0014] In order to solve the above-mentioned technical problems, an embodiment of the present application also provides a computer-readable storage medium, which adopts the technical solution described below: the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the method for generating a three-dimensional model hole triangular mesh as described above are implemented.
[0015] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0016] The present application provides a method, device, computer equipment and storage medium for generating a triangular mesh of a hole in a three-dimensional model. The method projects the boundary vertices of the hole of the three-dimensional model into a two-dimensional image space, forms a quadrilateral mesh in the two-dimensional image space, obtains the projection vertices of the three-dimensional model vertices in the image space, and then generates a triangular mesh of the hole based on the quadrilateral mesh and the projection vertices. That is, the present application converts the mesh generation in the three-dimensional space into the two-dimensional image space, reduces the dimension of the mesh generation, improves the generation efficiency of the triangular mesh, and simplifies the complexity of the algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 It is a flowchart of a first embodiment of a method for generating a triangular mesh of a hole in a three-dimensional model of the present application;
[0019] Figure 2 It is the projection of the boundary vertices of the three-dimensional model of this application in the image space;
[0020] Figure 3 This application Figure 1 A schematic flow chart of an implementation method of step S200;
[0021] Figure 4 It is a schematic diagram of the quadrilateral mesh and projection vertices of this application;
[0022] Figure 5 It is a schematic diagram of an implementation method of forming a triangular mesh from a quadrilateral mesh of the present application;
[0023] Figure 6 It is a flowchart of a second embodiment of the method for generating a three-dimensional model hole triangular mesh of the present application;
[0024] Figure 7 This application Figure 1 A schematic flow chart of an implementation method of step S500;
[0025] Figure 8 It is a schematic diagram illustrating two angles formed by a ring vertex of a grid vertex and a central vertex and its ring vertex in the present application;
[0026] Fig. 9 This application Figure 7 A schematic flow chart of an implementation method of step S550;
[0027] Fig.10 is a schematic diagram of the angles in the harmonic equation of this application;
[0028] Fig.11 It is a schematic diagram of a first embodiment of a device for generating a triangular mesh of a hole in a three-dimensional model of the present application;
[0029] Fig.12 It is a schematic diagram of a second embodiment of a device for generating a triangular mesh of a hole in a three-dimensional model of the present application;
[0030] Fig.13 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used herein in the specification of the application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The terms "including" and "having" in the specification and claims of the present application and the above-mentioned accompanying drawings and any variations thereof are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned accompanying drawings are used to distinguish different objects, rather than to describe a specific order.
[0032] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0033] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0034] See also Figure 1 , Figure 1 A flow chart of an embodiment of a method for generating a triangular mesh of a hole in a three-dimensional model according to the present application is shown. The method for generating a triangular mesh of a hole in a three-dimensional model according to the present application comprises the following steps:
[0035] S100, obtaining the hole boundary vertices of the three-dimensional model, and projecting the hole boundary into the image space.
[0036] It can be understood that in step S100, the hole boundary vertices of the three-dimensional model are first detected, and the boundary vertices are indexed and marked, for example, from 0 to N, where N can represent the number of boundary vertices.
[0037] Further, the hole boundary is projected into the image space, and an image with a suitable resolution is selected according to the size of the grid. Specifically, an image with a suitable resolution can be selected according to the actual size of the grid, for example, the resolution is 1920*1920, which is not specifically limited here. Figure 2 , Figure 2 The projection diagram of the boundary vertices of the three-dimensional model in the image space for this application. Figure 2 is the projection of the spatial boundary of the three-dimensional model into the dimensional image space, where Figure 2 The x in represents the boundary vertex, and the line connecting the boundary vertices represents the boundary of the hole.
[0038] S200, forming a quadrilateral mesh in the image space, and obtaining the projection vertices of the vertices in the hole boundary of the three-dimensional model in the image space.
[0039] Please further combine Figure 3 , Figure 3 For this application Figure 1 A flow chart of an implementation method of step S200 is shown in FIG. Figure 3 Step S200 of the present application further includes the following sub-steps:
[0040] S210, determining a preset side length value of a grid according to a resolution of the image.
[0041] It is understandable that in the embodiment of the present application, the preset side length value of the square grid can be determined according to the size of the image resolution when generating a quadrilateral grid in the image space. In a specific application scenario of the present application, the resolution size of the image can be M*M, where M=1920. In this way, the side length value of the square grid can be selected as 120. Of course, in other embodiments, the preset side length value can also be set to other values, which are not specifically limited here.
[0042] S220, generating a first straight line at intervals of a preset side length along the first direction.
[0043] Furthermore, a first straight line is generated at every interval of a preset side length value (120 in this application) along the first direction.
[0044] S230, generating a second straight line at intervals of a preset side length value (120 in the present application) along the second direction, wherein the first direction is perpendicular to the second direction.
[0045] Further, a second straight line is generated at intervals of a preset side length along the second direction, wherein the first direction is perpendicular to the second direction.
[0046] S240: Determine projection vertices of hole boundary vertices of the three-dimensional model in the image space according to intersection points of all first straight lines and all second straight lines.
[0047] Further, the projection vertices of the hole boundary vertices of the three-dimensional model in the image space are determined according to the intersection points of all the first straight lines and all the second straight lines. Figure 4 , Figure 4 This is a schematic diagram of the quadrilateral mesh and projection vertices of this application.
[0048] It can be understood that compared with the prior art in which the hole grid vertices are sparsely generated, the number is uncontrollable, the angles are different, and the generation method is complex, the present application determines the squares with preset side length values through image resolution to control the number and density of projected vertices generated within the boundary, so that the density and density of the generated projected vertices can be controlled.
[0049] S300, generating a hole triangle mesh according to the quadrilateral mesh and the projection vertices.
[0050] It can be understood that after step S200 and before entering step S300, the step further includes marking the projection vertices within the hole boundary, specifically including:
[0051] Draw the hole boundary in the image space. Specifically, in the present application, the hole boundary can be drawn in the image space based on the Opencv image processing library.
[0052] All pixel values inside the hole boundary and outside the hole boundary are marked as the first preset pixel value and the second pixel value, respectively. Specifically, in the embodiment of the present application, all pixel values inside the hole boundary are marked as the first preset pixel value 255, and all pixel values outside the hole boundary are marked as the second pixel value 0.
[0053] The projected vertices within the hole boundary are marked based on the first preset pixel value and the second preset pixel value.
[0054] It is understandable that the projection vertex within the hole boundary in step S200 can be determined based on the first preset pixel value and the second preset pixel value. Specifically, if the pixel value is 255, it is the projection vertex inside the hole boundary. Figure 4 O represents the projected vertex of the hole generation mesh.
[0055] It is understandable that, since there are missing vertices inside the holes of the three-dimensional model, it is necessary to fill in the missing vertices in the two-dimensional space. Since the present application is converted from the three-dimensional space to the two-dimensional image space, the pixels in the image space are used to fill in the missing vertices in the three-dimensional space. Therefore, the hole represented by O generates the projected vertices of the mesh. Specifically, in step S300, these vertices will be generated into triangles to complete the generation of the hole triangular mesh. It is understandable that the triangular mesh is composed of a series of vertices and triangular facets formed by these vertices. For a closed mesh, an edge connects two triangular facets, and an edge only connects one triangular facet. Then this edge is called the mesh boundary edge, and the vertex on the boundary edge is called the boundary vertex.
[0056] Further, in step S300, a hole triangle mesh is generated according to the quadrilateral mesh and the projection vertices, and the formation of the triangle mesh in this application can be divided into the following two cases:
[0057] 1. Divide the quadrilateral into two triangles in a counterclockwise manner. Please refer to 5. Figure 5 Schematic diagram of an implementation method of forming a triangular mesh from a quadrilateral mesh of the present application, as shown in Figure 5, A, B, D, E are four vertices of the quadrilateral mesh, and by connecting vertex A and vertex E, triangles AED and ABE can be generated, thus completing the division of a quadrilateral mesh. Optionally, the remaining quadrilaterals are also divided in the same way.
[0058] 2. Associate the projected vertex x of the boundary with the projected vertex inside the hole to form a complete two-dimensional triangular mesh.
[0059] Specifically, starting from any point of the marked boundary projection vertex x in the preset direction order, find the internal projection vertex O closest to the next boundary projection vertex x, and then the three points form a triangular mesh, and so on, until the boundary projection vertex N-1 is reached, and the triangular mesh is generated. It can be understood that the preset direction in this application can be set off in a clockwise order or in a counterclockwise order, which is not specifically limited here.
[0060] In the above implementation, the hole boundary vertices of the three-dimensional model are projected into the two-dimensional image space to form a quadrilateral mesh in the two-dimensional image space, the projection vertices of the three-dimensional model vertices in the image space are obtained, and then the hole triangular mesh is generated based on the quadrilateral mesh and the projection vertices. That is, the present application reduces the dimension of mesh generation, improves the generation efficiency of triangular meshes, and simplifies the complexity of the algorithm by converting the mesh generation in the three-dimensional space into the two-dimensional image space.
[0061] See also Figure 6 , Figure 6 This is a flow chart of the second embodiment of the method for generating a hole triangular mesh of a three-dimensional model of the present application. The difference from the first embodiment is that the second embodiment of the method for generating a hole triangular mesh of a three-dimensional model of the present application also includes calculating the positions of all hole triangular meshes respectively using the Poisson equation to repair the positions of the hole triangular meshes. The remaining steps are the same as the first embodiment and will not be repeated here. The specific description is as follows:
[0062] S100, obtaining the hole boundary vertices of the three-dimensional model, and projecting the hole boundary into the image space.
[0063] S200, forming a quadrilateral mesh in the image space, and obtaining the projection vertices of the vertices in the hole boundary of the three-dimensional model in the image space.
[0064] S300, generating the hole triangle mesh according to the quadrilateral mesh and the projection vertices.
[0065] S400, respectively calculating the initial position coordinates of all projection vertices in the three-dimensional space to obtain the position of the hole triangle mesh.
[0066] It can be understood that since the boundary projection vertex can find the corresponding three-dimensional vertex in the three-dimensional space, its three-dimensional spatial position is determined, so the position of the projection vertex in the image space in the three-dimensional space can be calculated according to the following steps:
[0067] Specifically, the horizontal coordinate of the projected vertex O may be equal to the horizontal coordinate of the nearest hole boundary vertex in the column where the point O is located in the image space, the vertical coordinate of the projected vertex O may be equal to the vertical coordinate of the nearest hole boundary vertex in the row where the point O is located in the image space, and the Z coordinate of the projected vertex O may be equal to the Z coordinate of the three-dimensional space vertex corresponding to the nearest hole boundary vertex in the row where the point O is located. By analogy, the initial coordinates of the three-dimensional space positions of all projected vertices are calculated, so that the position of the hole triangle mesh can be obtained.
[0068] S500, using Poisson's equation to calculate the positions of all hole triangle meshes respectively, so as to repair the positions of the hole triangle meshes.
[0069] It is understandable that since the position of the hole triangle mesh is inferred based on the nearest hole boundary point without reference to the vertex normal information, it cannot well express the original shape of the object and needs to be recalculated and the mesh position adjusted. In this application, the Poisson equation with Dirichlet boundary conditions is selected to refine the patch mesh. The Poisson equation is defined as follows:
[0070]
[0071] Where f represents an unknown scalar function, represents the Laplace operator, h represents the guide vector field, divh represents the divergence of the guide vector field, and f* represents the definition in scalar function on Ω, Ω represents the set of all vertices of the mesh, Represents the set of all boundary vertices on the boundary of the hole.
[0072] See also Figure 7 , Figure 7 For this application Figure 6 A flow chart of an implementation method of step S500 is shown in FIG. Figure 7 Step S500 further includes the following sub-steps:
[0073] S510, calculating the divergence value of each vertex of all hole triangle meshes.
[0074] Furthermore, the Poisson equation in formula (1) can be transformed into a minimization problem, and the function satisfies:
[0075]
[0076] in, Represents the gradient operator.
[0077] Furthermore, since the guidance vector field h is in discrete form, the vertex v of the hole mesh i The divergence of can be defined as follows:
[0078]
[0079] Among them, N i is the vertex v i A vertex of a ring, |T k | is a triangle T k The area of ▽B i,k In the triangle T k The gradient vector of the vertex in .
[0080] S520, calculating the gradient value of each vertex of the hole triangle mesh according to the divergence value.
[0081] Furthermore, the gradient value of each vertex of the hole triangle mesh can be calculated according to the divergence of each vertex of the hole triangle mesh. Specifically, the discrete gradient form of the scalar function f can be expressed as:
[0082]
[0083] Among them, φi(·) is a linear basis function, at the vertex v i The value is 1 when it is, otherwise it is 0. i Yes i One of the coordinates.
[0084] S530, determining a sparse matrix of the discrete Poisson equation.
[0085] Further, f i Yes i One of the coordinates, the discrete Laplacian operator is expressed as follows:
[0086]
[0087] Among them, f i Represents vertex v i One of the coordinates (x, y, z), f j Represents vertex v i The coordinates (x, y, z) of a vertex in a ring are one of them, so formula (5) is calculated three times to calculate the complete vertex coordinates. Figure 8 , Figure 8 2 is a schematic diagram illustrating two angles formed by a ring vertex of a mesh vertex and a central vertex and a ring vertex thereof in the present application, wherein it is assumed that v j-1 and v j+1 For vertex v iThe adjacent vertices of a ring, then α i,j Indicates the angle ∠v i v j-1 v j+1 ,cotα i,j Indicates the angle ∠v i v j-1 v j+1 The cotangent of i,j Indicates the angle ∠v i v j+1 v j , cotβ i,j Indicates the angle ∠v i v j+1 v j The cotangent of .
[0088] It can be understood that the discrete form of the Poisson equation can be expressed as: Δf≡div(▽f)=divh. Further, the discrete form of the Poisson equation is a sparse linear system, which is expressed as follows:
[0089] Ax=b (6)
[0090] Among them, x is the coordinate vector of each vertex to be solved, the sparse matrix A can be obtained by formula (5), and the vector b can be the divergence value of each vertex obtained by formula (3). From formula (3), we can know that in order to solve the Poisson equation, we must know the guide vector field h, so we use the triangle rotation method to construct the guide vector field.
[0091] S540: Initialize the divergence value of each vertex of the hole triangle mesh according to the divergence value of the hole boundary and the boundary vertices.
[0092] S550, constructing a guidance vector field.
[0093] Please further combine Fig. 9 , Fig. 9 For this application Figure 7 A flow chart of an implementation method of step S550 is shown in FIG. Fig. 9 , step S550 further includes the following sub-steps:
[0094] S551, obtaining the original normal vector of each triangle in the hole triangle mesh.
[0095] Furthermore, the original normal vector of each triangle in the hole triangle mesh is obtained.
[0096] S552, using the harmonic equation to calculate the normal vector of each vertex of the triangle in the hole triangle mesh, so as to obtain a new normal vector of each triangle.
[0097] Please combine Fig.10 , Fig.10 Schematic diagram of the angle in the harmonic equation of this application. Specifically, the discrete harmonic function in the embodiment of this application aims to find a piecewise linear mapping f: S T →S* to minimize the Dirichlet energy:
[0098]
[0099] The Dirichlet energy can also be expressed as follows:
[0100]
[0101] Among them, ST represents the surface set, represents the boundary surface, f0 represents the known surface, and θ3, θ2, θ1 represent the angle values of the vertices of the triangle. It can be understood that by replacing ST (surface) with a triangular face and combining it with the above formula (5), we can get formula (8).
[0102] Furthermore, the equation can be expressed as the following linear system:
[0103] ∑ vj∈Ni ω i,j (f(v j )-f(v i ))=0,v i ∈V I (9)
[0104] Among them, ω i,j =cotα i,j +cotβ i,j , α i,j ,β i,j See also Figure 7 . N i is the vertex v i The number of vertices in a ring. f(v) refers to the normal of vertex v rather than the coordinates, where α i,j Indicates the angle ∠v i v j-1 v j+1 ,cotα i,j Indicates the angle ∠v i v j-1 v j+1 The cotangent of i,j Indicates the angle ∠v i v j+1 v j , cotβ i,j Indicates the angle ∠v i v j+1 v j The cotangent of .
[0105] S553, forming a guiding vector field from the new normal vector of each triangle in the hole triangle mesh.
[0106] It is understandable that after the normals of the vertices of the triangle are calculated, the new normals of the triangles in the hole triangle mesh can be calculated through the normals of the three vertices. In this way, the new normal vectors of each triangle in the hole triangle mesh can be used to form a guided vector field.
[0107] Furthermore, before forming the guiding vector field from the new normal vector of each triangle in the hole triangle mesh in step S553, the following steps are also included:
[0108] The rotation matrix is calculated based on the original normal vector and the new normal vector. Specifically, assuming n i ,n i ',c i The original normal, new normal and center of the triangle are respectively, around the center c i Rotation normal n i to n i ', the rotation matrix R can be obtained i .
[0109] Furthermore, the new coordinate value of each triangle vertex in the hole triangle mesh is calculated according to the rotation matrix.
[0110] S560, calculating new coordinate values of each vertex in the hole triangle mesh according to the Poisson equation.
[0111] Furthermore, the new coordinate values of each vertex in the hole triangle mesh are calculated according to the Poisson equation.
[0112] S570: Repair the position of the hole triangle mesh according to the new coordinate value.
[0113] The position of the hole triangle mesh is repaired according to the new coordinate value, so as to update the coordinates of each vertex of each hole mesh, and complete the repair of the hole in the 3D model.
[0114] In the above embodiment, the hole boundary vertices of the three-dimensional model are projected into the two-dimensional image space to form a quadrilateral mesh in the two-dimensional image space, and the projection vertices of the three-dimensional model vertices in the image space are obtained, and then the hole triangular mesh is generated according to the quadrilateral mesh and the projection vertices. That is, the present application converts the mesh generation of the three-dimensional space into the two-dimensional image space, reduces the dimension of the mesh generation, improves the generation efficiency of the triangular mesh, and simplifies the complexity of the algorithm. In addition, the Poisson's equation is used to calculate the positions of all the hole triangular meshes respectively to repair the positions of the hole triangular meshes, so that the repaired triangular mesh can better express the shape of the object.
[0115] Please combine Fig.11 , Fig.11 Schematic diagram of the first embodiment of the device for generating a triangular mesh of a hole in a three-dimensional model of the present application, as shown in Fig.11 The three-dimensional model hole triangular mesh generation device 100 provided in the present application includes a projection module 110 , a quadrilateral mesh forming module 120 and a generation module 130 .
[0116] The projection module 110 is used to obtain the hole boundary vertices of the three-dimensional model and project the hole boundary into the image space.
[0117] The quadrilateral mesh forming module 120 is used to form a quadrilateral mesh in the image space to obtain the projection vertices of the vertices in the hole boundary of the three-dimensional model in the image space. The quadrilateral mesh forming module 120 is also used to determine the preset side length value of the square according to the resolution of the image; generate a first straight line at each interval of the preset side length value along the first direction; generate a second straight line at each interval of the preset side length value along the second direction, wherein the first direction is perpendicular to the second direction; and obtain the projection vertices of the vertices in the hole boundary of the three-dimensional model in the image space according to the intersection points of all the first straight lines and all the second straight lines.
[0118] The generating module 130 is used to generate the hole triangle mesh according to the quadrilateral mesh and the projection vertices.
[0119] In the above implementation, the hole boundary vertices of the three-dimensional model are projected into the two-dimensional image space to form a quadrilateral mesh in the two-dimensional image space, the projection vertices of the three-dimensional model vertices in the image space are obtained, and then the hole triangular mesh is generated based on the quadrilateral mesh and the projection vertices. That is, the present application reduces the dimension of mesh generation, improves the generation efficiency of triangular meshes, and simplifies the complexity of the algorithm by converting the mesh generation in the three-dimensional space into the two-dimensional image space.
[0120] Please combine Fig.12 , Fig.12 Schematic diagram of the second embodiment of the device for generating a triangular mesh of a hole in a three-dimensional model of the present application, as shown in Fig.12 The three-dimensional model hole repairing device 200 provided in the present application includes a projection module 210 , a quadrilateral mesh forming module 220 , a generation module 230 , a first calculation module 240 and a second calculation module 250 .
[0121] The projection module 210 is used to obtain the hole boundary vertices of the three-dimensional model and project the hole boundary into the image space.
[0122] The quadrilateral mesh forming module 220 is used to form a quadrilateral mesh in the image space to obtain the projection vertices of the vertices in the hole boundary of the three-dimensional model in the image space. The quadrilateral mesh forming module 220 is also used to determine the preset side length value of the square according to the resolution of the image; generate a first straight line at each interval of the preset side length value along the first direction; generate a second straight line at each interval of the preset side length value along the second direction, wherein the first direction is perpendicular to the second direction; and obtain the projection vertices of the vertices in the hole boundary of the three-dimensional model in the image space according to the intersection points of all the first straight lines and all the second straight lines.
[0123] The generating module 230 is used to generate the hole triangle mesh according to the quadrilateral mesh and the projection vertices.
[0124] The first calculation module 240 is used to calculate the initial position coordinates of all the projection vertices in the three-dimensional space respectively to obtain the position of the hole triangle mesh.
[0125] The second calculation module 250 is used to calculate the positions of all the hole triangle meshes respectively using the Poisson equation to repair the positions of the hole triangle meshes. The second calculation module 250 is also used to calculate the divergence values of all the vertices of the hole triangle meshes; calculate the gradient values of each vertex of the hole triangle mesh according to the divergence values; determine the sparse matrix of the discrete Poisson equation; initialize the divergence values of each vertex of the hole triangle mesh according to the divergence values of the hole boundary and the boundary vertices; construct a guided vector field; calculate the new coordinate values of each vertex in the hole triangle mesh according to the Poisson equation; and repair the position of the hole triangle mesh according to the new coordinate values.
[0126] In the above embodiment, the hole boundary vertices of the three-dimensional model are projected into the two-dimensional image space to form a quadrilateral mesh in the two-dimensional image space, and the projection vertices of the three-dimensional model vertices in the image space are obtained, and then the hole triangular mesh is generated according to the quadrilateral mesh and the projection vertices. That is, the present application converts the mesh generation of the three-dimensional space into the two-dimensional image space, reduces the dimension of the mesh generation, improves the generation efficiency of the triangular mesh, and simplifies the complexity of the algorithm. In addition, the Poisson's equation is used to calculate the positions of all the hole triangular meshes respectively to repair the positions of the hole triangular meshes, so that the repaired triangular mesh can better express the shape of the object.
[0127] To solve the above technical problems, the present application also provides a computer device. Fig.13 , Fig.13 This is a basic structural block diagram of the computer device in this embodiment.
[0128] The computer device 300 includes a memory 301, a processor 302, and a network interface 303 which are interconnected and communicated via a system bus. It should be noted that: Fig.13 Only a computer device 300 having components 301-303 is shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.
[0129] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0130] The memory 301 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 301 can be an internal storage unit of the computer device 300, such as a hard disk or memory of the computer device 300. In other embodiments, the memory 301 can also be an external storage device of the computer device 300, such as a plug-in hard disk equipped on the computer device 300, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 301 can also include both the internal storage unit of the computer device 300 and its external storage device. In this embodiment, the memory 301 is generally used to store the operating system and various application software installed on the computer device 300, such as computer-readable instructions of the interface calling method, etc. In addition, the memory 301 can also be used to temporarily store various data that have been output or will be output.
[0131] The processor 302 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 302 is generally used to control the overall operation of the computer device 300. In this embodiment, the processor 302 is used to run computer-readable instructions or process data stored in the memory 301, such as computer-readable instructions for running a method for generating a triangular mesh of a hole in a three-dimensional model.
[0132] The network interface 303 may include a wireless network interface or a wired network interface. The network interface 303 is generally used to establish a communication connection between the computer device 300 and other electronic devices.
[0133] By projecting the hole boundary vertices of the three-dimensional model to the two-dimensional image space, a quadrilateral mesh is formed in the two-dimensional image space, the projection vertices of the three-dimensional model vertices in the image space are obtained, and then the hole triangular mesh is generated according to the quadrilateral mesh and the projection vertices. That is, the present application reduces the dimension of mesh generation, improves the generation efficiency of triangular mesh, and simplifies the complexity of the algorithm by converting the mesh generation in the three-dimensional space to the two-dimensional image space.
[0134] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions. The computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the method for generating a three-dimensional model hole triangular mesh as described above.
[0135] By projecting the hole boundary vertices of the three-dimensional model to the two-dimensional image space, a quadrilateral mesh is formed in the two-dimensional image space, the projection vertices of the three-dimensional model vertices in the image space are obtained, and then the hole triangular mesh is generated according to the quadrilateral mesh and the projection vertices. That is, the present application reduces the dimension of mesh generation, improves the generation efficiency of triangular mesh, and simplifies the complexity of the algorithm by converting the mesh generation in the three-dimensional space to the two-dimensional image space.
[0136] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0137] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for generating a triangular mesh of a hole in a three-dimensional model, characterized in that: The generation method comprises: Obtaining the hole boundary vertices of the three-dimensional model, and projecting the hole boundary into the image space; Forming a quadrilateral mesh in the image space to obtain projection vertices of vertices within the hole boundary of the three-dimensional model in the image space; Generate the hole triangle mesh according to the quadrilateral mesh and the projection vertices; Calculating the initial position coordinates of all the projection vertices in the three-dimensional space respectively to obtain the position of the hole triangle mesh; The positions of all the hole triangle meshes are calculated respectively using the Poisson equation to repair the positions of the hole triangle meshes; Calculating the divergence value of each vertex of all the hole triangle meshes; Calculate the gradient value of each vertex of the hole triangle mesh according to the divergence value; Determine the sparse matrix for the discrete Poisson equation; Initializing the divergence value of each vertex of the hole triangle mesh according to the divergence value of the hole boundary and the boundary vertex; Constructing the guidance vector field; Calculate new coordinate values of each vertex in the hole triangle mesh according to the Poisson equation; Repairing the position of the hole triangle mesh according to the new coordinate value; The Poisson equation is expressed as: in, represents an unknown scalar function, represents the Laplace operator, represents the guidance vector field, is expressed as the divergence of the guidance vector field, Indicates that the definition is A scalar function on , Represents the set of all vertices of the mesh, Represents the set of all boundary vertices on the hole boundary.
2. The generation method according to claim 1, characterized in that: The forming of a quadrilateral mesh in the image space to obtain projection vertices of vertices within the hole boundary of the three-dimensional model in the image space further includes: Determine the preset side length value of the square according to the resolution of the image; Generate a first straight line at every interval of the preset side length along the first direction; Generate a second straight line at every interval of the preset side length along a second direction, wherein the first direction is perpendicular to the second direction; The projection vertices of the vertices within the hole boundary of the three-dimensional model in the image space are obtained according to the intersection points of all the first straight lines and all the second straight lines.
3. The generation method according to claim 1, characterized in that: The constructing of the guidance vector field further comprises: Obtaining the original normal vector of each triangle in the hole triangle mesh; Using a harmonic equation to calculate the normal vector of each vertex of each triangle in the hole triangle mesh, thereby obtaining a new normal vector of each triangle; The new normal vectors of the triangles in the hole triangle mesh constitute the guidance vector field.
4. The generation method according to claim 3, characterized in that: After the harmonic equation is used to calculate the normal vector of each vertex of each triangle in the hole triangle mesh to obtain a new normal vector of each triangle, and before the new normal vectors of the triangles in the hole triangle mesh are used to form the guide vector field, the method further includes: Calculate a rotation matrix according to the original normal vector and the new normal vector; The new coordinate value of each triangle vertex in the hole triangle mesh is calculated according to the rotation matrix.
5. A device for generating a triangular mesh of holes in a three-dimensional model, characterized in that: The generating device comprises: A projection module, used to obtain the hole boundary vertices of the three-dimensional model and project the hole boundary into the image space; A quadrilateral mesh forming module, used to form a quadrilateral mesh in the image space, and obtain projection vertices of vertices within the hole boundary of the three-dimensional model in the image space; A generating module, used for generating the hole triangle mesh according to the quadrilateral mesh and the projection vertices; A first calculation module is used to calculate the initial position coordinates of all the projection vertices in the three-dimensional space respectively to obtain the position of the hole triangle mesh; The second calculation module is used to calculate the positions of all the hole triangle meshes respectively using the Poisson equation to repair the positions of the hole triangle meshes; the second calculation module is also used to calculate the divergence values of all the vertices of the hole triangle meshes; calculate the gradient values of each vertex of the hole triangle mesh according to the divergence values; determine the sparse matrix of the discrete Poisson equation; initialize the divergence values of each vertex of the hole triangle mesh according to the divergence values of the hole boundary and the boundary vertex; construct a guided vector field; calculate the new coordinate values of each vertex in the hole triangle mesh according to the Poisson equation; and repair the position of the hole triangle mesh according to the new coordinate values; The Poisson equation is expressed as: in, represents an unknown scalar function, represents the Laplace operator, represents the guidance vector field, is expressed as the divergence of the guidance vector field, Indicates that the definition is A scalar function of Represents the set of all vertices of the mesh, Represents the set of all boundary vertices on the hole boundary.
6. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the method for generating a three-dimensional model hole triangular mesh as described in any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the method for generating a three-dimensional model hole triangular mesh as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Tooth-and-gum-oriented high-efficiency mesh repairing method
CN102930091A
Correction method, electronic device and storage medium
CN113593010A