Sei sulla pagina 1di 5

6th International Advanced Technologies Symposium (IATS11), 16-18 May 2011, Elaz, Turkey

A Method for Slicing CAD Models


in Binary STL Format
O. Topu1, Y. Tacolu2 and H. . nver3
1

TOBB University of Economics and Technology, Ankara, Turkey, otopcu@etu.edu.tr


TOBB University of Economics and Technology, Ankara, Turkey, ytascioglu@etu.edu.tr
3
TOBB University of Economics and Technology, Ankara, Turkey, hounver@etu.edu.tr

A Method for Slicing CAD Models in Binary


STL Format
AbstractAdditive manufacturing (AM) is a technique that
fabricates parts layer by layer. As a result of this capability it
offers numerous advantages over conventional manufacturing.
This study concentrates on the process planning stage of the AM
and presents a STL slicing algorithm with the ability of G-Code
generation.. This work is part of a wider range effort
concentrated on the development of an open-source AM system
therefore a special emphasis is given that all the software
packages used in this study are freely available open source or
freeware applications. The results and the capability of the code
are tested by simulating several complex 3D geometries on a CNC
milling simulator software using the generated G-Codes.
Keywordsdirect slicing,
prototyping, STL format.

additive

manufacturing,

rapid

I. INTRODUCTION

dditive manufacturing (AM) is defined by a range of


technologies in which solid objects are built, directly
from 3D CAD models, by adding material in thin layers.
Physical parts which are technically impossible to produce
with conventional manufacturing methods are produced in
hours instead of days and at a relatively low cost. AM is
commonly used for producing prototypes of consumer
products, patterns for molds, and medical implants.
Research on the AM technology, which is also called as
Rapid Prototyping (RP), Layered Manufacturing (LM), and
Solid Freeform Fabrication (SFF), has been carried out in
various universities and companies for over 20 years. A small
list of some known commercial AM technologies includes:
Stereolithography (SLA) by 3D Systems, Selective Laser
Sintering (SLS) by DTM Corp., Fused Deposition Modeling
(FDM) by Stratasys Corp., Solid Ground Curing (SGC) by
Cubital and Laminated Object Manufacturing (LOM) by
Helisys. In addition to known commercial solutions, quite a
few AM processes are under development at various
universities such as University of Texas, University of
Michigan, University of Dayton, MIT, Stanford and Carnegie
Melon University [1]. The focus of the research is not only on
production methods but also on data exchange standard and
process planning.

The STL (STereoLithography) file format is considered to


be the de-facto data exchange standard for AM processes.
Most, if not all, of the major 3D CAD software packages
provide tools for STL conversion. The conversion is the
execution of a surface triangulation algorithm which is used
frequently in finite element analysis since 1970s. Shortcomings
of the STL format in terms of processing time and precision
set a barrier for demanding engineering projects [1-4]. While
some researchers suggest improvements to the STL, others
adapt existing CAD formats to AM or propose new formats.
Jacob et al. [4] reduce the file size of current STL format by
eliminating the repeating vertices data. Zhang et al. [5] use
models in IGES format in their welding-based AM system. In
[6], a new format PLY (Polygon File Format) is described. In
applications where high quality surfaces and dimensional
tolerances are less important, the STL format is well
researched and is appropriate for professional and nonprofessional users of the area.
Process planning includes the steps for slicing the parts
triangulated surfaces, tool path generation for each layer and
conversion of the tool path data to a suitable CNC data (i.e Gcodes). The latter two steps are well established and are almost
identical to CNC milling. Different part slicing algorithms for
various AM processes exist in literature. Adaptive slicing [7]
is one of the approaches to resolve the inevitable staircase
effect by using variable layer thickness. The algorithm
proposed by Asiabanpour and Khoshnevis [8] saves each layer
data on a separate file in order to ease path generation process
and free computer memory. In [9], a slicing method suitable
for Color Rapid Prototyping (CRP) is presented. There is
presently no industrial or formal standard for slice data. As a
result the developer or the manufacturer is free to decide on or
to develop its own slice data to create the required AM
machine code. Some proposals made in this area are listed
below.
Common Layer Interface (CLI) represents each layer by
its thickness and a set of contours. These contours define
the boundaries of the solid material;
Layer Exchange ASCII Format (LEAF) provides each
contour as a non-self-intersecting polygon described in
terms of 2D primitives, the polyline and the circular arc;
SLC Formats represents several slice formats that use a
polyline approximation to represent the contours of a
slice.

