CN112073736B - Encoding method, decoding method and device of 3D model file and 3D printer - Google Patents

Encoding method, decoding method and device of 3D model file and 3D printer Download PDF

Info

Publication number
CN112073736B
CN112073736B CN202010774547.2A CN202010774547A CN112073736B CN 112073736 B CN112073736 B CN 112073736B CN 202010774547 A CN202010774547 A CN 202010774547A CN 112073736 B CN112073736 B CN 112073736B
Authority
CN
China
Prior art keywords
data segment
layer
model file
comparison
continuous
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010774547.2A
Other languages
Chinese (zh)
Other versions
CN112073736A (en
Inventor
易瑜
高爱明
谢信福
刘醴
凌少华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen CBD Technology Co Ltd
Original Assignee
Shenzhen CBD Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen CBD Technology Co Ltd filed Critical Shenzhen CBD Technology Co Ltd
Priority to CN202010774547.2A priority Critical patent/CN112073736B/en
Publication of CN112073736A publication Critical patent/CN112073736A/en
Application granted granted Critical
Publication of CN112073736B publication Critical patent/CN112073736B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/597Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding specially adapted for multi-view video sequence encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/83Generation or processing of protective or descriptive data associated with content; Content structuring
    • H04N21/845Structuring of content, e.g. decomposing content into time segments
    • H04N21/8456Structuring of content, e.g. decomposing content into time segments by decomposing the content in the time domain, e.g. in time segments

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

The application belongs to the technical field of 3D printing, and particularly relates to a 3D model file encoding method, a 3D model file decoding method, a 3D model file encoding device, a 3D model file decoding device, a computer-readable storage medium and a 3D printer. The coding method comprises the following steps: slicing the 3D model to obtain slice data of each layer; respectively encoding each layer of slice data, and converting continuous data segments in each layer of slice data into compressed data segments to obtain encoded each layer of slice data; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes; and constructing a model file of the 3D model according to the encoded slice data of each layer. According to the embodiment of the application, when encoding is carried out, only continuous data segments in each layer of slice data need to be converted into compressed data segments, so that an encoding algorithm is greatly simplified, a corresponding decoding algorithm is simplified, and consumption of computing resources is reduced.

Description

Encoding method and decoding method and device of 3D model file and 3D printer
Technical Field
The application belongs to the technical field of 3D printing, and particularly relates to a 3D model file encoding method, a 3D model file decoding method, a 3D model file encoding device, a 3D model file decoding device, a computer-readable storage medium and a 3D printer.
Background
In the prior art, a ZIP coding and decoding strategy is generally adopted to code and decode a 3D model file, but the algorithm of the existing ZIP coding and decoding strategy is complex and needs to consume a large amount of computing resources.
Disclosure of Invention
In view of this, embodiments of the present application provide an encoding method, a decoding method, an apparatus, a computer-readable storage medium, and a 3D printer for a 3D model file, so as to solve the problem that the algorithm of the existing ZIP coding and decoding strategy is complex and needs to consume a large amount of computing resources.
A first aspect of an embodiment of the present application provides a method for encoding a 3D model file, which may include:
slicing the 3D model to obtain slice data of each layer;
respectively encoding each layer of slice data, and converting continuous data segments in each layer of slice data into compressed data segments to obtain encoded each layer of slice data; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes;
and constructing a model file of the 3D model according to the encoded slice data of each layer.
Further, the encoding each layer of slice data, and converting the continuous data segment in each layer of slice data into a compressed data segment to obtain each layer of coded slice data, includes:
determining a first digit code in the slice data as a reference digit code;
initializing a preset count value;
determining a first digit behind the reference digit as a comparative digit;
comparing the comparison number with the reference number;
if the comparison number is the same as the reference number, increasing the counting value by one counting unit;
if the count value is smaller than the preset threshold value, determining the first digit after the comparison digit as a new comparison digit, and returning to execute the step of comparing the comparison digit with the reference digit and the subsequent steps;
if the counting value is larger than or equal to the threshold value, determining the data segment from the reference number to the comparison number as a continuous data segment, and determining the first number after the comparison number as a new reference number;
if the comparison number is different from the reference number, determining a data segment from the reference number to a first number before the comparison number as a continuous data segment, and determining the comparison number as a new reference number;
and converting the determined continuous data segment into a compressed data segment, and returning to the step of executing the initialized preset count value and the subsequent steps until the coding of the slice data is completed.
In a specific implementation of the embodiment of the present application, the compressed data segment is one byte;
the converting the determined continuous data segment into a compressed data segment includes:
storing repeated single digital codes in the continuous data segment into the highest bit of the compressed data segment;
the count value is stored into the lower 7 bits of the compressed data segment.
In another specific implementation of the embodiment of the present application, the compressed data segment is one byte;
the converting the determined continuous data segment into a compressed data segment includes:
storing the repeated single digit in the continuous data segment into the lowest bit of the compressed data segment;
the count value is stored into the upper 7 bits of the compressed data segment.
Further, the constructing a model file of the 3D model according to the encoded slice data of each layer includes:
constructing a model file of the 3D model according to the sequence of a file header, a preview picture, a slice data header and each layer of coded slice data; and the slice layer data header is an index of each layer of coded slice data.
A second aspect of the embodiments of the present application provides a method for decoding a 3D model file, which may include:
extracting the coded slice data of each layer from a model file of the 3D model;
respectively decoding the encoded slice data of each layer, and converting a compressed data segment in the encoded slice data of each layer into a continuous data segment to obtain the decoded slice data of each layer; the continuous data segment is a data segment composed of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes.
A third aspect of an embodiment of the present application provides an apparatus for encoding a 3D model file, which may include:
the slicing processing module is used for carrying out slicing processing on the 3D model to obtain each layer of slice data;
the slice data coding module is used for coding each layer of slice data respectively, converting continuous data segments in each layer of slice data into compressed data segments and obtaining coded each layer of slice data; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes;
and the model file construction module is used for constructing a model file of the 3D model according to the encoded slice data of each layer.
Further, the slice data encoding module may include:
a reference number determining unit configured to determine a first digit number in the slice data as a reference number;
a count value initialization unit for initializing a preset count value;
the comparison digital code determining unit is used for determining a first digital code after the reference digital code as a comparison digital code;
a comparison unit for comparing the comparison number with the reference number;
a count value updating unit for increasing the count value by one count unit if the comparison number is the same as the reference number;
the comparison digital updating unit is used for determining the first digit after the comparison digital as a new comparison digital if the count value is smaller than the preset threshold value;
a first continuous data segment determining unit, configured to determine a data segment from the reference number to the comparison number as a continuous data segment if the count value is greater than or equal to the threshold value, and determine a first digit after the comparison number as a new reference number;
a second continuous data segment determining unit, configured to determine a data segment from the reference number to a first number before the comparison number as a continuous data segment if the comparison number is different from the reference number, and determine the comparison number as a new reference number;
and the data conversion unit is used for converting the determined continuous data segment into a compressed data segment.
In a specific implementation of the embodiment of the present application, the data segment is compressed into one byte, and the data conversion unit may include:
the first storage subunit is used for storing repeated single digital codes in the continuous data segments into the highest bit of the compressed data segments; the count value is stored into the lower 7 bits of the compressed data segment.
In another specific implementation of the embodiment of the present application, the compressed data segment is one byte, and the data conversion unit may include:
a second storage subunit, configured to store the repeated single code in the consecutive data segment into the lowest bit of the compressed data segment; the count value is stored into the upper 7 bits of the compressed data segment.
Further, the model file constructing module is specifically configured to construct a model file of the 3D model according to a sequence of a file header, a preview picture, a slice data header, and encoded slice data of each layer; and the slice layer data header is an index of each layer of coded slice data.
A fourth aspect of the embodiments of the present application provides an apparatus for decoding a 3D model file, which may include:
the slice data extraction module is used for extracting the coded slice data of each layer from the model file of the 3D model;
the slice data decoding module is used for respectively decoding the encoded slice data of each layer, converting the compressed data section in the encoded slice data of each layer into a continuous data section and obtaining the decoded slice data of each layer; the continuous data segment is a data segment composed of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes.
A fifth aspect of embodiments of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of any one of the above-mentioned methods for encoding or decoding a 3D model file.
A sixth aspect of embodiments of the present application provides a 3D printer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of any one of the above methods for encoding or decoding a 3D model file when executing the computer program.
A seventh aspect of embodiments of the present application provides a computer program product, which, when running on a 3D printer, causes the 3D printer to perform the steps of any one of the above-described methods for encoding or decoding a 3D model file.
Compared with the prior art, the embodiment of the application has the advantages that: the embodiment of the application performs slicing processing on the 3D model to obtain slice data of each layer; respectively encoding each layer of slice data, and converting continuous data segments in each layer of slice data into compressed data segments to obtain encoded each layer of slice data; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes; and constructing a model file of the 3D model according to the encoded slice data of each layer. According to the embodiment of the application, when encoding is carried out, only continuous data segments in each layer of slice data need to be converted into compressed data segments, so that an encoding algorithm is greatly simplified, a corresponding decoding algorithm is simplified, and consumption of computing resources is reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed for the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a flowchart illustrating an embodiment of a method for encoding a 3D model file according to an embodiment of the present disclosure;
FIG. 2 is a schematic illustration of a slicing effect;
FIG. 3 is a schematic view of a three-dimensional view of a triangular face;
FIG. 4 is a schematic diagram of a slicing path;
FIG. 5 is a schematic view of a path entry and a path exit;
FIG. 6 is a schematic illustration of the area of a solid region and the area of an edge lattice;
FIG. 7 is a schematic diagram illustrating the effect of gradually transitioning the gray level from pure black to pure white;
FIG. 8 is a sliced gray scale image composed of gray scale images of successive lattices;
FIG. 9 is a first schematic diagram of an encoding process;
FIG. 10 is a second diagram of an encoding process;
FIG. 11 is a schematic view of the construction of a model file;
FIG. 12 is a schematic diagram of a decoding process;
FIG. 13 is a diagram illustrating a decompression process under a combination of hardware and software;
fig. 14 is a block diagram of an embodiment of an apparatus for encoding a 3D model file according to an embodiment of the present application;
fig. 15 is a schematic block diagram of a 3D printer in an embodiment of the present application.
Detailed Description
In order to make the objects, features and advantages of the present invention more apparent and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the embodiments described below are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
In addition, in the description of the present application, the terms "first," "second," "third," and the like are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
3D prints and is a novel rapid prototyping manufacturing technology, and it makes the product through multilayer stack growth principle, can overcome the special construction obstacle that traditional machining can't realize, can realize the simplification production of arbitrary complex structure part. Photocuring 3D printing based on Liquid Crystal Display (LCD) is to slice a three-dimensional object through a certain algorithm to generate a slice image, and the image is output on an LCD screen by a projection device. Due to the photoreactive energy of the photosensitive resin, light is selectively irradiated on the photosensitive resin through the slice image, the irradiated photosensitive resin is subjected to photocuring reaction, after a period of time, the photocuring reaction is complete, the photosensitive resin is converted from a liquid state to a solid state, the curing of a given pattern is completed at a certain height, and a slice layer is printed. And at the moment, the model is lifted to a certain height, namely the height of the next slice layer to be cured, the next slice image is output on the LCD screen, the photosensitive resin is exposed and cured in a given shape and time, and the next slice layer is finished after the exposure is finished. And sequentially outputting all the sliced layers according to the sequence, and always enabling the next layer to be solidified and molded on the basis of the previous layer, thereby finally finishing the solidification of the whole model.
In the field of LCD photocuring 3D printing, a ZIP (zero-crossing detection) coding and decoding compression strategy can be used for processing a PNG (pseudo noise group) format picture of a 3D model, the PNG format picture is in a lossless compression picture format, so that the decompression of the PNG format picture is particularly important, however, the coding, decoding, compressing and packaging speed of the PNG format picture by using ZIP is low, the compression efficiency of an auxiliary information XML (extensible markup language) format file is low, the resource consumption of the ZIP coding and decoding compression on a single chip microcomputer is high, the requirement on embedded hardware is high, and the memory requirement is high.
Referring to fig. 1, an embodiment of a method for encoding a 3D model file in an embodiment of the present application may include:
and S101, slicing the 3D model to obtain slice data of each layer.
After the 3D model is led in, the 3D model can be sliced under a preset Cartesian coordinate system, the slicing idea is that the 3D model is cut one by one along the Z-axis direction according to the preset slice thickness, so that the 3D model becomes a layer of stacked printing model supported by the LCD printer, and each layer of slices is parallel to the X axis and the Y axis. Fig. 2 is a schematic diagram of the slicing effect, wherein the left diagram is a slice display of the 3D model, and the right diagram is a cross-sectional view of each layer after the model is sliced.
Preferably, in order to save printing materials, the 3D model may be hollowed before slicing to obtain a hollowed 3D model, and then the hollowed 3D model is sliced to obtain slices of each layer of 3D model.
As shown in fig. 3, since a three-dimensional volume is composed of a large number of triangular surfaces and a "volume" is composed of "surfaces", when a 3D model is sliced in the Z-axis direction, the resulting cross section is a set composed of a large number of triangles. In the embodiment of the present application, the sets formed by the triangles may be intersected to obtain a slice path of a 3D model slice, where a counterclockwise direction is a solid path and a clockwise direction is a hole path, and fig. 4 is a schematic diagram of the slice path. In the embodiments of the present application, the solid refers to a portion that needs to be filled with the printing material, and the hole refers to a portion that does not need to be filled with the printing material, that is, a blank portion. The region enclosed along the slicing path in the counterclockwise direction is a solid region, and the region enclosed along the slicing path in the clockwise direction is a hole region.
After the slicing path of a slice of a layer is determined, the gray value area of the lattice through which the path passes can be calculated. It should be noted that in the embodiments of the present application, the lattice refers to the smallest basic unit of printing, and each layer of slices is a lattice matrix formed by arranging a large number of lattices in order.
Taking any lattice traversed by the slicing path as an example, the solid regions in the lattice can be first determined.
Specifically, as shown in fig. 5, an intersection point at which the slicing path first intersects the lattice in the counterclockwise direction is determined as a path entrance of the lattice; determining the intersection point of the slicing path and the crystal lattice for the second time along the anticlockwise direction as a path outlet of the crystal lattice; determining a region of the lattice on the left side in a direction from the path entrance to the path exit as a solid region; the area on the left side of the lattice in the direction from the path entrance to the path exit is determined as a blank area.
After the solid region is determined, the gray value area of the crystal lattice can be calculated according to the area of the solid region and the area of the crystal lattice.
The gray-value area refers to an area represented by a gray value. Specifically, the gray value area of the lattice can be calculated according to the following formula:
Grey=SubArea÷TotalArea×MaxGrey
wherein SubArea is the area of the solid region, TotalArea is the area of the lattice, fig. 6 is a schematic diagram of the two areas, MaxGrey is a preset maximum gray value, Grey is the gray value area of the lattice, the gray value is an integer, and the calculation result can be rounded.
Taking 256-level gray as an example, the gray value interval is 0-255, where 0 represents pure black, 255 represents the maximum gray value, and represents pure white, and the gray value between 0 and 255 represents the gradual transition from pure black to pure white, and the effect is shown in fig. 7. According to the steps, the gray-scale map corresponding to each crystal lattice is obtained, and the gray-scale maps of the continuous crystal lattices form the slice gray-scale map shown in FIG. 8.
After the gray value area of each lattice of the slice is obtained through calculation, the gray value area of each lattice can be processed through a machine assembly language to obtain a series of data consisting of binary numbers "0" and "1", such as "0011110100111", and the data are sequentially stored into an array from left to right and from top to bottom according to the lattice in the slice gray level image, so that slice data of the slice can be obtained.
And S102, coding each layer of slice data respectively, and converting continuous data segments in each layer of slice data into compressed data segments to obtain coded each layer of slice data.
The continuous data segment is a data segment composed of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes.
Taking slice data of any layer as an example, first digit codes in the slice data are determined as reference digits, and a preset count value is initialized, where the count value is denoted as P, that is, the following steps are set: p is 1.
Then, the first digit behind the reference digit is determined as a comparison digit, and the comparison digit is compared with the reference digit.
If the comparison number is the same as the reference number, increasing the count value by one count unit, namely executing: p + 1; if the count value is smaller than the preset threshold value, determining the first digit after the comparison digit as a new comparison digit, and returning to execute the step of comparing the comparison digit with the reference digit and the subsequent steps; and if the counting value is greater than or equal to the threshold value, determining the data segment from the reference number to the comparison number as a continuous data segment, and determining the first digit after the comparison number as a new reference number. The threshold is denoted as PMax, and a value thereof may be set according to an actual situation, which is not specifically limited in the embodiment of the present application.
If the comparison number is different from the reference number, the data segment from the reference number to the first number before the comparison number is determined as a continuous data segment, and the comparison number is determined as a new reference number.
And then, converting the determined continuous data segment into a compressed data segment, wherein the number of bytes occupied by each compressed data segment can be set according to the actual situation.
In a specific implementation of the embodiment of the present application, each compressed data segment occupies two bytes, and then a single digital code repeated in consecutive data segments can be stored in a first byte of the compressed data segment, and a count value can be stored in a second byte of the compressed data segment; alternatively, a single number repeated in a consecutive data segment may be stored in the second byte of the compressed data segment and a count value may be stored in the first byte of the compressed data segment.
In another specific implementation of the embodiment of the present application, if each compressed data segment occupies one byte, a repeated single digital code in consecutive data segments may be stored in the highest bit of the byte, and a count value may be stored in the lower 7 bits of the byte; alternatively, a single digital code repeated in successive data segments may be stored in the lowest order bit of the byte, and the count value may be stored in the upper 7 orders of the byte.
Since a scheme of occupying one byte per compressed data segment can compress the occupied storage space by half compared with a scheme of occupying two bytes, a scheme of occupying one byte is preferably adopted, in which case: PMax is 127, i.e. the minimum length of one continuous data segment is 1 bit, and the maximum length is 127 bits.
After converting a continuous data segment into a compressed data segment, the conversion process of the next continuous data segment can be continued, that is, the step of executing the initialized preset count value and the subsequent steps are returned until the coding of the slice data is completed.
Assuming that slice data before encoding is "0011110100111", PMax is 3, the reference number is a, and the alignment number is B, and the encoding process is shown in fig. 9 and 10.
First, a conversion process of a first continuous data segment is performed, a first digit "0" in the slice data is determined as a reference digit, that is, a is 0, and a count value is initialized: p is 1. The first digit "0" after the reference digit "0" is determined as a comparison digit, i.e., B is equal to 0, and the current comparison digit "0" is compared with the current reference digit "0", and if the two digits are the same, i.e., a is equal to B, P is incremented by 1, i.e.: p + 1+ 2. At this time, P < PMax, the first digit "1" after the comparison digit "0" is determined as a new comparison digit, that is, B is 1, the current comparison digit "1" is compared with the current reference digit "0", if a is not equal to B, the current continuous data segment is determined as "00", and the current comparison digit "1" is determined as a new reference digit, that is, a is 1. Encoding the current continuous data segment '00', storing a repeated single digital code '0' in the continuous data segment into the highest bit of the byte, storing a counting value '2' into the lower 7 bits of the byte, and obtaining the byte of the compressed data segment as '00000010', wherein the byte is expressed as 0x02 by using hexadecimal notation.
Then, the conversion process of the next continuous data segment is carried out, and the count value is initialized: p is 1. The first digit "1" after the reference digit "1" is determined as a comparison digit, i.e., B is equal to 1, and the current comparison digit "1" is compared with the current reference digit "1", and if the two digits are the same, i.e., a is equal to B, P is incremented by 1, i.e.: p + 1+ 2. At this time, P < PMax, the first digit "1" after the comparison digit "1" is determined as a new comparison digit, i.e., B is 1, the current comparison digit "1" is compared with the current reference digit "1", and if the two digits are the same, i.e., a is B, P is incremented by 1, i.e.: p + 1+ 2+ 1-3. At this time, when P is PMax, the current continuous data segment is determined to be "111", and the first digit "1" following the current parity "1" is determined to be a new reference digit, that is, a is 1. Encoding the current continuous data segment '111', storing repeated single digital code '1' in the continuous data segment into the highest bit of the byte, storing the counting value '3' into the lower 7 bits of the byte, and obtaining the byte of the compressed data segment as '10000011', which is expressed as 0x83 by hexadecimal.
By analogy, a third continuous data segment is obtained in sequence as '1', the byte of the compressed data segment obtained by conversion is '10000001', and the hexadecimal representation is 0x 81; the fourth continuous data segment is '0', the byte of the compressed data segment obtained by conversion is '00000001', and the hexadecimal representation is 0x 01; the fifth continuous data segment is '1', the byte converted into the compressed data segment is '10000001', and the hexadecimal representation is 0x 81; the sixth continuous data segment is '00', the byte of the compressed data segment obtained by conversion is '00000010', and the hexadecimal representation is 0x 02; the seventh continuous data segment is "111", the byte of the compressed data segment obtained by conversion is "10000011", and the hexadecimal representation is 0x83, thereby completing the encoding of the slice data.
And S103, constructing a model file of the 3D model according to the encoded slice data of each layer.
As shown in fig. 11, in the embodiment of the present application, a model file of the 3D model may be constructed in the order of a file header, a preview picture, a slice data header, and encoded slice data of each layer; the slice layer data header is an index of each layer of coded slice data, and each layer of slice data such as slice data 1, slice data 2, slice data 3 and … can be respectively indexed through the slice layer data header. The constructed model file can be referred to as cbddlp file.
Corresponding to the above 3D model file encoding method, the embodiment of the present application further provides a 3D model file decoding method, which is used for decoding the above 3D model file.
In the decoding method, each layer of encoded slice data can be extracted from a model file of the 3D model, then each layer of encoded slice data is decoded, and compressed data segments in each layer of encoded slice data are converted into continuous data segments to obtain each layer of decoded slice data.
It is easy to understand that the decoding process is the inverse process of the encoding process, and the continuation encoding process is exemplified here, assuming that some slice data after encoding is: 0x02838101810283, as shown in fig. 12, first, the first compressed data segment, that is, the first byte 0x02, is decoded, the most significant value "0" of the byte is determined as the repeated single number in the continuous data segment, and the lower 7-significant value "2" of the byte is determined as the counting value, that is, the number of times of repetition of the single number, then the continuous data segment "00" can be obtained through conversion. By analogy, the subsequent consecutive data segments "111", "1", "0", "1", "00", and "111" are obtained by decoding, and the decoded slice data is "0011110100111".
Fig. 13 is a schematic diagram of the decompression process under the combination of software and hardware. As shown in the figure, the model file obtained after coding is stored in a Secure Digital (SD) card, under the combination of software and hardware, the model file can be transmitted to a Micro Controller Unit (MCU), the MCU transmits data to a Field-Programmable Gate Array (FPGA), the FPGA sends a storage request instruction to an SDRAM, the SDRAM dynamically stores the model file, when the FPGA receives a decoding instruction, the FPGA extracts the model file from a Synchronous Dynamic Random Access Memory (SDRAM), decodes the model file, and finally transmits the decoded data to a screen, so as to perform subsequent 3D printing.
In summary, the embodiment of the present application performs slicing processing on the 3D model to obtain slice data of each layer; respectively encoding each layer of slice data, and converting continuous data segments in each layer of slice data into compressed data segments to obtain encoded each layer of slice data; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes; and constructing a model file of the 3D model according to the encoded slice data of each layer. According to the embodiment of the application, when encoding is carried out, only continuous data segments in each layer of slice data need to be converted into compressed data segments, the encoding algorithm is greatly simplified, the corresponding decoding algorithm is simplified, and consumption of computing resources is reduced.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 14 is a structural diagram of an embodiment of an encoding apparatus for a 3D model file according to the present invention, which corresponds to the encoding method for a 3D model file described in the foregoing embodiment.
In this embodiment, an encoding apparatus for a 3D model file may include:
a slicing processing module 1401, configured to perform slicing processing on the 3D model to obtain slice data of each layer;
the slice data encoding module 1402 is configured to encode each layer of slice data, and convert a continuous data segment in each layer of slice data into a compressed data segment to obtain encoded each layer of slice data; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes;
a model file constructing module 1403, configured to construct a model file of the 3D model according to the encoded slice data of each layer.
Further, the slice data encoding module may include:
a reference number determining unit configured to determine a first digit number in the slice data as a reference number;
a count value initialization unit for initializing a preset count value;
the comparison digital code determining unit is used for determining a first digital code after the reference digital code as a comparison digital code;
a comparison unit for comparing the comparison number with the reference number;
a count value updating unit for increasing the count value by one count unit if the comparison number is the same as the reference number;
the comparison digital updating unit is used for determining the first digit after the comparison digital as a new comparison digital if the count value is smaller than the preset threshold value;
a first continuous data segment determining unit, configured to determine a data segment from the reference number to the comparison number as a continuous data segment if the count value is greater than or equal to the threshold value, and determine a first digit after the comparison number as a new reference number;
a second continuous data segment determining unit, configured to determine, if the comparison number is different from the reference number, a data segment from the reference number to a first number before the comparison number as a continuous data segment, and determine the comparison number as a new reference number;
and the data conversion unit is used for converting the determined continuous data segment into a compressed data segment.
In a specific implementation of the embodiment of the present application, the data segment is compressed into one byte, and the data conversion unit may include:
the first storage subunit is used for storing repeated single codes in the continuous data segments into the highest bit of the compressed data segments; the count value is stored into the lower 7 bits of the compressed data segment.
In another specific implementation of the embodiment of the present application, the compressed data segment is one byte, and the data conversion unit may include:
a second storage subunit, configured to store the repeated single code in the consecutive data segment into the lowest bit of the compressed data segment; the count value is stored into the upper 7 bits of the compressed data segment.
Further, the model file constructing module is specifically configured to construct a model file of the 3D model according to a sequence of a file header, a preview picture, a slice data header, and encoded slice data of each layer; and the slice layer data header is an index of each layer of coded slice data.
Corresponding to the method for decoding a 3D model file described in the foregoing embodiment, a device for decoding a 3D model file in this embodiment may include:
the slice data extraction module is used for extracting the coded slice data of each layer from the model file of the 3D model;
the slice data decoding module is used for respectively decoding the coded slice data of each layer, converting compressed data segments in the coded slice data of each layer into continuous data segments and obtaining the decoded slice data of each layer; the continuous data segment is a data segment composed of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, modules and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Fig. 15 shows a schematic block diagram of a 3D printer provided in an embodiment of the present application, and only a part related to the embodiment of the present application is shown for convenience of explanation.
As shown in fig. 15, the 3D printer 15 of this embodiment includes: a processor 150, a memory 151 and a computer program 152 stored in said memory 151 and executable on said processor 150. The processor 150 implements the steps in the above-described embodiments of the method for encoding or decoding each 3D model file when executing the computer program 152, or the processor 150 implements the functions of each module/unit in the above-described embodiments of the apparatus when executing the computer program 152.
Illustratively, the computer program 152 may be partitioned into one or more modules/units that are stored in the memory 151 and executed by the processor 150 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 152 in the 3D printer 15.
Those skilled in the art will appreciate that fig. 15 is merely an example of the 3D printer 15, and does not constitute a limitation of the 3D printer 15, and may include more or less components than those shown, or combine certain components, or different components, for example, the 3D printer 15 may also include input and output devices, network access devices, buses, etc.
The Processor 150 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 151 may be an internal storage unit of the 3D printer 15, such as a hard disk or a memory of the 3D printer 15. The memory 151 may also be an external storage device of the 3D printer 15, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the 3D printer 15. Further, the memory 151 may also include both an internal storage unit and an external storage device of the 3D printer 15. The memory 151 is used to store the computer programs and other programs and data required by the 3D printer 15. The memory 151 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/3D printer and method may be implemented in other ways. For example, the above-described device/3D printer embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable storage medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable storage media that does not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (9)

1. A method for encoding a 3D model file, comprising:
slicing the 3D model to obtain slice data of each layer;
determining a first digit code in the slice data as a reference digit code;
initializing a preset count value;
determining the first digit after the reference digit as a comparative digit;
comparing the comparison number with the reference number;
if the comparison number is the same as the reference number, increasing the counting value by one counting unit;
if the count value is smaller than the preset threshold value, determining the first digit after the comparison digit as a new comparison digit, and returning to execute the step of comparing the comparison digit with the reference digit and the subsequent steps;
if the counting value is larger than or equal to the threshold value, determining the data segment from the reference number to the comparison number as a continuous data segment, and determining the first number after the comparison number as a new reference number;
if the comparison number is different from the reference number, determining a data segment from the reference number to a first number before the comparison number as a continuous data segment, and determining the comparison number as a new reference number;
converting the determined continuous data segment into a compressed data segment, and storing repeated single codes in the continuous data segment into the most marginal bit of the compressed data segment; storing the count value into the remaining bits of the compressed data segment; and returning to the step of executing the initialized preset count value and the subsequent steps until the coding of the slice data is finished; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes;
and constructing a model file of the 3D model according to the encoded slice data of each layer.
2. The method of encoding a 3D model file according to claim 1, wherein the compressed data segment is one byte;
the converting the determined continuous data segment into a compressed data segment includes:
storing repeated single digital codes in the continuous data segment into the highest bit of the compressed data segment;
the count value is stored into the lower 7 bits of the compressed data segment.
3. The method of encoding a 3D model file according to claim 1, wherein the compressed data segment is one byte;
the converting the determined continuous data segment into a compressed data segment includes:
storing the repeated single digit in the continuous data segment into the lowest bit of the compressed data segment;
the count value is stored into the upper 7 bits of the compressed data segment.
4. The method for encoding a 3D model file according to any one of claims 1 to 3, wherein constructing the model file of the 3D model from the encoded slice data of each layer includes:
constructing a model file of the 3D model according to the sequence of a file header, a preview picture, a slice data header and each layer of coded slice data; and the slice layer data header is an index of each layer of coded slice data.
5. A method for decoding a 3D model file generated by the method for encoding a 3D model file according to any one of claims 1 to 4, comprising:
extracting the coded slice data of each layer from a model file of the 3D model;
respectively decoding the encoded slice data of each layer, and converting a compressed data segment in the encoded slice data of each layer into a continuous data segment to obtain the decoded slice data of each layer; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value of the single code and the repetition times.
6. An apparatus for encoding a 3D model file, comprising:
the slicing processing module is used for carrying out slicing processing on the 3D model to obtain each layer of slice data;
a reference number determining unit configured to determine a first digit number in the slice data as a reference number;
a count value initialization unit for initializing a preset count value;
the comparison digital code determining unit is used for determining a first digital code after the reference digital code as a comparison digital code;
a comparison unit for comparing the comparison number with the reference number;
a count value updating unit for increasing the count value by one count unit if the comparison number is the same as the reference number;
the comparison digital updating unit is used for determining the first digit after the comparison digital as a new comparison digital if the count value is smaller than the preset threshold value;
a first continuous data segment determining unit, configured to determine a data segment from the reference number to the comparison number as a continuous data segment if the count value is greater than or equal to the threshold value, and determine a first digit after the comparison number as a new reference number;
a second continuous data segment determining unit, configured to determine, if the comparison number is different from the reference number, a data segment from the reference number to a first number before the comparison number as a continuous data segment, and determine the comparison number as a new reference number;
the data conversion unit is used for converting the determined continuous data segment into a compressed data segment; storing repeated single digital codes in the continuous data segment into the most edge bit of the compressed data segment; storing the count value into the remaining bits of the compressed data segment; the continuous data segment is a data segment consisting of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes;
and the model file construction module is used for constructing a model file of the 3D model according to the encoded slice data of each layer.
7. A 3D model file decoding apparatus for decoding the model file of the 3D model generated by the 3D model file encoding method according to any one of claims 1 to 4, comprising:
the slice data extraction module is used for extracting the coded slice data of each layer from the model file of the 3D model;
the slice data decoding module is used for respectively decoding the coded slice data of each layer, converting compressed data segments in the coded slice data of each layer into continuous data segments and obtaining the decoded slice data of each layer; the continuous data segment is a data segment composed of continuous single codes, and the compressed data segment comprises the value and the repetition times of the single codes.
8. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method for encoding a 3D model file according to any one of claims 1 to 4 or the steps of the method for decoding a 3D model file according to claim 5.
9. A 3D printer comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method of encoding a 3D model file according to any one of claims 1 to 4 or the steps of the method of decoding a 3D model file according to claim 5 when executing the computer program.
CN202010774547.2A 2020-08-04 2020-08-04 Encoding method, decoding method and device of 3D model file and 3D printer Active CN112073736B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010774547.2A CN112073736B (en) 2020-08-04 2020-08-04 Encoding method, decoding method and device of 3D model file and 3D printer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010774547.2A CN112073736B (en) 2020-08-04 2020-08-04 Encoding method, decoding method and device of 3D model file and 3D printer

Publications (2)

Publication Number Publication Date
CN112073736A CN112073736A (en) 2020-12-11
CN112073736B true CN112073736B (en) 2022-06-21

Family

ID=73657445

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010774547.2A Active CN112073736B (en) 2020-08-04 2020-08-04 Encoding method, decoding method and device of 3D model file and 3D printer

Country Status (1)

Country Link
CN (1) CN112073736B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704208B (en) * 2021-10-27 2022-02-08 浙江闪铸三维科技有限公司 Compression method of 3D printing file

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109774152A (en) * 2018-12-18 2019-05-21 西安交通大学 A method of it is compressed and is stored based on threedimensional model serial section image increment type
CN110799959A (en) * 2017-05-26 2020-02-14 深圳配天智能技术研究院有限公司 Data compression method, decompression method and related equipment
CN111260784A (en) * 2020-01-20 2020-06-09 广州海格星航信息科技有限公司 City three-dimensional space grid compression coding method and device and terminal equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002100125A (en) * 2000-09-26 2002-04-05 Sony Corp Dc free encoding method and device, mastering device of recording medium, method of encoding binary number data and device for the same as well as recording medium
US6653954B2 (en) * 2001-11-07 2003-11-25 International Business Machines Corporation System and method for efficient data compression
US9734595B2 (en) * 2014-09-24 2017-08-15 University of Maribor Method and apparatus for near-lossless compression and decompression of 3D meshes and point clouds
CN109450596B (en) * 2018-11-12 2022-02-01 湖南瑞利德信息科技有限公司 Encoding method, decoding method, encoding device, decoding device, storage medium, and terminal

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110799959A (en) * 2017-05-26 2020-02-14 深圳配天智能技术研究院有限公司 Data compression method, decompression method and related equipment
CN109774152A (en) * 2018-12-18 2019-05-21 西安交通大学 A method of it is compressed and is stored based on threedimensional model serial section image increment type
CN111260784A (en) * 2020-01-20 2020-06-09 广州海格星航信息科技有限公司 City three-dimensional space grid compression coding method and device and terminal equipment

Also Published As

Publication number Publication date
CN112073736A (en) 2020-12-11

Similar Documents

Publication Publication Date Title
CN111699696A (en) Method and apparatus for encoding and decoding a byte stream
US8483500B2 (en) Run length coding with context model for image compression using sparse dictionaries
WO2020237647A1 (en) Point cloud data encoding method, encoding device, decoding method and decoding device
CN110874625B (en) Data processing method and device
CN116506073B (en) Industrial computer platform data rapid transmission method and system
CN112073736B (en) Encoding method, decoding method and device of 3D model file and 3D printer
CN112399181B (en) Image coding and decoding method, device and storage medium
CN116016606B (en) Sewage treatment operation and maintenance data efficient management system based on intelligent cloud
IT202000018043A1 (en) ARTIFICIAL NEURAL NETWORK PROCESSES AND PROCESSING SYSTEMS
AU2012283580A1 (en) System and method for encoding and decoding a bitstream for a 3D model having repetitive structure
EP2730089A1 (en) System and method for encoding and decoding a bitstream for a 3d model having repetitive structure
CN108235019A (en) A kind of storage method and device for compressing image
CN115082371B (en) Image fusion method and device, mobile terminal equipment and readable storage medium
WO2022027243A1 (en) 3d model file encoding method and apparatus, 3d model file decoding method and apparatus, and 3d printer
CN114466082B (en) Data compression and data decompression method and system and artificial intelligent AI chip
CN116330664A (en) 3D printing precision control method and system based on image morphology operation
CN115914631A (en) Encoding and decoding method and system with controllable entropy decoding complexity
CN113422965A (en) Image compression method and device based on generation countermeasure network
CN114417998A (en) Data feature mapping method, device, equipment and storage medium
CN110348554B (en) Digital information encoding and decoding method and device, electronic equipment and storage medium
CN113382244A (en) Coding and decoding network structure, image compression method, device and storage medium
CN208522900U (en) A kind of three-dimensional animation is from encoding/decoding device
CN206712982U (en) A kind of Huffman coded systems for VLSI designs
Balevic et al. Using arithmetic coding for reduction of resulting simulation data size on massively parallel GPGPUs
CN111143641A (en) Deep learning model training method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant