1 Introduction

Additive manufacturing (AM) is a manufacturing method that describes a group of processes to produce objects by depositing materials layer by layer [1]. Given its ability to obtain near-net shape products with very little material waste, this method is revolutionizing the manufacturing industry [2]. Some of the advantages of AM are its high resolution and the possibility to decide the pattern to fill the areas that form the 2D layers of the model. There is a great variety of patterns, which can be grouped according to their shape and/or continuity. The fact of having a strictly continuous trajectory becomes very relevant in certain cases. In wire and arc AM one of the requirements is to minimize the number of tool path-passes, and following continuous paths a single pass per polygon is obtained [3]. In solid freeform fabrication based on welding, one of the most important requirements is that the path is strictly continuous [4]. In fused deposition modelling, recent studies show that the use of continuous carbon fibre-reinforced thermoplastics improves the mechanical properties of the model compared to different approaches like the use of additive of short fibres [5, 6]. Yao et al. [7] employed a continuous toolpath planning strategy for fused filament fabrication that not only reduced the post-processing time but also supported material recycling and reuse. When it comes to scaffold fabrication, it is very important to minimize the number of start and stop points, as they cause material agglomeration, which does not satisfy the Tissue Engineering goals [8]. Finally, there are materials, such as clays [9] or bioinks, which do not have the ability to retract and the dripping produced by travelling movements could produce undesired material overlap. This fact becomes especially relevant in bioprinting, where respecting the internal geometry with a high fidelity is crucial to guarantee cell survival and proliferation [10]. However, it cannot be guaranteed that non-convex polygons, i.e. those with at least one interior angle greater than 180°, can be continuously filled with any separation between parallel lines and orientation. Therefore, if the area to be filled is concave, it will be necessary to break it down into convex areas. In this manuscript, we present a methodology for the generation of continuous infill paths that follow a hybrid zig-zag and contour pattern with configurable separation between parallel lines and direction. In this way, the print head avoids travelling movements within a closed polygon with or without holes. To do this, an algorithm that decomposes concave polygons into convex subpolygons has been extended. Then we present an algorithm that fills each of the convex areas with the desired pattern and joins each of them into a single continuous path. Finally, we provide a publicly available dataset of 2D polygons that present challenges to the convex decomposition and path joining algorithms, such that other researchers can evaluate their own methods and compare with our results. The outline of this article is organized as follows: Section 2 shows a summary of the most relevant literature. Section 3 explains the method followed for path planning. Section 4 shows and discusses the results obtained by this method. Finally, Section 5 summarizes the conclusions drawn about the proposed method.

2 Literature review

2.1 Generation of continuous path

Hergel et al. [9] propose a method to generate continuous paths without transfer movements to avoid artifacts when printing ceramics, but that prioritizes to be self-supporting rather than having a concrete internal structure. Zhao and Guo [11] reviewed the most typical patterns used in conventional AM, namely raster, zig-zag, contour, grid, spiral, Hilbert filling curve and honeycomb. Among the mentioned patterns only the zig-zag, the spiral, the Hilbert filling curve and the honeycomb can be obtained with continuous paths. Zhao et al. [12] propose a variation of the conventional spiral, resulting in a single connected path of Fermat spirals, but which doesn’t allow the direction of the infill to be changed. Bertoldi et al. [13] agree that when the head deposits long straight lines, the quality of union can be very poor, so they proposed using the Hilbert curve. However, the printing time is between 2 and 4 times longer than other patterns. Hexagonal honeycombs offer excellent mechanical strength at low density, but like the Hilbert curve, the printing time increases considerably compared to other patterns [14]. Ding et al. [3] present a variation of contour and zig-zag pattern, obtaining a continuous path that acquires the precision of the contour pattern and the simplicity of the zig-zag. Besides, zig-zag pattern works well for filling with high density, the computational cost to generate it is relatively short and its internal structure is very regular, which makes it suitable for being applied in fields that require fidelity in internal structures. The main disadvantage of this pattern, in contrast, is that continuity cannot be guaranteed for every direction and polygon combination. In fact, for many concave polygons it will be impossible to obtain a continuous path if they are not processed previously. Section 2.2 discusses different methods to break down concave polygons into convex areas.

