A compression storage method for 3D printing files

By evaluating the local density and distance accumulation sum of the triangle face sheets in 3D printed files and dynamically adjusting the length of the to-code area of ​​the sliding window, the problem of the low efficiency of the LZ77 algorithm in 3D printed files is solved, and more efficient data compression and storage is achieved.

CN119417917BActive Publication Date: 2025-05-20JIANGSU VILORY ADVANCED MATERIALS TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510020239.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-05-20
Estimated Expiration
2045-01-07

AI Technical Summary

Technical Problem

In 3D printed file compression, the LZ77 algorithm has low compression efficiency due to the disordered storage of triangular face sheets and fixed-sized sliding windows.

Method used

By evaluating the local density of the triangular face sheet and the sum of the distance between the triangular face sheets, the target triangular face sheet and non-target triangular face sheet are determined, and data preprocessing and sorting are performed, the length of the area to be encoded in the sliding window is dynamically adjusted to adapt to the characteristics of different density areas.

Benefits of technology

The compression efficiency of the LZ77 algorithm is improved, and the repetitive mode utilization in the data sequence is enhanced by optimizing the storage sequence of the triangle sheet and the setting of sliding windows, and the cost of storage and transmission is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119417917B_ABST
    Figure CN119417917B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data processing technology, and in particular to a method for compressing and storing a 3D printing file. The method comprises: reading a triangular mesh of a 3D printing file, screening target triangular facets and non-target triangular facets, preprocessing data information of the target triangular facets and non-target triangular facets into byte data, creating a data storage space, first storing the byte data of the target triangular facets in its data storage space, then sorting the data in the data storage space, sorting all the data storage spaces in descending order according to the local density of the target triangular facets to obtain the sorted data storage space, dynamically adjusting the length of a to-be-encoded area of ​​a sliding window of each byte data according to the position of each byte data in each data storage space, compressing and storing the 3D printing file based on the length of the to-be-encoded area using an LZ77 algorithm, thereby improving compression efficiency and saving storage costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing. Specifically, it relates to a method for compressing and storing 3D printing files. Background Art

[0002] Metal 3D printing is an advanced additive manufacturing technology. Based on digital model files, it uses special wax materials, powdered metals, plastics and other bondable materials to manufacture three-dimensional objects by layer-by-layer printing of the bondable materials. To achieve high-precision 3D printing, highly subdivided triangular meshes are usually required to represent 3D models. These triangular meshes are usually stored in the STL (Stereolithography) format. The STL format is a stereolithography computer-aided design file format for storing 3D models. It describes the model through the three vertex coordinates and normal vectors of each triangular facet in the triangular mesh.

[0003] As the degree of subdivision of the triangular mesh increases, the number of triangular facets contained in the 3D printing file will also increase accordingly, which easily leads to an increase in the file size, increasing the hardware storage cost and transmission bandwidth cost of 3D printing. Therefore, it is necessary to compress and store the 3D printing file to reduce the storage and transmission costs. For example, the Chinese patent document with the publication number CN117893625A discloses a method, device and computer equipment for compressing slice data of a 3D model. Among them, the compression method includes: performing slice processing on the target model to obtain slice data; performing replacement processing on the pixel values of multiple pixel points in the slice data that meet the first preset rule to obtain the pixel values after replacement of the multiple pixel points; encoding the pixel values after replacement of the multiple pixel points to obtain the encoded slice data; and compressing the encoded slice data to obtain the target compressed file.

[0004] The LZ77 (Lempel-Ziv-1977) algorithm is a common dictionary-based lossless data compression algorithm. When using the LZ77 algorithm to compress 3D printing files, since the LZ77 algorithm compresses based on the sequential characteristics of the data, and the data of triangular facets in STL files are stored disorderly, this means that triangular facets with common vertices may not be adjacent in the file sequence, which will affect the effectiveness of compression. For example, assume that two adjacent triangular facets have a common vertex, but they are not stored adjacent to each other in the file, and the LZ77 algorithm cannot effectively utilize the common vertex information of these two triangular facets for compression. In addition, the LZ77 algorithm compresses data using a fixed-size window, and different triangular facets are surrounded by different numbers of triangular facets. The fixed-size sliding window cannot effectively utilize the characteristics of triangular facets for compression, resulting in a low compression ratio. For example, in areas where triangular facets are dense, a larger sliding window may be more suitable for capturing repeating patterns, while in areas where triangular facets are sparse, a smaller sliding window may be more appropriate.

