Skip to content

Commit

Permalink
Cleaned up issue with 2 issues with switch statement on the absorptio…
Browse files Browse the repository at this point in the history
…n weighting type: 1) added Analog option so switch encompasses all enum types, and 2) removal of the empty case clause.
  • Loading branch information
hayakawa16 committed May 2, 2024
1 parent 906b80b commit 042d944
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/Vts/MonteCarlo/Detectors/dMCdROfRhodMuaDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,15 @@ public void Initialize(ITissue tissue, Random rng)
/// <param name="awt">absorption weighting type</param>
protected void SetAbsorbAction(AbsorptionWeightingType awt)
{
// AbsorptionWeightingType.Analog cannot have derivatives so not a case
switch (awt)
// AbsorptionWeightingType.Analog cannot have derivatives so exception
_absorbAction = awt switch
{
// note: pMC is not applied to analog processing, only DAW and CAW
case AbsorptionWeightingType.Continuous:
case AbsorptionWeightingType.Discrete:
default:
_absorbAction = AbsorbContinuousOrDiscrete;
break;
}
AbsorptionWeightingType.Continuous => AbsorbContinuousOrDiscrete,
AbsorptionWeightingType.Discrete => AbsorbContinuousOrDiscrete,
AbsorptionWeightingType.Analog => throw new ArgumentException(@"Analog is not allowed with this detector", nameof(awt)),
_ => throw new ArgumentOutOfRangeException(typeof(AbsorptionWeightingType).ToString())
};
}

/// <summary>
Expand Down
15 changes: 7 additions & 8 deletions src/Vts/MonteCarlo/Detectors/dMCdROfRhodMusDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,15 @@ public void Initialize(ITissue tissue, Random rng)
/// <param name="awt">absorption weighting type</param>
protected void SetAbsorbAction(AbsorptionWeightingType awt)
{
// AbsorptionWeightingType.Analog cannot have derivatives so not a case
switch (awt)
// AbsorptionWeightingType.Analog cannot have derivatives so exception
_absorbAction = awt switch
{
// note: pMC is not applied to analog processing, only DAW and CAW
case AbsorptionWeightingType.Continuous:
case AbsorptionWeightingType.Discrete:
default:
_absorbAction = AbsorbContinuousOrDiscrete;
break;
}
AbsorptionWeightingType.Continuous => AbsorbContinuousOrDiscrete,
AbsorptionWeightingType.Discrete => AbsorbContinuousOrDiscrete,
AbsorptionWeightingType.Analog => throw new ArgumentException(@"Analog is not allowed with this detector", nameof(awt)),
_ => throw new ArgumentOutOfRangeException(typeof(AbsorptionWeightingType).ToString())
};
}

/// <summary>
Expand Down

0 comments on commit 042d944

Please sign in to comment.