Exemplo n.º 1
0
 /// <summary>
 /// Given stream and traceCount, reads the requested number
 /// of traces into memory. The given traceCount may exceed
 /// the number of traces in the file;
 /// in that case all the traces in the file are read.
 /// Assumes the stream is at the start of the file.
 /// </summary>
 public virtual ISegyFile Read(Stream stream, int traceCount, IReadingProgress progress = null)
 {
     using (var reader = new BinaryReader(stream))
     {
         var fileHeader = ReadFileHeader(reader);
         var traces     = new List <ITrace>();
         for (int i = 0; i < traceCount; i++)
         {
             if (progress != null)
             {
                 // TODO: Check if stream.Length breaks when streaming from web
                 int percentage = (int)(100 * stream.Position / stream.Length);
                 progress.ReportProgress(percentage);
                 if (progress.CancellationPending)
                 {
                     break;
                 }
             }
             var trace = ReadTrace(reader, fileHeader.SampleFormat, fileHeader.IsLittleEndian);
             if (trace == null)
             {
                 break;
             }
             traces.Add(trace);
         }
         return(new SegyFile {
             Header = fileHeader, Traces = traces
         });
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Given stream and traceCount, reads the requested number
 /// of traces into memory. The given traceCount may exceed
 /// the number of traces in the file; 
 /// in that case all the traces in the file are read.
 /// Assumes the stream is at the start of the file.
 /// </summary>
 public virtual ISegyFile Read(Stream stream, int traceCount, IReadingProgress progress = null)
 {
     using (var reader = new BinaryReader(stream))
     {
         var fileHeader = ReadFileHeader(reader);
         var traces = new List<ITrace>();
         for (int i = 0; i < traceCount; i++)
         {
             if (progress != null)
             {
                 // TODO: Check if stream.Length breaks when streaming from web
                 int percentage = (int)(100 * stream.Position / stream.Length);
                 progress.ReportProgress(percentage);
                 if (progress.CancellationPending)
                     break;
             }
             var trace = ReadTrace(reader, fileHeader.SampleFormat, fileHeader.IsLittleEndian);
             if (trace == null)
                 break;
             traces.Add(trace);
         }
         return new SegyFile { Header = fileHeader, Traces = traces };
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Given stream, reads entire SEGY file into memory.
 /// Assumes the stream is at the start of the file.
 /// </summary>
 public virtual ISegyFile Read(Stream stream, IReadingProgress progress = null)
 {
     return(Read(stream, int.MaxValue, progress));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Given a file path, reads entire SEGY file into memory
 /// </summary>
 public virtual ISegyFile Read(string path, IReadingProgress progress = null)
 {
     using (var stream = File.OpenRead(path))
         return(Read(stream, progress));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Given stream, reads entire SEGY file into memory.
 /// Assumes the stream is at the start of the file.
 /// </summary>
 public virtual ISegyFile Read(Stream stream, IReadingProgress progress = null)
 {
     return Read(stream, int.MaxValue, progress);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Given a file path, reads entire SEGY file into memory
 /// </summary>
 public virtual ISegyFile Read(string path, IReadingProgress progress = null)
 {
     using (var stream = File.OpenRead(path))
         return Read(stream, progress);
 }