Image Generation from STL Models and its Potential Role in Layer-Quality Evaluation for the Electron Beam Melting Process

Electron Beam Melting (EBM) is an increasingly used Additive Manufacturing (AM) technique employed by many industrial sectors, including the medical device and aerospace industries. In EBM process monitoring, data analysis for processed layer quality evaluation is currently focused on the extraction of information from the raw data collected in-EBM process, i.e. thermal/ optical / electronic images, and the comparison between the collected data and the Computed Tomography (CT)/ microscopy images generated post-EBM process. This article postulates that a stack of bitmaps could be generated from the 3D model at a range of Z heights during file preparation of the EBM process, and serve as a reference image set. In-EBM process comparison between that and the workpiece images collected during the EBM process could then be used for quality assessment purposes. In addition, despite the extensive literature on 3D model slicing and contour generation for AM process preparation, no methods regarding image generation from cross sections of the 3D models have been disseminated in details. This article aims to address this by presenting a piece of 3D modelimage generation software. The software is capable of generating binary 3D model reference images with user-defined Region-of-Interest (ROI) of the processing area, and Z heights of the model. It is envisaged that this 3D model-reference image generation ability opens up new opportunities in quality assessment for the in-process monitoring of the EBM process. Preprints (www.preprints.org) | NOT PEER-REVIEWED | Posted: 14 January 2019 © 2019 by the author(s). Distributed under a Creative Commons CC BY license.


Introduction
This section provides the background of this study in the following order, technology gap in STL-image generation for EBM quality evaluation, typical Additive Manufacturing (AM) and Electron Beam Melting (EBM) build cycles, and 3D model tessellation, slicing and Gcode.

Technology Gap in STL-Image Generation for Quality Evalaiton
EBM layer-quality monitoring has been studied by various academic groups.The data collection methods developed so far have focused on thermal / optical / electronic in-process imaging.Regarding data analysis for the evaluation of layer-quality, Raplee et al [1] evaluated the quality of the melting process by analysing regional slopes in pixel values of the in-process thermal images.The relationship between temperature profile and microstructure of components were also investigated by comparing the in-process thermal images with post-process Electron Backscatter Diffraction (EBSD) results of EBM manufactured components.Mireles et al [2,3] detected intentional defects in in-process thermal images of an EBM component via contour tracing (Moore-Neighbour tracing algorithm).These thermal images were also correlated with post-process Computed Tomography (CT) scan data of the EBM component to confirm the observation of the thermal imaging system.In other articles, Mireles et al [3,4] detected porosity in EBM manufactured components and monitored the EBM processing area temperature via the comparison between a calculated average pixel intensity (represents an average temperature) from in-process thermal images and the user pre-defined pixel intensity range (represents the desired temperature range).Rodriguez et al [5] analysed the in-process thermal images histogram of the EBM processing area to distinguish between components with uniform temperature and that with cold spots.Arnold et al [6] evaluated the topography and porosity of an EBM manufactured component by comparing the in-process electronic images with post-process CT scans and images from an optical microscope.The data analysis attempts described so far have shown that no methodologies involve the evaluation of in-process images against reference images generated from STL models.This article aims to fill this knowledge gap by proposing an EBM layer-quality metric based on the use STL reference images.
Regarding the slicing of STL models and contour generation for the preparation of an AM process, the academic communities have contributed considerably.Eragubi [7] investigated the slicing of STL models for laser path generation, Ding et al [8] introduced the commonly used STL slicing strategies and various types of paths in 2D path planning for AM processes, Adnan et al [9] evaluated a line-plane analysis based STL slicing method by investigating the layer-slicing time of STL models with a range of model complexities.Minetto et al [10] disseminated an algorithm which makes use of arbitrary layer thicknesses to optimise STL slicing (reduce layer thickness to reveal finer details, vice versa).Zhang et al [11] developed an effective STL model correction and slicing algorithm to handle models with defects, such as cracks, overlapping and non-manifold facets.Sahatoo et al [12] summarised the influences of slicing on the AM process and components, which include, model preparation time and surface finish.Brown et al [13] presented an algorithm for both STL slicing and G-code generation for an entry-level 3D printer.Despite the extensive account on STL slicing, when it comes to image generation from STL models, a detailed methodology is still yet to be disseminated.This article aims to present the development of STL-image generation software in details to address this knowledge gap.

