예제 #1
0
        public bool LoadPayloadFromStream(BinaryReader reader,
                                          bool loadLatestData,
                                          bool loadAllPasses)
        {
            // Read the stream offset where the cell pass stacks start
            int CellStacksOffset = reader.ReadInt32();

            if (HasLatestData && loadLatestData)
            {
                if (reader.ReadBoolean())
                {
                    LatestPasses.Read(reader);
                }
                else
                {
                    LatestPasses = null;
                }
            }

            if (!HasAllPasses && loadAllPasses)
            {
                Log.LogError("LoadPayloadFromStream asked to load all passes but segment does not have all passes store allocated");
            }

            if (HasAllPasses && loadAllPasses)
            {
                reader.BaseStream.Seek(CellStacksOffset, SeekOrigin.Begin);

                PassesData.Read(reader);
            }

            return(true);
        }
예제 #2
0
        public bool SavePayloadToStream(BinaryWriter writer)
        {
            if (!HasAllPasses)
            {
                throw new TRexSubGridIOException("Leaf sub grids being written to persistent store must be fully populated with pass stacks");
            }

            int CellStacksOffset = -1;

            // Write the cell pass information (latest and historic cell pass stacks)
            long CellStacksOffsetOffset = writer.BaseStream.Position;

            writer.Write(CellStacksOffset);

            // Segments may not have any defined latest pass information
            writer.Write(LatestPasses != null);
            LatestPasses?.Write(writer);

            CellStacksOffset = (int)writer.BaseStream.Position;

            PassesData.Write(writer);

            int EndPosition = (int)writer.BaseStream.Position;

            // Write out the offset to the cell pass stacks in the file
            writer.BaseStream.Seek(CellStacksOffsetOffset, SeekOrigin.Begin);
            writer.Write(CellStacksOffset);

            writer.BaseStream.Seek(EndPosition, SeekOrigin.Begin);

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Determines if this segment violates either the maximum number of cell passes within a
        /// segment limit, or the maximum number of cell passes within a single cell within a
        /// segment limit.
        /// If either limit is breached, this segment requires cleaving
        /// </summary>
        public bool RequiresCleaving(out int TotalPasses, out int MaxPassCount)
        {
            const int cleaveSegmentPassCountDeadBand = 100;

            PassesData.CalculateTotalPasses(out TotalPasses, out _, out MaxPassCount);

            return(TotalPasses > _subGridSegmentPassCountLimit + cleaveSegmentPassCountDeadBand ||
                   MaxPassCount > _subGridMaxSegmentCellPassesLimit);
        }
예제 #4
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    LatestPasses?.Dispose();
                    LatestPasses = null;

                    PassesData?.Dispose();
                    PassesData = null;
                }

                disposedValue = true;
            }
        }
예제 #5
0
 public void DeAllocateFullPassStacks()
 {
     PassesData?.Dispose();
     PassesData = null;
 }