[0005] It can be seen that during the process of compressing 3D printing files using the LZ77 algorithm, both the disorderly storage of triangular facets and the fixed-size sliding window will affect the compression efficiency. Summary of the Invention

[0006] To solve the problems that the LZ77 algorithm has in 3D printing file compression due to the disorderly storage of triangular facets and the fixed-size sliding window affecting the compression efficiency, the present invention proposes a compression and storage method for 3D printing files, and specifically adopts the following scheme:

[0007] The present invention provides a compression and storage method for 3D printing files, including:

[0008] Read the triangular mesh of the 3D printing file. The triangular mesh includes a number of triangular facets. Determine all target triangular facets and non-target triangular facets according to the local density of each triangular facet and the sum of distances between each triangular facet and the remaining triangular facets, and preprocess the data information of the target triangular facets and non-target triangular facets into byte data;

[0009] Create a data storage space for each of the target triangular facets. First, store the byte data of the target triangular facets in their data storage spaces, and then store the byte data of the non-target triangular facets in the data storage space of the target triangular facet closest to it;

[0010] Sort the byte data of the non-target triangular patches in the data storage space of the target triangular patches in ascending order of the distance, and sort all the data storage spaces of the target triangular patches in descending order of the local density of the target triangular patches to obtain multiple sorted data storage spaces;

[0011] Determine the length of the to-be-encoded area of the sliding window for each byte data according to the position of each byte data in each data storage space, and use the LZ77 algorithm to compress and store the 3D printing file based on the length of the to-be-encoded area.

[0012] The above technical solution can determine the target triangular patches with higher local density and the non-target triangular patches with lower local density by evaluating the local density of each triangular patch and the cumulative sum of the distances between the triangular patches. This helps to preferentially process the triangular patches with higher local density in the subsequent compression process, thereby increasing the repeated patterns in the data sequence. And sorting the byte data of the non-target triangular patches in ascending order of the distance can ensure that the triangular patches with common vertices are more closely adjacent in the data sequence. Sorting the data storage spaces of the target triangular patches in descending order of the local density can ensure that the triangular patches with higher local density are in the front in the data sequence, so that the repeated patterns in these triangular patches can be utilized earlier in the compression process, which can improve the compression effect. And by dynamically adjusting the length of the to-be-encoded area of the sliding window according to the position of each byte data, it can better adapt to the characteristics of different density regions and improve the compression efficiency. For example, in the area where triangular patches are dense, a larger sliding window may be more suitable for capturing repeated patterns, while in the area where triangular patches are sparse, a smaller sliding window may be more appropriate. This dynamic adjustment can more effectively utilize the repeated patterns in the data sequence and improve the compression efficiency.

[0013] Further, the method for determining the length of the to-be-encoded area of the sliding window for each byte data according to the position of each byte data in each data storage space is as follows:

[0014] Statistical maximum value of the number of all triangular patches to which each vertex in the triangular mesh belongs ;

[0015] If a certain byte data is at the starting position of any of the data storage spaces, the length of the to-be-encoded area of the sliding window of this byte data is , is the first preset value;

[0016] If this byte data is at other positions, the length of the to-be-encoded area of the sliding window of this byte data is: , where is the maximum value function, is the length of the area to be encoded in the sliding window of the previous byte data of this byte data.

[0017] Through the above technical solution, by dynamically adjusting the length of the area to be encoded in the sliding window of each byte data, it can be ensured that when each byte is compressed, the sliding window can better adapt to different data density regions, so that the data in the area to be encoded in the sliding window has high repeatability and the compression efficiency is improved.

