2 using System.Collections;
3 using System.Collections.Generic;
10 private static string currentPath =
"";
11 private static List<PatientMeta> mPatientEntries =
new List<PatientMeta>();
12 private static bool currentlyLoading =
false;
16 private static bool loadingLock =
false;
21 PatientEventSystem.startListening(PatientEventSystem.Event.PATIENT_Loaded, loadPatientFinish);
26 PatientEventSystem.stopListening(PatientEventSystem.Event.PATIENT_Loaded, loadPatientFinish);
30 public static void setPath(
string newPath)
34 if (!Directory.Exists(newPath))
35 throw (
new System.Exception(
"Invalid path given: " + newPath));
38 if (!currentlyLoading) {
39 currentlyLoading =
true;
42 mPatientEntries.Clear ();
44 currentPath = newPath;
46 Debug.Log (
"Looking for Patients in:\n" + currentPath);
48 string[] folders = Directory.GetDirectories (currentPath);
50 foreach (
string folder
in folders) {
52 PatientMeta newPatient = PatientMeta.createFromFolder (folder);
53 if (newPatient != null) {
54 mPatientEntries.Add (newPatient);
57 PatientEventSystem.triggerEvent (
58 PatientEventSystem.Event.PATIENT_NewPatientDirectoryFound
64 currentlyLoading =
false;
68 public static int getCount()
70 return mPatientEntries.Count;
75 if (index >= 0 && index < mPatientEntries.Count)
76 return mPatientEntries[index];
78 throw (
new System.Exception(
"Could not find entry with index " + index.ToString()));
81 public static void loadPatient(
int index )
85 Debug.LogWarning(
"[PatientDirectoryLoader.cs] Loading aborted. Still loading other patient");
90 if (index >= 0 && index < mPatientEntries.Count)
92 entry = mPatientEntries[index];
94 PatientEventSystem.triggerEvent (PatientEventSystem.Event.PATIENT_StartLoading, entry);
100 throw (
new System.Exception(
"Could not find patient with index " + index.ToString()));
107 private static void loadPatientFinish(
object obj = null)
113 DICOMLoader.instance.setDirectory (entry.dicomPath);
116 MeshLoader mModelLoader = GameObject.Find(
"GlobalScript").GetComponent<MeshLoader>();
117 mModelLoader.LoadFile(entry.meshPath);
static void setPath(string newPath)