2.2 Polygon decomposition

Whenever we want to fill in a non-convex polygon with a continuous zig-zag pattern we will proceed to break it down into convex parts. There are different methods to decompose concave polygons into convex subpolygons. De Berg et al. [15] collect several methods of triangular decomposition which would result in multiple convex triangular areas, but some triangle angles could be too sharp, potentially leading to overlapping material. Decomposing a polygon into trapezoids is a valid option that was catalogued by Asano et al. [16] as an NP-complete problem,Footnote 1 for which a method with a \(\mathcal {O}(n \log n)\) (n being the number of vertices of the polygon) running timeFootnote 2 was proposed for polygons containing holes. However, other methods are able to produce less convex subpolygons, such as the one in Ding et al. [3], which decomposes a concave polygon into convex subpolygons following a divide-and-conquer strategy.Footnote 3 This method defines as notches all the vertices that join edges that form internal angles greater than 180°, and tries to eliminate them by 3 different routines depending on the number of notches and vertices that lie between the extensions of the two edges that form each notch and their distance to the bisector line. Given its relative simplicity and its compatibility with the zig-zag pattern, we extend their formulation.

2.3 Limitations of the literature

The method proposed by Ding et al. [3] does not include the following aspects in relation to the generation of continuous paths with hybrid zig-zag and contour pattern:

  • The method to obtain convex polygons does not mention the possibility of two extension lines intersecting in different polygons, and therefore does not state how these cases should be managed.

  • The method to obtain convex polygons may achieve a suboptimal solution when a hole is contained in the area covered by the extension lines and the polygon in which the node to be removed is located.

  • The method to obtain convex polygons may achieve a suboptimal solution because only contemplates joining the reference notch with the notch/vertex that is closest to the bisector.

  • The method to obtain a continuous trajectory does not cover how to join the paths of different subpolygons. In addition, the literature does not include a 2D polygon dataset with its coordinates that would allow to check and compare the performance of convex polygon decomposition and the joining of the paths of the decomposed subpolygons.

3 Methodology

The infill generation produces the paths that will be printed in the internal area of the polygons of each layer that are obtained from the slicing of the model. It means that only geometrical aspects are considered but not the process parameters (deposition, speed, acceleration, etc.). In this work, we implemented an algorithm that aims to fill in the polygons that form a 2D layer following a continuous hybrid zig-zag and contour pattern with any direction and separation between parallel lines. Figure 1 shows a polygon of a 2D layer and a possible infill.

Fig. 1
figure 1

Definition of the problem to be solved in this work. (a) Polygon P to be filled. (b) Polygon P filled with a possible hybrid zig-zag and contour pattern

Given a 2D polygon \(P\subset \mathbb {R}^{2}\) that may contain holes and that is closed and bounded, the goal is to obtain a sequence of points \(P_{1},P_{2},\ldots ,P_{k} \in \mathbb {R}^{2}\), that defines a closed and continuous polyline, without self-intersections, and moreover such polyline forms a hybrid zig-zag pattern which fills the area described by the input polygon P.

The scope of the methods proposed in this work is shown resumed in Fig. 2.

Fig. 2
figure 2

Flowchart of the main steps of the method described in this work

3.1 2D layer layout

For each 2D layer there is a hierarchy of polygons in the form of a tree, like the one shown on the left of Fig. 3. Even-level polygons are polygons that are going to be filled, and their vertices are numbered counter-clockwise, whereas odd-level polygons are holes that do not have to be filled and their vertices are numbered clockwise. It is assumed that these structures are already defined and will be input parameters for our algorithm. To simplify the problem, the algorithm restructures the 2D layer, so that all the even-depth polygons greater than 1 are set as level 0 polygons and their holes as level 1 polygons. By eliminating the nests, a new tree with maximum depth 2 (see the right side of Fig. 3) is obtained and each sibling polygon is tackled as if they were independent problems.

Fig. 3
figure 3

