Calculation of Each Slice Profile
Practically every AM system will have the ability to read both binary and ASCII STL files. As most AM processes operate by adding layers of the material of the specified thickness, beginning at the bottom of the part and moving upward, the definition of the part of the file must be processed in order to obtain the profile of each layer.Each layer can be assumed a plane in a nominal Cartesian XY frame. The incremental movement of each layer can then be along the orthogonal axis of the Z. The XY plane, which is located along the Z-axis, can be called a cutting plane. Any triangle intersecting this plane may be considered to contribute to the profile of the slice. An algorithm such as the one in Flowchart 2.1 can be used to extract all the profile segments of the STL file. The outcome of this algorithm is a set of intersecting lines that are ordered according to a set of intersecting planes.
A program that is written as per this algorithm would have a number of additional components, including a way to define the start and end of each file and each plane. Furthermore, there would be no order for each line segment to be defined in terms of the XY components and indexed to the plane corresponding to each Z value. Also, the assumption is that the STL file has an arbitrary set of triangles which are randomly distributed. It may be possible to pre-process each file so that searches can be performed in a more efficient manner. One way to optimize the search would be to order the triangles according to the minimum value of Z. A simple check for the intersection of a triangle with a plane will be to check the value of Z for each vertex. If the Z value of any vertex in the triangle is less than or equal to the Z value of the plane, that triangle may intersect the plane. Using the above test, once it has been established that the triangle may not intersect with the cutting plane, then every other triangle is known to be above that triangle and therefore does not require a check.A similar test could be performed with the maximum value Z of the triangle.
There are a number of discrete scenarios illustrating the intersection of each triangle with the cutting plane:
- 1. All the vertices of the triangle are above or below the intersecting plane. This triangle is not going to contribute to the profile on this plane.
- 2. A single vertex is directly on the plane. In this case, there is one intersection point that can be neglected, but the same vertex will be used in other triangles satisfying another condition below.
- 3. There are two vertices lying on the plane. Here, one of the edges of the corresponding triangle is on that plane, and that edge contributes fully to the profile.
FLOWCHART 2.1 Algorithm used to test triangles and create line intersections. The result is an unordered matrix of intersecting lines.
- 4. There are three vertices lying on the plane. In this case, the entire triangle contributes entirely to the profile, unless there are also one or more adjacent triangles on the plane, in which case the included edges can be neglected.
- 5. Another vertex is above or below the intersecting plane, and the other two vertices are on the opposite side of the plane. In this case, the intersection vector must be calculated from the edges of the triangle.
Most triangles should adhere to Scenario 1 or Scenario 5. Scenarios 2-4 may be considered as special cases and require special treatment. Assuming that we have carried out the appropriate checks and that the triangle corresponds to Scenario 5, then we have to take action and generate the corresponding intersecting profile vector.
In this case, there will be two vectors defined by the vertices of the triangle, and these vectors will intersect with the cutting plane. The line joining these two intersection points will form part of the plane’s outline. The problem to be resolved is a classical line intersection with a plane problem.
In this case, the line is defined using Cartesian coordinates in (x, y, z). The plane is defined in (x, y) for a specific constant height, z. In a general case, we can therefore project the line and plane onto the x = 0 and у = 0 planes. For the у = 0 plane, we can obtain something similar to Figure 2.5. Points PI and P2 correspond to two points of the intersecting triangle. Pp is the projected point onto the у = 0 plane to form a unique right-angled triangle. The angle 0 can be calculated from
Since we know the z height of the plane, we can use the following equation:
and solve for xi.
A point yi can also be found after projecting the same line onto the x = 0 plane to fully define the intersecting point Pi. A second point of intersection can be calculated using another line of the triangle that intersects the plane. These two points will be a line on the plane that forms part of the outline of the model. It is possible to determine the directionality of this line by exact use of the right-hand rule, thus
FIGURE 2.5 A vertex taken from an STL triangle projected onto the Y = 0 plane. Since the height Z; is known, w'e can derive the intersection point Xr A similar case can be done for Y, in the X = 0 plane.
turning this segment of the line into a vector. This can be useful in deciding whether the completed curve is part of the enclosing outline or corresponds to a hole. After all, the intersection lines have been calculated according to Flowchart 2.1; these lines must be joined together to make complete curves. This would be done using an algorithm based on the one described in Flowchart 2.2. In this case, each segment of the line is checked to determine which segment is nearest to it.
The “nearest point” algorithm is necessary because the calculations may not precisely locate points together, even though the same line would normally be used to determine the starting position of one segment and the end of another. Note that this algorithm should actually have a further nesting to test whether a curve has been completed. If the curve is complete, any other remaining line segments would correspond to additional curves. These additional curves could form a nest of curves lying inside or outside others, or they could be separated. The two algorithms listed here concentrate on the intersection of the triangular facet with the cutting surface.
The normal vectors of each triangle could be used to further develop these algorithms. In this way, the actual path of the curve could be determined. It will help to
FLOWCHART 2.2 Algorithm for ordering the intersections of the line into complete outlines. This assumes that there is only one contour in each plane.
assess the nested curves. Outside the section, the outermost curve will point. When the curve set is pointing inward to itself, then it is obvious that there must be a further curve enveloping it (see Figure 2.5). The use of normal vectors may also be helpful in organizing curve sets that are very close to each other.
Once this stage has been completed, there will be a file containing an ordered set of vectors to trace the complete outlines corresponding to the intersecting plane. The way these outlines are used depends somewhat on which AM technology is to be used. Many machines can use the vectors generated in Flowchart 2.2 to control the plotting process for drawing the outlines of each layer. However, most computers will still have to fill in these outlines to make them solid. Flowchart 2.3 uses
FLOWCHART 2.3 Algorithm for filling a 2D profile based on vectors created using Flowchart 2.2 and a raster scanning method. Assume that the profile suits within the build volume, the raster scans in the X direction, and the lines increase in the Y direction.
an inside/outside algorithm to determine when to switch on a filling mechanism to draw scanning lines perpendicular to one of the plane axes. The assumption is that the part is fully enclosed within the build envelope and therefore the default fill is switched off.