internal void WriteToBinaryWriter(BinaryWriter bw)
        {
            bw.Write(ProfileMagic);
            bw.Write(ScanHeadID);
            bw.Write((int)Camera);
            bw.Write((int)Laser);
            bw.Write(Timestamp);
            bw.Write(EncoderValues.Count);
            foreach (var val in EncoderValues.Values)
            {
                bw.Write(val);
            }

            bw.Write((int)LaserOnTime);
            var rawPointsArray = RawPoints.ToArray();

            bw.Write(rawPointsArray.Length);
            foreach (var pt in rawPointsArray)
            {
                bw.Write(pt.X);
                bw.Write(pt.Y);
                bw.Write(pt.Brightness);
            }

            if (CameraCoordinates != null)
            {
                bw.Write(CameraCoordinates.Count);
                foreach (var sc in CameraCoordinates)
                {
                    bw.Write(sc.X * 1000);
                    bw.Write(sc.Y * 1000);
                    bw.Write(sc.Brightness);
                }
            }
            else
            {
                bw.Write(0); // no camera coordinates
            }
        }
Exemple #2
0
        internal bool Reconstruct(
            BlamLib.Blam.CacheFile c,
            global_geometry_section_info_struct section,
            geometry_block_info_struct gbi
            )
        {
            int index = 0;

            byte[][] data = gbi.GeometryBlock;

            if (data == null)
            {
                return(false);
            }

            foreach (geometry_block_resource_block gb in gbi.Resources)
            {
                using (IO.EndianReader er = new BlamLib.IO.EndianReader(data[index]))
                {
                    switch (gb.Type.Value)
                    {
                        #region TagBlock
                    case (int)geometry_block_resource_type.TagBlock:
                        int count = gb.GetCount();
                        switch (gb.PrimaryLocater.Value)
                        {
                        case OffsetRawPoints:
                            RawPoints.Resize(count);
                            RawPoints.Read(er);
                            break;

                        case OffsetRigidPointGroups:
                            RigidPointGroups.Resize(count);
                            RigidPointGroups.Read(er);
                            break;

                        case OffsetVertexPointIndices:
                            VertexPointIndices.Resize(count);
                            VertexPointIndices.Read(er);
                            break;
                        }
                        break;

                        #endregion
                        #region TagData
                    case (int)geometry_block_resource_type.TagData:
                        switch (gb.PrimaryLocater.Value)
                        {
                        case OffsetRuntimePointData:
                            RuntimePointData.Reset(er.ReadBytes(gb.Size));
                            break;
                        }
                        break;
                        #endregion
                        #region VertexBuffer
                        //case (int)geometry_block_resource_type.VertexBuffer:
                        #endregion
                    }

                    index++;
                }
            }

            return(true);
        }
 /// <summary>
 /// Gets the valid <see cref="Point2D"/>s in the <see cref="Profile"/>.
 /// </summary>
 /// <returns>A <see cref="IEnumerable{Point2D}"/> of the valid <see cref="Point2D"/>s in the <see cref="Profile"/>.</returns>
 public IEnumerable <Point2D> GetValidXYPoints()
 {
     return(RawPoints.ToArray().Where(q => !double.IsNaN(q.Y)));
 }