[0018] Further, the local density is calculated according to the following relational expression:

[0019] ;

[0020] In the formula, is the local density of the th triangular facet, , are the maximum value and minimum value functions respectively, is the cosine similarity between the sums of the normal vectors of all the triangular facets to which the first and second vertices of the th triangular facet belong, is the cosine similarity between the sums of the normal vectors of all the triangular facets to which the second and third vertices of the th triangular facet belong, is the cosine similarity between the sums of the normal vectors of all the triangular facets to which the first and third vertices of the th triangular facet belong, is the mean value of the cosine similarities between the normal vector of the th triangular facet and the normal vectors of all the adjacent triangular facets of the th triangular facet.

[0021] Through the above technical solution, by calculating the local density of each triangular facet, the regions with relatively complex local features in the 3D model can be effectively distinguished, which is very crucial for subsequent triangular facet classification and compression processing. And this formula quantifies the difference in normal vectors between triangular facets through cosine similarity, can reflect the detail complexity of the environment around the triangular facet, helps to accurately identify the high-density regions, and takes these complex regions as the key points of compression in subsequent compression, thus being beneficial to improving the compression efficiency.

[0022] Further, the sliding window includes an area to be encoded and a dictionary area.

[0023] Further, the method for obtaining all the adjacent triangular facets of the triangular facet is: taking all the triangular facets having a common vertex with this triangular facet as all the adjacent triangular facets of this triangular facet.

[0024] Through accurately identifying the adjacent relationships between triangular patches, the above technical solution can better utilize the similarities between these triangular patches for data compression to improve the compressibility of the data.

[0025] Further, the method for obtaining all the triangular patches to which the vertex belongs is: taking all the triangular patches with this vertex as the common vertex as all the triangular patches to which this vertex belongs.

[0026] The above technical solution helps to optimize the data organization method by identifying the triangular patches associated with each vertex, ensuring that the triangular patches with common vertices are in close positions when stored.

[0027] Further, the method for determining all the target triangular patches and non-target triangular patches is:

[0028] Selecting the top % of the triangular patches with the largest local density in the triangular mesh as the first triangular patches, where

[0029] Taking the mean value of all vertex coordinates of each of the first triangular patches as the coordinate of each of the first triangular patches, and calculating the cumulative sum of the Euclidean distances between each of the first triangular patches and other triangular patches;

[0030] Taking the first triangular patches with the largest cumulative sum of the Euclidean distances as the target triangular patches, and taking the other triangular patches in the triangular mesh except the target triangular patches as the non-target triangular patches, where

[0031] The above technical solution can effectively identify the target triangular patches with large local density and relatively dispersed distribution, which helps to adjust the subsequent compression strategy, giving priority to processing the target triangular patches during compression and then processing the non-target triangular patches around each target triangular patch to improve the compression effect of the LZ77 algorithm.

[0032] Further, the data information includes: vertex coordinates, normal vectors, and attributes.

[0033] The present invention has the following effects:

[0034] In the compression of 3D printing files, by reordering triangular facets, triangular facets with common vertices can be made adjacent in the file sequence, thereby improving the compression efficiency of the LZ77 algorithm. In addition, by dynamically adjusting the size of the area to be encoded in the sliding window, byte data with high repeatability is placed in the same area to be encoded, so as to better utilize the characteristics of triangular facets in the data sequence for compression, thereby improving the compression efficiency and reducing the storage and transmission costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] By referring to the following detailed description with reference to the accompanying drawings, the above and other objects, features, and advantages of the exemplary embodiments of the present invention will become readily understandable. In the drawings, several embodiments of the present invention are shown in an exemplary rather than restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0036] Figure 1 is a schematic flowchart of the method of the present invention;

[0037] Figure 2 is a schematic diagram of triangular facets of the present invention;