Example of the hierarchy of polygons and vertex numbering that can be found in a 2D layer

3.2 Polygon decomposition

The first step is to check if the polygon is convex or not, for which we check if there are internal angles greater than 180°, as Ding et al. [3] do. If it is convex, the decomposition is unnecessary and we can proceed to generate the infill (Section 3.3). Otherwise, we will need to carry out the decomposition, for which we present an extension of the method of Ding et al. [3] that handles cases that were not considered in their formulation. On the one hand, the method of Ding et al. [3] does not consider the possibility that the extensions of the edges that form a notch intersect two different polygons, which is illustrated in Fig. 4(a). It turns out that in these cases it is not possible to determine how many vertices and notches remain between both since they are two different contours. In our formulation, we have catalogued those notches as unmanageable and we will try to eliminate them once some partition line has been generated and the vertices have been reorganized.

Fig. 4
figure 4

First limitation of the method proposed by Ding et al. [3] to decompose polygons into convex areas. (a) Example where both extension lines intersect the same polygon, (b) example where the extension lines intersect two different polygons

To generate the partition lines the method of Ding et al. [3] follows 3 different routines according to the number of notches and vertices along the edges from point A to B. However, this way of counting notches and vertices presents two limitations when a hole is completely within the area covered by the extension lines and the contour of the polygon they intersect. The first limitation, which is shown in Fig. 5(a), can occur when there are notches along the geometry edges between points A and B. In those cases, according to the method of Ding et al. [3] the partition line should be the one that joins the reference notch with the closest notch to the bisector line of the reference notch, thus eliminating two notches with a single partition line. However, if the hole is along the path of the partition line, the second notch that was expected to be removed cannot be removed. The second limitation is derived from the first one, and is illustrated in Fig. 5(b). As we said, only the union with the notches and vertices that are along the geometry edges between points A and B is considered. However, if the notches of the hole were also taken into account, we would avoid the previous limitation and would give the possibility of eliminating the reference notch and another one of the hole with a single partition line.

Fig. 5
figure 5

Second limitation of the method proposed by Ding et al. [3] to decompose polygons into convex areas. (a) Partition line generated following the method of Ding et al. [3]. (b) Partition line generated following the method proposed in this work

In case there is more than one notches/vertices between points A and B, according to the method of Ding et al. [3], the partition line should be formed with the notch/vertex that is closer to the bisector line of the reference notch. However, we have found cases in which the decomposition results in more subpolygons than the necessary to have only convex areas. With the aim of obtaining better results in such cases, we also consider the option of creating the partition line with the closest notch/vertex to the reference notch. The number of subpolygons obtained with this method is always equal or smaller than following the method proposed by Ding et al. [3], but shapes can vary. In order to obtain the subpolygons with less sharp turns we look at the angles of the ends of each of the possible partition lines:

  1. 1.

    Get the interior angles in both ends of the possible partition line (see the red and blue angles in Fig. 6) and add them.

  2. 2.

    Get the exterior angles in both ends of the possible partition line (see the angles plotted in black in Fig. 6) and add them.

  3. 3.

    Keep the result of the smallest summation.

  4. 4.

    Repeat steps 1-3 for the other possible partition line.

  5. 5.

    Compare the results of each possible partition line that have been stored. The definitive partition line will be the one with the greatest result.

Fig. 6
figure 6

Evaluation made to choose the partition line that gives better results. The selected partition line is the blue dotted one

Figure 7 presents the results obtained following the decomposition method proposed by Ding et al. [3] and the method proposed in this work.

Fig. 7
figure 7

Comparison of the convex subpolygons obtained following the method proposed by Ding et al. [3] and the method proposed in this work. (a) Polygon decomposition achieved following the method proposed by Ding et al. [3], where 19 convex subpolygons are obtained (b) Polygon decomposition achieved following the method proposed in this work, where 18 convex subpolygons are obtained

Once the decomposition is finished, it is necessary to identify those edges shared by two subpolygons, and in case they have different lengths, add the necessary vertices to the one with the greatest length, so that the edge they finally share has the same vertices (see Fig. 8). Although this may mean having collinear segments in the same subpolygon, it will simplify the union of their zig-zags.

