public static PhaseSpaceFrame GetMotionFrame(TrcFrame frame)
        {
            PhaseSpaceFrame ret = new PhaseSpaceFrame();

            ret.Markers = new PhaseSpaceMarker[frame.Markers.Length];
            for (int i = 0; i < ret.Markers.Length; i++)
            {
                if (frame.Markers[i].HasValue)
                {
                    float x = 0f, y = 0f, z = 0f;
                    if (float.TryParse(frame.Markers[i].Value.X, out x) &&
                        float.TryParse(frame.Markers[i].Value.Y, out y) &&
                        float.TryParse(frame.Markers[i].Value.Z, out z))
                    {
                        ret.Markers[i] = new PhaseSpaceMarker(5, x, y, z);
                    }
                    else
                    {
                        ret.Markers[i] = new PhaseSpaceMarker(-1, 0, 0, 0);
                    }
                }
                else
                {
                    ret.Markers[i] = new PhaseSpaceMarker(-1, 0, 0, 0);
                }
            }
            ret.Time = frame.Time;
            return(ret);
        }
示例#2
0
 /// <summary>
 /// フレーム番号と時間を維持してファイルにフレームを書き込みます。
 /// </summary>
 /// <param title="frame">書き込むフレーム</param>
 /// <returns></returns>
 public bool WriteRawFrame(TrcFrame frame)
 {
     if (_frames >= _header.NumFrames)
     {
         return(false);
     }
     _frames++;
     frame.WriteTo(this);
     return(true);
 }
示例#3
0
 /// <summary>
 /// ファイルにフレームを書き込みます。フレーム番号と時間は修正されます。
 /// </summary>
 /// <param title="frame">書き込むフレーム</param>
 /// <returns></returns>
 public bool WriteFrame(TrcFrame frame)
 {
     if (_frames >= _header.NumFrames)
     {
         return(false);
     }
     _frames++;
     frame.Number = _frames;
     frame.Time   = TrcFrame.GetTimeFromNumber(frame.Number, _header, TimeOffset);
     frame.WriteTo(this);
     return(true);
 }
示例#4
0
        /// <summary>
        /// 次の1フレームを取得します。
        /// </summary>
        /// <returns>取得されたフレーム</returns>
        /// <exception cref="InvalidDataException"></exception>
        public TrcFrame ReadFrame()
        {
            TrcFrame ret = new TrcFrame();

            if (this.EndOfStream)
            {
                throw new EndOfStreamException();
            }
            ret.ReadFrom(this);
            _frames++;
            return(ret);
        }
        public static TrcFrame GetTrcFrame(PhaseSpaceFrame frame, int number)
        {
            TrcFrame ret = new TrcFrame();

            ret.Markers = new TrcMarker?[frame.Markers.Length];
            for (int i = 0; i < ret.Markers.Length; i++)
            {
                if (frame.Markers[i].Condition > 0)
                {
                    ret.Markers[i] = new TrcMarker(frame.Markers[i].X.ToString("R"),
                                                   frame.Markers[i].Y.ToString("R"),
                                                   frame.Markers[i].Z.ToString("R"));
                }
            }
            ret.Number = number;
            ret.Time   = frame.Time;
            return(ret);
        }
示例#6
0
        public TrcFrame JoinAll(TrcFrame[] others)
        {
            TrcFrame ret = this;

            if (this.Markers == null)
            {
                this.Markers = new TrcMarker?[0];
            }
            int length = this.Markers.Length;

            for (int i = 0; i < others.Length; i++)
            {
                if (others[i].Markers == null)
                {
                    others[i].Markers = new TrcMarker?[0];
                }
            }
            foreach (var frame in others)
            {
                length += frame.Markers.Length;
            }
            ret.Markers = new TrcMarker?[length];
            for (int i = 0; i < this.Markers.Length; i++)
            {
                if (this.Markers[i].HasValue)
                {
                    ret.Markers[i] = this.Markers[i].Value;
                }
            }
            int offset = this.Markers.Length;

            foreach (var frame in others)
            {
                for (int i = 0; i < frame.Markers.Length; i++)
                {
                    if (frame.Markers[i].HasValue)
                    {
                        ret.Markers[i + offset] = frame.Markers[i].Value;
                    }
                }
                offset += frame.Markers.Length;
            }
            return(ret);
        }
示例#7
0
        /// <summary>
        /// 指定範囲のマーカーのみを保持するフレームを返します。
        /// </summary>
        /// <param title="lower">範囲の開始インデックス</param>
        /// <param title="length">範囲の長さ</param>
        /// <returns>新しいフレーム</returns>
        public TrcFrame TrimMarkers(int begin, int length)
        {
            TrcFrame ret = this;

            ret.Markers = new TrcMarker?[length];
            if (this.Markers == null)
            {
                this.Markers = new TrcMarker?[0];
            }
            for (int i = 0; i < length; i++)
            {
                if (i + begin >= this.Markers.Length)
                {
                    break;
                }
                if (this.Markers[i + begin].HasValue)
                {
                    ret.Markers[i] = this.Markers[i + begin].Value;
                }
            }
            return(ret);
        }
示例#8
0
        /// <summary>
        /// ほかのフレームのマーカーをこのフレームの末尾に追加したフレームを返します。
        /// </summary>
        /// <param title="another">ほかのフレーム</param>
        /// <param title="useAnothersNumberAndTime">ほかのフレームのフレーム番号と時間を新しいフレームに用いるか</param>
        /// <returns>新しいフレーム</returns>
        public TrcFrame JoinWith(TrcFrame another, bool useAnothersNumberAndTime)
        {
            TrcFrame ret;

            if (useAnothersNumberAndTime)
            {
                ret = another;
            }
            else
            {
                ret = this;
            }
            if (this.Markers == null)
            {
                this.Markers = new TrcMarker?[0];
            }
            if (another.Markers == null)
            {
                another.Markers = new TrcMarker?[0];
            }
            ret.Markers = new TrcMarker?[this.Markers.Length + another.Markers.Length];
            for (int i = 0; i < this.Markers.Length; i++)
            {
                if (this.Markers[i].HasValue)
                {
                    ret.Markers[i] = this.Markers[i].Value;
                }
            }
            for (int i = 0; i < another.Markers.Length; i++)
            {
                if (another.Markers[i].HasValue)
                {
                    ret.Markers[i + this.Markers.Length] = another.Markers[i].Value;
                }
            }
            return(ret);
        }
示例#9
0
 /// <summary>
 /// ほかのフレームのマーカーをこのフレームの末尾に追加したフレームを返します。
 /// </summary>
 /// <param title="another">ほかのフレーム</param>
 /// <returns>新しいフレーム</returns>
 public TrcFrame JoinWith(TrcFrame another)
 {
     return(JoinWith(another, false));
 }