[0038] Figure 3 is a schematic diagram of the sorting of the data storage space of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0039] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0040] The following will describe in detail the specific embodiments of the present invention with reference to the accompanying drawings.

[0041] Refer to Figure 1 , a method for compressing and storing 3D printing files, including steps S1 - S3, specifically as follows:

[0042] S1: Read the triangular mesh of the 3D printing file, and determine the target triangular facets and non-target triangular facets.

[0043] S11: Read the triangular mesh of the 3D printing file.

[0044] First, determine the format of the 3D printing file. The most common format is the STL format. Then, parse the file header to obtain the basic information of the file. The file header usually contains 80 bytes (bytes 0 to 79) of text information, which can include the file name or other descriptive information. Next, read the number of triangular facets. The 4 bytes (bytes 80 to 83) after the file header represent the total number of triangular facets, indicating how many triangular facets need to be parsed. That is, the first 84 bytes all represent the relevant descriptive information of the 3D printing file. Finally, read the triangular facet data: traverse the data of each triangular facet, including the normal vector (12 bytes), vertex coordinates (each vertex coordinate occupies 12 bytes, and each triangular facet has 3 vertices, a total of 36 bytes), and the attribute byte counter (2 bytes, usually set to 0).

[0045] Construct a triangular facet mesh based on the data read above. The triangular facet mesh consists of multiple triangular facets, and each triangular facet contains three vertex coordinates and a normal vector.

[0046] S12: Evaluate the local density of each triangular facet in the triangular mesh.

[0047] In the triangular facet mesh, within the same range, the areas with complex surfaces have relatively more triangular facets (higher density), while the areas with smooth surfaces have relatively fewer triangular facets (lower density). To improve the local data repeatability in the 3D printing file and better utilize the LZ77 algorithm to compress the 3D printing file, it is necessary to analyze the density of the triangular facets, as follows:

[0048] For any triangular facet, consider all the triangular facets that share a common vertex with this triangular facet as all the neighboring triangular facets of this triangular facet; for any vertex of this triangular facet, consider all the triangular facets that have this vertex as a common vertex as all the triangular facets to which this vertex belongs.

[0049] As Figure 2 shown, taking the triangular facet as an example, its 3 vertices are respectively 、 、 , taking as the common vertex, the other triangular facets are triangular facet 、triangular facet 、triangular facet 、triangular facet 、triangular facet , then these triangular facets are all the triangular facets to which belongs. Taking as the common vertex, the other triangular facets are triangular facet 、triangular facet 、triangular facet , triangular facets , triangular facets , then these triangular facets are all the triangular facets to which it belongs, with the other triangular facets sharing it as a common vertex being triangular facet , triangular facet , triangular facet , triangular facet , then these triangular facets are all the triangular facets to which it belongs, and finally the adjacent triangular facets of triangular facet are: triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , triangular facet , In this way, all the adjacent triangular facets of each triangular facet in the triangular mesh and all the triangular facets to which each vertex belongs are obtained.

[0050] Based on the cosine similarity between the normal vector of each triangular facet and the normal vectors of its adjacent triangular facets, and the cosine similarity between the sum of the normal vectors of all the triangular facets to which each vertex belongs and the sum of the normal vectors of all the triangular facets to which other vertices belong, calculate the local density of each triangular facet. The calculation formula is as follows:

[0051]

[0052] In the formula, is the local density of the -th triangular facet, , are the maximum and minimum value functions respectively, is the cosine similarity between the sum of the normal vectors of all the triangular facets to which the first vertex of the -th triangular facet belongs and the sum of the normal vectors of all the triangular facets to which the second vertex belongs, is the cosine similarity between the sum of the normal vectors of all the triangular facets to which the second vertex belongs and the sum of the normal vectors of all the triangular facets to which the third vertex belongs, is the cosine similarity between the sum of the normal vectors of all the triangular facets to which the first vertex belongs and the sum of the normal vectors of all the triangular facets to which the third vertex belongs, is the The mean cosine similarity between the normal vector of a triangular patch and the normal vectors of all its neighboring triangular patches.

