Background
The 3D printing technology is to cut the three-dimensional digital model into two-dimensional sections layer by layer according to a given layer thickness, namely, slices, so as to guide a printer to print layer by layer. Wherein the slicing layering technique is one of the key techniques in 3D printing. The existing layering technologies mainly include two types, one is an equal-height layering mode, namely, a three-dimensional digital model is layered by adopting a fixed slicing layer thickness, and if the slicing layer thickness is the minimum, the printing precision of the model is higher, but the number of layers is also larger, so that the side length of processing time is caused. The second method is variable layer thickness layering, also called adaptive layering, that is, the model is layered by adopting layer thicknesses with different thicknesses, and the method aims to reduce the number of layering as far as possible on the premise of ensuring the printing precision so as to improve the processing efficiency. In the existing variable layer thickness layering method, the layering of different layer thicknesses of a model is realized by mainly performing characteristic analysis on a three-dimensional digital model and giving a certain layering criterion.
Patent application No. CN201410015269.7 discloses a saliency-based mesh model 3D printing slicing method, which includes the following steps: step A1, inputting a grid model file, and performing significance calculation on the grid model to obtain the significance of each grid vertex; a2, slicing the grid model, wherein the slice thickness is the highest precision which can be achieved by actually using a 3D printer; a3, calculating the significance of each slice; step A4, merging and re-layering adjacent slices according to the significance of the slices, and re-slicing the original grid model according to the height and the layer thickness of each layer obtained after re-layering; and step A5, generating a general Gcode file from the re-slicing result, and enabling the general Gcode file to be read and printed by a 3D printer.
Patent specification with patent application number CN201410015269.7 discloses a 3D printing self-adaptive slicing method for reserving model features, and belongs to the technical field of 3D printing. The method comprises the following steps: 1) establishing a three-dimensional model according to the actual engineering design, and carrying out gridding processing on the model to generate STL file data; 2) preprocessing the STL file data of the model; 3) processing the preprocessed file data by adopting a self-adaptive layering algorithm to obtain slice contour information; 4) judging whether the slice on any two adjacent slice heights in the slice profile information has the characteristic possibly by adopting the characteristic existence condition, if so, carrying out secondary slicing on the model data between the slices by adopting the minimum slice thickness lmin, otherwise, not carrying out processing; simultaneously recording slice outline information; 5) and generating a printing file according to the slice profile information processed in the step four and the slice format, and performing 3D printing.
Patent application No. CN201410016504.2 discloses an adaptive layering method in 3D printing, which includes: obtaining a maximum allowable layer thickness and a minimum allowable layer thickness according to the corresponding 3D printing equipment; obtaining an SLC file of an entity to be processed according to the minimum allowable thickness; reading an SLC file to obtain the outline information of each layer of the entity; keeping the first layer profile, and then setting an initial value of i as 2; calculating an intersecting polygon set between the ith layer contour and the remained first layer contour; calculating an area ratio parameter and an average distance parameter, and judging whether the profile of the ith layer is reserved according to the two parameters and the maximum allowable layer thickness; i is increased by 1, if the value of i is not more than the total number n of the layers of the entity, the step 5 is returned; otherwise, the calculation is finished, and the entity self-adaptive layering result is output.
The current variable layering technical scheme is mainly to layer a model according to a layering criterion condition defined in advance, but in an actual printing process, the layering thickness of a specific area is often required to be specified in a manual interaction mode, namely, a specified model height interval range is layered, and the specified areas are, for example, areas such as a support structure of a three-dimensional model, an assembly surface among multiple parts and the like. Therefore, it is desirable to provide an interactive variable layer thickness slicing method, in which a system automatically performs layering according to a given layer thickness of a section by setting height sections requiring different layer thicknesses.
Disclosure of Invention
The present invention is directed to a method for interactive variable layer thickness slicing in three-dimensional printing, which solves the above-mentioned problems of the prior art.
In order to achieve the purpose, the invention provides the following technical scheme: an interactive variable layer thickness slicing method in three-dimensional printing, as shown in fig. 1, comprises the following steps:
step 1: appointing N cutting sections needing different layer thickness layering in the three-dimensional model through a computer manual interaction interface;
step 2: calculating the total number of layers of the three-dimensional model and the z-axis height value of each layer according to the z-axis height interval range and the slice layer thickness between each height, and establishing a layer linked list layer step to record all triangular patches contained in each layer;
and step 3: traversing all triangular patches of the three-dimensional model, calculating the minimum value zMin and the maximum value zMax of the z axis of each triangular patch, and calculating the number of layers to which the triangular patches belong according to the zMin and zMax of each triangular patch;
and 4, step 4: traversing the number of layers to which the triangular patch belongs, and storing the current triangular patch into the layer container layer step [ i ] of the ith layer for each layer i;
and 5: traversing a layer linked list layer, acquiring all triangular patches contained in the current layer, and performing intersection calculation on all triangular patches and the tangent plane of the current layer to obtain a slice segment of each triangular patch;
step 6: sequentially connecting the slicing line segments of each triangular surface patch end to form a polygonal contour;
and 7: and storing the contour data of the sliced layer into a computer file, and establishing memory mapping from the file to a computer memory so as to facilitate a computer program to read the data.
Further, in the above interactive variable layer thickness slicing method in three-dimensional printing, instep 1, the user may adjust the position coordinates of the cut section through an input device of the computer, such as a mouse or a keyboard, so that the three-dimensional model is divided into N + 1Z-axis height sections by the cut section, and the slice layer thickness of each height section is set.
Further, in the above interactive variable layer thickness slicing method in three-dimensional printing, in the step 5, for each slicing segment, the index number of the triangular patch to which the slicing segment belongs, the coordinates of the start point and the end point of the slicing segment, and the index number of the adjacent patch on the side where the end point is located are recorded.
Further, in the interactive variable layer thickness slicing method in three-dimensional printing, in thestep 2, the specific steps are as follows:
step 2.1: sorting the Z-axis height values Z1, Z2 and … Zn of each cutting section from small to large, wherein the range of each height interval is 0-Z1, Z1-Z2 and … Zn-Zmax in sequence, and Zmax is the maximum Z-axis height of the three-dimensional model;
step 2.2: traversing each height interval, and calculating the layer number N of each height intervali=(Zimax-Zimin)/tiIn the formula NiNumber of layers, Z, representing the ith intervalimaxDenotes the maximum height, Z, of the ith intervaliminDenotes the starting slice height of the ith interval, and if i is 0, Z isimin=0,tiRepresents the layer thickness value of the ith interval;
step 2.3: after the number of layers of each height interval is calculated, the interval initial layered height value needs to be updated: zimin=Zimin+Ni×ti;
Step 2.4: adding the calculated layer number of each height interval to obtain the total layer number N of the slices;
step 2.5: calculating a z-axis height value of each layer;
step 2.6: and establishing a layer step container class to store all triangular patches contained in each layer, wherein the element number of the container is the total layer number.
Further, in the interactive variable layer thickness slicing method in three-dimensional printing, in thestep 3, the specific steps are as follows:
step 3.1: traversing from the first height interval according to the minimum z-axis zMin of the triangular patch, judging whether zMin is smaller than the maximum height value of the current height interval, and if so, calculating the number N of layers where the vertex with the minimum z-axis of the triangular patch is locatedTminComprises the following steps:
NTmin=Nblock+(Zcur-Zimin)/ti
in the formula NblockFor all layers of traversed altitude interval, ZcurIs the current Z-axis nadir height, ZiminDenotes the starting hierarchy height, t, of the current access intervaliThe slice layer thickness for the current access height interval;
if zMin is greater than the maximum height value of the current height interval, adding the number of layers of the current height interval to NblockIn, update NblockThen continue to visit the next altitude interval until the current zMin is less than the maximum value of the current altitude interval;
step 3.2: similarly, according to the method in step 3.1, the number of layers N where the vertex of the maximum z-axis zMax of the triangular patch is located is calculatedTmaxIf the number of layers of the triangular patch is NthTminLayer to NthTmaxAnd (3) a layer.
Further, in the interactive variable layer thickness slicing method in three-dimensional printing, in the step 5, the specific steps are as follows:
step 5.1: all triangular surface patches contained in the ith layer are obtained in the layer step container, the z-axis height value of the ith layer is obtained, intersection calculation is carried out on each triangular surface patch of the current layer and the tangent plane of the z-axis height of the layer in sequence, and the slicing line segment of each triangular surface patch on the layer is obtained;
step 5.2: for each slice segment, storing the index number of the triangle corresponding to each slice segment, storing the coordinates of the starting point and the ending point of each slice segment, finding the index number of the adjacent patch of the edge where the ending point of each slice segment is located according to the topological relation between the triangle patches, and storing the index number of the adjacent patch of each slice segment.
Further, in the interactive variable layer thickness slicing method in three-dimensional printing, in the step 6, the specific steps are as follows:
step 6.1: traversing each slice segment, and for the ith slice segment, accessing the next slice segment if the current slice segment has been added to the polygon outline; if the current slicing line segment is not added into the polygon outline, the next step is carried out;
step 6.2: adding the current slicing line segment into the polygonal contour, acquiring the index number of the adjacent patch stored in the previous step 5.2, acquiring the slicing line segment on the adjacent patch according to the index number of the adjacent patch, adding the adjacent slicing line segment into the polygonal contour, taking the adjacent slicing line segment as a new current slicing line segment, and repeating the current step until the found adjacent slicing line segment is equal to the initial slicing line segment;
step 6.3: and for each polygonal contour, judging whether the gap between the open-loop contours meets the connection condition, and if so, sequentially connecting the open-loop contours into closed section contours.
Further, in the interactive variable layer thickness slicing method in three-dimensional printing, in the step 7, the specific steps are as follows:
step 7.1: creating a slice file in a disk space of a computer for storing the contour data generated by the slice;
step 7.2: the memory mapped file is used in the data processing software to process the slice file stored on the disk so that the data processing software can access and read the slice data.
Compared with the prior art, the invention has the beneficial effects that:
according to the invention, the layering intervals with different layer thicknesses are specified in a man-machine interaction mode, and the height interval with high printing precision requirement can be determined before slicing is carried out, so that the layering is carried out on different height intervals by adopting different layer thicknesses; the method has good interactivity, is suitable for three-dimensional models with any complex shapes, is easy to realize in 3D printing data processing software, and can greatly improve the printing efficiency.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, 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 invention.
Referring to fig. 1-5, the present invention provides a technical solution: an interactive variable layer thickness slicing method in three-dimensional printing, comprising the steps of:
step 1: through a computer manual interaction interface, as shown in fig. 2, N cutting sections requiring different layer thicknesses for layering are specified in a three-dimensional model; a user can adjust the position coordinates of the cutting section through input equipment of a computer, such as a mouse and a keyboard, so that the three-dimensional model is divided into N + 1Z-axis height intervals by the cutting section, and the thickness of a slice layer of each height interval is set; the effect of cutting the section is shown in figure 3;
step 2: calculating the total number of layers of the three-dimensional model and the z-axis height value of each layer according to the z-axis height interval range and the slice layer thickness between each height, and establishing a layer linked list layer step to record all triangular patches contained in each layer;
and step 3: traversing all triangular patches of the three-dimensional model, as shown in fig. 4, calculating the minimum value zMin and the maximum value zMax of the z axis of each triangular patch, and calculating the number of layers to which the triangular patches belong according to zMin and zMax of each triangular patch;
and 4, step 4: traversing the number of layers to which the triangular patch belongs, and storing the current triangular patch into the layer container layer step [ i ] of the ith layer for each layer i;
and 5: traversing a layer linked list layer, acquiring all triangular patches contained in the current layer, and performing intersection calculation on all triangular patches and the tangent plane of the current layer to obtain a slice segment of each triangular patch; in the step 5, for each slice segment, the index number of the triangular patch to which the slice segment belongs, the coordinates of the start point and the end point of the slice segment, and the index number of the adjacent patch on the side where the end point is located are recorded;
step 6: sequentially connecting the slicing line segments of each triangular surface patch end to form a polygonal contour;
and 7: and storing the contour data of the sliced layer into a computer file, and establishing memory mapping from the file to a computer memory so as to facilitate a computer program to read the data.
Wherein, in thestep 2, the specific steps are as follows:
step 2.1: sorting the Z-axis height values Z1, Z2 and … Zn of each cutting section from small to large, wherein the range of each height interval is 0-Z1, Z1-Z2 and … Zn-Zmax in sequence, and Zmax is the maximum Z-axis height of the three-dimensional model;
step 2.2: traversing each height interval, and calculating the layer number N of each height intervali=(Zimax-Zimin)/tiIn the formula NiNumber of layers, Z, representing the ith intervalimaxDenotes the maximum height, Z, of the ith intervaliminDenotes the starting slice height of the ith interval, and if i is 0, Z isimin=0,tiRepresents the layer thickness value of the ith interval;
step 2.3: after the number of layers of each height interval is calculated, the interval initial layered height value needs to be updated: zimin=Zimin+Ni×ti;
Step 2.4: adding the calculated layer number of each height interval to obtain the total layer number N of the slices;
step 2.5: calculating a z-axis height value of each layer;
step 2.6: and establishing a layer step container class to store all triangular patches contained in each layer, wherein the element number of the container is the total layer number.
In thestep 3, the specific steps are as follows:
step 3.1: traversing from the first height interval according to the minimum z-axis zMin of the triangular patch, judging whether zMin is smaller than the maximum height value of the current height interval, and if so, calculating the number N of layers where the vertex of the minimum z-axis of the triangular patch is locatedTminComprises the following steps:
NTmin=Nblock+(Zcur-Zimin)/ti
in the formula NblockFor all layers of traversed altitude interval, ZcurIs the current Z-axis nadir height, ZiminDenotes the starting hierarchy height, t, of the current access intervaliThe slice layer thickness for the current access height interval;
if zMin is greater than the maximum height value of the current height interval, adding the number of layers of the current height interval to NblockIn, update NblockThen continue to visit the next altitude interval until the current zMin is less than the maximum value of the current altitude interval;
step 3.2: similarly, according to the method in step 3.1, the number of layers N where the vertex of the maximum z-axis zMax of the triangular patch is located is calculatedTmaxThen threeThe number of the layers where the corner patches are located is NthTminLayer to NthTmaxAnd (3) a layer.
In the step 5, the specific steps are as follows:
step 5.1: all triangular surface patches contained in the ith layer are obtained in the layer step container, the z-axis height value of the ith layer is obtained, intersection calculation is carried out on each triangular surface patch of the current layer and the tangent plane of the z-axis height of the layer in sequence, and the slicing line segment of each triangular surface patch on the layer is obtained;
step 5.2: for each slice segment, storing the index number of a triangle corresponding to each slice segment, storing the coordinates of the starting point and the end point of each slice segment, finding the index number of an adjacent patch of the edge where the end point of each slice segment is located according to the topological relation between the triangular patches, and storing the index numbers of the adjacent patches of the slice segments;
in the step 6, the specific steps are as follows:
step 6.1: traversing each slice segment, and for the ith slice segment, accessing the next slice segment if the current slice segment has been added to the polygon outline; if the current slicing line segment is not added into the polygon outline, the next step is carried out;
step 6.2: adding the current slicing line segment into the polygonal contour, acquiring the index number of the adjacent patch stored in the previous step 5.2, acquiring the slicing line segment on the adjacent patch according to the index number of the adjacent patch, adding the adjacent slicing line segment into the polygonal contour, taking the adjacent slicing line segment as a new current slicing line segment, and repeating the current step until the found adjacent slicing line segment is equal to the initial slicing line segment;
step 6.3: and for each polygonal contour, judging whether the gap between the open-loop contours meets the connection condition, and if so, sequentially connecting the open-loop contours into closed section contours.
In the step 7, the specific steps are as follows:
step 7.1: creating a slice file in a disk space of a computer for storing the contour data generated by the slice;
step 7.2: processing the slice file stored on the disk by using the memory mapping file in the data processing software so that the data processing software can access and read the slice data; FIG. 5 is a diagram showing the effect of the interactive variable layer thickness slicing method after slicing.
In the description herein, references to the description of "one embodiment," "an example," "a specific example" or the like are intended to mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
The preferred embodiments of the invention disclosed above are intended to be illustrative only. The preferred embodiments are not intended to be exhaustive or to limit the invention to the precise embodiments disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and the practical application, to thereby enable others skilled in the art to best utilize the invention. The invention is limited only by the claims and their full scope and equivalents.