public override void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //header header = new Header(); header.Randomize(); //cloud cloud = new Messages.sensor_msgs.PointCloud2(); cloud.Randomize(); //polygons arraylength = rand.Next(10); if (polygons == null) { polygons = new Messages.pcl_msgs.Vertices[arraylength]; } else { Array.Resize(ref polygons, arraylength); } for (int i = 0; i < polygons.Length; i++) { //polygons[i] polygons[i] = new Messages.pcl_msgs.Vertices(); polygons[i].Randomize(); } }
public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; object __thing; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; //header header = new Header(SERIALIZEDSTUFF, ref currentIndex); //cloud cloud = new Messages.sensor_msgs.PointCloud2(SERIALIZEDSTUFF, ref currentIndex); //polygons hasmetacomponents |= true; arraylength = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (polygons == null) { polygons = new Messages.pcl_msgs.Vertices[arraylength]; } else { Array.Resize(ref polygons, arraylength); } for (int i = 0; i < polygons.Length; i++) { //polygons[i] polygons[i] = new Messages.pcl_msgs.Vertices(SERIALIZEDSTUFF, ref currentIndex); } }
public override void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //name strlength = rand.Next(100) + 1; strbuf = new byte[strlength]; rand.NextBytes(strbuf); //fill the whole buffer with random bytes for (int __x__ = 0; __x__ < strlength; __x__++) { if (strbuf[__x__] == 0) //replace null chars with non-null random ones { strbuf[__x__] = (byte)(rand.Next(254) + 1); } } strbuf[strlength - 1] = 0; //null terminate name = Encoding.ASCII.GetString(strbuf); //ground_truth_mesh ground_truth_mesh = new Messages.shape_msgs.Mesh(); ground_truth_mesh.Randomize(); //ground_truth_point_cloud ground_truth_point_cloud = new Messages.sensor_msgs.PointCloud2(); ground_truth_point_cloud.Randomize(); }
public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; object __thing; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; //header header = new Header(SERIALIZEDSTUFF, ref currentIndex); //type piecesize = Marshal.SizeOf(typeof(uint)); h = IntPtr.Zero; if (SERIALIZEDSTUFF.Length - currentIndex != 0) { h = Marshal.AllocHGlobal(piecesize); Marshal.Copy(SERIALIZEDSTUFF, currentIndex, h, piecesize); } if (h == IntPtr.Zero) { throw new Exception("Alloc failed"); } type = (uint)Marshal.PtrToStructure(h, typeof(uint)); Marshal.FreeHGlobal(h); currentIndex += piecesize; //points points = new Messages.sensor_msgs.PointCloud2(SERIALIZEDSTUFF, ref currentIndex); }
public override void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //header header = new Header(); header.Randomize(); //type type = new Messages.object_recognition_msgs.ObjectType(); type.Randomize(); //confidence confidence = (float)(rand.Next() + rand.NextDouble()); //point_clouds arraylength = rand.Next(10); if (point_clouds == null) { point_clouds = new Messages.sensor_msgs.PointCloud2[arraylength]; } else { Array.Resize(ref point_clouds, arraylength); } for (int i = 0; i < point_clouds.Length; i++) { //point_clouds[i] point_clouds[i] = new Messages.sensor_msgs.PointCloud2(); point_clouds[i].Randomize(); } //bounding_mesh bounding_mesh = new Messages.shape_msgs.Mesh(); bounding_mesh.Randomize(); //bounding_contours arraylength = rand.Next(10); if (bounding_contours == null) { bounding_contours = new Point[arraylength]; } else { Array.Resize(ref bounding_contours, arraylength); } for (int i = 0; i < bounding_contours.Length; i++) { //bounding_contours[i] bounding_contours[i] = new Point(); bounding_contours[i].Randomize(); } //pose pose = new PoseWithCovarianceStamped(); pose.Randomize(); }
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 void Randomize() { int arraylength = -1; Random rand = new Random(); int strlength; byte[] strbuf, myByte; //header header = new Header(); header.Randomize(); //type type = (uint)rand.Next(); //points points = new Messages.sensor_msgs.PointCloud2(); points.Randomize(); }
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 void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; object __thing; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; //name name = ""; piecesize = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex); currentIndex += 4; name = Encoding.ASCII.GetString(SERIALIZEDSTUFF, currentIndex, piecesize); currentIndex += piecesize; //ground_truth_mesh ground_truth_mesh = new Messages.shape_msgs.Mesh(SERIALIZEDSTUFF, ref currentIndex); //ground_truth_point_cloud ground_truth_point_cloud = new Messages.sensor_msgs.PointCloud2(SERIALIZEDSTUFF, ref currentIndex); }
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); }
public override void Deserialize(byte[] SERIALIZEDSTUFF, ref int currentIndex) { int arraylength = -1; bool hasmetacomponents = false; object __thing; int piecesize = 0; byte[] thischunk, scratch1, scratch2; IntPtr h; //header header = new Header(SERIALIZEDSTUFF, ref currentIndex); //type type = new Messages.object_recognition_msgs.ObjectType(SERIALIZEDSTUFF, ref currentIndex); //confidence piecesize = Marshal.SizeOf(typeof(Single)); h = IntPtr.Zero; if (SERIALIZEDSTUFF.Length - currentIndex != 0) { h = Marshal.AllocHGlobal(piecesize); Marshal.Copy(SERIALIZEDSTUFF, currentIndex, h, piecesize); } if (h == IntPtr.Zero) { throw new Exception("Alloc failed"); } confidence = (Single)Marshal.PtrToStructure(h, typeof(Single)); Marshal.FreeHGlobal(h); currentIndex += piecesize; //point_clouds hasmetacomponents |= true; arraylength = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (point_clouds == null) { point_clouds = new Messages.sensor_msgs.PointCloud2[arraylength]; } else { Array.Resize(ref point_clouds, arraylength); } for (int i = 0; i < point_clouds.Length; i++) { //point_clouds[i] point_clouds[i] = new Messages.sensor_msgs.PointCloud2(SERIALIZEDSTUFF, ref currentIndex); } //bounding_mesh bounding_mesh = new Messages.shape_msgs.Mesh(SERIALIZEDSTUFF, ref currentIndex); //bounding_contours hasmetacomponents |= true; arraylength = BitConverter.ToInt32(SERIALIZEDSTUFF, currentIndex); currentIndex += Marshal.SizeOf(typeof(System.Int32)); if (bounding_contours == null) { bounding_contours = new Point[arraylength]; } else { Array.Resize(ref bounding_contours, arraylength); } for (int i = 0; i < bounding_contours.Length; i++) { //bounding_contours[i] bounding_contours[i] = new Point(SERIALIZEDSTUFF, ref currentIndex); } //pose pose = new PoseWithCovarianceStamped(SERIALIZEDSTUFF, ref currentIndex); }
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); }