123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Collections.Generic;
- using System.IO;
- using fis.Vid.Visuals;
- namespace fis.Vid
- {
- public class VinnoCarotid3DPhysicalData
- {
- /// <summary>
- /// Get cartid type.
- /// </summary>
- public CarotidType CarotidType { get; }
- /// <summary>
- /// Get vinno visual.
- /// </summary>
- public IList<VinnoVisual> VinnoVisuals { get; }
- /// <summary>
- /// Get vinno visual.
- /// </summary>
- public VinnoProbe VinnoProbe { get; }
- public VinnoCarotid3DPhysicalData(CarotidType carotidType, VinnoProbe vinnoProbe, IList<VinnoVisual> vinnoVisuals)
- {
- VinnoProbe = vinnoProbe;
- VinnoVisuals = vinnoVisuals;
- CarotidType = carotidType;
- }
- /// <summary>
- /// Convert to bytes.
- /// </summary>
- /// <returns>Bytes.</returns>
- public byte[] ToBytes()
- {
- using (var stream = new MemoryStream())
- {
- var writer = new VinnoStreamWriter(stream);
- writer.WriteByte((byte)CarotidType);
- writer.WriteBytes(VinnoProbe.ToBytes());
- writer.WriteByte((byte)VinnoVisuals.Count);
- foreach (var visual in VinnoVisuals)
- {
- writer.WriteBytes(visual.ToBytes());
- }
- return stream.ToArray();
- }
- }
- /// <summary>
- /// From bytes.
- /// </summary>
- /// <param name="bytes">bytes.</param>
- /// <returns>Instance of vinno carotid 3d physical data.</returns>
- public static VinnoCarotid3DPhysicalData FromBytes(byte[] bytes)
- {
- using (var stream = new MemoryStream(bytes))
- {
- stream.Position = 0;
- var reader = new VinnoStreamReader(stream);
- var carotidType = (CarotidType)reader.ReadByte();
- var probe = VinnoProbe.FromBytes(reader.ReadBytes());
- var visualCount = reader.ReadByte();
- var visuals = new List<VinnoVisual>();
- for (int i = 0; i < visualCount; i++)
- {
- var visual = VinnoVisual.FromBytes(reader.ReadBytes());
- visuals.Add(visual);
- }
- return new VinnoCarotid3DPhysicalData(carotidType, probe, visuals);
- }
- }
- }
- }
|