本文整理汇总了C#中IByteSource.PopMilestone方法的典型用法代码示例。如果您正苦于以下问题:C# IByteSource.PopMilestone方法的具体用法?C# IByteSource.PopMilestone怎么用?C# IByteSource.PopMilestone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IByteSource
的用法示例。
在下文中一共展示了IByteSource.PopMilestone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseItemSequence
private void ParseItemSequence(IByteSource source, object state) {
try {
_result = DicomReaderResult.Processing;
while (!source.IsEOF && !source.HasReachedMilestone()) {
if (_state == ParseState.Tag) {
source.Mark();
if (!source.Require(8, ParseItemSequence, state)) {
_result = DicomReaderResult.Suspended;
return;
}
ushort group = source.GetUInt16();
ushort element = source.GetUInt16();
_tag = new DicomTag(group, element);
if (_tag != DicomTag.Item && _tag != DicomTag.SequenceDelimitationItem) {
// assume invalid sequence
source.Rewind();
if (!_implicit)
source.PopMilestone();
_observer.OnEndSequence();
if (_badPrivateSequence) {
_explicit = !_explicit;
_badPrivateSequence = false;
}
return;
}
_length = source.GetUInt32();
if (_tag == DicomTag.SequenceDelimitationItem) {
// end of sequence
_observer.OnEndSequence();
if (_badPrivateSequence) {
_explicit = !_explicit;
_badPrivateSequence = false;
}
ResetState();
return;
}
_state = ParseState.Value;
}
if (_state == ParseState.Value) {
if (_length != UndefinedLength) {
if (!source.Require(_length, ParseItemSequence, state)) {
_result = DicomReaderResult.Suspended;
return;
}
source.PushMilestone(_length);
}
_observer.OnBeginSequenceItem(source, _length);
ResetState();
ParseDataset(source, state);
ResetState();
_observer.OnEndSequenceItem();
continue;
}
}
// end of explicit length sequence
if (source.HasReachedMilestone())
source.PopMilestone();
_observer.OnEndSequence();
if (_badPrivateSequence) {
_explicit = !_explicit;
_badPrivateSequence = false;
}
} catch (Exception e) {
_exception = e;
_result = DicomReaderResult.Error;
} finally {
if (_result != DicomReaderResult.Processing && _result != DicomReaderResult.Suspended) {
_async.Set();
}
}
}
示例2: ParseDataset
//.........这里部分代码省略.........
_vr = DicomVR.SQ;
}
_state = ParseState.Value;
}
if (_state == ParseState.Value) {
// check dictionary for VR after reading length to handle 16-bit lengths
// check before reading value to handle SQ elements
if (_vr == DicomVR.UN && IsExplicitVR) {
var entry = Dictionary[_tag];
if (entry != null)
_vr = entry.ValueRepresentations.FirstOrDefault();
if (_vr == null)
_vr = DicomVR.UN;
}
if (_tag == DicomTag.ItemDelimitationItem) {
// end of sequence item
return;
}
while (_vr == DicomVR.SQ && _tag.IsPrivate) {
if (!IsPrivateSequence(source)) {
_vr = DicomVR.UN;
break;
}
if (IsPrivateSequenceBad(source)) {
_badPrivateSequence = true;
_explicit = !_explicit;
}
break;
}
if (_vr == DicomVR.SQ) {
// start of sequence
_observer.OnBeginSequence(source, _tag, _length);
_state = ParseState.Tag;
if (_length != UndefinedLength) {
_implicit = false;
source.PushMilestone(_length);
} else
_implicit = true;
PushState(state);
ParseItemSequence(source, null);
continue;
}
if (_length == UndefinedLength) {
_observer.OnBeginFragmentSequence(source, _tag, _vr);
_state = ParseState.Tag;
PushState(state);
ParseFragmentSequence(source, null);
continue;
}
if (!source.Require(_length, ParseDataset, state)) {
_result = DicomReaderResult.Suspended;
return;
}
IByteBuffer buffer = source.GetBuffer(_length);
if (!_vr.IsString)
buffer = EndianByteBuffer.Create(buffer, source.Endian, _vr.UnitSize);
_observer.OnElement(source, _tag, _vr, buffer);
// parse private creator value and add to lookup table
if (_tag.IsPrivate && _tag.Element != 0x0000 && _tag.Element <= 0x00ff) {
var creator = DicomEncoding.Default.GetString(buffer.Data, 0, buffer.Data.Length).TrimEnd((char)DicomVR.LO.PaddingValue);
var card = (uint)(_tag.Group << 16) + (uint)(_tag.Element);
_private[card] = creator;
}
ResetState();
}
}
if (source.HasReachedMilestone()) {
// end of explicit length sequence item
source.PopMilestone();
return;
}
if (_result != DicomReaderResult.Processing)
return;
// end of processing
_result = DicomReaderResult.Success;
} catch (Exception e) {
_exception = e;
_result = DicomReaderResult.Error;
} finally {
if (_result != DicomReaderResult.Processing && _result != DicomReaderResult.Suspended) {
_async.Set();
}
}
}
示例3: ParseItemSequencePostProcess
private void ParseItemSequencePostProcess(IByteSource source)
{
// end of explicit length sequence
if (source.HasReachedMilestone())
{
source.PopMilestone();
}
this.observer.OnEndSequence();
if (this.badPrivateSequence)
{
this.isExplicitVR = !this.isExplicitVR;
this.badPrivateSequence = false;
}
}
示例4: ParseItemSequenceTag
private bool ParseItemSequenceTag(IByteSource source)
{
if (this.parseStage == ParseStage.Tag)
{
source.Mark();
if (!source.Require(8))
{
this.result = DicomReaderResult.Suspended;
return false;
}
var group = source.GetUInt16();
var element = source.GetUInt16();
this._tag = new DicomTag(@group, element);
if (this._tag != DicomTag.Item && this._tag != DicomTag.SequenceDelimitationItem)
{
// assume invalid sequence
source.Rewind();
if (!this._implicit)
{
source.PopMilestone();
}
this.observer.OnEndSequence();
if (this.badPrivateSequence)
{
this.isExplicitVR = !this.isExplicitVR;
this.badPrivateSequence = false;
}
return false;
}
this.length = source.GetUInt32();
if (this._tag == DicomTag.SequenceDelimitationItem)
{
// #64, in case explicit length has been specified despite occurrence of Sequence Delimitation Item
if (source.HasReachedMilestone() && source.MilestonesCount > this.sequenceDepth)
{
this.ResetState();
return true;
}
// end of sequence
this.observer.OnEndSequence();
if (this.badPrivateSequence)
{
this.isExplicitVR = !this.isExplicitVR;
this.badPrivateSequence = false;
}
this.ResetState();
return false;
}
this.parseStage = ParseStage.Value;
}
return true;
}
示例5: ParseDatasetAsync
private async Task ParseDatasetAsync(IByteSource source)
{
this.result = DicomReaderResult.Processing;
while (!source.IsEOF && !source.HasReachedMilestone() && this.result == DicomReaderResult.Processing)
{
if (!this.ParseTag(source)) return;
if (!this.ParseVR(source)) return;
if (!this.ParseLength(source)) return;
if (!await this.ParseValueAsync(source).ConfigureAwait(false)) return;
}
if (source.HasReachedMilestone())
{
// end of explicit length sequence item
source.PopMilestone();
return;
}
if (this.result != DicomReaderResult.Processing) return;
// end of processing
this.result = DicomReaderResult.Success;
}
示例6: ParseDataset
private void ParseDataset(IByteSource source)
{
this.result = DicomReaderResult.Processing;
while (!source.IsEOF && !source.HasReachedMilestone() && this.result == DicomReaderResult.Processing)
{
if (!this.ParseTag(source)) return;
if (!this.ParseVR(source)) return;
if (!this.ParseLength(source)) return;
if (!this.ParseValue(source)) return;
}
if (source.HasReachedMilestone())
{
// end of explicit length sequence item
source.PopMilestone();
return;
}
if (this.result != DicomReaderResult.Processing) return;
// end of processing
this.result = DicomReaderResult.Success;
}
示例7: ParseDataset
private void ParseDataset(IByteSource source)
{
if (this.isDeflated)
{
#if NET35
throw new NotSupportedException("Deflated datasets not supported in Unity.");
#else
source = this.Decompress(source);
#endif
}
this.result = DicomReaderResult.Processing;
while (!source.IsEOF && !source.HasReachedMilestone() && this.result == DicomReaderResult.Processing)
{
if (!this.ParseTag(source)) return;
if (!this.ParseVR(source)) return;
if (!this.ParseLength(source)) return;
if (!this.ParseValue(source)) return;
}
if (source.HasReachedMilestone())
{
// end of explicit length sequence item
source.PopMilestone();
return;
}
if (this.result != DicomReaderResult.Processing) return;
// end of processing
this.result = DicomReaderResult.Success;
}