public DiDataElement() { _groupId = 0; _elementId = 0; _vl = 0; _vr = 0; _values = null; }
public static void ChangeVRType(VRType vrType) { #if UNITY_EDITOR string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone); List <string> definesList = defines.Split(new char[] { ';' }).ToList <string>(); // go through all the defines and edit the edwon vr specific ones to the new vr type for (int i = definesList.Count - 1; i >= 0; i--) { switch (definesList[i]) { case "EDWON_VR_OCULUS": { if (vrType == VRType.SteamVR) { definesList[i] = "EDWON_VR_STEAM"; } } break; case "EDWON_VR_STEAM": { if (vrType == VRType.OculusVR) { definesList[i] = "EDWON_VR_OCULUS"; } } break; } } switch (vrType) { case VRType.SteamVR: { if (!definesList.Contains("EDWON_VR_STEAM")) { definesList.Add("EDWON_VR_STEAM"); } } break; case VRType.OculusVR: { if (!definesList.Contains("EDWON_VR_OCULUS")) { definesList.Add("EDWON_VR_OCULUS"); } } break; } defines = String.Join(";", definesList.ToArray()); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, defines); #endif }
bool ToggleByVRType(CanvasGroup parentCG, bool enabled, VRType vrType) { CanvasGroup[] cgs = parentCG.GetComponentsInChildren <CanvasGroup>(); foreach (CanvasGroup cg in cgs) { if (cg.gameObject.name == vrType.ToString()) { Utils.ToggleCanvasGroup(cg, enabled); ToggleChildMovies(cg.transform, enabled); return(true); } } return(false); }
/// <summary> /// Reads the next DiDataElement from a (dicom) input stream. /// </summary> /// <param name="inputStream">is a DiInputStream - must be open and readable</param> public void ReadNext(DiFileStream inputStream) { bool exp; int vrFormat; uint b0 = (uint)inputStream.ReadByte(); uint b1 = (uint)inputStream.ReadByte(); _groupId = (b1 << 8) | b0; // --- meta group part start ---------------------------- if (inputStream.BeforeMetaGroup && _groupId == 0x0002) { // we just entered the meta group inputStream.BeforeMetaGroup = false; inputStream.MetaGroup = true; } if (inputStream.MetaGroup && _groupId != 0x0002) { // we just left the meta group inputStream.MetaGroup = false; } if (inputStream.BeforeMetaGroup || inputStream.MetaGroup) { // are we still before or inside meta group? vrFormat = DiFile.VrExplicit; Endianess = DiFile.EndianLittle; } else { vrFormat = inputStream.VrFormat; Endianess = inputStream.Endianess; } if (Endianess == DiFile.EndianBig) { _groupId = (b0 << 8) | b1; } // --- meta group part end ------------------------------ _elementId = inputStream.ReadUShort(Endianess); b0 = (uint)inputStream.ReadByte(); b1 = (uint)inputStream.ReadByte(); _vr = (VRType)((b0 << 8) | b1); // check if we are explicit or implicit: // b0 and b1 could a) be an explicit VR or b) be the first part of the VL exp = (vrFormat == DiFile.VrExplicit) || (vrFormat == DiFile.VrUnknown && (_vr == VRType.AE || _vr == VRType.AS || _vr == VRType.AT || _vr == VRType.CS || _vr == VRType.DA || _vr == VRType.DS || _vr == VRType.DT || _vr == VRType.FD || _vr == VRType.FL || _vr == VRType.IS || _vr == VRType.LO || _vr == VRType.LT || _vr == VRType.PN || _vr == VRType.SH || _vr == VRType.SL || _vr == VRType.SS || _vr == VRType.ST || _vr == VRType.TM || _vr == VRType.UI || _vr == VRType.UL || _vr == VRType.US || _vr == VRType.UT || _vr == VRType.OB || _vr == VRType.OW || _vr == VRType.SQ || _vr == VRType.UN || _vr == VRType.QQ)); // There are three special SQ related Data Elements that are not ruled by the VR encoding rules // conveyed by the Transfer Syntax. They shall be encoded as Implicit VR. These special Data Elements are // Item (FFFE,E000), Item Delimitation Item (FFFE,E00D), and Sequence Delimitation Item (FFFE,E0DD). // However, the Data Set within the Value Field of the Data Element Item (FFFE,E000) shall be encoded // according to the rules conveyed by the Transfer Syntax. if (_groupId == 0xfffe && (_elementId == 0xe000 || _elementId == 0xe00d || _elementId == 0xe0dd)) { exp = false; } if (exp) { // explicit VR -> get the VR first // VL can have 2 or 4 byte ... if (_vr == VRType.OB || _vr == VRType.OW || _vr == VRType.SQ || _vr == VRType.UT || _vr == VRType.UN) { inputStream.ReadByte(); // skip 2 bytes ... inputStream.ReadByte(); _vl = inputStream.ReadInt(Endianess); } else { _vl = inputStream.ReadShort(Endianess); } } else { // implicit VR -> lookup VR in the DicomDictionary _vr = _diDictionary.getVR(GetTag()); uint b2 = (uint)inputStream.ReadByte(), b3 = (uint)inputStream.ReadByte(); if (Endianess == DiFile.EndianLittle) { _vl = (int)((b3 << 24) + (b2 << 16) + (b1 << 8) + b0); } else { _vl = (int)((b0 << 24) + (b1 << 16) + (b2 << 8) + b3); } } if (_vl == -1) { _vl = 0; // _vl can be -1 if VR == SQ } _values = new byte[_vl]; inputStream.Read(_values, 0, _values.Length); if (Endianess == DiFile.EndianBig) { // VR's affected by endianess: // 2-byte US, SS, OW and each component of AT // 4-byte UL, SL, and FL // 8 byte FD if (_vr == VRType.US || _vr == VRType.SS || _vr == VRType.OW || _vr == VRType.UL || _vr == VRType.SL || _vr == VRType.FL || _vr == VRType.FD) { for (var i = 0; i < _values.Length / 2; i++) { var tmp = _values[i]; _values[i] = _values[_values.Length - 1 - i]; _values[_values.Length - 1 - i] = tmp; } } } if (DiDictonary.ToTag(_groupId, _elementId) == 0x00020010) { // check endianess and VR format var tsUid = GetValueAsString(); inputStream.VrFormat = DiDictonary.get_ts_uid_vr_format(tsUid); inputStream.Endianess = DiDictonary.get_ts_uid_endianess(tsUid); if (inputStream.VrFormat == DiFile.EndianUnknown) { Debug.Log("DiDataElement Unknown Transfer Syntax UID \"" + tsUid + "\". Endianess & VR format will be guessed."); } } try { _rawInt = GetValueAsInt(); } catch (Exception) { //nothing to worry about, some elements aren't supposed to be used with Int } try { if (_groupId == 0x0028 && (_elementId == 0x1050 || _elementId == 0x1051)) { var numbers = GetValueAsString().Split('\\'); _rawDoubles = new double[numbers.Length]; for (var index = 0; index < numbers.Length; index++) { _rawDoubles[index] = double.Parse(numbers[index]); } } else { _rawDoubles[0] = GetValueAsDouble(); } } catch (Exception) { //nothing to worry about, some elements aren't supposed to be used with Double } }