141

O. Topu, Y. Tacolu, H. . nver


The AM process is mainly composed of three stages. First
stage includes 3D CAD modelling and STL conversion.
Nowadays this stage can be performed by using the freely
available 3D modeling software such as SketchUp 3D,
CoCreate Modeling Personal Edition, PowerShape-e and etc.
Second stage is the aforementioned process planning and the
final stage is the production of the physical part, which
depends entirely on the AM machine.
This study concentrates on the second stage of the AM
process and presents a STL slicing algorithm with the ability
of G-Code generation. Special emphasis is given that all the
software packages used in this study are freely available open
source or freeware applications. This work is part of a wider
range effort concentrated on the development of an opensource AM system.
II. SLICE ALGORITHM

x
z y

imported STL data of the solid body. Given the oriented


model, part slicing is a purely geometrical process. Figure 2
exemplifies possible relations between the slicing plane and a
facet of the model.
From this point on the mentioned facet will be labeled as F,
its vertices as V1, 2, 3 (x1, 2, 3, y1, 2, 3, z1, 2, 3) and its normal vector
as N (xn, yn, zn). Normal vectors are required for graphical
visualization of the solid body on a computer screen hence
they are omitted in the slicing algorithm.
According to slicing planes z-axis value, z, there are five
kinds of different positional relationships between the slicing
plane and the corresponding facet, as shown in Fig.2 and listed
below:
1) z1= z & z2= z & z3= z.
2) z1= z & z2= z & (z3< z || z3> z).
3) z1= z & ((z2< z & z3> z) || (z2> z & z3< z)).
4) ((z1< z) & ((z2> z & z3> z)) || ((z1> z) & ((z2< z & z3< z)).
5) z1= z & ((z2> z & z3> z) || (z2< z & z3< z)).
When the numbering is different from the listed above, the
algorithm that is given in Fig.3 is capable of handling facets,
which are randomly numbered as a circumstance.

z
x
y

Figure 1: (a) a tessellated cube with twelve facets (b) a sliced cube

Fig.1(a) shows triangulated STL representation of the


surfaces of a simple cube shape and Fig.1(b) shows the sliced
cube. The algorithm is mainly developed to obtain the contour
data of the desired slicing level. As a result it does not have the
capacity to slice some facets which are positioned between two
slicing planes where no intersections occur. This problem can
be solved easily by reducing the gap between two adjacent
slices. The gap between two adjacent slices defines the layer
thickness which is also a variable inside the code. Also, the
software code is developed based on the assumption that the
STL representation of the geometry is error-free and is
normally assigned in the z-direction. Intentionally, the
developed code has divided into separate sections which carry
on the calculations based on the results of the previous section.
This approach has simplified the debugging process and made
the code more flexible when needed.
A. Intersection Point Detection

Figure 2: Possible intersection cases.

The first section of the slicing algorithm finds intersection


points between equally set apart slicing planes and the

Figure 3: Intersection detection algorithm.

In CASE I, F is parallel to the base and there is no need to


calculate the intersection points because all three vertices of
the F represent the intersection points.
In CASE II, F touches the slicing plane with its two vertices
and these two points are the intersection locations. The stored
information are values of these vertices and the z value of the
remaining vertex which will be used to determine whether to
keep or dispose of the data.
In CASE III, one of the Fs vertices touches the slicing
plane. The other intersection must be calculated using the

142

A Method for Slicing CAD Models in Binary STL Format


common form of the well-known line equation (1), where the
slope is m and the two variables are x and y.
y mx b

(1)

Also in CASE III, z values of the corresponding points are


both stored as 1. This coding enables the algorithm to
identify the obtained line data in further parts of the code.
In CASE IV, none of the Fs vertices touch the slicing plane
but one of the vertices is on the other side of the plane when
observed from x- or y-axis. As expected, this case creates two
intersection points. Obtained line data is also labeled with
1.
In CASE V, F touches the slicing plane at a single point
which is redundant information for the rest of the code.
The outputs of the intersection point detection algorithm are
all the points that are located on the slicing plane with the
appointed classification reference values.
B. Line Creation
Fig.4 shows the algorithm that is designed to create lines of
the slice data with mentioned z values. Line creation algorithm
is similar to the intersection detection. For simplicity and
future improvement possibilities, it is kept apart as another
process.

Figure 4: Line generation algorithm.

The outputs of the line creation algorithm are lines that are
obtained from the outputs of the aforementioned intersection
point detection algorithm with the appointed classification
reference value. Tab.1 show the column labels of the output
data arrays where the number of points and the number of lines
represent the row count of the array. The z values are
unchanged and the two associated points are grouped to create
a line.
Table 1: Output data of intersection point detection and line creation
algorithms.
Output Data
Point Array
Line Array

C. Repeating Lines
Fig.5 represents the overlapping lines which happen when
two facets share an edge at the slicing plane.

Column labels of the array

x, y, zref
x1, y1, x2, y2, zref

Figure 5: Repeating line cases.

As an example, top of a cube can have 10 lines after line


creation algorithm. However, only a polygon with 4 lines is
enough to draw the boundary of the cube. In order to define
interior and exterior of the contour the repeating lines must be
removed or merged into a single line. At this point, previously
stored z values 2, 1 and the reference values play
important role. Comparison between these values and the z
values of the overlapping lines zLine1 and zLine2 are listed below:
1) zLine1=2 & zLine2=2.
2) (zLine1=2 & zLine2 2) || (zLine1 2 & zLine2=2).
3) ((zLine1< z & zLine2> z) || (zLine1> z & zLine2< z)).
4) ((zLine1<z) & (zLine2<z)) || ((zLine1>z) & (zLine2>z)).
In the first case (Fig.5 CASE A), neither line represent any
boundary. Therefore these two lines are removed from the data
that is going to be used to obtain the edge contour at that
slicing plane.
In the second case (Fig.5 CASE B), both lines reside in the
same edge and one of them is removed from the data. As a
fact, which line is removed does not matter; because the
obtained contour data does not need any reference
information.
In the third case (Fig.5 CASE C), both lines share the same
edge that is actually a boundary for the solid body.
Consequently one of the lines is removed.
In the fourth case (Fig.5 CASE D), the edge does not
represent any boundary of the solid body when the slicing
plane is considered. In other words, this data do not create a
closed area which is going to be built in the AM process at
further points. As a result both lines are removed from the
contour data.
The outputs of the repeating lines algorithm are the lines
that represent the boundary of the solid body on the slicing
plane.
D. Line Grouping
Line grouping is rearranging of the vertices so that they
form a closed loop. This closed loop defines the hatch path
boundary. Hatch path generation is necessary when additive or
subtractive building processes are used to shorten production
time and improve surface quality. In this study, line grouping
is omitted because the aim of this study is to understand slicing
procedure and use this knowledge as a base for future AM
process developments.

