-
Notifications
You must be signed in to change notification settings - Fork 0
/
DICOM Controller.txt
180 lines (163 loc) · 6.11 KB
/
DICOM Controller.txt
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using UnityEngine;
public class TestController : MonoBehaviour
{
[SerializeField]
private GameObject myVolume;
[SerializeField]
private GameObject mySTL;
[SerializeField]
private GameObject minX;
[SerializeField]
private GameObject minY;
[SerializeField]
private GameObject minZ;
[SerializeField]
private GameObject maxX;
[SerializeField]
private GameObject maxY;
[SerializeField]
private GameObject maxZ;
private GameObject minAxis;
private GameObject maxAxis;
public Texture3D texture;
myAxis axis = new myAxis();
private void Update()
{
if (Input.GetKey(KeyCode.A))
{
LowPosition(false);
}
if (Input.GetKey(KeyCode.D))
{
LowPosition(true);
}
if (Input.GetKey(KeyCode.Q))
{
HighPosition(false);
}
if (Input.GetKey(KeyCode.E))
{
HighPosition(true);
}
}
public void OnClickAxis(string str)
{
switch (str)
{
case "X":
axis = myAxis.X;
break;
case "Y":
axis = myAxis.Y;
break;
case "Z":
axis = myAxis.Z;
break;
default:
break;
}
}
public void LowPosition(bool isPlus)
{
switch (axis)
{
case myAxis.X:
if (isPlus && minX.transform.localPosition.x <= maxX.transform.localPosition.x)
{
minX.transform.localPosition = new Vector3(minX.transform.localPosition.x + 0.1f, minX.transform.localPosition.y, minX.transform.localPosition.z);
}
else if (!isPlus && minX.transform.localPosition.x >= -3f)
{
minX.transform.localPosition = new Vector3(minX.transform.localPosition.x - 0.1f, minX.transform.localPosition.y, minX.transform.localPosition.z);
}
break;
case myAxis.Y:
if (isPlus && minY.transform.localPosition.y <= maxY.transform.localPosition.y)
{
minY.transform.localPosition = new Vector3(minY.transform.localPosition.x, minY.transform.localPosition.y + 0.1f, minY.transform.localPosition.z);
}
else if (!isPlus && minY.transform.localPosition.y >= -3f)
{
minY.transform.localPosition = new Vector3(minY.transform.localPosition.x, minY.transform.localPosition.y - 0.1f, minY.transform.localPosition.z);
}
break;
case myAxis.Z:
if (isPlus && minZ.transform.localPosition.z <= maxZ.transform.localPosition.z)
{
minZ.transform.localPosition = new Vector3(minZ.transform.localPosition.x, minZ.transform.localPosition.y, minZ.transform.localPosition.z + 0.1f);
}
else if (!isPlus && minZ.transform.localPosition.z >= -3f)
{
minZ.transform.localPosition = new Vector3(minZ.transform.localPosition.x, minZ.transform.localPosition.y, minZ.transform.localPosition.z - 0.1f);
}
break;
default:
break;
}
}
public void HighPosition(bool isPlus)
{
switch (axis)
{
case myAxis.X:
if (isPlus && maxX.transform.localPosition.x <= 3)
{
maxX.transform.localPosition = new Vector3(maxX.transform.localPosition.x + 0.1f, maxX.transform.localPosition.y, maxX.transform.localPosition.z);
}
else if (!isPlus && maxX.transform.localPosition.x >= minX.transform.localPosition.x)
{
maxX.transform.localPosition = new Vector3(maxX.transform.localPosition.x - 0.1f, maxX.transform.localPosition.y, maxX.transform.localPosition.z);
}
break;
case myAxis.Y:
if (isPlus && maxY.transform.localPosition.y <= 3)
{
maxY.transform.localPosition = new Vector3(maxY.transform.localPosition.x, maxY.transform.localPosition.y + 0.1f, maxY.transform.localPosition.z);
}
else if (!isPlus && maxY.transform.localPosition.y >= minY.transform.localPosition.y)
{
maxY.transform.localPosition = new Vector3(maxY.transform.localPosition.x, maxY.transform.localPosition.y - 0.1f, maxY.transform.localPosition.z);
}
break;
case myAxis.Z:
if (isPlus && maxZ.transform.localPosition.z <= 3)
{
maxZ.transform.localPosition = new Vector3(maxZ.transform.localPosition.x, maxZ.transform.localPosition.y, maxZ.transform.localPosition.z + 0.1f);
}
else if (!isPlus && maxZ.transform.localPosition.z >= minZ.transform.localPosition.z)
{
maxZ.transform.localPosition = new Vector3(maxZ.transform.localPosition.x, maxZ.transform.localPosition.y, maxZ.transform.localPosition.z - 0.1f);
}
break;
default:
break;
}
}
public void ChangeTexture(Texture3D _texture)
{
Material material = myVolume.GetComponent<MeshRenderer>().material;
texture = _texture;
material.SetTexture("_Volume", texture);
//texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture3D)) as Texture3D;
//texture.UpdateExternalTexture(Application.persistentDataPath + @path);
//texture = (Texture3D)((Application.persistentDataPath + @path) as object);
}
public void OnClickVolumeOnOff()
{
if (myVolume.activeSelf)
myVolume.SetActive(false);
else
myVolume.SetActive(true);
}
public void OnClickSTLOnOff()
{
if (mySTL.activeSelf)
mySTL.SetActive(false);
else
mySTL.SetActive(true);
}
}
public enum myAxis
{
X, Y, Z
}