Fig. 8
figure 8

Proposed vertices for convex subpolygons. Red squares, which were not originally part of the blue subpolygon, have been added to ease the generation of the continuous pattern

3.3 Path generation for convex polygons

The steps to generate the path with the desired orientation and distances between lines for convex polygons are described below:

  1. 1.

    Transform the polygon to a coordinate system in which the main lines of the zig-zag are parallel to the horizontal axis, which simplifies the code.

  2. 2.

    If the polygon to be filled is the result of the decomposition of a non-convex polygon, apply an offset of a distance D equal to one of the zig-zag separations. This will prevent it from overlapping with the polygon next to it, as well as giving enough space for the union between them. The resultant polygon, which will be called unionPolygon, is shown in solid green in Fig. 9(a). If unionPolygon cannot be generated, no infill pattern can be generated. In case the polygon was originally convex, unionPolygon is the polygon itself.

  3. 3.

    Identify the left chain of unionPolygon, which is defined as the polyline that goes from the lowest to the highest vertex of the polygon by the left side of it. The left chain of unionPolygon is plotted in dash-dotted dark blue in Fig. 9(b).

  4. 4.

    Offset the left chain the same distance as in step 2 and form a new polygon using the remaining edges of unionPolygon. The resultant polygon, called contourPolygon, is used together with unionPolygon to generate the contour of the path, and it is graphed in dotted violet in Fig. 9(c).

  5. 5.

    Offset contourPolygon the same distance as in step 2. The resultant polygon, plotted in solid cyan in Fig. 9(d), is called zigzagPolygon and it is used to create the zig-zag of the path. If zigzagPolygon cannot be generated (result of too wide line separations), the resultant infill pattern will be the contour of unionPolygon.

  6. 6.

    To generate the zig-zag, build horizontal lines from the lowest point of zigzagPolygon, varying the separation between them according to the side of the turn of the zig-zag, until the highest point is reached and look for the intersections with zigzagPolygon. Join the intersections by the right and left side alternatively following the contour of zigzagPolygon. Figure 10(a) shows the evolution of the zig-zag and Fig. 10(b) shows the final zig-zag pattern. At this point, we have implemented an automatic adjustment of the chosen line separations (which can be enabled or disabled) to ensure that the polygon is completely filled at the top.

  7. 7.

    Extend the zig-zag, following if possible the slope of the corresponding edge of zigzagPolygon, to contourPolygon. If the extension of the zig-zag intersects the left chain of contourPolygon (see Fig. 11(a)), a line parallel, at a distance D, to the first segment of the left chain is defined and its point of intersection with contourPolygon will be the point of union between the zig-zag and the contour (see Fig. 11(b)). This step turns to be especially relevant when the variation of the slope of adjacent edges is very slight (curved polygons, for example) and when the chosen line separations is very big, where the number of vertices of contourPolygon and zigzagPolygon is not the same. Once the union is made, go through contourPolygon in clockwise direction until the lowest part of its left chain is reached.

  8. 8.

    Traverse unionPolygon in a clockwise direction until the highest part of the left chain of contourPolygon is reached, as shown in Fig. 10(c).

  9. 9.

    Go through contourPolygon in counter-clockwise direction, as shown in Fig. 10(d), until the point where the extension of the first line of the zig-zag and contourPolygon would intersect, and join it with the beginning of the zig-zag. Figure 10(d) shows the final path of a convex polygon with a horizontal continuous hybrid zig-zag and contour pattern.

  10. 10.

    Transform the original polygon and the whole pattern to the original coordinate system. Figure 12 shows the infill of the same polygon with the same separation between lines and different orientations.

Fig. 9
figure 9

Auxiliary polygons used to generate the infill pattern. (a) unionPolygon. (b) leftChain of unionPolygon in dash-dotted dark blue. (c) contourPolygon in dotted violet. (d) zigzagPolygon in solid cyan

Fig. 10
figure 10

