0% found this document useful (0 votes)
13 views11 pages

PDF-3 SRT - Files - PKJ

Uploaded by

manekar0312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views11 pages

PDF-3 SRT - Files - PKJ

Uploaded by

manekar0312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

PDPM IIITDM Jabalpur September 9, 2024

Rapid Product Development Technologies Rapid Product Development Technologies


STL Files

Instructor: Dr. Prashant K. Jain


Professor (ME Discipline)
PDPM Indian Institute of Information Technology,
Design and Manufacturing Jabalpur, Jabalpur, INDIA
Resources: web.iiitdmj.ac.in/~pkjain/
Email: [email protected], [email protected]
http://www.iiitdmj.ac.in/Faculty/pkjain.html
http://in.linkedin.com/in/pkjain2006
https://www.facebook.com/pkjain2006

PDPM
INDIAN INSTITUTE OF INFORMATION TECHNOLOGY,
DESIGN AND MANUFACTURING JABALPUR
(An Institute of National Importance (INI) established by MHRD, Govt. of INDIA) 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 2

Slicing and contour retrieval STL Files


Contour drawn in sequence as found in STL
STL stands for “STANDARD TESSELATION LANGUAGE”. The STL
100

80
format was developed in 1987 for moving 3D CAD models to its
60
stereolithography apparatus (SLA) machines.
40

20 The STL file format has become the Rapid Prototyping industry's
20 40 60 80 100 120 140 160 180 200

standard data transmission format. Rapid prototyping machines are


120
Internal contours basically 3D printers that can build any volume shape as a series of
Z Axis (mm)

20
200 100 slices. Ultimately these machines require a series of closed 2D
0

100
80 100
150
80 contours that are filled in with solidified material as the layers are
Y Axis (mm)

60

Y Axis (mm)
40
20
50
X Axis (mm)
60
fused together.
40

20
The natural file format for such a machine would be a series of
closed polygons corresponding to different Z-values.
External contours
40
Z Axis (mm)

0
20

0
200 20 40 60 80 100 120
X Axis (mm)
140 160 180 200 STL file format are capable of creating those 2D layers.
150
100
80 100
60
40 50
20
9-Sep-24 Y Axis (mm) Dr. P. K. Jain IIITDM Jabalpur
X Axis (mm) 4 September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 6

STL File Format


STL Files
The normal and each vertex of every facet are specified by three
An STL file is a triangular representation of coordinates each, so there is a total of 12 numbers stored for each facet.
a 3D surface geometry. Each facet is part of the boundary between the interior and the exterior of
The surface is tessellated logically into the object.
a set of oriented triangles (facets). The orientation of the facets (which way is ‘out’ and which way is ‘in’) is
Each facet is described by the unit specified redundantly in two ways which must be consistent.
outward normal and three points listed in  First, the direction of the normal is outward.

counterclockwise order representing the  Second, the vertices are listed in counter clockwise order when looking
vertices of the triangle. at the object from the outside (right-hand rule).

Consistency rules: v1x, v1y, v1z


Each triangle must share two vertices
• The number of faces must be even.
with each of its adjacent triangles. This
• The number of edges must be a is known as vertex-to-vertex rule.
multiple of three.
The object represented must be
• Two times the number of edges located in the all-positive octant (all CCW
must equal three times the number
vertex coordinates must be positive).
of faces v2x, v2y, v2z v3x, v3y, v3z

September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 8

Dr. Prashant K. Jain (IIITDMJ) 1


PDPM IIITDM Jabalpur September 9, 2024

STL standard data formats STL standard data formats


The STL file format generally uses two data formats :-  ASCII
1. ASCII 2. BINARY  More descriptive and human readable
solid name UINT8[80] – Header
 Very large size of the CAD data
facet normal ni nj nk
UINT32 - Number of triangles
outer loop
vertex v1x v1y v1z
for each triangle  BINARY
vertex v2x v2y v3z REAL32[3] - Normal vector
 More common and compressed in size
vertex v3x v3y v3z REAL32[3] - Vertex 1
endloop REAL32[3] - Vertex 2
endfacet
REAL32[3] - Vertex 3
… (next facet)
endsolid name UINT16 - Attribute byte count
end