143

O. Topu, Y. Tacolu, H. . nver


E. G-Code Generation
This section of the algorithm uses the standard milling GCode. Only a few machine codes are sufficient to create the
required slice as a layer of the whole artifact. The algorithm
traces the whole slice data along the x-axis of the slicing plane
for every y-axis value and then marks the required locations.
In other words, it detects the locations of start and end points
of the building process. If the STL file is error free, there
exists an even number of marking points. The schematic
illustration of G-Code generation obtained from a hollow cube
solid is given in Fig.6 The dark, thick lines symbolize the solid
and the light, thin lines symbolize the empty space.

difference between the figures is due to difference in the step


size of the G-Code. The step size is determined from the
dimensions of the workpiece. Fig.8 shows one of the slices of
the whole part obtained from a 100mm x 100mm x 1mm
dimensioned rectangular solid. Fig.9 shows one of the slices
produced from a 1m x 1m x 1mm in size solid rectangular
workpiece.

Figure 8: CNC milling simulation result of logo 1.

Figure 6: (a) Schematic illustration of G-Code generation and (b)


resultant code of the algorithm.

III. CASE STUDIES


Examined geometries, which are specially chosen for the
purpose of this study, are shown in Fig.7. Single layers of
these geometries are tested on CNCSimulator [10], a freeware
CNC milling simulation software, by using the G-codes
generated with the algorithm described at the previous section.
Hollow cube and Keplers rhombic dodecahedron solid bodies
provide all the cases mentioned in the intersection point
detection algorithm. For this reason these models are
frequently used to detect bugs in the coding phase.

