ProfilePoint[] TransProfileData(KObject rawData)
        {
            ProfilePoint[] profileBuffer = null;
            GoDataSet      _dataSource   = new GoDataSet();

            _dataSource  = (GoDataSet)rawData;
            _dataContext = new DataContext();
            ProfileShape _profileShape = new ProfileShape();

            for (UInt32 i = 0; i < _dataSource.Count; i++)
            {
                GoDataMsg dataObj = (GoDataMsg)_dataSource.Get(i);
                switch (dataObj.MessageType)
                {
                case GoDataMessageType.ResampledProfile:
                {
                    GoResampledProfileMsg profileMsg = (GoResampledProfileMsg)dataObj;
                    _dataContext.xResolution = (double)profileMsg.XResolution / 1000000;
                    _dataContext.zResolution = (double)profileMsg.ZResolution / 1000000;
                    _dataContext.xOffset     = (double)profileMsg.XOffset / 1000;
                    _dataContext.zOffset     = (double)profileMsg.ZOffset / 1000;
                    _profileShape.width      = profileMsg.Width;
                    _profileShape.size       = profileMsg.Size;
                    _syncContext.Post(delegate
                        {
                            xRes.Content = _dataContext.xResolution.ToString();
                            zRes.Content = _dataContext.zResolution.ToString();
                        }, null);
                    //generate csv file for point data save
                    short[] points = new short[_profileShape.width];
                    profileBuffer = new ProfilePoint[_profileShape.width];
                    IntPtr pointsPtr = profileMsg.Data;
                    Marshal.Copy(pointsPtr, points, 0, points.Length);

                    for (UInt32 arrayIndex = 0; arrayIndex < _profileShape.width; ++arrayIndex)
                    {
                        if (points[arrayIndex] != -32768)
                        {
                            profileBuffer[arrayIndex].x = _dataContext.xOffset + _dataContext.xResolution * arrayIndex;
                            profileBuffer[arrayIndex].z = _dataContext.zOffset + _dataContext.zResolution * points[arrayIndex];
                        }
                        else
                        {
                            profileBuffer[arrayIndex].x = _dataContext.xOffset + _dataContext.xResolution * arrayIndex;
                            profileBuffer[arrayIndex].z = activeArea.Top;
                        }
                    }
                }
                break;

                default: break;
                }
            }

            return(profileBuffer);
        }
 public static void AddProfileShape(FlatBufferBuilder builder, ProfileShape profileShape)
 {
     builder.AddSbyte(20, (sbyte)profileShape, 0);
 }