Rapid conversion method and system from explicit geometry to implicit geometry
By constructing a linear boundary body hierarchy and octree structure, computing the adaptive grid unsigned distance field in parallel, and combining the angle weight pseudo-normal algorithm, a fast and efficient conversion from explicit geometry to implicit geometry is achieved, solving the existing solutions The problem of low conversion efficiency in technology improves graphics processing and physical simulation performance.
Patent Information
- Application Number
- CN202411222622.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-09-02
AI Technical Summary
The prior art is complex and inefficient in the conversion process of explicit geometry to implicit geometry, especially when processing complex scenarios or large-scale geometric data, and still needs to be optimized for processing efficiency and accuracy in large-scale or real-time applications. .
By constructing a linear boundary body hierarchy and octree structure on the input triangle mesh, and using nodes of the octree structure to calculate the adaptive mesh unsigned distance field in parallel, and compute the pseudo-normal algorithm for angle weights to calculate the pseudo-normal algorithm Line, finalize the symbol distance field data, and complete the conversion from implicit geometry to explicit geometry.
While maintaining high precision, greatly improve conversion efficiency, improve performance in fields such as graphics processing and physical simulation, and is suitable for multiple industrial and research fields.
Smart Images

Figure CN119206055A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer-aided design, and in particular to a method and system for quickly converting from explicit geometry to implicit geometry. Background Art
[0002] In the fields of computer-aided design (CAD) and computer graphics, the representation and processing of geometric models is one of the core methods. Geometric models are usually divided into two categories: explicit geometry and implicit geometry. Explicit geometry (such as STL and OBJ formats) usually directly represents the surface information of an object through data structures such as vertices, edges, and faces, and is widely used in 3D modeling, rendering, and manufacturing. Implicit geometry indirectly represents the surface of an object through functions (such as signed distance fields, SDF), and defines the geometric shape by judging the distance from a spatial point to the surface of the object. Implicit geometry has unique advantages in collision detection, physical simulation, and shape optimization.
[0003] The advantage of explicit geometry is that it is intuitive and easy to edit, but in some complex geometric operations and analyses (such as Boolean operations, collision detection, and physical simulation), explicit geometry has low computational efficiency. In contrast, implicit geometry exhibits higher computational efficiency and flexibility in these applications due to its continuity and analyticity. However, the conversion process between explicit and implicit geometry is usually computationally complex and time-consuming, especially when dealing with complex scenes or large-scale geometric data. This conversion often becomes a bottleneck in the entire workflow.
[0004] At present, there are many methods that attempt to solve the problem of efficient conversion from explicit geometry to implicit geometry, such as implicit representation methods based on neural networks and methods based on Voronoi diagrams. Nevertheless, these methods still have room for improvement in processing efficiency and accuracy, especially in large-scale or real-time applications, and still need further optimization.
[0005] Therefore, developing a method that can quickly convert explicit geometric models into implicit geometric models, especially a method that greatly improves the conversion efficiency while maintaining high accuracy, is of great significance for improving the overall performance of graphics processing, physical simulation, and related fields. The realization of this method will provide a powerful tool for multiple industries and research fields, and help promote the development and application of related methods. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a method and system for quickly converting from explicit geometry to implicit geometry in view of the deficiencies of the above-mentioned prior art.
[0007] The technical solution of the present invention to solve the above technical problem is as follows: a method for fast conversion from explicit geometry to implicit geometry, comprising the following steps:
[0008] Constructing a linear bounding volume hierarchy structure for the input triangular mesh, and constructing an octree structure based on the linear bounding volume hierarchy structure;
[0009] Using the nodes of the octree structure as sampling points, and using a linear bounding volume hierarchy combined with a minimum bounding box pruning method, the adaptive grid unsigned distance field is calculated in parallel for each sampling point;
[0010] The pseudo normal of the triangle mesh is calculated using the angle weighted pseudo normal algorithm, and the pseudo normal of the triangle mesh is used to calculate the sign of the unsigned distance field of the adaptive mesh;
[0011] The data of the signed distance field is determined according to the adaptive mesh unsigned distance field and the sign of the adaptive mesh unsigned distance field, and the conversion from implicit geometry to explicit geometry is completed.
[0012] The beneficial effects of the present invention are as follows: the fast conversion method from explicit geometry to implicit geometry of the present invention constructs a linear boundary volume hierarchy and an octree structure for a triangular mesh, calculates an adaptive mesh unsigned distance field based on the nodes of the octree structure, and then determines the sign of the unsigned distance field in combination with the pseudo-normal of the triangular mesh, and finally determines the data of the signed distance field to complete the conversion from implicit geometry to explicit geometry. The method greatly improves the conversion efficiency while maintaining high precision, and can improve the performance of graphics processing, physical simulation and application scenarios.
[0013] On the basis of the above technical solution, the present invention can also be improved as follows:
[0014] Further: the step of constructing a linear boundary volume hierarchy structure for the input triangular mesh specifically includes the following steps:
[0015] Taking the centroid coordinates of each triangle patch of the triangular mesh as initial data, the magic bit method is used to interleave the centroid position coordinates of the triangle patch represented by a 32-bit binary integer into a first Morton code represented by a 64-bit binary integer, and the axis-aligned bounding box of each triangle patch is calculated;
[0016] The first Morton codes of the centroid positions of the triangular face patches are sorted in order of size, the division position of the triangular face patches corresponding to each of the first Morton codes is determined by using a parallel algorithm, and the leaf nodes and internal nodes of the division nodes of the triangular face patches are stored in two different independent arrays according to a preset classification method, so as to obtain a first binary radix tree;
[0017] A corresponding axis-aligned bounding box is assigned to each of the first binary radix trees in a one-to-one correspondence, and the paths from the leaf nodes to the root nodes of the first binary radix trees are processed in parallel, so that each internal node and leaf node of the first binary radix tree matches the corresponding axis-aligned bounding box, thereby obtaining a linear boundary volume hierarchy.
[0018] The beneficial effect of the above further scheme is: by converting the centroid position coordinates of the triangular face into a 64-bit first Morton code, it is convenient to determine the division position of the corresponding triangular face, thereby constructing a first binary radix tree, and then assigning the corresponding axis-aligned bounding box to the first binary radix tree to complete the construction of the linear boundary volume hierarchy.
[0019] Further: the preset classification method is:
[0020] For each triangular face, compare the common prefix lengths of the first Morton codes of the two triangular facets on the left and right, and determine the division direction and division nodes;
[0021] All triangular facets represented by the first Morton code are regarded as leaf nodes, the division position is determined based on the leaf nodes, and whether the division node is an internal node is determined according to whether the leaf node is at the position of the division node.
[0022] The beneficial effect of the above further scheme is that the division direction and division node can be accurately found through the common prefix length of the first Morton code of the left and right triangular facets, and then whether the division node is an internal node is determined according to whether the triangular facet is at the position of the division node, thereby completing the division of leaf nodes and internal nodes, and facilitating the subsequent construction of an octree structure and an unsigned distance field.
[0023] Further: the step of constructing an octree structure based on the linear boundary volume hierarchy specifically includes the following steps:
[0024] Given an octree division level, the enclosing space of the triangular mesh is evenly divided into three-dimensional meshes corresponding to the voxel data one by one according to the octree division level, and a second binary radix tree is constructed using the voxel data;
[0025] Determine a corresponding second Morton code based on the second binary radix tree, use the second Morton code to determine all level nodes of the octree, allocate memory for all the level nodes, and store level node information of the octree;
[0026] Based on the set parent-child node relationship, a parallel processing method is used to determine the parent and child nodes of each level node, and an octree structure is obtained;
[0027] The parent-child node relationship is that the common prefix length between any two internal nodes of the octree can be divided by three, and the difference between the common prefix lengths of the two nodes divided by three is one.
[0028] The beneficial effect of the above further scheme is: by evenly dividing the enclosing space of the triangular mesh through a given octree division level, a three-dimensional mesh corresponding one-to-one to the voxel data can be obtained, thereby realizing the construction of a second binary radix tree, so that all the hierarchical nodes of the octree can be determined according to the second Morton code determined by the binary radix tree, thereby determining the parent and child nodes of the hierarchical nodes and obtaining the octree structure.
[0029] Further: the method of using the nodes of the octree structure as sampling points, using a linear bounding volume hierarchy structure combined with a minimum bounding box pruning method, and parallelizing the calculation of the adaptive grid unsigned distance field for each sampling point specifically includes the following steps:
[0030] Calculate the second Morton codes of all nodes of the octree structure, remove repeated Morton codes, and use the nodes of the octree structure corresponding to the different second Morton codes as sampling points p;
[0031] Determine the position of the projection point x of the sampling point p on the nearest triangular facet, and calculate the distance from the sampling point p to the nearest triangular facet based on the space reduction method of R-TREE;
[0032] Traverse the linear bounding volume hierarchy structure from top to bottom, and store all nodes of the linear bounding volume hierarchy structure into a stack S one by one;
[0033] For any node in the stack S, if the left child node or the right child node of the node is an internal node, the minimum distance and the minimum maximum distance from the node to the axis-aligned bounding box are calculated, and the minimum bounding box pruning process is performed, and the newly added internal nodes are stored in the stack S at the same time until all the nodes in the stack S are processed;
[0034] For any node in the stack S, if the left child node or the right child node of the node is a leaf node, the distance from the sampling point to the triangle patch represented by the leaf node is calculated, and the minimum value of all distances is used as the minimum distance from the sampling point to the triangle mesh, thereby completing the construction of the unsigned distance field.
[0035] The beneficial effect of the above further scheme is: by eliminating repeated second Morton codes, the computational efficiency can be improved, and the distance from the sampling point p to the nearest triangular facet can be accurately calculated according to the position of the projection point x of the sampling point p on the nearest triangular facet, and then the minimum bounding box pruning process is performed based on whether the left child node or the right child node of the node of the linear bounding volume hierarchy is an internal node, and finally, for the node whose left child node or right child node is a leaf node, the distance from the sampling point to the triangular facet represented by the leaf node is calculated, and then the minimum distance is determined, and the construction of the unsigned distance field can be completed.
[0036] Further: using the angle weighted pseudo-normal algorithm to calculate the pseudo-normal of the triangular mesh, and using the pseudo-normal of the triangular mesh to calculate the sign of the adaptive mesh unsigned distance field specifically includes the following steps:
[0037] Determine the pseudo normal of the triangle mesh according to the position of the projection point x of the sampling point p on the nearest triangle patch, specifically including: when the projection point x of the sampling point p on the nearest triangle patch is located in the triangle patch, determine the normal of the triangle patch according to the sampling point p and the projection point x, when the projection point x of the sampling point p on the nearest triangle patch is located on the edge of the triangle patch, define the edges between faces i and j to have normals n respectively i and n j , then the pseudo normal n of the triangle patch edge edge =π·n i +π·n j , when the projection point x of the sampling point p on the nearest triangle patch is located on the vertex of the triangle patch, the pseudo normal of the vertex of the triangle patch is n vertice =∑a i n i , where a i is the angle value of the vertex angle corresponding to the i-th face;
[0038] The pseudo normal of the triangular mesh is determined based on the pseudo normals of all triangular faces, and the direction vector r=px from the projection point x of the sampling point p to the query point p is determined according to the pseudo normal of the triangular mesh, and the sign of the query point p is determined according to the dot product of the direction vector r and the normal or pseudo normal at the projection point x.
[0039] The beneficial effect of the above further solution is that the pseudo normal of the triangle face can be accurately calculated through the position of the projection point x of the sampling point p on the nearest triangle face, and then the pseudo normal of the entire triangle mesh can be obtained, so that the sign of the unsigned distance field can be accurately obtained.
[0040] Further: the method for rapid conversion from explicit geometry to implicit geometry also includes the following steps:
[0041] The data of the signed distance field is stored in a vtk unstructured grid, and its isosurface is extracted to complete the visualization of the implicit geometry.
[0042] The beneficial effect of the above further solution is that by storing the data of the signed distance field in the vtk unstructured grid, the data of the signed distance field can be easily mapped to the visualization graphic data structure to realize the visualization of implicit geometry.
[0043] Further: the data of the signed distance field is stored in the vtk unstructured grid, and the isosurface is extracted, specifically comprising the following steps:
[0044] Initialize a vtk unstructured network, add the midpoint coordinates of the octree structure data to the vtk unstructured network, create a hexahedral unit according to the data type of the octree structure, and add the hexahedral unit to the vtk unstructured network;
[0045] Writing the data of the symbol distance field into the vtk unstructured grid in the form of point data;
[0046] Initialize the isosurface value and obtain the surface contour of the signed distance field. Use the isosurface filter module in the vtk unstructured network to extract the isosurface of the signed distance field and map it to the visualization graph data structure.
[0047] The beneficial effect of the above further solution is that by writing the data of the signed distance field into the vtk unstructured grid in the form of point data, it is convenient to extract isosurfaces and map them into a visualization graphic data structure to realize the visualization of implicit geometry.
[0048] The present invention also provides a fast conversion system from explicit geometry to implicit geometry, comprising a construction module, a first calculation module, a second calculation module and a conversion module:
[0049] The construction module is used to construct a linear boundary volume hierarchy structure for the input triangle mesh, and to construct an octree structure based on the linear boundary volume hierarchy structure;
[0050] The first calculation module is used to use the nodes of the octree structure as sampling points, and to calculate the adaptive grid unsigned distance field in parallel for each sampling point by using a linear bounding volume hierarchy combined with a minimum bounding box pruning method;
[0051] The second calculation module is used to calculate the pseudo normal of the triangular mesh by using the angle weighted pseudo normal algorithm, and calculate the sign of the adaptive mesh unsigned distance field by using the pseudo normal of the triangular mesh;
[0052] The conversion module is used to determine the data of the signed distance field according to the adaptive mesh unsigned distance field and the sign of the adaptive mesh unsigned distance field, so as to complete the conversion from implicit geometry to explicit geometry.
[0053] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for rapid conversion from explicit geometry to implicit geometry. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of a flow chart of a method for rapid conversion from explicit geometry to implicit geometry according to an embodiment of the present invention;
[0055] Figure 2 A schematic diagram of an octree structure according to an embodiment of the present invention;
[0056] Figure 3 A schematic diagram of a region divided by a triangular facet according to an embodiment of the present invention;
[0057] Figure 4 It is a schematic diagram of implicit geometry in different dimensions of an embodiment of the present invention;
[0058] Figure 5 A schematic diagram of an initial implicit geometry and a converted implicit geometry according to an embodiment of the present invention;
[0059] Figure 6 The figure is a schematic diagram of the structure of a system for rapid conversion from explicit geometry to implicit geometry according to an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.
[0061] like Figure 1As shown, the present invention provides a fast conversion method from explicit geometry to implicit geometry, and implements the construction of the algorithm on NVIDIA GeForce RTX 4080 laptop (GPU parameters are: 7424 CUDA cores, 12GB GDDR6 video memory, video memory bit width 192bit, core frequency 1510MHz, video memory frequency 2250MHz, acceleration frequency 1930MHz, CPU parameters are: Windows 11 Ultimate 64bits / Intel I9 CPU @ 2.3GHz / 32GRAM). This paper uses Visual Studio 2019 and CUDA 12.0 toolkit to implement the development of the algorithm, uses thrust library to implement the use of basic algorithms such as GPU sorting and reduction, and uses vtk library to implement the extraction of isosurfaces of signed distance fields, including the following steps:
[0062] S1: constructing a linear bounding volume hierarchy structure for the input triangular mesh, and constructing an octree structure based on the linear bounding volume hierarchy structure;
[0063] S2: using the nodes of the octree structure as sampling points, and using a linear bounding volume hierarchy combined with a minimum bounding box pruning method to parallelly calculate an adaptive grid unsigned distance field for each sampling point;
[0064] S3: Calculate the pseudo normal of the triangle mesh using the angle weighted pseudo normal algorithm, and calculate the sign of the adaptive mesh unsigned distance field using the pseudo normal of the triangle mesh;
[0065] S4: Determine the data of the signed distance field according to the adaptive mesh unsigned distance field and the sign of the adaptive mesh unsigned distance field, and complete the conversion from implicit geometry to explicit geometry.
[0066] The fast conversion method from explicit geometry to implicit geometry of the present invention constructs a linear boundary volume hierarchy and an octree structure for the triangular mesh, calculates an adaptive mesh unsigned distance field based on the nodes of the octree structure, and then determines the sign of the unsigned distance field in combination with the pseudo-normal of the triangular mesh, and finally determines the data of the signed distance field to complete the conversion from implicit geometry to explicit geometry. The method greatly improves the conversion efficiency while maintaining high precision, and can improve the performance of graphics processing, physical simulation and application scenarios.
[0067] In one or more embodiments of the present invention, constructing a linear bounding volume hierarchy structure for an input triangular mesh specifically includes the following steps:
[0068] S11: using the centroid coordinates of each triangle patch of the triangular mesh as initial data, using the magic bit method, interweaving the centroid position coordinates of the triangle patch represented by a 32-bit binary integer into a first Morton code represented by a 64-bit binary integer, and calculating the axis-aligned bounding box of each triangle patch;
[0069] In the embodiment of the present invention, the stanford bunny.st l file is used as the explicit geometric input source. The model has 112402 triangular facets. A program is written to read the st l file, read the triangular mesh data, and store it in the memory created by the cpu side, and then copy it to the gpu side for subsequent parallel calculation. Then, the "magic bit" method is used to interweave the centroid position coordinates of the triangular facets represented by 32-bit binary integers into the first morton code represented by 64-bit binary integers in the order of z, y, and x.
[0070] S12: sorting the first Morton codes of the centroid positions of the triangular face patches in order of size, determining the division position of the triangular face patches corresponding to each of the first Morton codes by using a parallel algorithm, and storing the leaf nodes and internal nodes of the division nodes of the triangular face patches into two different independent arrays according to a preset classification method, to obtain a first binary radix tree;
[0071] In order to construct a linear boundary volume hierarchy, the present invention adopts a parallel algorithm for constructing a binary radix tree. First, the previously generated first Morton codes are sorted in order of size. Due to the spatial characteristics of the first Morton codes, the first Morton codes are sorted so that the triangular facets represented by similar Morton codes are also positioned similarly in space.
[0072] Specifically, in one or more embodiments of the present invention, the preset classification method is:
[0073] S121: for each triangular face patch, compare the common prefix lengths of the first Morton codes of the two triangular face patches on the left and right, and determine the division direction and division nodes;
[0074] S122: All triangular facets represented by the first Morton code are regarded as leaf nodes, a division position is determined based on the leaf nodes, and whether the division node is an internal node is determined according to whether the leaf node is at the position of the division node γ.
[0075] Here, after identifying the internal nodes and leaf nodes, the internal nodes and leaf nodes are stored in two independent arrays, denoted as I and L. The arrangement order of the leaf nodes is arranged according to the initial order of the leaf nodes, that is, the order of the first Morton code in order of size, and the arrangement order of the internal nodes can be simply defined by the node layout, so that the root node of the internal node is located at the first position I0 of the array I, and the index of the child node of any internal node in the array I is allocated according to its respective division position. Specifically, if its left child node covers multiple leaf nodes (the node is an internal node), the left child node needs to be stored in I γ If the left child node is a leaf node (the node is not an internal node), the left child node needs to be stored in L γ Similarly, the right child node needs to be stored in I γ+1 or L γ+1 With this node layout, the construction of a binary radix tree can be completed by finding the appropriate split position to identify the child nodes.
[0076] S13: Assign a corresponding axis-aligned bounding box to each of the first binary radix trees in a one-to-one correspondence, and process the path from the leaf node to the root node of the first binary radix tree in parallel, so that each internal node and leaf node of the first binary radix tree matches the corresponding axis-aligned bounding box to obtain a linear boundary volume hierarchy.
[0077] Since the structure of the first binary radix tree is the same as the corresponding linear bounding volume hierarchy, after calculating the axis-aligned bounding box of each triangle patch, the corresponding axis-aligned bounding box is assigned to each leaf node of the first binary radix tree in a one-to-one correspondence, and then the path from the leaf node to the root node is processed in parallel so that each internal node of the first binary radix tree is also assigned a corresponding axis-aligned bounding box. Each thread starts from a leaf node and traverses the tree upward through the parent pointer recorded during the radix tree construction process.
[0078] It should be noted that, in the embodiment of the present invention, an atomic counter is used to track how many threads have accessed each internal node, and then when the first thread completes the processing, the first thread is immediately terminated, and the second thread continues to process the node. Finally, the corresponding axis-aligned bounding box is assigned to the internal node of the binary radix tree, and finally the construction of the linear bounding volume hierarchy is realized.
[0079] In one or more embodiments of the present invention, constructing an octree structure based on the linear boundary volume hierarchy structure specifically includes the following steps:
[0080] S14: given a division level of the octree, evenly dividing the enclosing space of the triangular mesh into three-dimensional meshes corresponding to the voxel data one by one according to the division level of the octree, and constructing a second binary radix tree using the voxel data;
[0081] In an embodiment of the present invention, since reducing sampling points can significantly improve computing efficiency without changing the resolution, nodes of an octree structure are used as sampling points. To realize the construction of an octree structure of an input mesh, a given octree division level is first set, which is set to 10 in this case, that is, the dimension of the octree structure is 512x512x512. Then, a parallelized triangle mesh voxelization method is used to obtain all nodes of a given level of the octree. Specifically, in each thread, the enclosing space of the entire triangle mesh is divided into a uniform three-dimensional grid according to a preset division level, each grid unit corresponds to a voxel, each thread processes a voxel independently, checks whether each triangle face intersects with the current voxel, and records the intersection information, and then reuses the binary radix tree construction method to construct a binary radix tree for the voxel data.
[0082] S15: determining a corresponding second Morton code based on the second binary radix tree, determining all level nodes of the octree using the second Morton code, and allocating memory for all the level nodes to store level node information of the octree;
[0083] Then, after constructing the second binary radix tree of voxel data, the characteristics of the second Morton code are used to find all the hierarchical nodes of the octree structure, assuming that each 3k-bit prefix of a given second Morton code is directly mapped to an octree node of level k.
[0084] S16: Based on the set parent-child node relationship, a parallel processing method is used to determine the parent and child nodes of each level node, and an octree structure is obtained;
[0085] The parent-child node relationship is that the common prefix length between any two internal nodes of the octree can be divided by three, and the difference between the common prefix lengths of the two nodes divided by three is one.
[0086] Specifically, in the binary radix tree of voxel data, if the common prefix length δ of a node is a multiple of three, it means that the node is an internal node of the octree. For example, if the common prefix length δ of a node is 0, then the node is the root node in the octree. Similarly, if the common prefix length δ of a node is 3, then the node is a child node of the root node in the octree. Therefore, for the common prefix length δ parent The parent node and the common prefix length are δ children If If it is divisible by three, an octree node can be generated between the child node and the parent node.
[0087] In practice, first a counter is set for each thread and initialized to zero, the number of octree nodes found by each thread is found, and then the set algorithm is executed to find the number of octree nodes of all levels and allocate memory for them, and then the octree node information is calculated and stored. Due to the characteristics of the second Morton code, if the common prefix length between two internal nodes can be divided by three, and the difference between the common prefix length of the two after dividing by three is one, it indicates that there is a parent-child node relationship between the two nodes. Based on the above relationship, a parallelization strategy is adopted to find the parent-child node relationship for each node, and finally the construction of the octree is completed, such as Figure 2 As shown in FIG. 2( a ), 2( b ) and 2( c ) are schematic diagrams of the octree structures of the front perspective, the top perspective and the side perspective, respectively.
[0088] In one or more embodiments of the present invention, using the nodes of the octree structure as sampling points, using a linear bounding volume hierarchy structure combined with a minimum bounding box pruning method, and parallelizing the calculation of the adaptive grid unsigned distance field for each sampling point specifically comprises the following steps:
[0089] S21: Calculate the third Morton codes of all nodes of the octree structure, remove repeated Morton codes, and use the nodes of the octree structure corresponding to the different third Morton codes as sampling points p;
[0090] Here, the grid nodes of the octree structure constructed above are used as sampling points. However, since the grid points are shared between adjacent nodes of the octree structure, there are a lot of repeated calculations in these queries. Specifically, each node of the octree structure needs to query its eight corner points separately, but since these corner points are usually shared by multiple nodes of the octree structure, most of the queries are actually repeated. In order to avoid this situation, in an embodiment of the present invention, a Morton code is calculated for each corner point according to its position. By using the third Morton code, it is ensured that each corner point is queried only once, thereby improving the efficiency of the overall calculation.
[0091] S22: Determine the position of the projection point x of the sampling point p on the nearest triangular facet, and calculate the distance from the sampling point p to the nearest triangular facet based on the space reduction method of R-TREE;
[0092] In the embodiment of the present invention, in order to calculate the minimum distance from the sampling point p to the triangle mesh, it is necessary to calculate the minimum distance from the sampling point p to the nearest triangle patch. To calculate the distance from the sampling point p to the nearest triangle patch, it is first necessary to determine whether the projection point x of the sampling point p falls on an edge, a vertex, or within a triangle patch. The reason is that in three different cases, the distance from the sampling point p to the line, point, or plane should be calculated respectively. When point p is projected into the triangle patch, the triangle patch can be divided into one of seven regions according to the position of the projection point x, such as Figure 3 As shown. If the projected point x is located in region R1, then the shortest distance from the point to the triangle patch is equal to the distance from the point to the triangle plane. If the projected point x is located in region R2, R3 or R4, the distance to the corresponding line should be calculated. For region R5, R6 or R7, the distance to the corresponding vertex should be calculated. In addition, since the sign of the distance field needs to be calculated using the angle-weighted pseudo-normal algorithm later, the region of the point projection needs to be recorded in the process of calculating the distance from the point to the triangle patch.
[0093] When calculating the minimum distance from a point to a triangular mesh, a spatial reduction method based on R-TREE is used to accelerate this process. In order to use this method, it is necessary to first understand the concepts of minimum distance and minimum maximum distance. The minimum distance (MinDist) is the lower limit or optimistic estimate of the distance between the query point and a spatial object in the bounding box. However, the actual minimum distance between the query point and the nearest object may be larger than the minimum distance, so it is necessary to use the minimum maximum distance (MinMaxDist) as the second metric, which provides an upper limit on the distance between the actual object and the query point. In other words, the minimum maximum distance provides a conservative estimate of the distance between the query point and a spatial object in the bounding box, that is, finding the minimum distance in a set of maximum distances. After constructing the minimum distance and minimum maximum distance from the query point to the bounding box, the pruning strategy of the present invention is that if the minimum maximum distance from the sampling point to the A bounding box is less than the minimum distance from the sampling point to the B bounding box, the distance from the query point to the spatial object in the B bounding box must not be the minimum distance, so the spatial objects in the B bounding box do not need to be calculated and can be directly pruned. Therefore, using the R-TREE-based space reduction method to perform minimum distance calculation can reduce the number of triangles that need to be calculated and can speed up the calculation efficiency.
[0094] S23: traverse the linear boundary volume hierarchy structure from top to bottom, and store all nodes of the linear boundary volume hierarchy structure into a stack S one by one;
[0095] Here, one root node is stored each time, and then the nodes to be processed are stored in sequence according to whether they meet the pruning conditions and the parent-child relationship of the nodes until all nodes are processed.
[0096] S24: for any node in the stack S, if the left child node or the right child node of the node is an internal node, the minimum distance and the minimum maximum distance from the node to the axis-aligned bounding box are calculated, and a minimum bounding box pruning process is performed, and the newly added internal nodes are stored in the stack S at the same time until all nodes in the stack S are processed;
[0097] S25: For any node in the stack S, if the left child node or the right child node of the node is a leaf node, the distance from the sampling point to the triangle patch represented by the leaf node is calculated, and the minimum value of all distances is used as the minimum distance from the sampling point to the triangle mesh, thereby completing the construction of the unsigned distance field.
[0098] In one or more embodiments of the present invention, using an angle-weighted pseudo-normal algorithm to calculate a pseudo-normal of a triangular mesh, and using the pseudo-normal of the triangular mesh to calculate the sign of an adaptive mesh unsigned distance field specifically include the following steps:
[0099] S31: determining a pseudo normal of the triangle mesh according to the position of the projection point x of the sampling point p on the nearest triangle patch;
[0100] Specifically, when the projection point x of the sampling point p on the nearest triangular patch is located within the triangular patch, the normal of the triangular patch is determined according to the sampling point p and the projection point x;
[0101] When the projection point x of the sampling point p on the nearest triangular patch is located on the edge of the triangular patch, the edge between the defined faces i and j has normals n i and n j , then the pseudo normal n of the triangle patch edge edge =π·n i +π·n j , when the projection point x of the sampling point p on the nearest triangle patch is located on the vertex of the triangle patch, the pseudo normal of the vertex of the triangle patch is n vertice =∑a i n i , where a i is the angle value of the vertex angle corresponding to the i-th face;
[0102] S32: Determine the pseudo-normal of the triangular mesh based on the pseudo-normals of all triangular meshes, and determine the direction vector r=px from the projection point x of the sampling point p to the query point p according to the pseudo-normal of the triangular mesh, and determine the sign of the query point p according to the dot product of the direction vector r and the normal or pseudo-normal at the projection point x.
[0103] The pseudo normal of the triangle patch can be accurately calculated through the position of the projection point x of the sampling point p on the nearest triangle patch, and then the pseudo normal of the entire triangle mesh can be obtained, so that the sign of the unsigned distance field can be accurately obtained.
[0104] Optionally, in one or more embodiments of the present invention, the method for fast conversion from explicit geometry to implicit geometry further includes the following steps:
[0105] S5: Store the data of the signed distance field in a vtk unstructured grid, extract its isosurface, and complete the visualization of the implicit geometry.
[0106] By storing the data of the signed distance field in a vtk unstructured grid, the data of the signed distance field can be easily mapped to a visualization graph data structure to achieve visualization of implicit geometry.
[0107] In one or more embodiments of the present invention, the step of storing the data of the signed distance field in a vtk unstructured grid and extracting its isosurface specifically comprises the following steps:
[0108] S51: Initialize the vtk unstructured network, add the midpoint coordinates of the octree structure data to the vtk unstructured network, create a hexahedral unit according to the data type of the octree structure, and add the hexahedral unit to the vtk unstructured network;
[0109] S52: writing the data of the signed distance field into the vtk unstructured grid in the form of point data;
[0110] S53: Initialize the isosurface value and obtain the surface contour of the signed distance field, extract the isosurface of the signed distance field through the isosurface filter module in the vtk unstructured network, and map it to the visualization graph data structure.
[0111] Here, the isosurface value is initialized to zero, and after being mapped to the visualization graphics data structure, the generated isosurface is presented through the cooperation of the vtk rendering module to realize the three-dimensional visualization of the signed distance field. This process can dynamically adjust the viewing angle and isosurface parameters to better analyze and display geometric features and realize the visualization of implicit geometry, such as Figure 4 and 5 As shown, Figure 4 (4a) is the implicit geometry diagram when the grid dimension is 128*128*128 and the time is 153.3ms. Figure 4 (4b) is the implicit geometry diagram when the grid dimension is 256*256*256 and the time is 243.3ms. Figure 4(4c) is a schematic diagram of implicit geometry when the grid dimension is 512*512*512 and the time is 560.2ms. Figure 5 (5a) is the initial explicit geometry diagram. Figure 5 (5b) is a schematic diagram of the explicit geometry after the conversion. It can be seen that the image is almost not distorted before and after the conversion by the method of the present invention, and the conversion efficiency is greatly improved while maintaining high accuracy.
[0112] It should be noted that after the visualization of implicit geometry is completed, the extracted isosurface data can also be set as the input source of the writer. If needed, use the vtkSTLWriter module in VTK to export the extracted isosurface data to STL format. This process can convert implicit geometry into explicit geometry, so that the model can be built and saved after implicit modeling is completed. Through this conversion, a bridge can be established between implicit geometry and explicit geometry, which is convenient for subsequent application and analysis.
[0113] like Figure 6 As shown, the present invention also provides a fast conversion system from explicit geometry to implicit geometry, including a construction module, a first calculation module, a second calculation module and a conversion module:
[0114] The construction module is used to construct a linear bounding volume hierarchy structure for the input triangular mesh, and to construct an octree structure based on the linear bounding volume hierarchy structure;
[0115] The first calculation module is used to use the nodes of the octree structure as sampling points, and to calculate the adaptive grid unsigned distance field in parallel for each sampling point by using a linear bounding volume hierarchy combined with a minimum bounding box pruning method;
[0116] The second calculation module is used to calculate the pseudo normal of the triangular mesh by using the angle weighted pseudo normal algorithm, and calculate the sign of the adaptive mesh unsigned distance field by using the pseudo normal of the triangular mesh;
[0117] The conversion module is used to determine the data of the signed distance field according to the adaptive grid unsigned distance field and the sign of the adaptive grid unsigned distance field, and complete the visualization of implicit geometry and the conversion to explicit geometry.
[0118] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for rapid conversion from explicit geometry to implicit geometry.
[0119] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A fast conversion method from explicit geometry to implicit geometry, characterized in that: The steps include: Constructing a linear bounding volume hierarchy structure for the input triangular mesh, and constructing an octree structure based on the linear bounding volume hierarchy structure; Using the nodes of the octree structure as sampling points, and using a linear bounding volume hierarchy combined with a minimum bounding box pruning method, the adaptive grid unsigned distance field is calculated in parallel for each sampling point; The pseudo normal of the triangle mesh is calculated using the angle weighted pseudo normal algorithm, and the pseudo normal of the triangle mesh is used to calculate the sign of the unsigned distance field of the adaptive mesh; The data of the signed distance field is determined according to the adaptive mesh unsigned distance field and the sign of the adaptive mesh unsigned distance field, and the conversion from implicit geometry to explicit geometry is completed.
2. The method for fast conversion from explicit geometry to implicit geometry according to claim 1, characterized in that: The step of constructing a linear boundary volume hierarchy structure for the input triangular mesh specifically includes the following steps: Taking the centroid coordinates of each triangle patch of the triangular mesh as initial data, the magic bit method is used to interleave the centroid position coordinates of the triangle patch represented by a 32-bit binary integer into a first Morton code represented by a 64-bit binary integer, and the axis-aligned bounding box of each triangle patch is calculated; The first Morton codes of the centroid positions of the triangular face patches are sorted in order of size, the division position of the triangular face patches corresponding to each of the first Morton codes is determined by using a parallel algorithm, and the leaf nodes and internal nodes of the division nodes of the triangular face patches are stored in two different independent arrays according to a preset classification method, so as to obtain a first binary radix tree; A corresponding axis-aligned bounding box is assigned to each of the first binary radix trees in a one-to-one correspondence, and the paths from the leaf nodes to the root nodes of the first binary radix trees are processed in parallel, so that each internal node and leaf node of the first binary radix tree matches the corresponding axis-aligned bounding box, thereby obtaining a linear boundary volume hierarchy.
3. The method for fast conversion from explicit geometry to implicit geometry according to claim 2, characterized in that: The preset classification method is: For each triangular face, compare the common prefix lengths of the first Morton codes of the two triangular facets on the left and right, and determine the division direction and division nodes; All triangular facets represented by the first Morton code are regarded as leaf nodes, the division position is determined based on the leaf nodes, and whether the division node is an internal node is determined according to whether the leaf node is at the position of the division node.
4. The method for fast conversion from explicit geometry to implicit geometry according to claim 2, characterized in that: The step of constructing an octree structure based on the linear boundary volume hierarchy specifically includes the following steps: Given an octree division level, the enclosing space of the triangular mesh is evenly divided into three-dimensional meshes corresponding to the voxel data one by one according to the octree division level, and a second binary radix tree is constructed using the voxel data; Determine a corresponding second Morton code based on the second binary radix tree, use the second Morton code to determine all level nodes of the octree, allocate memory for all the level nodes, and store level node information of the octree; Based on the set parent-child node relationship, a parallel processing method is used to determine the parent and child nodes of each level node, and an octree structure is obtained; The parent-child node relationship is that the common prefix length between any two internal nodes of the octree can be divided by three, and the difference between the common prefix lengths of the two nodes divided by three is one.
5. The method for fast conversion from explicit geometry to implicit geometry according to claim 1, characterized in that: The method of using the nodes of the octree structure as sampling points and using a linear bounding volume hierarchy structure combined with a minimum bounding box pruning method to parallelly calculate the adaptive grid unsigned distance field for each sampling point specifically includes the following steps: Calculate the third Morton codes of all nodes of the octree structure, remove repeated Morton codes, and use the nodes of the octree structure corresponding to the different third Morton codes as sampling points p; Determine the position of the projection point x of the sampling point p on the nearest triangular facet, and calculate the distance from the sampling point p to the nearest triangular facet based on the space reduction method of R-TREE; Traverse the linear bounding volume hierarchy structure from top to bottom, and store all nodes of the linear bounding volume hierarchy structure into a stack S one by one; For any node in the stack S, if the left child node or the right child node of the node is an internal node, the minimum distance and the minimum maximum distance from the node to the axis-aligned bounding box are calculated, and the minimum bounding box pruning process is performed, and the newly added internal nodes are stored in the stack S at the same time until all the nodes in the stack S are processed; For any node in the stack S, if the left child node or the right child node of the node is a leaf node, the distance from the sampling point to the triangle patch represented by the leaf node is calculated, and the minimum value of all distances is used as the minimum distance from the sampling point to the triangle mesh, thereby completing the construction of the unsigned distance field.
6. The method for fast conversion from explicit geometry to implicit geometry according to claim 5, characterized in that: Calculating the pseudo normal of the triangular mesh using the angle weighted pseudo normal algorithm and calculating the sign of the adaptive mesh unsigned distance field using the pseudo normal of the triangular mesh specifically include the following steps: Determine the pseudo normal of the triangle mesh according to the position of the projection point x of the sampling point p on the nearest triangle patch, specifically including: when the projection point x of the sampling point p on the nearest triangle patch is located in the triangle patch, determine the normal of the triangle patch according to the sampling point p and the projection point x, when the projection point x of the sampling point p on the nearest triangle patch is located on the edge of the triangle patch, define the edges between faces i and j to have normals n respectively i and n j , then the pseudo normal n of the triangle patch edge edge =π·n i +π·n j , when the projection point x of the sampling point p on the nearest triangle patch is located on the vertex of the triangle patch, the pseudo normal of the vertex of the triangle patch is n vertice =∑a i n i , where a i is the angle value of the vertex angle corresponding to the i-th face; The pseudo normal of the triangular mesh is determined based on the pseudo normals of all triangular faces, and the direction vector r=px from the projection point x of the sampling point p to the query point p is determined according to the pseudo normal of the triangular mesh, and the sign of the query point p is determined according to the dot product of the direction vector r and the normal or pseudo normal at the projection point x.
7. The method for fast conversion from explicit geometry to implicit geometry according to claim 1, characterized in that: The following steps are also included: The data of the signed distance field is stored in a vtk unstructured grid, and its isosurface is extracted to complete the visualization of the implicit geometry.
8. The method for fast conversion from explicit geometry to implicit geometry according to claim 7, characterized in that: The method of storing the data of the signed distance field in the vtk unstructured grid and extracting its isosurface specifically includes the following steps: Initialize a vtk unstructured network, add the midpoint coordinates of the octree structure data to the vtk unstructured network, create a hexahedral unit according to the data type of the octree structure, and add the hexahedral unit to the vtk unstructured network; Writing the data of the symbol distance field into the vtk unstructured grid in the form of point data; Initialize the isosurface value and obtain the surface contour of the signed distance field. Use the isosurface filter module in the vtk unstructured network to extract the isosurface of the signed distance field and map it to the visualization graph data structure.
9. A fast conversion system from explicit geometry to implicit geometry, characterized in that: It includes a building module, a first calculation module, a second calculation module and a conversion module: The construction module is used to construct a linear bounding volume hierarchy structure for the input triangular mesh, and to construct an octree structure based on the linear bounding volume hierarchy structure; The first calculation module is used to use the nodes of the octree structure as sampling points, and to calculate the adaptive grid unsigned distance field in parallel for each sampling point by using a linear bounding volume hierarchy combined with a minimum bounding box pruning method; The second calculation module is used to calculate the pseudo normal of the triangular mesh by using the angle weighted pseudo normal algorithm, and calculate the sign of the adaptive mesh unsigned distance field by using the pseudo normal of the triangular mesh; The conversion module is used to determine the data of the signed distance field according to the adaptive mesh unsigned distance field and the sign of the adaptive mesh unsigned distance field, so as to complete the conversion from implicit geometry to explicit geometry.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for fast conversion from explicit geometry to implicit geometry described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Rendering method based on three-dimensional model layering implicit field
CN114283245A
Triangular mesh model distance field generation method and system based on multi-information voxel
CN115423973A
Adaptive distance field construction method based on bounding volume hierarchy
CN116310119A
Additive manufacturing of a 3D part
EP3483755A1
Systems and methods for implicit surface modeling
US10083264B1
Cited By
Three-dimensional model filling method and device, storage medium and electronic equipment
CN119579841A
Unstructured grid division method based on structured grid and electronic equipment
CN120726262A
Architectural design modeling method and system based on parameter entity and Boolean relationship thereof
CN121502893A
