-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
41 lines (33 loc) · 1.22 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import re
f = open("ring.stl", "r").read()
tristr = "\\triangle\\left("
cnt = 0
x = []
y = []
z = []
for i in f.splitlines():
if i.strip().__contains__("vertex"):
if cnt == 0:
x = i.replace("vertex ", "").strip().split(" ")
for v in range(0, len(x)):
if x[v].__contains__("e"):
x[v]=x[v].split("e")[0] + "*10^{" + str(int(x[v].split("e")[1]))+"}"
if cnt == 1:
y = i.replace("vertex ", "").strip().split(" ")
for v in range(0, len(y)):
if y[v].__contains__("e"):
y[v]=y[v].split("e")[0] + "*10^{" + str(int(y[v].split("e")[1]))+"}"
if cnt == 2:
z = i.replace("vertex ", "").strip().split(" ")
for v in range(0, len(z)):
if z[v].__contains__("e"):
z[v]=z[v].split("e")[0] + "*10^{" + str(int(z[v].split("e")[1]))+"}"
cnt+=1
if cnt >= 3:
tristr+="("+str(x)+"), ("+str(y)+"), ("+str(z)+")\\right)\n\\triangle\\left("
cnt = 0
tristr=tristr.replace("[", "").replace("]", "").replace("'", "")
tristr=tristr[:len(tristr)-15]
print(tristr)
nf = open("output.txt", "w")
nf.write(tristr)