While the ASCII form is more descriptive, the binary form is far
more common due to the very large resulting size of the CAD
data when saved in the ASCII format.
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 11 September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 12

solid EXAMPLE_PART
facet normal 0.000000e+00 0.000000e+00 -1.000000e+00
GIVE N PART

outer loop
15
vertex 5.000000e+00 3.000000e+00 0.000000e+00
vertex 5.000000e+00 0.000000e+00 0.000000e+00 10

vertex 0.000000e+00 0.000000e+00 0.000000e+00 STL File export from various software

Z AXIS
5

endloop 0

endfacet Reading STL file using MATLAB Programming -5


15
facet normal 0.000000e+00 -1.000000e+00 0.000000e+00 10
10
15
5
outer loop 0 0
5

vertex 0.000000e+00 0.000000e+00 2.000000e+00 Y AXIS -5 -5


X A XIS

vertex 0.000000e+00 0.000000e+00 0.000000e+00


vertex 5.000000e+00 0.000000e+00 0.000000e+00 15
GIVEN PART
10
GIVEN PART

endloop
endfacet
facet normal 0.000000e+00 0.000000e+00 1.000000e+00
outer loop 10 5
vertex 5.000000e+00 0.000000e+00 2.000000e+00
vertex 0.000000e+00 3.000000e+00 2.000000e+00
vertex 0.000000e+00 0.000000e+00 2.000000e+00
Y A X IS

Y AXIS
endloop 5 0

endfacet
facet normal 0.000000e+00 0.000000e+00 1.000000e+00
outer loop 0
vertex 5.000000e+00 0.000000e+00 2.000000e+00
-5

vertex 5.000000e+00 3.000000e+00 2.000000e+00


vertex 0.000000e+00 3.000000e+00 2.000000e+00
endloop -5 -10
-5 0 5 10 15
endfacet
-10 -5 0 5 10
X AXIS X AXIS
endsolid EXAMPLE_PART
September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 13 September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 16

Advantages of STL Format Disadvantages of STL Format


 Disadvantage regarding non usefulness of poly-hedra since
only triangular forms are used. Hence long syntax.
 Its very simple to understand and very simple to code.
 STL file is many times larger than the original CAD data file for
 Any kind of geometry can be tessellated in STL and hence can
a given accuracy parameter.
be formed using RP machine.
 STL file carries much redundant information
 It is already a de facto standard and has been used by most
CAD systems and Rapid Prototyping systems. such as duplicate vertices and edges

Common
Edge

Common
Vertices

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 17 September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 18

Dr. Prashant K. Jain (IIITDMJ) 2


PDPM IIITDM Jabalpur September 9, 2024

Reason for bad STL file The Existing Problems


The first rule states that adjacent triangles must have two Several problems exist in STL files and they are due to the very
vertices in common. Second, the orientation of the triangles nature of STL files as they contain no topological data. Many
commercial tessellation algorithms used by CAD vendors today
(what side of the triangle is in and what side is out) as specified are also not robust and as a result they tend to create
by the vertices and normals must agree. If either of these two polygonal approximation models which exhibit the following
types of error:
criteria are not met, problems exist in the stl file.
1. Gaps (cracks, holes, punctures) that is, missing facets
2. Degenerate facets (where all its edges are collinear)
3. Overlapping facets
4. Non-manifold topology conditions

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 26 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 27

Missing Facets or Gaps Degenerate Facets


Tessellation of surfaces with large curvature can result in A geometrical degeneracy of a facet occurs when all of the
errors at the intersections between such surfaces, leaving facet’s edges are collinear even though all its vertices are
gaps or holes along edges of the part model. distinct.
Degenerate facets do not contain valid surface normal.

September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 28 September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 29

Non-Manifold Conditions
Overlapping Facets There are 3 types of non-manifold conditions:
Due to numerical round-off errors occurring during 1. A valid model would be one whose facets have only one
tessellation. adjacent facet each, that is, one edge shares two facets only.
The vertices are represented in 3D space as floating-point Hence the non-manifold edges must be resolved such that each
numbers instead of integers. Thus the numerical round- facet has only one neighbouring facet along each edge, which
off can cause facets to overlap if tolerances are set too reconstructs a topologically manifold surface.

liberally.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 30 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 31

Dr. Prashant K. Jain (IIITDMJ) 3


PDPM IIITDM Jabalpur September 9, 2024

2. A non-manifold point:
STL file repairing methods

3. A non-manifold face:

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 32

Introduction Consequences of Building a Valid and Invalid Tessellated Model

All vendors of RP systems accept this format and practically A Valid Model: A tessellated model is said to be valid if there
all major suppliers of CAD/CAM systems today provide an are no missing facets, degenerate facets, overlapping facets
interface between their CAD model and the STL file. The STL or any other abnormalities.
file (a collection of coordinate values of triangles) however, Valid tessellated model will first be sliced into 2D layers
not ideal and has inherent problems in this format. Each layer would be converted into unidirectional (or 1D) scan lines for
the laser or other RP techniques to commence building the model
New formats such as LEAF (layer exchange ASCII format),
The scan lines would act as on/off points for the laser beam controller
contour files which are slice formats and cubital facet list
so that the part model can be built accordingly without any problems.
(CFL). However, none of these has been accepted yet as a
replacement of STL.
Users of RP systems have to contend with existing STL file
problems and solutions have to be found to repair errors in
them.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 43 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 44

An Invalid Model
The solid model is tessellated non-robustly which results in a gap
If this error is not corrected and the model is subsequently sliced
No predefined stopping boundary on the particular slice, thus the building
process would continue right to the physical limit of the RP machine,
creating a stray physical solid line and ruining the part being produced Generic Solution
(a) (b) (c)

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 45 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 46

Dr. Prashant K. Jain (IIITDMJ) 4


PDPM IIITDM Jabalpur September 9, 2024

Insight to the Basic Approach of the Generic Solution The algorithm for solving the ‘‘Missing Facet’’ problem
The main problem of repairing the invalid tessellated model is Detect and identify the boundaries of all the gaps in the
that of matching the solution to the designer's intent when model.
the intent may have been lost in the overall process. Without Suitable facets would then be generated to repair and "patch
the knowledge of the designer's intent, it would indeed be up" the gaps.
difficult to determine what the "right" solution should be. The size of the generated facets would be restricted by the
Hence, an "educated" guess is usually made when faced with gap's boundaries while the orientation of its normal would be
the ambiguities of the invalid model. controlled by comparing it with the rest of the shell. This is to
The algorithm aims to match, if not exceed, the quality of ensure that the generated facet orientation is correct and
repair done manually by a skilled technician when consistent throughout the gap closure process.
information of the designer's intent is not available.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 47 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 48

The orientation of the shell's facets can be obtained from the STL
file which lists its vertices in an ordered manner following the Solving the "Missing Facets" Problem
Mobius rule. The following procedure illustrates the detection of gaps in the
Mobius rule: For every facet edge, there must be another facet and tessellated model and its subsequent repair. It is carried out in four
only that facet sharing the same edge. Since the vertices of a facet steps.
are ordered, the direction on one facet’s edge is exactly opposite to Step 1: Checking for Approved Edges with Adjacent Facets
another facet sharing the same edge.
The algorithm exploits this feature so that the repair carried out on
A representation of a portion of a
the invalid model, using suitably created facets, has the correct tessellated surface without any gaps.
orientation.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 49 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 50

The checking routine is executed as follows for facet A as seen in figure: Step 2: Detection of Gaps in the Tessellated Model
1. (i) Read in first edge (vertex 1-2) from the STL file. The detection routine executes as follows:

(ii) Search file for a similar edge in the opposite direction (vertex 2-1). For Facet A

(iii) If edge exists, store this under a temporary file (file B) for approved edges. 1. (i) Read in edge {vertex 2-3} from the STL file.

2.(i) Read in second edge (vertex 2-3) from the STL file. (ii) Search file for a similar edge in the opposite direction { vertex 3-2}.

(ii) Search file for a similar edge in the opposite direction (vertex 3-2}. (iii) If edge does not exist, store edge (vertex 3-2) in another temporary file
(e.g. file C) for suspected gap's bounding edges and store vertex 2-3 in file B1
(iii) If edge exists, store this under a temporary file (file B) for approved edges.
for existing edges without adjacent facets. (this will be used later for checking
3. (i) Read in third (vertex 3-1) from the STL file.
the orientation of the generated facet).
(ii) Search file for a similar edge in the opposite direction (vertex 1-3).
(iii) If edge exists, store this under a temporary file (file B) for approved edges.

This process is repeated for the next facet


until all the facets have been searched.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 51 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 52

Dr. Prashant K. Jain (IIITDMJ) 5


PDPM IIITDM Jabalpur September 9, 2024

For Facet B The following is a simple illustration of what could be stored in


2. (i) Read in edge {vertex 5-2} from the STL file. file C (Table 2) for edges that do not have an adjacent edge:
Table 2. File C containing all the “erroneous” edges that would form
(ii) Search file for a similar edge in the opposite direction (vertex 2-5). the boundary of each gap.

(iii) If it does not exist, store edge (vertex 2-5) in another temporary file C. Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th
3. (i) Repeat for edges: 5-2; 7-5; 9-7; 11-9; 3-11.
1st 3 5 * 11 2 7 * 9 *
(ii) Search for edges: 2-5; 5-7; 7-9; 9-11; 11-3.
2nd 2 7 * 3 5 9 * 11 *
(iii) Store all the edges in temporary file B1 for edges without any adjacent *represent all the other edges that would form the boundaries of
other gaps.
facet and store all the suspected bounding edges of the gap in temporary file C.
Step 3: Sorting of Erroneous
File B1 can appear as in Table 1. Edges into a Closed Loop
Table 2: all the edges are
Table 1. File B1 contains existing edges without adjacent facets.
unordered. Hence, the Table 3. File D containing sorted edges
Edge
edges have been sorted to Edge
Vertex 1st 2nd 3rd 4th 5th 6th
get a closed loop, it would Vertex 1st 2nd 3rd 4th 5th 6th
1st 2 7 3 5 9 11
then be stored in a 1st 3 2 5 7 9 11
2nd 3 5 11 2 7 9
temporary file, say file D. 2nd 2 5 7 9 11 3
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 53 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 54

Step 4: Generation of Facets for the Repair of the Gaps Step 4: Generation of Facets for the Repair of the Gaps
With reference to File D. With reference to File D.
Generating the first facet: Generating the second facet:
the first two vertices (V3 and V2) in the first two edges of file D will be Remaining vertices in file D, the previous second vertex (V2) will become
connected to the first vertex in the last edge (V11) in file D and the facet is the first vertex of file D. The second facet is formed by connecting the first
stored in a temporary file E (Table 5). vertex (V2) of the first edge with that of the last two vertices in file D (V9,
The facet is then checked for its orientation using the information stored in V11) and facet is stored in temporary file E. It is then checked to confirm if
file B1. Once its orientation is determined to be correct, the first vertex (V3) its orientation is correct.
from file D is temporarily removed. If it is correct, the vertex (V11) of the last edge in file D is then temporarily
removed.
Table 4. Process of facet generation.
Table 4. Process of facet generation.
V3 V2 V5 V7 V9 V11 V3 V2 V5 V7 V9 V11
F1 1 2 - - - 3 F1 1 2 - - - 3
F2 E 1 - - 2 3 F2 E 1 - - 2 3
Generation
Generation
of facets F3 E 1 2 - 3 E of facets F3 E 1 2 - 3 E
F4 E E 1 2 3 E F4 E E 1 2 3 E
V = vertex, F = facet, E = eliminated from the process of V = vertex, F = facet, E = eliminated from the process of
facet generation. facet generation.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 55 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 56

Step 4: Generation of Facets for the Repair of the Gaps


With reference to File D.
STL File Repair implementation using MATLAB Programming
Generating the third facet:
The whole process is repeated same as for the generation of facet 1 and 2. 60

