Get the data point from the STL file. These points are saved in form of Matrices. For Example, the Vertex matrix is saved a 3-dimensional matrix, having 3 vertices for each face, and each vertex have three coordinates. So the size of the matrix V will be D1x3x3, where D1 is the number of faces.
In order to simplify mesh, we have used the method where we combine the two vertices of the face if they are less than a threshold value, say t= 1.1 units.
For a particular face Fn, let its three vertices be V1, V2 and V3.
Now from the cloud of vertex points for each face obtained from STL file, in order to assign the vertex numbers viz 1, 2 &3, we have used the ‘mod’ function. When we apply mod function, we get three cases: A. i’ = 0 here we assign:
V(i) th vertex as V1
V(i-2)th vertex to V2
V(i-1)th vertex to V3
B. i’ = 1 here we assign:
V(i) th vertex as V1
V(i+1)th vertex to V2
V(i+2)th vertex to V3
C. i’ =2 here we assign:
V(i-1) th vertex as V1
V(i)th vertex to V2
V(i+1)th vertex to V3
Remember: V1, V2 & V3 are vectors.
Now after we have assigned the vertices, we compare; If : distance between V1 and V2 is less than t Then: both V1 & V2 get replaced by their midpoints i.e. (V1+V2)/2
Else
If : Distance between V1 and V3 is less than t Then: both V1 and V3 get replaced by their midpoints i.e. (V1+V3)/2
As we get new points we write it in a new STL file with a simplified