Пример #1
0
        //-----------------------------------------------------------------------------

        private void Initialize(String prmFile, TcTileBlockInfoCollection prmInfo)
        {
            OutputFile         = prmFile;
            Info               = prmInfo;
            GridCount          = (Int32)Math.Ceiling(TileSize * 1.0 / GridSize);
            MinZ               = Double.MaxValue;
            MaxZ               = Double.MinValue;
            MaxRowsInGridBlock = (Int32)Math.Floor(TcConstants.MaxBytesToLoadInTorBlock * 1.0 / (Info.TileInfo.Col * GridCount * sizeof(Single)));
            NumberOfGridBlocks = (Int32)Math.Ceiling(Info.TileInfo.Row * GridCount * 1.0 / MaxRowsInGridBlock);
            TorBlocks          = new List <TcTorBlock32>();

            Int32 rowsProcessed = 0;

            for (int gc = 0; gc < NumberOfGridBlocks; gc++)
            {
                Int32        rowsInGrid = Math.Min(MaxRowsInGridBlock, Info.TileInfo.Row * GridCount - rowsProcessed);
                TcTorBlock32 block      = new TcTorBlock32(gc, rowsInGrid, prmInfo.TileInfo.Col * GridCount);
                for (int r = 0; r < rowsInGrid; r++)
                {
                    for (int c = 0; c < prmInfo.TileInfo.Col * GridCount; c++)
                    {
                        block.Points[r, c] = TcConstants.TorNullValue32Bit;
                    }
                }
                TorBlocks.Add(block);
            }
        }
Пример #2
0
        //------------------------------------------------------------------

        private List <TcTorBlock32> GetTorBlocks(TcTolObject prmTol)
        {
            Int32 pointSize           = sizeof(Single);
            Int32 rowsInBlock         = (Int32)Math.Floor(TcConstants.MaxBytesToLoadInTorBlock * 1.0 / (prmTol.Columns * pointSize));
            Int64 noOfPointsAvailable = (Int64)((m_Reader.BaseStream.Length - m_Reader.BaseStream.Position) / pointSize);

            // Create a las point array of required size.
            List <TcTorBlock32> returnBlocks = new List <TcTorBlock32>();

            // Memory stream.
            Byte[] readBuffer;

            Int32 index         = 0;
            Int32 rowsProcessed = 0;

            while (rowsProcessed < prmTol.Rows)
            {
                Int32 rowsToProcess = Math.Min(rowsInBlock, prmTol.Rows - rowsProcessed);
                Int32 bytesToRead   = pointSize * rowsToProcess * prmTol.Columns;

                // Reads the points in a byte array.
                readBuffer = m_Reader.ReadBytes(bytesToRead);

                TcTorBlock32 block = new TcTorBlock32(index++, rowsToProcess, prmTol.Columns)
                {
                    Points = new Single[rowsToProcess, prmTol.Columns]
                };

                // Set a handle to the las point array.
                GCHandle pinnedHandle = GCHandle.Alloc(block.Points, GCHandleType.Pinned);

                // Copy the stream to the structures.
                Marshal.Copy(readBuffer, 0, pinnedHandle.AddrOfPinnedObject(), bytesToRead);

                returnBlocks.Add(block);
                rowsProcessed += rowsToProcess;
            }

            return(returnBlocks);
        }
Пример #3
0
        //------------------------------------------------------------------

        protected void Write(BinaryWriter prmWriter, TcTorBlock32 prmBlock)
        {
            Write(prmWriter, prmBlock.Points);
        }