public override byte[] Serialize(bool partofsomethingelse) { int currentIndex = 0, length = 0; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //header if (header == null) { header = new Header(); } pieces.Add(header.Serialize(true)); //cloud if (cloud == null) { cloud = new Messages.sensor_msgs.PointCloud2(); } pieces.Add(cloud.Serialize(true)); //polygons hasmetacomponents |= true; if (polygons == null) { polygons = new Messages.pcl_msgs.Vertices[0]; } pieces.Add(BitConverter.GetBytes(polygons.Length)); for (int i = 0; i < polygons.Length; i++) { //polygons[i] if (polygons[i] == null) { polygons[i] = new Messages.pcl_msgs.Vertices(); } pieces.Add(polygons[i].Serialize(true)); } //combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
public override byte[] Serialize(bool partofsomethingelse) { int currentIndex = 0, length = 0; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //name if (name == null) { name = ""; } scratch1 = Encoding.ASCII.GetBytes((string)name); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //ground_truth_mesh if (ground_truth_mesh == null) { ground_truth_mesh = new Messages.shape_msgs.Mesh(); } pieces.Add(ground_truth_mesh.Serialize(true)); //ground_truth_point_cloud if (ground_truth_point_cloud == null) { ground_truth_point_cloud = new Messages.sensor_msgs.PointCloud2(); } pieces.Add(ground_truth_point_cloud.Serialize(true)); //combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
public override byte[] Serialize(bool partofsomethingelse) { int currentIndex = 0, length = 0; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //header if (header == null) { header = new Header(); } pieces.Add(header.Serialize(true)); //type scratch1 = new byte[Marshal.SizeOf(typeof(uint))]; h = GCHandle.Alloc(scratch1, GCHandleType.Pinned); Marshal.StructureToPtr(type, h.AddrOfPinnedObject(), false); h.Free(); pieces.Add(scratch1); //points if (points == null) { points = new Messages.sensor_msgs.PointCloud2(); } pieces.Add(points.Serialize(true)); //combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }