Method and system for generating distance field of triangular mesh model based on multi-information voxels
The triangular mesh model is voxelized by the multi-information voxel method. The rough and precise distance fields are combined to construct the precise distance field only near the boundary. This solves the problem of low computational efficiency of the triangular mesh model and realizes efficient distance field processing.
Patent Information
- Application Number
- CN202211013303.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-08-23
AI Technical Summary
In the existing technology, the distance field calculation efficiency of triangular mesh models is low, especially on complex models, where the brute force algorithm has high time complexity, the scan line algorithm has poor robustness, and the pseudo-normal method has a large amount of calculation, making it difficult to efficiently process models in additive manufacturing.
The multi-information voxel method is used to voxelize the bounding box space of the triangular mesh model. A rough distance field is generated through distance transformation, and irrelevant triangles are filtered out to construct a multi-information voxel space. The precise and rough distance fields are combined to construct the precise distance field only near the boundary to reduce the amount of calculation.
While ensuring calculation accuracy, the efficiency of distance field processing of triangular mesh models is improved, especially in application scenarios near boundaries, which significantly reduces the calculation time.
Smart Images

Figure CN115423973B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer-aided design, and more particularly, relates to a method and system for generating a distance field of a triangular mesh model based on multi-information voxels. Background Art
[0002] A triangular mesh model is composed of triangles and is a way to represent complex 3D models, such as STL (stereolithography) and OBJ (object).
[0003] The signed distance field (hereafter referred to as the distance field) represents the shortest distance from any point in space to the surface of the model. The positive or negative sign indicates whether the point is outside or inside the model, as shown in the following formula:
[0004]
[0005] A distance field is an implicit representation of a model, enabling rapid model processing such as skeleton extraction, morphological processing, rendering, and modeling. Distance fields can be converted into triangular meshes using the Marching Cube (MC) or Dual Contouring (DC) algorithms. Because they are well-suited for operations such as Boolean operations, offsets, shell extraction, and conformal gradient lattice structure generation, distance field implicit modeling is increasingly being used in additive manufacturing, where the standard model is the triangular mesh. Therefore, converting triangular meshes into distance fields is crucial for processing complex models on the additive manufacturing front end.
[0006] There are two methods for calculating the distance field of a triangular mesh model: a voxel-based coarse distance field and a patch-based precise distance field. The coarse distance field generated by voxelizing the triangular mesh model and then performing a distance transform requires less computation, but loses the precise boundary of the triangular mesh model. Directly calculating the closest distance from the target point to the triangular mesh model surface can maintain complete boundary information, but this method is computationally expensive. Therefore, quickly calculating the distance field of a triangular mesh model has become an urgent problem. Distance field calculation involves two steps: absolute value calculation, which involves finding the closest point to the model surface; and sign determination, which involves determining whether the point is outside or inside the model.
[0007] The most intuitive method for calculating the distance field of a triangular mesh model is the brute force algorithm, which directly calculates the distance from a point to all the triangles in the model and takes the minimum value. However, the time complexity of the brute force algorithm is too high to be practical for calculating the distance field of complex models.
[0008] Methods for determining the sign of the distance field include the scanline algorithm, which determines the sign by checking the parity of the number of triangles intersected by a ray originating from the calculation point. This method is not robust and can be ambiguous when the intersection points are vertices or edges of a triangle facet. However, the scanline algorithm is the most commonly used method in voxel space. Another method is the pseudonormal method, which calculates pseudonormals for all points and edges of the triangle mesh based on the normals of the triangles. The pseudonormal of the nearest point on the model surface is used to determine the sign of the distance field. Summary of the Invention
[0009] In response to the above-mentioned defects or improvement needs of the prior art, the present invention provides a method and system for generating a distance field of a triangular mesh model based on multi-information voxels, the purpose of which is to improve the efficiency of processing triangular mesh models using distance fields while ensuring calculation accuracy.
[0010] To achieve the above object, according to one aspect of the present invention, a method for generating a distance field of a triangular mesh model based on multi-information voxels is proposed, comprising the following steps:
[0011] S1. Construct a triangular mesh model of the part to be manufactured;
[0012] S2, dividing the bounding box space of the triangular mesh model into multiple voxels of the same size, and determining all triangles in the voxel that intersect with the voxel to form a voxel space based on space segmentation;
[0013] S3. Perform distance transformation on the voxel space, i.e., calculate the signed distance from each voxel to its nearest boundary voxel to obtain a rough distance field; boundary voxels refer to voxels that intersect with the triangular mesh;
[0014] S4. Determine valid voxels based on the rough distance field; calculate the minimum distance from the triangle to the voxel center in each valid voxel, and then determine the valid triangle, and store the valid triangle in the index SdfBox corresponding to the corresponding voxel;
[0015] S5. Determine the voxel where the point to be found is located, and then obtain the index SdfBox corresponding to the voxel; if SdfBox is empty, use the rough distance field after distance transformation as the distance field; if SdfBox is not empty, calculate the shortest distance from the point to be found to the triangle stored in SdfBox, and then determine the distance field.
[0016] As a further preference, a voxel in the rough distance field DT(i,j,k) that satisfies the following formula is a valid voxel:
[0017]
[0018] Where DT0 is the shortest distance from the current voxel to the nearest boundary voxel, and d is the side length of the voxel.
[0019] As a further preferred embodiment, among the valid voxels, a triangle that satisfies the following formula is a valid triangle:
[0020]
[0021] Where D is the distance from the triangle to the center of the corresponding voxel, D0 is the minimum distance from all triangles in the voxel to the voxel center, and d is the side length of the voxel.
[0022] As a further preferred embodiment, in step S4, voxels far from the boundary are filtered, and valid voxels and valid triangles are determined within a certain offset range near the triangular mesh.
[0023] As a further preferred embodiment, in step S4, voxels far from the boundary are filtered, specifically, valid voxels are searched only among voxels that satisfy the following formula:
[0024]
[0025] Where DT is the distance from the current voxel to the nearest boundary voxel, F is the preset offset relative to the triangular mesh, and d is the side length of the voxel.
[0026] As a further preferred embodiment, in step S5, if SdfBox is not empty, the shortest distance dist from the target point to all triangles stored in SdfBox is calculated, and the pseudo-normal is used to determine whether the target point is inside or outside the model, thereby determining the sign sign of the distance field value, and obtaining the distance field as sign*dist.
[0027] According to another aspect of the present invention, a system for generating a distance field of a triangular mesh model based on multi-information voxels is provided, comprising a processor configured to execute the method for generating a distance field of a triangular mesh model based on multi-information voxels.
[0028] In general, the above technical solutions conceived by the present invention have the following technical advantages compared with the existing technology:
[0029] 1. This invention combines coarse distance fields with precise distance fields. Specifically, this method voxelizes the bounding box space of a triangular mesh model and performs a distance transform to obtain a coarse distance field. Then, during the calculation of the precise distance field, information from the coarse distance field is used to filter out a large number of irrelevant triangles, constructing a multi-information voxel space and reducing the time required to solve the precise distance field. This improves the efficiency of using distance fields to process triangular mesh models while ensuring computational accuracy.
[0030] 2. For applications focusing solely on the distance field near boundaries, the present invention uses a coarse distance field to filter out irrelevant solution space when constructing the distance field, constructing only the distance field near the boundary. The interior of the triangle mesh, away from the triangle mesh, is represented using a coarse distance field using a distance transform, reducing the area requiring precise distance field calculation. Therefore, the present invention can selectively construct a precise distance field for a local area, while representing the remaining area with a coarse distance field using a distance transform, generating a hybrid distance field. This reduces the precise distance field construction area in specific application scenarios, further improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is a flow chart of a method for generating a distance field of a triangular mesh model based on multi-information voxels according to an embodiment of the present invention;
[0032] Figure 2 The original triangular mesh model of the embodiment of the present invention;
[0033] Figure 3 A visual representation of the angle-weighted pseudo-normals of a triangular mesh model according to an embodiment of the present invention;
[0034] Figure 4 This is a schematic diagram of the multi-information voxel space calculation principle based on distance field segmentation according to an embodiment of the present invention;
[0035] Figure 5 Schematic diagram of the hybrid distance field principle according to an embodiment of the present invention;
[0036] Figure 6 A visual representation of the distance field generated for an embodiment of the present invention. DETAILED DESCRIPTION
[0037] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
[0038] The embodiment of the present invention provides a method for generating a distance field of a triangular mesh model based on multi-information voxels, such as Figure 1 As shown, the following steps are included:
[0039] S1. Construct a triangular mesh model of the part to be manufactured.
[0040] The triangular mesh model is used as input and is exported in formats such as STL and OBJ. It can be exported by 3D modeling software such as UG and SolidWorks. Figure 2 The model shown is used as an example to specifically illustrate the distance field generation method of the present invention.
[0041] S2. Read the triangle patch data of the triangular mesh model and calculate the pseudo normal.
[0042] Read the triangular face data of the model, establish the topological relationship of the triangle, store the normal information of the triangular face, and calculate the angle weighted pseudonormal of the edge and point. Figure 3 shown.
[0043] S3. Establish a multi-information voxel space based on spatial segmentation.
[0044] The bounding box space of the triangular mesh model is divided into single voxels at equal intervals in the three coordinate axis directions, and the index numbers of all triangles intersecting with the voxel are stored in the voxel to form a multi-information voxel space based on space segmentation that contains the precise boundary information of the triangles.
[0045] Specifically, space is represented by Space <box>[I][J][K] (<> indicates the type of data to be stored, [] indicates the dimension and size of the space, the same below), where Box <tri>[n] stores the triangle index. Space represents a three-dimensional voxel space with scales I, J, and K, respectively. Each voxel stores a box that stores the triangles that intersect it. Voxels are divided into two types: boundary voxels that intersect the triangle mesh, and non-boundary voxels that do not intersect the triangle mesh, meaning the box is empty.
[0046] More specifically, we traverse all triangles in the space and perform the following two-level intersection test on each triangle:
[0047] (1) Find the bounding box of the triangle patch and find the voxels that intersect with the bounding box of the triangle patch through hexahedron intersection detection.
[0048] (2) For each voxel that intersects with the bounding box of the triangle, the separating axis theorem is used for further judgment, and the index number of the current triangle is stored in the voxel that intersects with it.
[0049] The transformation from triangular mesh model to multi-information three-dimensional voxel space is established, so that the model is transformed from a continuous triangular mesh to discrete voxels that store boundary features.
[0050] S4. Perform distance transformation on the multi-information voxel space based on spatial segmentation.
[0051] The rough distance field is obtained by the fast distance transform algorithm, which is the signed distance of each voxel to the nearest boundary voxel.
[0052] S5. Establish a multi-information voxel space based on distance field segmentation.
[0053] After completing the distance transform, based on the distance field, (1) the precise distance field can be directly constructed; or (2) a hybrid distance field can be constructed. That is, in order to reduce the area where the precise distance field needs to be calculated, for application scenarios where only the distance field near the boundary is concerned, the precise distance field near the boundary can be selectively constructed, and the coarse distance field of the distance transform can be used internally.
[0054] The following are specific instructions:
[0055] (1) Constructing an accurate distance field
[0056] The triangular mesh model is converted into a multi-information voxel space based on spatial segmentation, where the side length of the voxel is d. For each voxel, define the voxel SdfBox based on distance field segmentation<D0,T0,T1,T2……> and multi-information voxel space SdfSpace <sdfbox>[I][J][K]. Each voxel corresponds to an SdfBox, which stores all possible nearest triangles T0, T1, T2, ... and the distance D0 of the nearest triangle to all the points P to be solved in the corresponding voxel, and is arranged in ascending order of the distance D to the voxel center C; the possible nearest triangles are called valid triangles.
[0057] Specifically, before determining valid triangles, valid voxels must be determined. Valid voxels refer to the voxels where all triangles that affect the current SdfBox are located, that is, the voxels may contain triangles that the current SdfBox needs to store. Valid voxels are extracted through the results of distance transformation. The principle of determining valid voxels is as follows:
[0058] Given the shortest distance DT0 (distance transform, where the distance transform takes absolute value) from the current voxel to the nearest boundary voxel, the maximum distance to the nearest triangle at the center of the current voxel is Then, it is deduced that the voxels where the triangles that meet the conditions at the center of the current voxel are located all meet the conditions. This results in the effective voxel distance transform distance field value
[0059] The search area for valid voxels forms a spherical shell centered on the voxel in the current SdfBox. Searching for valid voxels using Euclidean distance across the entire 3D space would be very time-consuming, so the search within this spherical shell is simplified to a hollow cube containing the spherical shell for computational simplicity.
[0060] After obtaining the valid voxels, determine the valid triangles and store the valid triangles in the valid voxels into the corresponding SdfBox, such as Figure 4 Specifically, all valid triangles meet the following conditions: the minimum distance of the SdfBox corresponding to the current voxel is D0, and the distance D from the triangle to the center of the current voxel satisfies The set of valid triangles is expressed as:
[0061]
[0062] The precise distance field of all points inside a voxel is only related to the triangles stored in the corresponding SdfBox. Therefore, constructing the SdfBox of a voxel is to store all valid triangles that meet the above conditions in the corresponding SdfBox.
[0063] (2) Constructing a hybrid distance field
[0064] The method for constructing an accurate distance field in (1) above calculates the SdfBox at any position within the voxel space of the triangular mesh model, which means that the distance field value at any position can be solved. Furthermore, in some scenarios, the construction time can be reduced by constructing a hybrid distance field, which also reduces the distance field solution time.
[0065] When generating the conformal gradient TPMS lattice structure of a triangular mesh model, not all points in the space need to have accurate distance field values. Therefore, not all voxels' SdfBoxes must be constructed. Only accurate distance field values are required for points near the boundary of the triangular mesh model, while the distance field values inside the model can be rough distance field values.
[0066] Specifically, for the solution of SdfBox with an offset of F in the vicinity of the triangular mesh, only all The SdfBox of the voxel is obtained (DT is the distance between the current voxel and the boundary voxel), thereby reducing the calculation. The calculation of SdfBox can adopt the method in (1) above, which will not be repeated here.
[0067] Therefore, the basic process of constructing a hybrid distance field is similar to that of constructing an exact distance field, except that voxels far from the boundary are filtered when constructing a multi-information voxel space based on distance field segmentation, such as Figure 5 shown.
[0068] S6. Distance field solution.
[0069] For a point P (x, y, z) to be found, calculate the voxel coordinates (I, J, K) where P is located, and then obtain the corresponding SdfBox that stores the triangle index. If SdfBox is empty, return the rough distance field value of the distance transformation; if it is not empty, calculate the shortest distance dist from P to all triangles stored in SdfBox and the pseudo normal of the nearest point. According to the pseudo normal, determine whether P is inside or outside the triangle mesh model, and then determine the sign of the distance field value, and return the distance field as sign*dist. The distance field result of the above model is as follows Figure 6 shown.
[0070] It will be easily understood by those skilled in the art that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.< / sdfbox> < / tri> < / box>
Claims
1. A method for generating distance fields of triangular mesh models based on multi-information voxels, characterized in that: The steps include: S1. Construct a triangular mesh model of the part to be manufactured; S2, dividing the bounding box space of the triangular mesh model into multiple voxels of the same size, and determining all triangles in the voxel that intersect with the voxel to form a voxel space based on space segmentation; S3. Perform distance transformation on the voxel space, i.e., calculate the signed distance from each voxel to its nearest boundary voxel to obtain a rough distance field; boundary voxels refer to voxels that intersect with the triangular mesh; S4. Determine valid voxels based on the rough distance field; calculate the minimum distance from the triangle to the voxel center in each valid voxel, and then determine the valid triangle, and store the valid triangle in the index SdfBox corresponding to the corresponding voxel; The voxels in the rough distance field DT(i,j,k) that satisfy the following formula are valid voxels: Where DT0 is the shortest distance from the current voxel to the nearest boundary voxel, and d is the side length of the voxel; S5. Determine the voxel where the point to be found is located, and then obtain the index SdfBox corresponding to the voxel; if SdfBox is empty, use the rough distance field after distance transformation as the distance field; if SdfBox is not empty, calculate the shortest distance from the point to be found to the triangle stored in SdfBox, and then determine the distance field.
2. The method for generating a distance field of a triangular mesh model based on multi-information voxels according to claim 1, wherein: Among valid voxels, a triangle that satisfies the following formula is a valid triangle: Where D is the distance from the triangle to the center of the corresponding voxel, D0 is the minimum distance from all triangles in the voxel to the voxel center, and d is the side length of the voxel.
3. The method for generating a distance field of a triangular mesh model based on multi-information voxels according to claim 1, wherein: In step S4, voxels far from the boundary are filtered, and valid voxels and valid triangles are determined within a certain offset range near the triangular mesh.
4. The method for generating a distance field of a triangular mesh model based on multi-information voxels according to claim 3, wherein: In step S4, voxels far from the boundary are filtered. Specifically, valid voxels are searched only among voxels that satisfy the following formula: Where DT is the distance from the current voxel to the nearest boundary voxel, F is the preset offset relative to the triangular mesh, and d is the side length of the voxel.
5. The method for generating a distance field of a triangular mesh model based on multi-information voxels according to claim 1, wherein: In step S5, if SdfBox is not empty, the shortest distance dist from the target point to all triangles stored in SdfBox is calculated, and the pseudo-normal is used to determine whether the target point is inside or outside the model, thereby determining the sign of the distance field value sign, and obtaining the distance field as sign*dist.
6. A distance field generation system for a triangular mesh model based on multi-information voxels, characterized in that: The method comprises a processor configured to execute the method for generating a distance field of a triangular mesh model based on multi-information voxels according to any one of claims 1 to 5.
Citation Information
Patent Citations
Multi-axis machining interference detection and processing method based on two-stage voxelization model
CN108663990A
Voxel-based image processing method and device
CN109242974A