[0053] In this formula, represents the maximum difference between the cosine similarities between the sums of the normal vectors of all the triangular patches to which any two vertices of the -th triangular patch belong among the three vertices of the -th triangular patch. The larger this value, the more complex the distribution of the triangular patches near the three vertices of the -th triangular patch, that is, the more triangular patches there may be around the -th triangular patch, and the greater the local density of the -th triangular patch. Conversely, the smaller this value, the simpler the distribution of the triangular patches near the three vertices of the -th triangular patch, that is, the fewer triangular patches there may be around the -th triangular patch, and the smaller the local density of the -th triangular patch.

[0054] In this formula, since the value range of is from -1 to 1, which is not convenient to directly participate in the calculation of local density, the range of action of is adjusted by adding 1 and dividing by 2. The larger the adjusted value, the closer the direction of the normal vector of the -th triangular patch is to the normal vectors of all its neighboring triangular patches. Then, the surface formed by the triangular patches around the -th triangular patch is smoother, and the number of triangular patches around the -th triangular patch may be fewer, that is, the relative local density of the -th triangular patch is relatively smaller. The larger the adjusted value, the greater the difference in the direction of the normal vector of the -th triangular patch from the normal vectors of all its neighboring triangular patches. Then, the surface formed by the triangular patches around the -th triangular patch is more complex, and the number of triangular patches around the -th triangular patch may be more, that is, the relative local density of the -th triangular patch is relatively larger.

[0055] S13: Determine all target triangular patches and non-target triangular patches according to the local density of each triangular patch and the cumulative sum of the distances between each triangular patch and the remaining triangular patches.

[0056] Specifically, it includes:

[0057] Select the top % of the triangular patches with the largest local density in the triangular mesh according to the local density of each triangular patch as the first triangular patches. is the second preset value. In this embodiment, That is, select 3% of the triangular patches with the top local density (high local density). For example, if there are 10,000 triangular patches in the triangular mesh, then select 300 triangular patches with the highest local density as the first triangular patches.

[0058] For each first triangular patch, use the coordinate mean of the three vertices of the triangular patch as the coordinate of the triangular patch. Calculate the cumulative sum of the Euclidean distances between the triangular patch and other triangular patches according to the coordinates of each first triangular patch. The first triangular patch with the largest cumulative sum of Euclidean distances is used as the target triangular patch, and the other triangular patches in the triangular mesh except the target triangular patch are used as non-target triangular patches. is the third preset value, which is set in this embodiment , that is, finally 6 target triangular patches are obtained. The setting of can be set according to the specific shape of the triangular mesh. If the overall shape of the triangular mesh is similar to a hexahedron, then set the number of target triangular patches , that is, determined by the number of faces , taking the hexahedron as an example in this embodiment, so set .

[0059] For example, among the 300 first triangular patches with the highest local density, calculate the cumulative sum of the Euclidean distances between each first triangular patch and other triangular patches, sort the cumulative sums of the Euclidean distances between each first triangular patch and other triangular patches in descending order, and use the first triangular patches corresponding to the top 6 cumulative sums of Euclidean distances as the target triangular patches, and use the remaining 294 first triangular patches as non-target triangular patches.

[0060] The target triangular patches divided by this operation are the triangular patches with the highest local density. They are scattered in different high-density regions in the 3D model. The local density of the non-target triangular patches is relatively low compared to the target triangular patches. The non-target triangular patches may be distributed around the target triangular patches or in other places. The target triangular patches are determined by calculating the sum of the local density and the Euclidean distances between the triangular patches. The reason these triangular patches are selected as target triangular patches is that they are located in different high-density regions in the 3D model, and these high-density regions are relatively scattered in space, which means that each target triangular patch is located in a region with a relatively high local density, and these regions are far from each other. There may be multiple non-target triangular patches distributed around each target triangular patch, and these non-target triangular patches are close to the target triangular patches in space and have many shared vertices with the target triangular patches.

