public void PointConvertFromTest() { PointXYZ point = (PointXYZ)TypeDescriptor.GetConverter(typeof(PointXYZ)).ConvertFrom("1 2 3"); Assert.AreEqual(1, point.X); Assert.AreEqual(2, point.Y); Assert.AreEqual(3, point.Z); }
private void trackBar3_Scroll(object sender, System.EventArgs e) { PointXYZ tmp = tChart1.Graphics3D.RotationCenter; tmp.Z = (int)trackBar3.Value; tChart1.Graphics3D.RotationCenter = tmp; tChart1.Invalidate(); }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { PointXYZ point = (PointXYZ)value; return(point.X + " " + point.Y + " " + point.Z); } return(base.ConvertTo(context, culture, value, destinationType)); }
public unsafe void TestCtorWH() { using (var cloud = new PointCloudOfXYZ(10, 10)) { ref PointXYZ foo = ref cloud.At(5, 5); foo.X = 5; var ptr = cloud.Data; Assert.AreEqual(5, ptr[55].X); }
public static ValueRange <PointXYZ> Limits <TPoint>(this IEnumerable <TPoint> points) where TPoint : IPoint3D { if (points == null) { return(new ValueRange <PointXYZ>(PointXYZ.Zero, PointXYZ.Zero)); } var xMin = double.MaxValue; var yMin = double.MaxValue; var zMin = double.MaxValue; var yMax = double.MinValue; var xMax = double.MinValue; var zMax = double.MinValue; foreach (var point in points) { if (point.X > xMax) { xMax = point.X; } if (point.Y > yMax) { yMax = point.Y; } if (point.Z > yMax) { zMax = point.Z; } if (point.X < xMin) { xMin = point.X; } if (point.Y < yMin) { yMin = point.Y; } if (point.Z < zMin) { zMax = point.Z; } } var min = new PointXYZ(xMin, yMin, zMin); var max = new PointXYZ(xMax, yMax, zMax); var range = new ValueRange <PointXYZ>(min, max); return(range); }
/// <summary> /// /// </summary> /// <param name="newPoint"></param> private void CheckMaxResult(PointXYZ newPoint) { PointXYZ minResult = null; foreach (PointXYZ point in listMaxResult) { //Get the minimin value if (minResult == null) { minResult = point; } else if (point.Z < minResult.Z) { minResult = point; } } if (newPoint.Z > minResult.Z) { minResult.X = newPoint.X; minResult.Y = newPoint.Y; minResult.Z = newPoint.Z; } }
private PointCloudData <T> ParseLines(FileInfo f, int id) { _metadata = new PointCloudMetaData(); bool isInitialized = false; int index = 0; _startData = false; T[] points = new T[0]; string[] lines = new string[0]; try { lines = File.ReadAllLines(f.FullName); } catch (Exception e) { UnityEngine.Debug.Log(e.Message); } foreach (string line in lines) { // Parse metadata if (!_startData) { ParseMetadata(line, ref _metadata); } else { if (!isInitialized) { points = new T[_metadata.pointSize]; isInitialized = true; } // Parse vertices string[] values = line.Split(' '); if (values.Length != _metadata.numFields) { throw new System.Exception("Vertices was not same as fields"); } float x = 0, y = 0, z = 0; bool success = float.TryParse(values[0], out x); success = success && float.TryParse(values[1], out y); success = success && float.TryParse(values[2], out z); if (!success) { throw new System.Exception("Could not parse a vertex"); } if (_metadata.field == PointCloudDataType.XYZ) { Vector3 pos = new Vector3(x, y, z); PointXYZ point = new PointXYZ(pos); points[index++] = (T)point; } /* * else if (_metadata.field == PointCloudDataType.XYZRGB) * { * float rgba = float.Parse(values[3]); * byte r, g, b; * * // Unpack packed float - 3 channel * byte[] colorBytes = BitConverter.GetBytes(rgba); * r = colorBytes[0]; * g = colorBytes[1]; * b = colorBytes[2]; * * Vector3 point = new Vector3(x, y, z); * Color col = new Color(r, g, b); * points[index++] = new PointXYZRGBA(point, col); * } * else if (_metadata.field == PointCloudDataType.XYZRGBA) * { * int rgba = int.Parse(values[3]); * byte r, g, b, a; * * // Unpack float - 4 channel * byte[] colorBytes = BitConverter.GetBytes(rgba); * r = colorBytes[0]; * g = colorBytes[1]; * b = colorBytes[2]; * a = colorBytes[3]; * * Vector3 point = new Vector3(x, y, z); * Color32 col = new Color32(r, g, b, a); * points[index++] = new PointXYZRGBA(point, col); * } */ } } if (points.Length == 0 || points.Length != _metadata.pointSize) { throw new System.Exception("Vertices were empty or did not match declared points. Was:" + points.Length + ", but expected: " + _metadata.pointSize); } PointCloudData <T> pcd = new PointCloudData <T>(points, points.Length, _metadata, id); return(pcd); }
public static bool CompareTwoPoint(PointXYZ p1, PointXYZ p2) { return((p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z) ? true : false); }
public static extern void std_vector_xyz_insert(IntPtr ptr, IntPtr idx, PointXYZ value);
public static extern void filters_voxelGrid_xyz_setLeafSize(IntPtr ptr, PointXYZ size);
public void Add(PointXYZ point) { columns.Add(point); }
/// <summary> /// /// </summary> /// <param name="newPoint"></param> private void CheckMinMaxResult(PointXYZ newPoint) { CheckMaxResult(newPoint); CheckMinResult(newPoint); }
public void PointConvertToTest() { PointXYZ point = new PointXYZ(1, 2, 3); Assert.AreEqual("1 2 3", TypeDescriptor.GetConverter(point).ConvertTo(point, typeof(string))); }
public static extern void std_vector_xyz_at(IntPtr ptr, UIntPtr idx, ref PointXYZ value);
public static extern void std_vector_xyz_add(IntPtr ptr, PointXYZ value);
public static extern int search_organizedNeighbor_xyz_nearestKSearch(IntPtr ptr, PointXYZ point, int k, VectorOfInt k_indices, VectorOfFloat k_sqr_distances);
private void button3_Click(object sender, EventArgs e) { //Filter<PointXYZ> ds = new Filter <PointXYZ>; PointCloudOfXYZ IN_cloud = new PointCloudOfXYZ(); PointCloudOfXYZ OUT_cloud = new PointCloudOfXYZ(); gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); double tempx = 0; double tempy = 0; double tempz = 0; //listBox1.Items.Clear(); Drawxs = false; Zcdk = true; //再次读取 // CCValue.thStart = true; this.openFileDialog1.ShowDialog(); string MyFileName = openFileDialog1.FileName; if (MyFileName.Trim() == "") { return; } StreamReader MyReader = null; try { MyReader = new StreamReader(MyFileName, System.Text.Encoding.Default); string content = MyReader.ReadToEnd(); string[] str = content.Split(new string[] { "\r\n" }, StringSplitOptions.None); char[] splitchar = new Char[] { ',' };//拆分数组 string[] data1; for (int i = 0; i < str.Length - 1; i++) { data1 = str[i].Split(splitchar); a.X = float.Parse(data1[0]); a.Y = float.Parse(data1[1]); a.Z = float.Parse(data1[2]); IN_cloud.Add(a); } // ABC.SetInputCloud(IN_cloud); // ABC.MeanK = 20; // ABC.StdDevMulThresh = (1.0); // ABC.filter(OUT_cloud); maxx = new float[IN_cloud.Count]; maxy = new float[IN_cloud.Count]; maxz = new float[IN_cloud.Count]; for (int i = 0; i < IN_cloud.Count - 1; i++) { a = IN_cloud.Points[i]; if (a.Z > -1500) { continue; } else { maxx[i] = a.X; maxy[i] = a.Y; maxz[i] = a.Z; tempx += maxx[i]; tempy += maxy[i]; tempz += maxz[i]; } } xds = IN_cloud.Count; _ZBxT = tempx / xds; _ZByT = tempy / xds; _ZBzT = tempz / xds; } catch (Exception Err) { MessageBox.Show("读文本文件发生错误!请检查源文件是否是文本文件?" + Err.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } IN_cloud.Dispose(); OUT_cloud.Dispose(); GC.Collect(); //ABC.SetInputCloud(cloud); }
public static extern int search_kdtree_xyz_nearestKSearch(IntPtr ptr, PointXYZ point, int k, VectorOfInt k_indices, VectorOfFloat k_sqr_distances);