Typical AM and EBM build cycles
AM, commonly referred to as 3D printing, is a manufacturing process which creates 3D components in a layer-by-layer fashion.A typical AM cycle overview is as follow: (1) 3D Computer-Aided Design (CAD) model creation, (2) Stereolithography (STL) file preparation, (3) STL file slicing, and (4) the AM component building process [14].EBM, a Powder-Bed Fabrication (PBF) process [15], is one of the AM processes for metals.The EBM process begins with a metal powder layer being deposited over a machine processing area.An accelerated electron beam, serving as a thermal energy source, is used to pre-heat and sinter the powder bed [16].Selective melting of the design cross section contour is then carried out and followed by hatching [17].These steps are repeated layer-upon-layer until the manufacture of the 3D model is complete.

3D Model Tessellation, Slicing and G-Code
3D surface geometries can be represented by triangular tessellation [14], as demonstrated by format, each tessellation triangle is described by two pieces of information: the 3D Cartesian coordinates of the triangle vertices, and the normal unit vector of the triangular plane (pointing outward of the model), as summarised in Table 1 [18].Table 1 Sample ASCII STL file format [18] Parameter Value Triangle Facet Normal (n x , n y , n z ) Triangle Vertices (v 1x , v 1y , v 1z ), (v 2x , v 2y , v 2z ), (v 3x , v 3y , v 3z ) In order to prepare for a typical AM process, the STL file of a design first undergoes a slicing operation, as described by Fig. 2.
Fig. 2 STL slicing schematic.Left -3D STL.Rightsliced STL cross sections [19] The slice depth is set to be equivalent to the AM processing layer thickness, whilst the slice direction is in the AM build direction.Layers of cross-sections of the original 3D design are generated as the output.Together with the heat source (e.g.laser, electron beam) parameters, the 2D design information is then translated into machine code, the G-code [20].During manufacturing, this G-code is read by the AM machine, and the AM process is carried out by building the design cross-sections with predefined beam parameters and machine steps, in a layer-by-layer fashion [21,22].

STL-Image Generation Software Development
The purpose of this software is to generate digial images from STL designs.The development is partly built upon an existing Python package called "Conformal Surfaces" (University of Liverpool, UK) [23].Part of the "Conformal Surfaces" source code is used to enable the import of STL files and extraction of the 3D Cartesian coordinates of triangle vertices contained in the STL files.Fig. 3 uses the operation on one Z plane to give the process flow overview of the STL-image generation software developed.
Fig. 3 STL-image generation overview, for one arbitrary Z plane

3D STL Design Slicing and 2D Contour Vector Generation
In an STL file, the surface geometry of a design is represented by a set of triangles via meshing.Fig. 4 illustrates an STL design and its element in triangulation.
Where (x 1S , y 1S , z 1S) and (x 1F , y 1F , z 1F ) are the Cartesian coordinates of the "start" and "finish" Regarding the slicing of a 3D STL design, the STL segments are analysed using vector calculus to generate a set of 2D contours based on a set of Z planes (in typical AM processes, the Z direction is the build direction).Fig. 5 and Eqs.2-7 describe the working principle of the slicing operation carried out by the software.Where   ⃑⃑⃑⃑⃑⃑ is an arbitary STL vector segment in a 3D Cartesian space,  0 ⃑⃑⃑⃑⃑⃑ is the vector connecting the origin and the start point S of   ⃑⃑⃑⃑⃑⃑ ,  0 ⃑⃑⃑⃑⃑⃑ is the vector connects the origin and the the finish point F of   ⃑⃑⃑⃑⃑⃑ , and  0 ⃑⃑⃑⃑⃑⃑ is the vector connecting the origin and an arbitrary point X in space Fig. 5, Eq. 4 and Eq. 5 show that if   ⃑⃑⃑⃑⃑⃑ is parallel to   ⃑⃑⃑⃑⃑⃑ , then   ⃑⃑⃑⃑⃑⃑ can be expressed by (  ⃑⃑⃑⃑⃑⃑ ), where t is a scale factor.

