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 if (type == null) { type = new Messages.object_recognition_msgs.ObjectType(); } pieces.Add(type.Serialize(true)); //confidence scratch1 = new byte[Marshal.SizeOf(typeof(Single))]; h = GCHandle.Alloc(scratch1, GCHandleType.Pinned); Marshal.StructureToPtr(confidence, h.AddrOfPinnedObject(), false); h.Free(); pieces.Add(scratch1); //point_clouds hasmetacomponents |= true; if (point_clouds == null) { point_clouds = new Messages.sensor_msgs.PointCloud2[0]; } pieces.Add(BitConverter.GetBytes(point_clouds.Length)); for (int i = 0; i < point_clouds.Length; i++) { //point_clouds[i] if (point_clouds[i] == null) { point_clouds[i] = new Messages.sensor_msgs.PointCloud2(); } pieces.Add(point_clouds[i].Serialize(true)); } //bounding_mesh if (bounding_mesh == null) { bounding_mesh = new Messages.shape_msgs.Mesh(); } pieces.Add(bounding_mesh.Serialize(true)); //bounding_contours hasmetacomponents |= true; if (bounding_contours == null) { bounding_contours = new Point[0]; } pieces.Add(BitConverter.GetBytes(bounding_contours.Length)); for (int i = 0; i < bounding_contours.Length; i++) { //bounding_contours[i] if (bounding_contours[i] == null) { bounding_contours[i] = new Point(); } pieces.Add(bounding_contours[i].Serialize(true)); } //pose if (pose == null) { pose = new PoseWithCovarianceStamped(); } pieces.Add(pose.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); }