[0061] Preprocess the data information of each target triangular patch and each non-target triangular patch into byte data, that is, convert the vertex coordinates, normal vectors, and attributes of the target triangular patches and non-target triangular patches into byte data to facilitate subsequent compression processing.

[0062] S2: Store the byte data of the target triangular patches and the byte data of the non-target triangular patches in the data storage space in a certain order.

[0063] Specifically, it includes:

[0064] S21: Create a data storage space for each target triangular patch. In this embodiment, a total of 6 corresponding data storage spaces are created for 6 target triangular patches. After the data storage space corresponding to each target triangular patch is created, first store the byte data of each target triangular patch in its own data storage space. At this time, each of the 6 data storage spaces contains the data of a target triangular patch. Then, for each non-target triangular patch, calculate its Euclidean distance from these 6 target triangular patches, and store the byte data of this non-target triangular patch in the storage space of the target triangular patch with the closest distance. Finally, the byte data in each storage space includes the byte data of a target triangular patch and the byte data of several non-target triangular patches, and the byte data of the target triangular patch is before the byte data of the non-target triangular patches.

[0065] S22: In the data storage space of each target triangular patch, sort according to the ascending order of the Euclidean distance between each non-target triangular patch and this target triangular patch. Here, the data is sorted inside each data storage space, as Figure 3 shown in Figure 3 The rectangles numbered 1-6 in the upper part of represent the data storage spaces corresponding to 6 target triangular patches. The length of the rectangle represents the size of the data storage space. At this time, the byte data inside these 6 data storage spaces is sorted according to the distance.

[0066] S23: For the data storage spaces of all target triangular patches, sort according to the descending order of the local density of the target triangular patch in each data storage space to obtain 6 sorted data storage spaces. As Figure 3 shown in, sort the local densities of the target triangular patches included in each of the 6 data storage spaces in descending order. Suppose the sorted order is 3, 5, 4, 2, 6, 1, then use this order as the arrangement order of the 6 data storage spaces during compressed storage.

[0067] Through S22 - S23, six data storage spaces with local densities arranged from large to small are obtained. Inside each data storage space, starting from the byte data of the target triangular patch, multiple non - target triangular patches from near to far are stored after the starting point. This operation disperses the target triangular patches with higher local densities into different data storage spaces and stores the surrounding non - target triangular patches sorted by distance in these data storage spaces, which can ensure that the triangular patches in the high - density area are better organized in the data sequence, making the data that appears repeatedly in the 3D printing file located adjacent to each other, and helping to more effectively compress the data using compression techniques such as the LZ77 algorithm.

[0068] S3: Determine the length of the to - be - encoded area of the sliding window for each byte data in each data storage space, and use the LZ77 algorithm to compress and store the 3D printing file based on the length of the to - be - encoded area.

[0069] The LZ77 algorithm is a classic data compression algorithm. Its core idea is to use the substrings that have already appeared in the data sequence for compression to reduce the size of data storage or transmission. In a 3D printing file, since the local density of more adjacent triangular patches is larger, these triangular patches usually appear earlier in the data sequence, while the part with a smaller local density and fewer adjacent triangular patches may appear later. Therefore, in order to effectively use the LZ77 algorithm, improve the compression ratio and minimize the impact on the compression efficiency, the size of the sliding window in the LZ77 algorithm can be dynamically adjusted according to the local density of the triangular patch and its position in the 3D printing file data sequence. This can ensure that the data substrings that have already appeared are more effectively identified and utilized during the compression process, thereby improving the compression ratio.

[0070] The sliding window of the LZ77 algorithm usually consists of two parts: The first part is the dictionary area: This is the encoded data area in the sliding window, used to find repeated patterns. The second part is the to - be - encoded area: The area where the data to be compressed is located. The working principle of the sliding window: The data in the to - be - encoded area is checked to see if there is a matching pattern in the dictionary area. If a matching pattern is found, the data in the to - be - encoded area can be replaced by an offset (pointing to the starting position of the matching pattern in the dictionary area) and a length (the number of matching characters), instead of directly encoding the data itself. Once the data in the to - be - encoded area is encoded, it moves from the to - be - encoded area to the dictionary area, and the sliding window moves forward.