Hybrid zig-zag and contour infill pattern generation for convex polygons. (a) Generation of the zig-zag. (b) Zig-zag pattern. (c) Extension to contour and traverse of unionPolygon. d) Finish the contour, using contourPolygon and union with the zig-zag

Fig. 11
figure 11

Extension of the zig-zag to the contour. (a) Self-intersecting path because the slope of the corresponding edge of zigzagPolygon makes the extension intersect the left chain of contourPolygon. (b) alternative extension to get a non-self-intersecting path

Fig. 12
figure 12

Possible infills for a convex polygon following a hybrid zig-zag and contour pattern infill. (a) Horizontal pattern. (b) Pattern with 45°

3.4 Joining of subpolygon paths into a single path

To carry out the union of the paths of the different subpolygons, which will be made around the edges shared by two of them, we make a graph of adjacency, where each subpolygon is a node and its degree is the number of shared edges it has. From the adjacency graph we construct a spanning tree as follows:

  1. 1.

    We identify the root node as the node with lowest degree and, in case of a tie, we choose the first-generated node among them.

  2. 2.

    We mark that root node as visited.

  3. 3.

    Starting from the root node, we proceed with a recursive traversal of the graph: we mark the edges that connect the current node of the traversal with a still-unmarked node, mark those still-unmarked nodes, and then recurse the traversal to them in order.

The spanning graph, which is shown in Fig. 13(b), is formed by all the marked edges and has the identified root. This way it is assured that the paths of all the subpolygons will be joined at least with another path, and globally all of them will be joined by the paths of other subpolygons.

Fig. 13
figure 13

Proposed method to define which paths should be joined to get a single continuous path. (a) Paths of convex subpolygons that have to be joined. (b) Adjacency graph used to identify which subpolygons have to be joined. The double lines indicate which is the spanning tree

The steps to make the union of the paths of two subpolygons are stated below:

  1. 1.

    Identify the two points of the same path that delimit the line parallel and closer to the edge that is shared by the subpolygons to be joined. These points are plotted in grey in Fig. 14.

  2. 2.

    Decide around which two points the union is going to be made, and identify them as p1 and p2. To try to avoid very sharp turns, the internal angle that would form each subpolygon in the environment of each point is calculated and if any of these angles is lower than 25°, it is proposed to make the union around the other end. If this is not the case, the angles of the two subpolygons around the same end are summed up and the union is made at the end at which there is an angle closer to 0, 90, 180 or 270°, prioritizing the angles closer to 0 and 180 over 90 and 270 and the convex ones over the concave ones.

  3. 3.

    Extend 1 and 2 and look for their point of intersection, which is called p1,2 (see Fig. 15).

  4. 4.

    Generate two lines parallel to 1 and 2 at a distance D (see \(\ell ^{\prime }_{1}\) and \(\ell ^{\prime }_{2}\) in Fig. 15). The intersection points of these lines with their respective zig-zags are labelled as \(p^{\prime }_{1}\) and \(p^{\prime }_{2}\) and the intersection of both as \(p^{\prime }_{1,2}\). There are 2 cases that can vary the way to obtain these points.

    1. (a)

      Variation 1: \(p^{\prime }_{1,2}\) is inside one of the zig-zags. Find the intersection of the line of the zig-zag in which \(p^{\prime }_{1,2}\) is not contained with the zig-zag in which \(p^{\prime }_{1,2}\) is contained. This point is shown as a dot with the name \(p^{\prime }_{{1,2}_{aux}}\) in Fig. 16.

    2. (b)

      Variation 2: \(\ell ^{\prime }_{1}\) or \(\ell ^{\prime }_{2}\) is left out of the zig-zag because the polygon is too small. In that case, the procedure used to obtain p1,2 is repeated at the other end, such that p1 and p2 become \(p^{\prime }_{1}\) and \(p^{\prime }_{2}\) and their intersection \(p^{\prime }_{1,2}\). Figure 17 shows this type of union, where the green pattern, due to its small size, is the cause of this variation.

  5. 5.

    Modify the original paths to join them by means of the found points. p1 and p2 are joined with p1,2, and the segments that joined p1 with \(p^{\prime }_{1}\) and p2 with \(p^{\prime }_{2}\) are removed. \(p^{\prime }_{1}\) and \(p^{\prime }_{2}\) will be joined between them, either directly or by crossing \(p^{\prime }_{1,2}\). To decide whether to pass through \(p^{\prime }_{1,2}\), calculate the internal angles that would result from going through it or not. From each of the options, the minimum angle is found and the greater of the two is chosen in order to avoid very abrupt turns, as it can be seen in Fig. 18. In case of a tie, going through \(p^{\prime }_{1,2}\) is preferred over the direct connection, as it respects more the fidelity of the contour of the polygon

