Exemplo n.º 1
0
        }  // of overloaded constructor

        public bool IsPointReachable(BlPoint pPoint)
        {
            if (ListPoints.FindAll(x => x.Distance(pPoint) <= Dist).Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }  // of IsPointReachable()
Exemplo n.º 2
0
        }  // of overloaded constructor

        public Cluster(double pDist, BlPoint pPoint)
            : this(pDist)
        {
            ListPoints.Add(pPoint);
        }  // of overloaded constructor
Exemplo n.º 3
0
        public static void FindSpheresUsingClusters(Point3DCollection inputpoints, double searchrad, out List <Point3DCollection> clusters, double zlimit, bool filter)
        {
            try
            {
                List <Point3D> pt = inputpoints.ToList();
                pt.Sort((x, y) => y.Z.CompareTo(x.Z));

                List <Point3D> selectedPoints;

                if (filter == true)
                {
                    selectedPoints = pt.TakeWhile(p => p.Z >= zlimit).ToList();
                }
                else
                {
                    selectedPoints = inputpoints.ToList();
                }

                List <BlPoint> lListPoints = new List <BlPoint>();
                foreach (var v in selectedPoints)
                {
                    lListPoints.Add(new BlPoint((float)v.X, (float)v.Y, (float)v.Z));
                }
                double lDist = searchrad;

                List <Cluster> lListClusters = new List <Cluster>();
                // take a point to create one cluster for starters
                BlPoint lP1 = lListPoints[0];

                lListPoints.Remove(lP1);

                // so far, we have a one-point cluster
                lListClusters.Add(new Cluster(lDist, lP1));

                List <Cluster> lListAttainableClusters;
                Cluster        lC;
                foreach (BlPoint p in lListPoints)
                {
                    lListAttainableClusters = new List <Cluster>();
                    lListAttainableClusters = lListClusters.FindAll(x => x.IsPointReachable(p));
                    lListClusters.RemoveAll(x => x.IsPointReachable(p));
                    lC = new Cluster(lDist, p);
                    // merge point's "reachable" clusters
                    if (lListAttainableClusters.Count > 0)
                    {
                        lC.AnnexCluster(lListAttainableClusters.Aggregate((c, x) =>
                                                                          c = Cluster.MergeClusters(x, c)));
                    }
                    lListClusters.Add(lC);
                    lListAttainableClusters = null;
                    lC = null;
                } // of loop over candidate points


                clusters = new List <Point3DCollection>();

                for (int i = 0; i < lListClusters.Count; i++)
                {
                    Point3DCollection pl = new Point3DCollection();
                    foreach (var v in lListClusters[i].ListPoints)
                    {
                        pl.Add(new Point3D(v.X, v.Y, v.Z));
                    }
                    clusters.Add(pl);
                    // EntityTools .PointCollections .WriteDelcamPICFile (new List<Point3DCollection> () {pl}, @"C:\temp\a" + i );
                }
            }
            catch
            {
                clusters = null;
            }

            //KneeInnovation3D .EntityTools.PointCollections.WriteDelcamPicFile(new List<Point3DCollection>() { clusters[0] }, @"C:\temp\a.pic");
            //KneeInnovation3D.EntityTools.PointCollections.WriteDelcamPicFile(new List<Point3DCollection>() { clusters[1] }, @"C:\temp\b.pic");
            //KneeInnovation3D.EntityTools.PointCollections.WriteDelcamPicFile(new List<Point3DCollection>() { clusters[2] }, @"C:\temp\c.pic");
        }