Fig. 5 Definition of a STL segment in vector calculus
[ If both the start and finish point of a chosen STL vector segment,   ⃑⃑⃑⃑⃑⃑ , are known, it is possible to decide if a selected Z plane intersects with the chosen STL vector segment.A selected Z plane is defined in Eq. 6 Where   and   are the X and Y coordinates within the selected Z plane, with values equal to any real numbers,and   is the Z coordinate of the selected Z plane, with a value of an arbitary constant B If Eq. 6 is plugged into Eq.5, it will result in Eq.7 Where   and   are the X and Y coordinate of an intersection between the selected Z plane and the arbitary STL segments With the coordintes of the arbitary STL segment start and finish points, and the Z coordintae of the selected plane known,   and   of the intersection can be calculated through finding the scale factor t. Fig. 3   lines are defined.Based on the definition given in Fig. 5 and Eq. 4, the interesctions between the 2D contour vectors and the virtual scan lines can be found by applying Eq. 8, which is a 2D version of Eq.4.Table 3 summarises the various outcomes in the interactions between virtual scan lines and the 2D contour vectors.Only the outcome which results in an even number of unique intersections is valid for further processing in the software.
Where C is the known Y location of a scan line, and   , is the X coordinate of an intersection between the scan line and a 2D contour vector, which can be found by first resolving for t.

Pixel Value Assignment
With regard to pixel value assigment, the 2D intersections on each virtual horizontal scan line are analysed, as described by process flow chart in Fig. 9 (an elaboration of the overview given in Fig. 3).The key factor is to only keep the scan lines with an even number of intersections, and discard the rest of the scan lines.

Image Generation from STL Design
Four STL designs, as summarised in Table 5, were downloaded from the free online STL   demonstrates that, apart from the sheer number of STL triangles to go through per Z height, their arrangement in space (how intricate the design is) is thought to also influence the image generation time.

Demonstration: Post-EBM Process Electronic and STL Images Generations
This section demonstrates the results of the STL-image generation software when it was used alongside a custom digital electronic imaging system prototype developed for an Arcam A1 EBM machine (Arcam AB/ GE Additive, USA) [24].Fig. 15(a) is the schematic of the prototype.The prototype consisted of a feedback electron sensor (modified Arcam heatshield frame and plates), a data logger (Arduino DUE microcontroller break-out board), signal amplifier and electronic image generation software.The prototype was designed to generate digital electronic images from the secondary electrons and backscattered electrons, originating from the interactions between the machine's primary electron beam and the processing area.Fig. 15(b) shows the imaging target [24] used in this demonstration.The target was manufactured by the EBM machine, made of Ti-6Al-4V alloy, and designed to consist of nine solidified / sintered powder regions.Upon completion, the target was taken out of the EBM machine for excess powder removal in a Powder Recovery System (PRS) (Arcam AB/ GE Additive, USA).In this demonstration, after the removal of excess powder, the imaging target was put back to the EBM machine processing area for electronic imaging.Digital electronic images were generated with the ROI of location "6" from the surface of the target, at room temperature.
(a) Schematic of the prototype (b) Imaging target Fig. 15 Electronic imaging system prototype and the imaging target [24] Raw digital electronic images were generated from location "6" of the imaging target, as illustrated by Figs.16(a) and (c).In order to generate binary electronic images, image processing was carried out before image thresholding.Noise was removed by applying a median filter, and image contrast was enhanced by carrying out histogram equalisation with the use of the FIJI software (same as ImageJ, open source).Eq. 9 [25] and Eq. 10 [25] define the median filter and histogram equalisation functions used respectively.The median filter applied had a user-defined neighbourhood area of a circle with radius of two pixels.The histogram equalisation was carried out with a user-defined saturated pixel value of 0.3%, allowing 0.3% of the total pixels to become saturated.is the cumulative probability distribution of the normalised histogram, and y k is an integer, the equalised number of pixel with a pixel-value of k.
Figs. 16(d) and (e) show the processed and binarised electronic images of location "6" respectively.Binary images with the same ROI (location "6") were also generated from the STL-image generation software, as shown in Figs.16(b) and (f).

Discussion
Discussion on image generation results will be presented in the following order: image generation from STL designs, and reference image generation.for EBM process monitoring.These bitmaps have the potential to be used as reference images in layer-quality assessment, and will be discussed in Section 4.2."workpiece images".The comparison between these reference and workpiece images is thought to have the potential to reveal typical EBM process issues which include, but not limited to, poor powder bed deposition [26] and peel-off metallisation fallen onto the processing area [27].These reference and workpiece image sets generated from the STLimage generation software and the custom electronic imaging system prototype are thought to open up opportunities for the development of a layer-quality measure for the EBM process.from a stack of deviation images generated throughout the EBM process.This model could serve as an overall, quantitative feedback to the users on the EBM build quality.Despite the possibilities suggested by the results and concepts derived from this study, Table 6 shows that the minimum reference image generation time was 4.56s whilst the maximum was 60.2s in this study.Although it is expected that the whole reference image set would be generated  layer fashion.There will, however, be challenges ahead in order to realise this potential.

Demonstration: Post-EBM Process Electronic and STL Images Generations
Future studies will need to focus on, firstly, improving the image generation algorithm to reduce the image generation time.In this study, the minimum and maximum times recorded to produce a reference image from STL models were 4.56s and 60.2s respectively.At these rates, the extra time incurred to the EBM build preparation stage due to the generation of a full stack of reference images from the whole STL model is expected to be too long to make this metric practical.Secondly, in order to further assess the applicability of this image comparison metric, the custom electronic imaging system prototype needs to carry out inprocess data collection in a real EBM build to generate electronic images on-the-fly.Imageimage comparison between a pair of STL reference image and workpiece electronic image needs to be conducted in real-time, after the processing of each EBM layer, during a real EBM build.

Fig. 1 .
Fig. 1.The American Standard Code for Information Interchange (ASCII) Stereolithography (STL) format, which is used in this study, is one of the tessellation file formats.In this

Fig. 6 Fig. 6
Fig.6illustrates all the possible outcomes between an arbitarily selected Z plane and an STL triangle during slicing.Only Fig.6(f) will generate a valid 2D contour ouput for further processing in the software.A valid output is defined as an unique intersection segment made of two unique intersections between the selected Z plane and two out of three STL segments in a STL triangle.

PreprintsTable 3
(www.preprints.org)| NOT PEER-REVIEWED | Posted: 14 January 2019 Preprints (www.preprints.org)| NOT PEER-REVIEWED | Posted: 14 January 2019 doi:10.20944/preprints201901.0140.v1Intersections between virtual scan lines and 2D contour vectors Scenario Description Write to output?Total number of intersection is an even number, intersections lie within vectors Yes Intersections lie beyond vectors No Total number of intersection is an odd number No One of the intersections is at the start/ finish point of one of the vectors No One of the vectors is running parallel to the virtual scan line No Three trials were conducted with different STL designs to verify the operation of slicing and 2D intersection generation.These designs were created in the Creo software (PTC, USA) and saved as STL files.
Figs. 10 (a) and (b) illustrate this idea with a set of 2D contour vectors of a STL cube.Pixels which lie between the 2D intersections are assigned the colour white, whilst others are assigned the colour black.The location, length and number of the virtual scan lines define the output 2D bitmap size (number of image pixel columns and rows).

Fig. 9 Fig. 10
Fig. 9 Pixel assignment algorithm in details database, Thingiverse (https://www.thingiverse.com/).The designs were imported into the Magics software (Materialise NV, Belgium) for re-scaling to fit into a 200mm x 200mm Region of Interest (ROI), and to align the design frontal plane direction with the origin Z axis in the software.These STL designs were then imported to the image generation software for trial runs.Figs.11 to 14 show the designs and bitmaps generated at different Z planes.Preprints (www.preprints.org)| NOT PEER-REVIEWED | Posted: 14 January 2019 Preprints (www.preprints.org)| NOT PEER-REVIEWED | Posted: 14 January 2019 doi:10.20944/preprints201901.0140.v1

Fig. 16 (
Fig. 16(b) and (f) verify that the STL-image generation software has the flexibility to allow users to define the image FOV by selecting specific ROI on the imaging target.It is thought that these STL images, i.e.Fig. 16(f), can serve as "reference images" whilst the electronic images, i.e.Fig. 16(e) (with the same Z height and ROI as Fig. 16(f)), from the prototype as

Fig. 17 illustrates
Fig.17illustrates this concept.Although, in this study, the workpiece electronic image, Fig.16(e), was generated post-EBM process, this demonstration is thought to have showcased the potential for image-image comparison to be conducted in-process for the evaluation of the EBM layer quality on-the-fly.With this EBM process monitoring concept, potential metrics could be developed as outlined below: (1) a deviation image could be generated for each EBM layer to reveal the differences in pixel values between a reference and workpiece image when overlaying one on top of the other, and (2) a 3D deviation model could be generated before the actual EBM process begins, further development is needed to improve the image generation software to reduce the image generation time, in order to minimise the extra time incurred in EBM build preparation due to the generation of a reference image set used for quality monitoring purposes.

Fig. 17
Fig. 17 Multi-layer monitoring and analysis

Table 2
Definition of segments in a STL triangle

Table 5
STL models and their complexity Preprints (www.

Table 6
STL-image generation time.Data rounded to 3.s.f.

Table 5 and
show that the STL-image generation software is capable of handling STL files with different level of complexities: from 20606 to 887500 number of STL triangles.In addition, Figs.11-14 verify that the software is capable of generating images at various Z heights, and the pixel values are correctly allocated to represent the interior and exterior of the STL models in the bitmaps.It is thought that the ability to generate bitmaps representing the 2D cross sections of STL designs at various Z heights is an important step