Professional Documents
Culture Documents
MMT 558
Lecture - 4
Manipulation of STL Files
Dr. Manjesh Kumar
Assistant Professor
Department of Mechanical Engineering
SRM University AP
Andhra Pradesh ‒ 522502, India
Contact No. +918100804553
Email : manjesh.k@srmap.edu.in,
phdmanjesh@gmail.com 1
Contents 2
Z Z
𝑦1 = 𝐿 cos 𝛼 𝑧2 = 𝐿 sin 𝜃 + 𝛼
𝒙𝟐 = 𝟏 𝒙𝟏 + 𝟎 𝒚𝟏 + 𝟎 𝒛𝟏
Y
𝒚𝟐 = 𝟎 𝒙𝟏 + 𝒚𝟏 𝐜𝐨𝐬 𝜽 − 𝒛𝟏 𝐬𝐢𝐧 𝜽
𝒛𝟐 = 𝟎 𝒙𝟏 + 𝐬𝐢𝐧 𝜽 𝐲𝟏 + 𝐜𝐨𝐬 𝜽 𝒛𝟏
𝑥2 1 0 0 𝑥1
𝑦2 = 0 cos 𝜃 − sin 𝜃 𝑦1
X 𝑧2 0 sin 𝜃 cos 𝜃 𝑧1
STL: Rotation 4
In the Cartesian Coordinate system the rotation of a point about the x-axis, y-axis or z-axis can be obtain
by multiplying with the rotation matrix:
1 0 0
𝑅 𝜃𝑥 = 0 cos 𝜃𝑥 − sin 𝜃𝑥
0 sin 𝜃𝑥 cos 𝜃𝑥
Z
cos 𝜃𝑦 0 sin 𝜃𝑦
𝑅 𝜃𝑦 = 0 1 0
−sin 𝜃𝑦 0 cos 𝜃𝑦
Y
cos 𝜃𝑧 − sin 𝜃𝑧 0
𝑅 𝜃𝑧 = sin 𝜃𝑧 cos 𝜃𝑧 0
0 0 1
X
STL: Rotation 5
𝑝1 𝑖
(𝑝𝑘𝑥 𝑖
, 𝑝𝑘𝑦 𝑖
, 𝑝𝑘𝑧 ) are the coordinates of the 𝑘𝑡ℎ (𝑘 = 1,2,3) vertex of the 𝑖 𝑡ℎ triangle,
Z
𝑖 = 1, 2, 3 … 𝑁 (N is the number of triangles).
𝑛ො
In the similar fashion the normal of the triangle can be rotated.
Y
𝑛𝑥𝑖 𝑛𝑥𝑖
𝑝2
𝑛𝑦𝑖 = 𝑹 𝜽𝒙 /𝜽𝒚 /𝜽𝒛 𝑛𝑦𝑖
𝑛𝑧𝑖 𝑛
𝑛𝑧𝑖
𝑝3 X
where (𝑛𝑥𝑖 , 𝑛𝑦𝑖 , 𝑛𝑧𝑖 ) are the coordinates of the outward normal of the 𝑖 𝑡ℎ facet
STL: Translation 6
𝑝1 𝑖
(𝑝𝑘𝑥 𝑖
, 𝑝𝑘𝑦 𝑖
, 𝑝𝑘𝑧 ) are the coordinates of the 𝑘𝑡ℎ (𝑘 = 1,2,3) vertex of the 𝑖 𝑡ℎ triangle,
Z
𝑖 = 1, 2, 3 … 𝑁 (N is the number of triangles).
𝑛ො
The normal vector will not change
Y
𝑛𝑥𝑖 𝑛𝑥𝑖
𝑝2
𝑛𝑦𝑖 = 𝑛𝑦𝑖
𝑛𝑧𝑖 𝑛
𝑛𝑧𝑖
𝑝3 X
where (𝑛𝑥𝑖 , 𝑛𝑦𝑖 , 𝑛𝑧𝑖 ) are the coordinates of the outward normal of the 𝑖 𝑡ℎ facet
STL: MATLAB Code 7
STL: Support Structure 8
The support structure is mainly required while creating the overhanging features. In some AM processes
the explicit support structures are not required such as in the case of binder jetting & Powder – Bed Fusion
(sintering) the remaining loose powder act as a support material. However, in some AM process the
support structures need to be created in during the pre-processing.
The support structure is a sacrificial material added to support the overhanging features. There are other
type of sacrificial material also used in AM and those will be discussed later.
STL: Support Structure 9
For a given STL file and build direction the support structure can be easily calculated based on the facet
normal of the tringles of the STL file and build direction. If the build direction is vertical (+Z) then the
triangles those are having normal pointing upward will not required the support structures and the normal
pointing downwards may required the support structures.
𝑝1 𝑝1
Z Z Z
𝑛ො
𝑛ො 𝑝1
Y Y
𝑝2 Y
𝑝2 𝑝3 𝑝2
𝑛ො
𝑝3 X X X
𝑝3
STL: Support Structure 10
Lets assume that the AM process can support the maximum overhang 𝑑 with the layer thickness 𝑡.
+Z
𝜃
t
T D
t
d
Therefore if the angle 𝛼 between the build direction (𝑘) and the
triangle normal is greater than 𝜃, the support will be required 𝑡
tan 𝜋 − 𝜃 =
𝛼 = cos −1 𝑛𝑥𝑖 𝑖Ƹ + 𝑛𝑦𝑖 𝑗Ƹ + 𝑛𝑧𝑖 𝑘 . 𝑘 𝑑 t
𝜋− 𝜃
𝛼 = cos −1 (𝑛𝑧𝑖 )
𝑡 d
where (𝑛𝑥𝑖 , 𝑛𝑦𝑖 , 𝑛𝑧𝑖 ) are the coordinates of the outward normal 𝜃=𝜋− tan−1
of the 𝑖 𝑡ℎ facet 𝑑
STL: Support Structure 11
In an AM process the maximum possible layer overhang can be 1 mm. The build direction +Z. The
minimum possible layer thickness is 3 mm. Find out the critical value of the z-component of the facet
normal of the triangles of an STL file beyond that the support is be required.
3
𝜃= 180° − tan−1 = 180° − 60° = 120°
1
𝛼 = cos −1 𝑛𝑧𝑖
Supports are extended until they intersect either with the base platform or another upward facing surface
of the part. (In the shown example the triangles with facet normal having angle greater than 120° with the
+Z axis are in yellow color)
STL: MATLAB Code 13
STL: Support Structure 14
Calculation
A (𝑥, 𝑦, 𝑧)
1. Support Generation from Facets
𝑁𝑥 , 𝑁𝑦 , 𝑁𝑧
Equation of a line 𝐴𝐴′ passing through a point (𝑥, 𝑦, 𝑧) and parallel to a vector
𝑥′ − 𝑥 𝑦′ − 𝑦 𝑧′ − 𝑧
= = =𝛼 1
𝑁𝑥 𝑁𝑦 𝑁𝑧
Get 𝛼:
Point A’ is on the plane
𝑁𝑥 𝛼𝑁𝑥 + 𝑥 + 𝑁𝑦 𝛼𝑁𝑦 + 𝑦 + 𝑁𝑧 𝛼𝑁𝑧 + 𝑧 − a = 0 3
𝑁𝑥 𝑥′ + 𝑁𝑦 𝑦′ + 𝑁𝑧 𝑧′ − 𝑎 = 0 2
STL: Support Structure 15
Calculation
1. Support Generation from Facets
If the build direction is +Z (𝑁𝑥 = 0, 𝑁𝑦 = 0, 𝑁𝑧 = 1) and base is at 𝑋𝑌 plane (𝑎 = 0)
𝑝1 Form equation 3:
𝛼 = −𝑧
𝑝2 𝑝′1
Y Form equation 2:
𝑥′ − 𝑥 𝑦′ − 𝑦 𝑧′ − 𝑧
= = =𝛼
𝑁𝑥 𝑁𝑦 𝑁𝑧
𝑝′3 𝑝′2
𝑥 ′ = 𝑥, 𝑦 ′ = 𝑦, 𝑧 ′ = 0
X
STL: Support Structure 16
Calculation
1. Support Generation from Facets
The volume of the support structure can be obtained as:
𝑛 𝑛
𝑝1
𝑉𝑠𝑝 = 𝑉𝑖 = 𝐴𝑖 × ℎ𝑖
𝑖=1 𝑖=1
Z
𝑝3 𝑛ො
Where 𝑛 is the total number of down-facing
Build Direction
Calculation
1. Support Generation from Facets
Self Supporting
Part
region
Support
Projected
on Part
Support
Projected
on base
Substrate/Base/Platform
STL: Support Structure 18
Example
The build direction of the object shown is +Z and support is not required for facet normal having angle
greater than 120° from the build direction.
1. Determine the projected area of the support required for the given facets. (Ignore the base support)
2. How many triangles you will examine for support calculation? Also highlight locations of these
triangles.
Build Direction
STL: Support Structure 19
Example
facet normal -0.500000 0.000000 -0.866025 facet normal 0.000000 0.000000 -1.000000 facet normal 0.866025 0.000000 -0.500000
outer loop outer loop outer loop
vertex 80.000000 0.000000 0.000000 vertex 50.000000 -0.000001 17.320511 vertex 30.000000 -0.000001 17.320511
vertex 50.000000 -10.000001 17.320511 vertex 30.000000 -10.000001 17.320511 vertex 20.000000 -10.000000 -0.000000
vertex 50.000000 -0.000001 17.320511 vertex 30.000000 -0.000001 17.320511 vertex 20.000000 0.000000 0.000000
endloop endloop endloop
Endfacet endfacet endfacet
facet normal -0.500000 0.000000 -0.866025 facet normal 0.000000 0.000000 -1.000000 facet normal 0.866025 0.000000 -0.500000
outer loop outer loop outer loop
vertex 80.000000 -10.000000 -0.000000 vertex 50.000000 -10.000001 17.320511 vertex 30.000000 -10.000001 17.320511
vertex 50.000000 -10.000001 17.320511 vertex 30.000000 -10.000001 17.320511 vertex 20.000000 -10.000000 -0.000000
vertex 80.000000 0.000000 0.000000 vertex 50.000000 -0.000001 17.320511 vertex 30.000000 -0.000001 17.320511
endloop endloop endloop
endfacet endfacet endfacet
facet normal -0.500000 0.000000 -0.866025 facet normal 0.000000 0.000000 -1.000000
outer loop outer loop
vertex 80.000000 0.000000 0.000000 vertex 50.000000 -0.000001 17.320511
vertex 50.000000 -10.000001 17.320511 vertex 30.000000 -10.000001 17.320511
vertex 50.000000 -0.000001 17.320511 vertex 30.000000 -0.000001 17.320511
endloop endloop
Endfacet endfacet
facet normal -0.500000 0.000000 -0.866025 facet normal 0.000000 0.000000 -1.000000
outer loop outer loop
vertex 80.000000 -10.000000 -0.000000 vertex 50.000000 -10.000001 17.320511
vertex 50.000000 -10.000001 17.320511 vertex 30.000000 -10.000001 17.320511
vertex 80.000000 0.000000 0.000000 vertex 50.000000 -0.000001 17.320511
endloop endloop
endfacet endfacet
1
Area (2D Triangle) = 𝑥1 𝑦2 − 𝑦3 + 𝑥2 𝑦3 − 𝑦1 + 𝑥3 𝑦1 − 𝑦2
2
STL: Support Structure 23
2a. Containment
2b. Optimal method
2a. Containment
The area to be supported is determined by projecting
all the contours on a plane and then merged to get the
external support. This big contour is then subtracted
from the contours at each slice to determine the
internal contour for support
STL: Support Structure 24
𝑛𝑡ℎ slice
𝑛−1 𝑡ℎ slice
STL: Support Structure 26
Example
Generate the support for the given object utilizing the optimal slicing contour method.
Show the stale and fresh support.
STL: Optimal Orientation 28
The orientation of the part during its fabrication can affect its quality and cost. Following
are the most popular models for obtaining the optimal orientation of the part:
Total cost
Pre-processing cost
Assume that the part is available and no cost is required to create the model
STL: Optimal Orientation 30
𝐶𝑝𝑟𝑒 = 𝑇𝑝𝑜𝑠 + 𝑇𝑠𝑢𝑝 + 𝑇𝑠𝑙𝑖 + 𝑇𝑝𝑎𝑡ℎ 𝑅𝑠𝑡𝑎𝑓𝑓 + 𝑅𝑐𝑜𝑚𝑝 + 𝑇𝑠𝑒𝑡𝑢𝑝 . 𝑅𝑠𝑡𝑎𝑓𝑓 + 𝑅𝑚𝑎𝑐ℎ
T= machine life
STL: Optimal Orientation 32
Staff cost/hr
Cost such as: UV-oven for SLA, HIP for Metal, Water works for FDM
STL: Optimal Orientation 35
Total cost
Pre-processing cost
𝑉𝑒 = 𝑉𝑖 = 𝐴𝑖 × ℎ𝑖
𝑖=1 𝑖=1
Where 𝑛 is the total number of down-facing facets of the STL file, requiring the support.
𝐴𝑖 is the project area of facet 𝑖 onto the horizontal slicing plane, and ℎ𝑖 the average
support height evaluated from the corresponding facet to either the platform or the next
interesting facet, which ever is less.
STL: Optimal Orientation 37
Multi-Objective Model
The optimal orientation of the object is a multi-objective problem with an appropriate
weightage for each of the individual criteria.
• Maximize the number of perpendicular surfaces
• Maximize the number of up-facing horizontal surfaces
• Maximize the number of holes with their axes in the build direction
• Maximize the number of curved cross section drawn in the horizontal plane
• Maximize the area of the base surface
• Minimize the number of sloped surface
• Minimize the number of trapped volumes.
STL: Optimal Orientation 38
Multi-Objective Model
• Maximize the number of perpendicular surfaces
STL: Optimal Orientation 39
Multi-Objective Model
• Maximize the number of up-facing horizontal surfaces
STL: Optimal Orientation 40
Multi-Objective Model
• Maximize the number of holes with their axes in the build direction
STL: Optimal Orientation 41
Multi-Objective Model
• Maximize the number of curved cross section drawn in the horizontal plane
STL: Optimal Orientation 42
Multi-Objective Model
• Maximize the area of the base surface
STL: Optimal Orientation 43
Multi-Objective Model
• Minimize the number of sloped surface
STL: Optimal Orientation 44
Multi-Objective Model
• Minimize the number of trapped volumes.
STL: Optimal Orientation 45
Multi-Objective Model
The optimal orientation of the object is a multi-objective problem with an appropriate
weightage for each of the individual criteria.
• Maximize the number of perpendicular surfaces
• Maximize the number of up-facing horizontal surfaces
• Maximize the number of holes with their axes in the build direction
• Maximize the number of curved cross section drawn in the horizontal plane
• Maximize the area of the base surface
• Minimize the number of sloped surface
• Minimize the number of trapped volumes.