Fig. 14
figure 14

Selection of the area where the union is going to be made

Fig. 15
figure 15

Auxiliary points used to make the union of two paths

Fig. 16
figure 16

Variation 1 to obtain the points needed to make the union

Fig. 17
figure 17

Variation 2 to obtain the points needed to make the union

Fig. 18
figure 18

Decide if \(p^{\prime }_{1}\) and \(p^{\prime }_{2}\) union should go through \(p^{\prime }_{1,2}\) or not. (a) Going through \(p^{\prime }_{1,2}\) the minimum angle is 90°. (b) Not going through \(p^{\prime }_{1,2}\) the minimum angle is 90°. As the angle is the same, the chosen option is (a) as it respects more the fidelity of the contour of the polygon

Once all the zig-zags have been joined and a unique continuous path has been achieved all the collinear segments that may have been generated are removed.

3.5 Evaluation

3.5.1 Theoretical evaluation

In order to validate the results obtained in both the non-convex polygon decomposition and the path generation, and given the lack of a 2D polygon dataset with which to check them, it has been decided to generate one. The repositoryFootnote 4 includes the coordinates of the polygons, together with a justification of why they are relevant, and the results obtained with our algorithm. In terms of the polygon decomposition the dataset allows the following situations to be evaluated:

  • The extensions of the edges that form the reference notch intersect two different boundaries.

  • There is a complete hole inside the area covered by the extensions of the edges that form the reference notch.

  • Intersection of lines with the same slope (overlap of lines).

When it comes to path generation, the dataset covers the following cases of relevance:

  • The edge of union of two subpolygons are not exactly the same, but one is longer than the other.

  • The edge of one of the subpolygons is used as a double union area with two different subpolygons.

  • Need to generate a graph that indicates which subpolygons are to be joined together.

  • Ideal position of the points used to generate the union of zig-zags.

  • The position of the points used to generate the union of zig-zags makes it necessary to use variation 1.

  • The position of the points used to generate the union of zig-zags makes it necessary to use variation 2.

This dataset contains 35 JSON encoded files with the coordinates of 15 convex polygons to check that the generation of the hybrid zig-zag and contour infill pattern is correctly performed, and 20 non-convex polygons to validate the algorithms of decomposition and generation of continuous paths. The case studies include the generation of the infill paths with 48 combinations of separation between lines and zig-zag orientations, except for polygon NCPolygon20.json, which only has a single configuration for the separation between lines (a total of 1633 cases). The purpose of having the polygon NCPolygon20.json in the dataset is to illustrate the performance of the method when polygons that have holes with coarse circular shapes are processed with our methodology. Finally, the repository also contains Python3 code that can be used to load and visualize the polygons and their infills.

3.5.2 Experimental evaluation

The infill trajectories generated for the polygons NCPolygon11.json and NCPolygon16.json of the evaluation dataset were used to perform an experimental printing test using a Creality Ender-5 Plus 3D printer. The infill for NCPolygon11.json has a separation of 2 mm between lines, while the infill for NCPolygon16.json has a separation of 0.5 mm. Polylactic acid (PLA) was extruded with no retraction during printing. The feed rate was set at 1.2 m/min and the extruder speed was 45 mm/s, obtaining a trace of 0.51 mm of diameter.

4 Results