The first vertex of the first two edges (V2, V5) is connected to the first
40
vertex of the last edge (V9) and the facet is stored in temporary file E. Once
its orientation is confirmed, the first vertex of the first edge (V2) will be 20

60 60
removed from file D temporarily. 0
50 40
60
50
40 40
30 20
20
30 10
0 0 60
20 60
50
10 40
40
0
20
60 30
50 40 30
20 10 0
20 0
60
10
40
0
60 20
50
40
30
20
10 0
0
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 57 September 9, 2024 Dr. Prashant K. Jain (IIITDM Jabalpur) 58

Dr. Prashant K. Jain (IIITDMJ) 6


PDPM IIITDM Jabalpur September 9, 2024

Generating the fourth facet:


Once the number of vertices in file D is less than 3, the process of facet Facet generation for gaps with even number of edges
generation will be terminated. After the last facet is generated, the data in
file E will be written to file A and its content (file E) will be subsequently Process of facet generation for gaps with even number of
deleted. Table 5 shows how file E may appear. edges
Table 4. Process of facet generation. Vertices
1 Facets
V3 V2 V5 V7 V9 V11 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
F1 1 2 - - - 3 2 10 F1 1 2 3
Generation F2 E 1 - - 2 3 F2 E 1 2 3
9
of facets F3 E 1 2 - 3 E F3 E 1 2 3 E
F4 E E 1 2 3 E
F4 E E 1 2 3 E
V = vertex, F = facet, E = eliminated from the process of facet generation. 8
3 F5 E E 1 2 3 E E
Table 5. Illustration of how data could be stored in file E.
F6 E E E 1 2 3 E E
First edge Second edge Third edge 7 F7 E E E 1 2 3 E E E
Generated First Second First Second First Second 4
F8 E E E E 1 2 3 E E E
facet vertex vertex vertex vertex vertex vertex 6
First V3 V2 V2 V11 V11 V3 First facet generated Second facet generated
Second V2 V9 V9 V11 V11 V2 Edge 1 – V1,V2 Edge 1 – V2,V9
5 Edge 2 – V2,V10 Edge 2 – V9,V10
Third V2 V5 V5 V9 V9 V2
Edge 3 – V10, V1 Edge 3 – V10, V2
Fourth V5 V7 V7 V9 V9 V5
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 59 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 60

Facet generation for gaps with odd number of edges


Process of facet generation
Process of facet generation for gaps with odd number of edges
Vertices F1 – First and second vertices are combined with the last vertex. Once
Facets
1 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 completed, eliminate first vertex. The remainder is ten vertices.
F1 1 2 3
F2 – First vertex is combined with the last two vertices. Once completed,
F2 E 1 2 3
eliminate the last vertex. The remainder is nine vertices.
2 F3 E 1 2 3 E
11 F3 – First and second vertices are combined with the last vertex. Once
3 F4 E E 1 2 3 E
10 completed, eliminate first vertex. The remainder is eight vertices.
F5 E E 1 2 3 E E
F6 E E E 1 2 3 E E F4 – First vertex is combined with last two vertices. Once completed,
9 F7 E E E 1 2 3 E E E eliminate the last vertex. The remainder is seven vertices.
4
F8 E E E E 1 2 3 E E E
8 F9 E E E E 1 2 3 E E E E This process is continued until all the gaps are patched.
5
First facet generated Second facet generated
7 Edge 1 – V1,V2 Edge 1 – V2,V10
6 Edge 2 – V2,V11 Edge 2 – V10,V11
Edge 3 – V11, V1 Edge 3 – V11, V2

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 61 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 62

