예제 #1
0
        public void Read(BinaryReader reader)
        {
            segmentPassCount = reader.ReadInt32();

            var passCountBuffer = GenericArrayPoolCacheHelper <long> .Caches().Rent(SubGridTreeConsts.CellsPerSubGrid);

            try
            {
                var fieldDescriptor = new EncodedBitFieldDescriptor();
                fieldDescriptor.Read(reader);

                using (var bfa = new BitFieldArray())
                {
                    bfa.Read(reader);
                    int bitLocation = 0;
                    bfa.ReadBitFieldVector(ref bitLocation, fieldDescriptor, SubGridTreeConsts.CellsPerSubGrid, passCountBuffer);
                }

                var counter = 0;

                for (var i = 0; i < SubGridTreeConsts.SubGridTreeDimension; i++)
                {
                    for (var j = 0; j < SubGridTreeConsts.SubGridTreeDimension; j++)
                    {
                        var passCount = (int)passCountBuffer[counter++];

                        if (passCount > 0)
                        {
                            AllocatePasses(i, j, passCount);

                            _passData[i, j].Passes.Count = passCount;
                            var passes = _passData[i, j].Passes;
                            for (int cpi = passes.Offset, limit = passes.OffsetPlusCount; cpi < limit; cpi++)
                            {
                                passes.Elements[cpi].Read(reader);
                            }
                        }
                    }
                }
            }
            finally
            {
                GenericArrayPoolCacheHelper <long> .Caches().Return(ref passCountBuffer);
            }
        }