Esempio n. 1
0
        public void FindNearest_Points_Rednaxela(List <Vertex> vertices)
        {
            //float fThreshold = kdTreeNeighbourThreshold;
            List <Vertex> nearestNeighbours = new List <Vertex>();

            for (int i = vertices.Count - 1; i >= 0; i--)
            {
                Vertex vToCheck = vertices[i];

                // Perform a nearest neighbour search around that point.
                KDTreeRednaxela.NearestNeighbour <EllipseWrapper> pIter = null;
                KDTreeVertex kv = KDTreeVertex.Instance;

                pIter = kv.KdTree_Rednaxela.FindNearest_EuclidDistance(new double[] { vToCheck.Vector.X, vToCheck.Vector.Y, vToCheck.Vector.Z }, NumberOfNeighboursToSearch, -1);
                int neighboursFound = 0;

                while (pIter.MoveNext())
                {
                    EllipseWrapper wr         = pIter.Current;
                    Vertex         vNeighbour = wr.Vertex;
                    if (vToCheck != vNeighbour)
                    {
                        if (!vToCheck.IndexNeighbours.Contains(vNeighbour.IndexInModel))
                        {
                            vToCheck.IndexNeighbours.Add(vNeighbour.IndexInModel);
                            vToCheck.DistanceNeighbours.Add(pIter.CurrentDistance);
                        }
                        for (int j = vNeighbour.IndexNeighbours.Count - 1; j >= 0; j--)
                        {
                            if (vNeighbour.IndexNeighbours[j] == vToCheck.IndexInModel)
                            {
                                vNeighbour.IndexNeighbours.RemoveAt(j);
                                vNeighbour.DistanceNeighbours.RemoveAt(j);
                            }
                        }
                        neighboursFound = vToCheck.DistanceNeighbours.Count;
                        //if (!vNeighbour.IndexNeighbours.Contains(vToCheck.IndexInModel))
                        //{
                        //    vNeighbour.IndexNeighbours.Add(vToCheck.IndexInModel);
                        //    vNeighbour.DistanceNeighbours.Add(pIter.CurrentDistance);
                        //}
                        if ((neighboursFound) > NumberOfNeighboursToSearch)
                        {
                            break;
                        }
                    }
                }
            }

            TimeCalc.ShowLastTimeSpan("Find neighbours");

            //RemoveAllVerticesBasedOnRadius(vertices);
        }
Esempio n. 2
0
        private void PrepareTargetTree(PointCloudVertices pointCloudTarget)
        {
            //second object:
            //-----------
            pointCloudTargetCentered = CalculatePCA_Internal(pointCloudTarget);
            //pointCloudTargetCentered = ShiftByCenterOfMass(pointCloudTarget);

            kdtree = new KDTreeVertex();
            kdtree.BuildKDTree_Rednaxela(pointCloudTargetCentered);

            pointCloudResult       = null;
            pointCloudTargetKDTree = null;
        }
Esempio n. 3
0
        public static List <Vector3> CalculateNormals_PCA(PointCloudVertices pointCloud, int numberOfNeighbours, bool centerOfMassMethod, bool flipNormalWithOriginVector)
        {
            KDTreeVertex kv = new KDTreeVertex();

            kv.NumberOfNeighboursToSearch = numberOfNeighbours;
            kv.BuildKDTree_Rednaxela(pointCloud);
            kv.ResetVerticesLists(pointCloud);
            kv.FindNearest_NormalsCheck_Rednaxela(pointCloud, false);



            PCA            pca     = new PCA();
            List <Vector3> normals = pca.Normals(pointCloud, centerOfMassMethod, flipNormalWithOriginVector);

            return(normals);
        }
Esempio n. 4
0
 public KDTreeVertex()
 {
     NumberOfNeighboursToSearch = 5;
     KDTreeMode = KDTreeMode.Rednaxala;
     instance   = this;
 }