// split block if it has columns with different sizes List<Block> SplitOnColumnLength() { List<Block> _lResult = new List<Block>(); if (this.m_lColumns.Count == 0) { return _lResult; } _lResult.Add(this); int _iN1 = this.m_lColumns[0].GetPointCount(); for (int _iI = 1; _iI < this.m_lColumns.Count; /*nothing*/) { int _iN = this.m_lColumns[_iI].GetPointCount(); // If two neighboring columns have the same size we can continue because the can stay in the same block. if (_iN == _iN1) _iI++; else { int _iNewBlockID = -1; for (int _iJ = 1; _iJ < _lResult.Count; _iJ++) { if (_lResult[_iJ].GetPointCount() == _iN) { _iNewBlockID = _iJ; break; } } if (_iNewBlockID == -1) { _iNewBlockID = _lResult.Count; Block _blckNewBlock = new Block(); _blckNewBlock.MetaData = this.MetaData; _blckNewBlock.Name = this.Name + "_" + _iN.ToString(); _lResult.Add(_blckNewBlock); } _lResult[_iNewBlockID].AddColumn(this.m_lColumns[_iI], string.Empty, true); this.m_lColumns.Remove(this.m_lColumns[0 + _iI]); } } return _lResult; }
public override void LoadData(System.IO.FileStream __fsFileStream) { System.IO.BinaryReader _brdrReader = new System.IO.BinaryReader(__fsFileStream); // only read necessary params from file header __fsFileStream.Seek(42, System.IO.SeekOrigin.Begin); int _iXDimension = (int)_brdrReader.ReadInt16(); __fsFileStream.Seek(108, System.IO.SeekOrigin.Begin); DataType _dtDataType = (DataType)_brdrReader.ReadInt16(); __fsFileStream.Seek(656, System.IO.SeekOrigin.Begin); int _iYDimension = (int)_brdrReader.ReadInt16(); __fsFileStream.Seek(1446, System.IO.SeekOrigin.Begin); UInt32 numframes = (UInt32)_brdrReader.ReadInt32(); // Start reading the XCalibStruct. SpeCalib XCalib = new SpeCalib(0, 0); __fsFileStream.Seek(3000, System.IO.SeekOrigin.Begin); XCalib.Offset = (double)_brdrReader.ReadDouble(); __fsFileStream.Seek(3008, System.IO.SeekOrigin.Begin); XCalib.Factor = (double)_brdrReader.ReadDouble(); __fsFileStream.Seek(3016, System.IO.SeekOrigin.Begin); XCalib.current_unit = (char)_brdrReader.ReadChar(); __fsFileStream.Seek(3098, System.IO.SeekOrigin.Begin); XCalib.CalibValid = (char)_brdrReader.ReadChar(); __fsFileStream.Seek(3101, System.IO.SeekOrigin.Begin); XCalib.PolynomOrder = (char)_brdrReader.ReadChar(); __fsFileStream.Seek(3263, System.IO.SeekOrigin.Begin); XCalib.PolynomCoeff[0] = _brdrReader.ReadDouble(); XCalib.PolynomCoeff[1] = _brdrReader.ReadDouble(); XCalib.PolynomCoeff[2] = _brdrReader.ReadDouble(); XCalib.PolynomCoeff[3] = _brdrReader.ReadDouble(); XCalib.PolynomCoeff[4] = _brdrReader.ReadDouble(); XCalib.PolynomCoeff[5] = _brdrReader.ReadDouble(); __fsFileStream.Seek(3311, System.IO.SeekOrigin.Begin); XCalib.LaserPosition = (double)_brdrReader.ReadDouble(); // Start reading the YCalibStruct. SpeCalib YCalib = new SpeCalib(0, 0); __fsFileStream.Seek(3489, System.IO.SeekOrigin.Begin); // move ptr to x_calib start YCalib.Offset = (double)_brdrReader.ReadDouble(); __fsFileStream.Seek(3497, System.IO.SeekOrigin.Begin); YCalib.Factor = (double)_brdrReader.ReadDouble(); __fsFileStream.Seek(3505, System.IO.SeekOrigin.Begin); YCalib.current_unit = (char)_brdrReader.ReadChar(); __fsFileStream.Seek(3587, System.IO.SeekOrigin.Begin); YCalib.CalibValid = (char)_brdrReader.ReadChar(); __fsFileStream.Seek(3590, System.IO.SeekOrigin.Begin); YCalib.PolynomOrder = (char)_brdrReader.ReadChar(); __fsFileStream.Seek(3752, System.IO.SeekOrigin.Begin); YCalib.PolynomCoeff[0] = _brdrReader.ReadDouble(); YCalib.PolynomCoeff[1] = _brdrReader.ReadDouble(); YCalib.PolynomCoeff[2] = _brdrReader.ReadDouble(); YCalib.PolynomCoeff[3] = _brdrReader.ReadDouble(); YCalib.PolynomCoeff[4] = _brdrReader.ReadDouble(); YCalib.PolynomCoeff[5] = _brdrReader.ReadDouble(); __fsFileStream.Seek(3800, System.IO.SeekOrigin.Begin); YCalib.LaserPosition = (double)_brdrReader.ReadDouble(); int _iDimension; SpeCalib _calCurrCalib; if (_iYDimension == 1) { _iDimension = _iXDimension; _calCurrCalib = XCalib; } else if (_iXDimension == 1) { _iDimension = _iYDimension; _calCurrCalib = YCalib; } else { throw new UnexpectedFormatException("xylib does not support 2-D images"); } __fsFileStream.Seek(4100, System.IO.SeekOrigin.Begin); // move ptr to frames-start for (int frm = 0; frm < (int)numframes; frm++) { Block _blkBlock = new Block(); Column _colXCol = this.GetCalibColumn(_calCurrCalib, _iDimension); _blkBlock.AddColumn(_colXCol, "", true); ListColumn _colYCol = new ListColumn(); for (int i = 0; i < _iDimension; ++i) { double _dYVal = 0; switch (_dtDataType) { case DataType.SPE_DATA_FLOAT: _dYVal = (double)_brdrReader.ReadSingle(); break; case DataType.SPE_DATA_LONG: _dYVal = (double)_brdrReader.ReadInt32(); break; case DataType.SPE_DATA_INT: _dYVal = (double)_brdrReader.ReadInt16(); break; case DataType.SPE_DATA_UINT: _dYVal = (double)_brdrReader.ReadUInt16(); break; default: break; } _colYCol.AddValue(_dYVal); } _blkBlock.AddColumn(_colYCol, "", true); this.m_blcklstBlocks.Add(_blkBlock); } }