Solving the "Wrong Orientation of Facets" Illustration showing how file D is manipulated to solve orientation problems
Edge
It can be seen that facet Z (vertices 1, 2, 11) is orientated in a clockwise Vertex First Second third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh
direction and this contradicts the right hand rule adopted by the STL format. First 1 2 3 4 5 6 7 8 9 10 11
Thus, this is not acceptable and needs correction. This can be done by Second 2 3 4 5 6 7 8 9 10 11 1
shifting the last record in file D .
All the edges, including the initial one will be shifted one position to the
right (assuming that the records are stored in the left to right structure).
Once this is done, step 4 of facet generation can be implemented.
Facet Z, is again generated
(vertices 1, 2, 11) and
checked for orientation.
When its orientation is
correct, it is saved and
stored in temporary file E. After the shift:
Illustration showing the result of the shift to correct the facet orientation
If any subsequently
generated facet has an Edge
incorrect orientation, the Vertex First Second third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh
whole process would be First 11 1 2 3 4 5 6 7 8 9 10
restarted. Second 1 2 3 4 5 6 7 8 9 10 11
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 63 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 64

Dr. Prashant K. Jain (IIITDMJ) 7


PDPM IIITDM Jabalpur September 9, 2024

The Need for an Expanded Algorithm Two or more gaps are formed from a Coincidental Vertex

In Previous, the algorithm presented could cater only for gaps The first special case deals with problems where two or more gaps are
(whether simple or complex) that are isolated from one another. formed from a coincidental vertex.
However, should any of the gaps meet at a common vertex, the
algorithm may not be able to work properly. The algorithm is
expanded to include solving some of these special cases:
1. Two or more gaps formed from a coincidental vertex
2. Degenerate facets
3. Overlapping facets File C containing “Erroneous” edges that would
form the boundaries of gaps
Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th
First V3 V5 V4 V1 V6 V2 V1
Second V4 V6 V1 V5 V1 V3 V2

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 66 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 68

Two or more gaps are formed from a Coincidental Vertex Step 1:


To Conduct Normal Search (for the Boundary of Gap 1)
Previous algorithm might mistakenly connect edges: 3-4; 4-1; and 1-5;
instead of 1-2. At the start of the normal search, the first edge of file C, vertices 3 and 4, is
Edge to be included in file D should be 1-2, and not 1-5. saved into a temporary file C1. The second vertex in the first edge (V4) of
Therefore, search of connecting vertices should not be halted at the first file C1, is searched against the first vertex of subsequent edge in file C
time the first vertex of subsequent edges are found. (refer to Table, shaded box). Once it is found to be the same vertex (V4)
The search should continue to check if there are other edges with V1 (e.g., and that there are no other edges sharing the same vertex, the edge (i.e.,
edge 1-2, in the seventh edge).
vertex 4-1) is stored as the second edge in file C1.
Every time, say for example, vertex 1 is found, there should be a count.
When the count is more than two, that would indicate that there is more
than one gap sharing the same vertex; this may be called the coincidental Representation of how file C and C1 would look like File C1:
vertex.
Edge Edge
File C containing “Erroneous” edges that would form the boundaries of gaps Vertex 1st 2nd 3rd 4th 5th 6th 7th Vertex First Second Third
Edge First V3 V5 V4 V1 V6 V2 V1 First V3 V4 ?
Vertex 1st 2nd 3rd 4th 5th 6th 7th Second V4 V6 V1 V5 V1 V3 V2 Second V4 V1 ?
First V3 V5 V4 V1 V6 V2 V1
Second V4 V6 V1 V5 V1 V3 V2

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 69 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 70

Step 2: To Detect More Than One Gap For the first count, reading from file C, all the edges that would form
The second vertex of the second edge (V1) in file C1 is searched for an the first alternative closed loop are sorted. These first alternatives in file
equivalent first vertex of subsequent edges in file C (refer to Table). Once it C2 are then saved. A closed loop is established once the second vertex
is found (V1, first vertex of fourth edge), a count of one is registered. of the last edge (V3) is the same as the first vertex of the first edge (V3).
The search for the same vertex is continued. If there is an additional edge First alternative closed loop that may represent the boundary of the gap
sharing the same vertex 1, (seventh edge), another count is registered, File C2
making a total of two counts. Particular record in which it happens is also Edge
recorded. Vertex First Second Third Fourth Fifth Sixth Seventh

The search is continued until there are no further edges sharing the same First V3 V4 V1 V5 V6 V1 V2
Second V4 V1 V5 V6 V1 V2 V3
vertex.

