-
Notifications
You must be signed in to change notification settings - Fork 0
/
printData_3D.py
144 lines (98 loc) · 3.06 KB
/
printData_3D.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from matplotlib import pyplot as plt
from mpl_toolkits import mplot3d
import csv
import numpy as np
import pyvista as pv
filename = "./InputData/collected_data.csv"
#Load features and labels
# initializing the titles and rows list
fields = []
rows = []
# reading csv file
with open(filename, 'r') as csvfile:
# creating a csv reader object
csvreader = csv.reader(csvfile)
# extracting field names through first row
fields = next(csvreader)
# extracting each data row one by one
for row in csvreader:
rows.append(row)
# # get total number of rows
# print("Total no. of rows: %d"%(csvreader.line_num))
X = np.zeros((csvreader.line_num-1,2))
y = np.zeros((csvreader.line_num-1))
i= 0
for row in rows[:]:
X[i][0]=row[6]
X[i][1]=row[7]
y[i]=row[5]
i+=1
#Print Debugg
print(X)
print(X.shape)
print("\n")
print(y)
print(y.shape)
print("\n")
#Add a new column for data input
k=0
Xrow, Xcol = X.shape
new_column = np.zeros((Xrow,1))
for ele in new_column:
new_column[k][0]=y[k]
k+=1
poi = np.append(X,new_column, axis=1)
# X.shape = (54,3)
# M = np.expand_dims(X, axis= )
print("New points", poi)
# arr = np.append(X,new_column, axis=1)
# for ele in X:
# X[k].append(y[k])
# print("X Geändert", X)
# #Display Datapoints
# plt.scatter(X.T[0],y)
# plt.show()
# plt.scatter(X.T[1],y)
# plt.show()
# def f(x, y):
# return np.sin(np.sqrt(x ** 2 + y ** 2))
# x = np.linspace(-6, 6, 30)
# y = np.linspace(-6, 6, 30)
# X1, X2 = np.meshgrid(X[0], X[1])
# X3 = f(X1, X2)
fig = plt.figure()
ax = plt.axes(projection='3d')
# print("X DAten:\n", X1)
# print("Y DAten:\n", X2)
# print("Z DAten:\n", X3)
#CHANGE FONT TYPE
plt.rc('font',family='Linux Biolinum')
#CHANGE FONT SIZES
# plt.rc('font', size=12, weight='bold') #controls default text size
#plt.rc('font', size=12) #controls default text size
plt.rc('axes', titlesize=14.4) #fontsize of the title
plt.rc('axes', labelsize=12) #fontsize of the x and y labels
plt.rc('xtick', labelsize=11) #fontsize of the x tick labels
plt.rc('ytick', labelsize=11) #fontsize of the y tick labels
plt.rc('legend', fontsize=12) #fontsize of the legend
plt.set_loglevel("error") # just shows important error. Ignores warnings.
# ax.plot_wireframe(X.T[0], X.T[1], y, color='black')
# ax.contour3D(X, Y, Z, 50, cmap='binary')
# ax.plot_surface(X1, X2, X3, rstride=1, cstride=1,
# cmap='viridis', edgecolor='none');
# PLOT
ax.scatter(X.T[0], X.T[1], y, c=y, cmap='RdYlGn', linewidth=0.5);
ax.set_xlabel('Laser Power [W]')
ax.set_ylabel('Scan Speed [mm/s]')
ax.set_zlabel('Relative Density [%]');
# ax.set_title('Visualisation Dataset')
plt.savefig("./Visual/VisualisationDataset_LP_SS.eps", format='eps',bbox_inches='tight') # saved as eps for high quality pictures
plt.savefig("./Visual/VisualisationDataset_LP_SS.svg", format='svg',bbox_inches='tight')
# plt.savefig("VisualisationDataset.png", bbox_inches='tight')
plt.show()
#Interpolation of Datapoints
cloud = pv.PolyData(poi)
cloud.plot()
volume = cloud.delaunay_3d(alpha=30.)
shell = volume.extract_geometry()
shell.plot()