[0071] In this step, during the compression process of the 3D printing file, the size of the to - be - encoded area of the sliding window is dynamically adjusted, aiming to better utilize the repeated patterns in the data and improve the compression efficiency.

[0072] Among them, determining the length of the area to be encoded of the sliding window for each byte of data according to the position of each byte of data in each data storage space includes:

[0073] Count the number of all triangular patches to which each vertex in the triangular mesh belongs, and obtain the maximum value of this number , for example, there are vertices D1, D2, D3, D4, D5, D6 in the triangular mesh, and the number of all triangular patches to which these vertices belong are 5, 5, 3, 4, 7, 6 respectively. Then the number of all triangular patches to which vertex D5 belongs is the largest. ;

[0074] If a certain byte of data is at the starting position of any of the said data storage spaces, the length of the area to be encoded of the sliding window for this byte of data is , , which is the first preset value. In this embodiment, it is set to 50. Since the first 84 bytes are the relevant description information of the 3D printing file, the lengths of the byte data included in the 6 sorted data storage spaces are N1, N2, N3, N4, N5, N6 respectively. Then the starting position sequence G of all byte data (including the relevant description information of the first 84 bytes and the byte data in the 6 sorted data storage spaces) in the 3D printing file can be expressed as

[0075] , that is, if the position where a certain byte is located belongs to sequence, then this byte is at a certain starting position in the 3D printing file, and the length of the area to be encoded of the sliding window for this byte of data is . At this time, the left side of the area to be encoded of the sliding window is the cut-off position of the byte data in the data storage space or the starting position of the 3D printing file. At this time, the data on the left side of the area to be encoded of the sliding window has a lower possibility of having a repeated part with the currently processed data. Therefore, the number of bytes corresponding to a triangular patch, 50, is used as the size of the area to be encoded of the sliding window to avoid the situation of reduced compression ratio caused by using an overly large area to be encoded of the sliding window for compression.

[0076] If this byte of data is in other positions, that is, the position where this byte of data is located does not belong to sequence, it indicates that this byte of data is at an internal position of each component of the 3D printing file, such as an internal position in the description information part or an internal position in each data storage space. At this time, the length of the area to be encoded of the sliding window for this byte of data is:

[0077]

[0078] Among them, is the maximum value function, It is the length of the area to be encoded in the sliding window of the previous byte data of this byte data.

[0079] If the position where this byte data is located is the internal position of each component of the 3D printing file, at this time, the data on the left side of the area to be encoded in the sliding window may have a certain repetition rate with the currently processed data. In order to make better use of this part of the repeated data, a larger window should be used. At the same time, to avoid the area to be encoded in the sliding window being too large and affecting the compression efficiency, is used as the maximum value of the size of the area to be encoded in the sliding window to avoid the area to be encoded in the sliding window being too large and affecting the compression efficiency. Because the triangular patches around a vertex are stored continuously, if the area to be encoded is too large, the triangular patches around a vertex, as well as other triangular patches near the surrounding triangular patches, will be regarded as an area to be encoded together. At this time, this vertex only has common vertices with the triangular patches around it, and this vertex has no common vertices with other triangular patches near the triangular patches around it, and it is not suitable to be encoded and compressed as the same area to be encoded, which will reduce the compression rate.

[0080] This operation realizes dynamically adjusting the size of the area to be encoded in the sliding window when compressing 3D files using the LZ77 algorithm, so as to make better use of the repeatedly occurring byte data and improve the compression effect and compression rate.

[0081] In the description of this specification, the meanings of "a plurality of" and "several" are at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.