Since our method expands the work by Ding et al. [3], we first present a comparison with their results in Table 1. These results have been generated with a variant of our method that allows to define the orientation of the infill pattern for each of the convex subpolygons independently, allowing a closer replication of the case studies in [3]. As we do not have the exact coordinates of the polygons or the parameters of the fill patterns used by Ding et al. [3], we can only make a visual comparison of the results, with no conclusions about the number of path elements.

Table 1 Comparison of a reproduction of the results obtained with the method proposed by Ding et al. [3] and the method proposed in this work

The additional results obtained for the other cases included in our evaluation dataset confirm the capability of the proposed methodology to deal with cases beyond those studied in [3], including nested polygons with holes (see Fig. 19), and other ones targeting the limitations discussed in Section 2.3. Furthermore, we provide an extensive report of our results in the repository introduced in Section 3.5.1, where we have stored the generated paths for each of the case studies of the evaluation dataset (there is a text file, .txt, file containing the coordinates of the trajectories generated for each polygon with the various combinations of separations between lines and orientations of the infill pattern). We believe that this information will ease quantitative comparisons with future works from other researchers. In addition to the mentioned results, we show in Figs. 20 and 21 the outcomes of the experimental tests (Section. 3.5.2), as a demonstration of the suitability of the generated trajectories to be printed with no interruptions in the thread deposition.

Fig. 19
figure 19

Final result for a complex polygon. (a) Complex polygon infill path. (b) Zoom of the paths of the polygons found within the holes

Fig. 20
figure 20

Comparison of the expected (a) and the obtained (b) results for polygon NCPolygon11.json using the experimental setup described in Section 3.5.2

Fig. 21
figure 21

Comparison of the expected (a) and the obtained (b) results for polygon NCPolygon16.json using the experimental setup described in Section 3.5.2

Although the reported results are satisfactory (in all of the cases a strictly continuous path that follows the required pattern was generated), the method presents limitations when dealing with polygons that have holes with curved shapes. In those cases, the convex decomposition algorithm produces subpolygons with small areas and very acute angles (this will produce undesired material accumulation in the corners of the trajectories). Polygons with those characteristics produce problems in the computation of the required insets/offsets to create the infill path for the subpolygon and also for the computation of the subpolygons’ unions (even the strategies presented in Section 3.4 may not suffice to solve all the possible cases). The result obtained for polygon NCPolygon20.json, which has holes with coarse curved shapes, is a demonstration of this limitation (Fig. 22). Furthermore, including more vertices to describe the curved holes would make the problem worse, since there would be too many notches to eliminate and the resulting convex areas would be too narrow to be filled with the zig-zag pattern without overlapping the material. In addition to this, when the size of the subpolygon and the configured separation between lines does not allow to generate any infill (not even the simplified version using unionPolygon), it will not be possible to generate a continuous trajectory for the entire non-convex polygon if that subpolygon is the only connecting path with other subpolygons.

Fig. 22
figure 22

Generated trajectories for polygon NCPolygon20.json of the evaluation dataset, which contains rough curved holes

Finally, we present the results of printing the infill paths for NCPolygon11.json and NCPolygon16.json (see Figs. 20 and 21, respectively) of the evaluation dataset, as a demonstration that the produced trajectories can be translated to G-Code and fabricated with a conventional 3D printer with strictly continuous material deposition.

5 Conclusions and future work

This work has presented the following contributions:

  • Improvement of the current state of art of polygon decomposition into convex areas and although we do not guarantee that we have a global optimal solution, we can get less subpolygons than in other methods of decomposition [3, 15, 16].

  • A method to create a closed hybrid zig-zag and contour infill pattern for convex polygons.

  • A method to join the hybrid zig-zag and contour patterns of two adjacent subpolygons, obtaining a single continuous path for the whole polygon, which makes it possible to be used in a wide variety of modes of additive manufacturing.

  • A publicly available dataset of 2D polygons to check and compare the results.

This method, however, has certain limitations. On the one hand, although a valid result can be achieved, our method is not the most suitable for filling polygons with curved holes, as it would generate many subpolygons with very sharp areas where material could overlap. On the other hand, this work does not cover the way in which the different polygons that make up a layer should be joined, nor the union between two consecutive layers.