Пример #1
0
        public bool BuildKDTree_Rednaxela(PointCloudVertices target)
        {
            GlobalVariables.ResetTime();
            ResetVerticesLists(target);

            try
            {
                KdTree_Rednaxela = new KDTreeRednaxela.KDTree_Rednaxela <EllipseWrapper>(3);

                for (int i = 0; i < target.Count; ++i)
                {
                    Vertex p = target[i];
                    KdTree_Rednaxela.AddPoint(new float[] { Convert.ToSingle(p.Vector.X), Convert.ToSingle(p.Vector.Y), Convert.ToSingle(p.Vector.Z) }, new EllipseWrapper(p));
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Error building kd-tree " + err.Message);
                return(false);
            }

            GlobalVariables.ShowLastTimeSpan("Build Tree Rednaxela - Number of points: " + target.Count.ToString() + " : ");

            return(true);
        }
Пример #2
0
        public bool BuildKDTree_Stark(PointCloudVertices target)
        {
            GlobalVariables.ResetTime();
            KdTree_Stark = KDTree_Stark.Build(target);
            GlobalVariables.ShowLastTimeSpan("Build Tree Stark");

            return(true);
        }
Пример #3
0
        public void FindNearest_NormalsCheck_Rednaxela(PointCloudVertices pointCloud, bool normalsCheck)
        {
            PointCloudVertices nearestNeighbours = new PointCloudVertices();

            //for (int i = pointCloud.Count - 1; i >= 0; i--)
            for (int i = 0; i < pointCloud.Count; i++)
            {
                Vertex vSource = pointCloud[i];

                // Perform a nearest neighbour search around that point.
                KDTreeRednaxela.NearestNeighbour <EllipseWrapper> nearestNeighbor = null;

                if (normalsCheck)
                {
                    nearestNeighbor = KdTree_Rednaxela.FindNearest_EuclidDistance(new float[] { Convert.ToSingle(vSource.Vector.X), Convert.ToSingle(vSource.Vector.Y), Convert.ToSingle(vSource.Vector.Z) }, NumberOfNeighboursToSearch + 1, -1);
                }
                else
                {
                    nearestNeighbor = KdTree_Rednaxela.FindNearest_EuclidDistance(new float[] { Convert.ToSingle(vSource.Vector.X), Convert.ToSingle(vSource.Vector.Y), Convert.ToSingle(vSource.Vector.Z) }, NumberOfNeighboursToSearch, -1);
                }

                while (nearestNeighbor.MoveNext())
                {
                    EllipseWrapper wr      = nearestNeighbor.CurrentPoint;
                    Vertex         vTarget = wr.Vertex;

                    if (vSource != vTarget)
                    {
                        if (!vSource.KDTreeSearch.Contains(vTarget.IndexInModel))
                        {
                            if (!vTarget.TakenInTree)
                            {
                                vTarget.TakenInTree = true;
                                KeyValuePair <int, float> el = new KeyValuePair <int, float>(vTarget.IndexInModel, nearestNeighbor.CurrentDistance);
                                vSource.KDTreeSearch.Add(el);
                                break;
                            }
                        }

                        if ((vSource.KDTreeSearch.Count) >= 1)
                        {
                            break;
                        }
                    }
                }
                //if (vSource.KDTreeSearch.Count == 0)
                //{
                //    System.Windows.Forms.MessageBox.Show("Error in finding neighbour for index " + i.ToString());
                //}
            }

            if (KdTree_Rednaxela.pLeft != null)
            {
                SetRecursive(KdTree_Rednaxela.pLeft);
            }
            if (KdTree_Rednaxela.pRight != null)
            {
                SetRecursive(KdTree_Rednaxela.pRight);
            }

            GlobalVariables.ShowLastTimeSpan("Find neighbours");

            //RemoveAllVerticesBasedOnRadius(pointCloud);
        }