public ConstraintResult CanConstrain(PlanningItem pi) { var message = string.Empty; //Check for null plan var valid = pi != null; if (!valid) { return(new ConstraintResult(this, ResultType.NOT_APPLICABLE, "Plan is null")); } //Check structure exists var structures = StructureName.Split('|').Select(n => n.Trim()); foreach (var s in structures) { valid = pi.ContainsStructure(s); if (!valid) { return(new ConstraintResult(this, ResultType.NOT_APPLICABLE_MISSING_STRUCTURE, $"{s} isn't contoured in {pi.Id}")); } } //Check dose is calculated valid = pi.Dose != null; if (!valid) { return(new ConstraintResult(this, ResultType.NOT_APPLICABLE_MISSING_DOSE, $"There is no dose calculated for {pi.Id}")); } return(new ConstraintResult(this, ResultType.PASSED, string.Empty)); }
public static uint ReadCBFWithOffsetUnsigned(int memberIndex, StructureName structureName, byte[] input) { int byteOffset = CaesarStructure.GetCBFOffset(memberIndex, structureName, input); using (BinaryReader reader = new BinaryReader(new MemoryStream(input))) { byte[] layout = CaesarStructure.GetCaesarLayout(structureName); return(CaesarReader.ReadUIntWithSize(reader, layout[memberIndex], byteOffset)); } }
public static int GetCBFOffset(int memberIndex, StructureName structureName, byte[] cbfInput) { // test: // byte[] cbfInput = new byte[] { 0x03, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x63, 0x54, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x50, 0x52, 0x45, 0x50, 0x5F, 0x55, 0x6E, 0x73, 0x69, 0x67, 0x6E, 0x65, 0x64, 0x5F, 0x31, 0x42, 0x79, 0x74, 0x65, 0x00 }; // int member_type = 0x1C; // CaesarStructure.StructureName.PRESENTATION_STRUCTURE // result = 0x13 // essentially checks if a bitflag is active, then returns the byte offset to the member byte[] structureLayout = GetCaesarLayout(structureName); byte bitmask = 1; int arrayOffset = structureLayout[0]; // first structure element is always a static offset, to skip past the bitflags int cbfOffset = 0; for (int i = 1; i < memberIndex; ++i) { bool bitflagIsEnabled = (bitmask & cbfInput[cbfOffset]) > 0; if (bitflagIsEnabled) { if (memberIndex != i) { arrayOffset += structureLayout[i]; } } else if ((memberIndex == i) && !bitflagIsEnabled) { // found the requested member, but the member is marked as absent in the bitflag, so there is no value arrayOffset = 0; } // move on to the next bit, and if our bitflag is fully read, move to the next bitflag if (bitmask == 0x80) { ++cbfOffset; bitmask = 1; } else { bitmask *= 2; } } return(arrayOffset); }
public static void GetOffset(StructureName name, int memberIndex) { FillCaesarTypes(); }
public static byte[] GetCaesarLayout(StructureName name) { FillCaesarTypes(); return(CaesarTypes[(int)name]); }