Representation on how file C and C1 would look like during the normal search
File C: Count 1 Count 2 Representation on how file C would look like during the normal search

Edge File C: Count 1 Count 2


Vertex First Second Third Fourth Fifth Sixth Seventh Vertex 1st 2nd 3rd 4th 5th 6th 7th
First V3 V5 V4 V1 V6 V2 V1 First V3 V5 V4 V1 V6 V2 V1
Second V4 V6 V1 V5 V1 V3 V2 Second V4 V6 V1 V5 V1 V3 V2

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 71 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 72

Dr. Prashant K. Jain (IIITDMJ) 8


PDPM IIITDM Jabalpur September 9, 2024

Step 3: To Compare Which Alternative Has the Least


For the second count, the edges are sorted to form a second alternative
Record to Form the Boundary of the Gap
of a closed loop that will represent the boundary of the gap. These edges
are then saved in another temporary file C3. Once a closed loop is From file C2 (first alternative) and file C3 (second alternative), it can be
established, the search is stopped. seen that the second alternative has the least record to form the boundary
of Gap 1. Hence the second alternative data would be written to file D for
Second alternative closed loop that may represent
the boundary of the gap the next stage of facet generation and the two temporary files C2 and C3
File C3: would be discarded.
Edge Once gap 1 is repaired, gap 2 can be repaired by using the generic solution.
Vertex First Second Third Fourth
First V3 V4 V1 V2
Second V4 V1 V2 V3

Representation on how file C would look like during the normal search

File C: Count 1 Count 2


Vertex 1st 2nd 3rd 4th 5th 6th 7th
First V3 V5 V4 V1 V6 V2 V1 Arrows indicating the direction of loop forming the boundary of gap
Second V4 V6 V1 V5 V1 V3 V2

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 73 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 74

Illustrations on How the Algorithm Works How file C may appear given three gaps sharing the same two vertices
Edge
The algorithm can cater for more than two gaps sharing the same vertex, Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V5 V4 V1 V6 V2 V1 V2 V8 V7
2nd V4 V6 V1 V5 V1 V3 V2 V7 V2 V8

Step 1. Normal Search


Edge
Vertex 1st 2nd 3rd 4th
1st V3 V4 ? ?
2nd V4 V1 ? ?

Step 2. Detection:
For V1, there are 2 counts
For V2, there are 2 counts

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 75 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 76

First Alternative: Count 1 for V1 and Count 1 for V2 Second Alternative: Count 1 for V1 and Count 2 for V2
Thus from file C the first alternative closed loop can be generated and
the file is shown in Table The second alternative of a closed loop can be sorted and is shown in Table

Edge
Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V4 V1 V5 V6 V1 V2 - - -
1st V3 V4 V1 V5 V6 V1 V2 V7 V8 V2
2nd V4 V1 V5 V6 V1 V2 V3 - - -
2nd V4 V1 V5 V6 V1 V2 V7 V8 V2 V3

How file C may appear given three gaps sharing the same two vertices How file C may appear given three gaps sharing the same two vertices

Edge Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V5 V4 V1 V6 V2 V1 V2 V8 V7 1st V3 V5 V4 V1 V6 V2 V1 V2 V8 V7
2nd V4 V6 V1 V5 V1 V3 V2 V7 V2 V8 2nd V4 V6 V1 V5 V1 V3 V2 V7 V2 V8
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 77 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 78

Dr. Prashant K. Jain (IIITDMJ) 9


PDPM IIITDM Jabalpur September 9, 2024

Third Alternative: Count 2 for V1 and Count 1 for V2 Fourth Alternative: Count 2 for V1 and Count 2 for V2
The third alternative of a closed loop can again be sorted and is The fourth alternative of a closed loop can also be sorted and is shown
shown in Table in Table
Edge Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V4 V1 V1 - - - - - - 1st V3 V4 V1 V2 V7 V8 V2 - - -
2nd V4 V1 V2 V3 - - - - - - 2nd V4 V1 V2 V7 V8 V2 V3 - - -

How file C may appear given three gaps sharing the same two vertices How file C may appear given three gaps sharing the same two vertices