[0082] Although this specification has shown and described multiple embodiments of the present invention, it is obvious to those skilled in the art that such embodiments are provided only by way of example. Those skilled in the art will think of many changes, alterations and alternative ways without departing from the spirit and concept of the present invention. It should be understood that various alternative solutions to the embodiments of the present invention described herein can be adopted in the process of practicing the present invention.

Claims

1. A method for compressing and storing 3D printing files, characterized in that: include: Reading a triangular mesh of a 3D printing file, the triangular mesh including a plurality of triangular facets, determining all target triangular facets and non-target triangular facets according to the local density of each triangular facet and the distance between each triangular facet and other triangular facets, and preprocessing the data information of the target triangular facets and non-target triangular facets into byte data; Create a data storage space for each target triangular face, first store the byte data of the target triangular face in its data storage space, and then store the byte data of the non-target triangular face in the data storage space of the target triangular face closest to it; Sorting the byte data of the non-target triangular facets in the data storage space of the target triangular facet in the order of the distance from small to large, and sorting the data storage spaces of all target triangular facets in the order of the local density of the target triangular facets from large to small, to obtain a plurality of sorted data storage spaces; The length of the to-be-encoded area of ​​the sliding window of each byte of data is determined according to the position of each byte of data in each of the data storage spaces, and the method is: counting the maximum number of all triangular facets belonging to each vertex in the triangular mesh ; If a byte of data is at the starting position of any of the data storage spaces, the length of the to-be-encoded area of ​​the sliding window of the byte of data is , is a first preset value; If the byte data is at other positions, the length of the to-be-encoded area of ​​the sliding window of the byte data is: ,in, To obtain the maximum value function, is the length of the to-be-encoded area of ​​the sliding window of the previous byte data of the byte data; The 3D printing file is compressed and stored based on the length of the area to be encoded using the LZ77 algorithm.

2. The method for compressing and storing 3D printing files according to claim 1, characterized in that: The local density is calculated according to the following relationship: ; In the formula, For the The local density of triangles, , are the maximum and minimum function respectively, For the The cosine similarity between the sum of the normal vectors of all triangles to which the first and second vertices of a triangle belong, For the The cosine similarity between the sum of the normal vectors of all triangles to which the second and third vertices of a triangle belong, For the The cosine similarity between the sum of the normal vectors of all triangles to which the first and third vertices of a triangle belong, For the The normal vector of the triangle is The mean of the cosine similarities between the normal vectors of all neighboring triangles of a triangle.

3. The method for compressing and storing 3D printing files according to claim 2, characterized in that: The sliding window includes a to-be-encoded area and a dictionary area.

4. The method for compressing and storing 3D printing files according to claim 2, characterized in that: The method for acquiring all the adjacent triangular facets of the triangular facet is: taking all the triangular facets having common vertices with the triangular facet as all the adjacent triangular facets of the triangular facet.

5. The method for compressing and storing 3D printing files according to claim 2, characterized in that: The method for acquiring all the triangular facets to which the vertex belongs is: taking all the triangular facets that use the vertex as a common vertex as all the triangular facets to which the vertex belongs.

6. The method for compressing and storing 3D printing files according to claim 2, characterized in that: The method for determining all target triangles and non-target triangles is: According to the local density of each triangle, the triangle mesh with the largest local density is selected. % of the triangles, as the first triangle, is a second preset value; Taking the average value of all vertex coordinates of each of the first triangular facets as the coordinate of each of the first triangular facets, calculating the cumulative sum of the Euclidean distances between each of the first triangular facets and other triangular facets; The maximum cumulative sum of the Euclidean distances The first triangular facet is used as a target triangular facet, and the other triangular facets in the triangular mesh except the target triangular facet are used as non-target triangular facets, is the third preset value.

7. The method for compressing and storing 3D printing files according to claim 1, characterized in that: The data information includes: vertex coordinates, normal vectors and attributes.

Citation Information

Patent Citations

  • Compression method and device for slice data of 3D model and computer equipment

    CN117893625A

  • Electronic seal data optimization storage method

    CN116977454A

  • Digital building information optimization storage method and system

    CN117435145A