Figure 7: Studied geometries to test the competence of the


algorithm.

Figure 9: CNC milling simulation result of logo 2.

IV. CONCLUSION
In this study a new STL slicing and G-Code generation
algorithm was explained. This software algorithm shapes the
foundation for future studies and generates slice data of any
given 3D model. Performance of the algorithm is evaluated by
simulating several complex 3D geometries on a CNC milling
simulator using the generated G-Codes. There is currently a
limitation on the STL file size but this limitation can be
handled by a modifying the code to study with one facet data
at a time. Moreover, considering that the operation of integers
is faster than that of floating point numbers, the floating point
coordinates of the facets in a model may be transformed to 32
bits integers to speed up the process.
ACKNOWLEDGMENT

Fig.8 and Fig.9 depict the simulation results of the two


studied geometries. As it can be seen, slices of relatively
complex 3D parts have been simulated using the developed
slicing and G-Code generation algorithms. The resolution

The authors appreciate . Ethem Bacs guidance for


NetBeans IDE and Javas memory heap problem.

144

A Method for Slicing CAD Models in Binary STL Format


REFERENCES
D. Dutta, F.B. Prinz, D. Rosen, L. Weiss, Layered Manufacturing:
Current Status and Future Trends, Journal of Computing and
Information Science in Engineering, vol. 1, pp. 6071, March 2001.
[2] M.J. Pratt, A.D. Bhatt, D. Dutta, K.W. Lyons, L. Patil, R.D. Sriram,
Progress towards an international standard for data transfer in rapid
prototyping and layered manufacturing, ComputerAided Design, 34,
11111121, 2002
[3] V. Kumar, D. Dutta, An assessment of data formats for layered
manufacturing, Advances in Engineering Software, 28, 151164, 1997
[4] Gan G.K. Jacob, C.C. Kai, T. Mei, Development of a new rapid
prototyping interface, Computers in Industry, 39, 6170, 1999
[5] Y. M. Zhang, P. Li, Y. Chen, A.T. Male, Automated system for
weldingbased rapid prototyping, Mechatronics, 12, 3753, 2002
[6] http://paulbourke.net/dataformats/ply/ (last visited 25.02.2011)
[7] W. Ma, P. He, An adaptive slicing and selective hatching strategy for
layered manufacturing, Journal of Materials Processing Technology,
8990, 191197, 1999
[8] B. Asiabanpour, B. Khoshnevis, Machine path generation for the SIS
process, Robotics and ComputerIntegrated Manufacturing, 20, 167
175, 2004
[9] D. X. Wang, D.M. Guo, Z.Y. Jia, H.W. Leng, Slicing of CAD models
in color STL format, Computers in Industry, 57, 310, 2006
[10] http://www.cncsimulator.com/ (last visited 25.02.2011)
[1]

145

Potrebbero piacerti anche