Edge Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V5 V4 V1 V6 V2 V1 V2 V8 V7 1st V3 V5 V4 V1 V6 V2 V1 V2 V8 V7
2nd V4 V6 V1 V5 V1 V3 V2 V7 V2 V8 2nd V4 V6 V1 V5 V1 V3 V2 V7 V2 V8
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 79 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 80

Corresponding tables representing the loops:


Edge Step 3: Comparison of the Four Alternatives :
1. Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th As can be seen from the four alternatives, the third alternative, as shown in
1st V3 V4 V1 V5 V6 V1 V2 - - - case 3, is considered the best solution and is the correct solution to fill
2nd V4 V1 V5 V6 V1 V2 V3 - - - gap 1.
Edge This correct solution can be found by comparing which alternative uses the
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th fewest edges to fill gap 1.
2. 1st V3 V4 V1 V5 V6 V1 V2 V7 V8 V2 Once the solution is found, the edges would be saved to file D for the next
2nd V4 V1 V5 V6 V1 V2 V7 V8 V2 V3
stage, which is that of facet generation.
Edge
After gap 1 is filled, gaps 2 and 3 can then be repaired using the basic
generic solution.
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V4 V1 V1 - - - - - - There are 4 cases:
3. Arrows indicating the direction of loop forming the boundary of gap
2nd V4 V1 V2 V3 - - - - - -
Edge
Vertex 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th
1st V3 V4 V1 V2 V7 V8 V2 - - -
4. 2nd V4 V1 V2 V7 V8 V2 V3 - - -
2. 3. 4.
1.
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 81 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 82

Degenerate Facets Degenerate Facets


When dealing with a degenerate facet such as the one shown in Figure, 3. If the two vectors are found to be collinear
vector algebra is applied. The following steps are taken: vectors, the position of vertex e is generated.
1. Edge a-c is converted into vectors: 4. (i) Facet A is split into two facets. The two
(c1 i + c2 j + c3 k) - (a1 i+ a2 j + a3 k) (1) facets are generated using the three vertices
2. (i) Collinear vectors are checked. in facet A.

Let x = ac => x1 i + x2 j + x3 k (2) First facet vertices are: a, b, e

y = ce => y1 i + y2 j + y3 k (3) Second facet vertices are: b, c, e

(ii) Mathematically, the two vectors x and y are said to be collinear if (ii) The orientation is checked.
there exist scalars s and t, which are both non-zero, such that: (iii) New facets are stored in a temporary
sx + ty = 0 (4) file.

But when applied in a computer, it is only necessary to have: 5. Search and delete facet A from original file.

sx + ty ≤ є (5) 6. The two new facets are stored in the original


where є is a definable tolerance. file and data are deleted from the temporary
file.

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 84 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 85

Dr. Prashant K. Jain (IIITDMJ) 10


PDPM IIITDM Jabalpur September 9, 2024

Overlapping Facets
Vertex to vertex rule
The condition of overlapping facets can be caused by errors introduced by
The most common error in an STL file is non compliance with the vertex-to- inconsistent numerical round-off.
vertex rule. The STL specifications require that all adjacent triangles share This problem can be resolved through vertex merging where vertices within
two common vertices. a predetermined numerical round-off tolerance of one another can be
Each vertex of a triangle should be shared by 2 adjacent triangle. merged into one vertex.
It is recommended that this merging of vertices be done before the
searching of the model for gaps. This will eliminate unnecessary
detection of erroneous edges and save substantial computational time in
checking whether the edges can be used to generate another facet.

The figure on the left shows a top triangle containing a total of 4 vertex points. The
outer vertices of the top triangle are not shared with and one other single triangle. The
lower 2 triangles each contain one of the points as well as the fourth invalid vertex
point. To make this valid under the vertex to vertex rule the top triangle must be
subdivided as in the example on the right.
9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 86 9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 87

mergin
g

mergin
g

9-Sep-24 Dr. P. K. Jain IIITDM Jabalpur 88 September 9, 2024 Dr. Prashant K. Jain (IIITDMJ) 90

Dr. Prashant K. Jain (IIITDMJ) 11

You might also like