예제 #1
0
파일: Cluster.cs 프로젝트: herbfunk/Funky
        public CacheObject GetNearestObjectToCenteroid()
        {
            double    minimumDistance   = 0.0;
            int       nearestPointIndex = -1;
            GridPoint centeroid         = Midpoint;

            foreach (GridPoint p in ListPoints)
            {
                double distance = GridPoint.GetDistanceBetweenPoints(p, centeroid);

                if (ListPoints.IndexOf(p) == 0)
                {
                    minimumDistance   = distance;
                    nearestPointIndex = ListPoints.IndexOf(p);
                }
                else
                {
                    if (minimumDistance > distance)
                    {
                        minimumDistance   = distance;
                        nearestPointIndex = ListPoints.IndexOf(p);
                    }
                }
            }

            return(ListCacheObjects[nearestPointIndex]);
        }
예제 #2
0
파일: Cluster.cs 프로젝트: herbfunk/Funky
        }          // of IsPointReachable()

        /// <summary>
        /// Incorporates all points from given cluster to this cluster
        /// </summary>
        /// <param name="p_Cluster"></param>
        /// <returns>true always</returns>
        public virtual bool AnnexCluster(cluster p_Cluster)
        {
            MidPoint += p_Cluster.MidPoint;
            ListPoints.AddRange(p_Cluster.ListPoints);
            RAGUIDS.AddRange(p_Cluster.RAGUIDS);
            return(true);
        }          // of AnnexCluster()
예제 #3
0
        }  // of IsPointReachable()

        public bool AnnexCluster(Cluster pCluster)
        {
            bool lBSuccess = true;

            ListPoints.AddRange(pCluster.ListPoints);

            return(lBSuccess);
        }  // of AnnexCluster()
예제 #4
0
        public void UpdateUnitPointLists(ClusterConditions CC)
        {
            if (ListUnits.Count == 0)
            {
                return;
            }

            List <int> RemovalIndexList = new List <int>();
            bool       changeOccured    = false;

            foreach (var item in ListUnits)
            {
                if (!item.IsStillValid() || (!CC.IgnoreNonTargetable || !item.IsTargetable.Value))
                {
                    RemovalIndexList.Add(ListUnits.IndexOf(item));
                    RAGUIDS.Remove(item.RAGUID);
                    changeOccured = true;
                }
            }


            if (changeOccured)
            {
                RemovalIndexList.Sort();
                RemovalIndexList.Reverse();
                foreach (var item in RemovalIndexList)
                {
                    //ListCacheObjects.RemoveAt(item);
                    ListUnits.RemoveAt(item);
                    ListPoints.RemoveAt(item);
                }

                if (ListUnits.Count > 1)
                {
                    //Logger.DBLog.InfoFormat("Updating Cluster");

                    //Reset Vars
                    Info = new ClusterInfo();

                    NearestMonsterDistance = -1f;

                    //Set default using First Unit
                    CacheUnit firstUnit = ListUnits[0];
                    MidPoint = firstUnit.PointPosition;
                    RAGUIDS.Add(firstUnit.RAGUID);
                    NearestMonsterDistance = firstUnit.CentreDistance;
                    Info.Update(ref firstUnit);


                    //Iterate thru the remaining
                    for (int i = 1; i < ListUnits.Count - 1; i++)
                    {
                        this.UpdateProperties(ListUnits[i]);
                    }
                }
            }
        }
예제 #5
0
 private void ClearListPoints_Click(object sender, EventArgs e)
 {
     if (ListPoints.Count > 0 && ListPointDesc.Count > 0)
     {
         ListPoints.Clear();
         ListPointDesc.Clear();
         setListBoxPoints();
     }
 }
예제 #6
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()
예제 #7
0
 private void DeleteSelectPoint_Click(object sender, EventArgs e)
 {
     if (listBoxPoints.Items.Count > 0 && listBoxPoints.SelectedIndex > -1)
     {
         ListPoints.RemoveAt(listBoxPoints.SelectedIndex);
         ListPointDesc.RemoveAt(listBoxPoints.SelectedIndex);
         setListBoxPoints();
     }
     else if (listBoxPoints.Items.Count > 0 && listBoxPoints.SelectedIndex == -1)
     {
         ListPoints.RemoveAt(0);
         ListPointDesc.RemoveAt(0);
         setListBoxPoints();
     }
 }
예제 #8
0
        private void AddPoint_Click(object sender, EventArgs e)
        {
            if (GetPointY.Length > 0 && GetPointX.Length > 0)
            {
                int x = Int32.Parse(GetPointX);
                GetPointX = "";
                int y = Int32.Parse(GetPointY);
                GetPointY = "";
                int[] point = { x, y };

                ListPoints.Add(point);
                ListPointDesc.Add($"Вершина с координатой: {x}; {y}");

                setListBoxPoints();
            }
        }
예제 #9
0
파일: Cluster.cs 프로젝트: herbfunk/Funky
        /// <summary>
        /// Adds point to this cluster only if it is "reachable"
        /// (if point is inside a circle of radius Dist of any cluster's points )
        /// </summary>
        /// <returns>false if point can't be added (that is either already in cluster
        /// or it is unreachable from any of the cluster's points)</returns>
        internal virtual bool AddObject(CacheObject obj)
        {
            bool l_bSuccess = true;

            if (!ContainsObject(obj) && IsPointReachable(obj.PointPosition))
            {
                ListCacheObjects.Add(obj);
                ListPoints.Add(obj.PointPosition);
                RAGUIDS.Add(obj.RAGUID);
                MidPoint += obj.PointPosition;
            }
            else
            {
                l_bSuccess = false;
            }

            return(l_bSuccess);
        }          // of AddPoint()
예제 #10
0
        }  // of overloaded constructor

        public Cluster(double pDist, BlPoint pPoint)
            : this(pDist)
        {
            ListPoints.Add(pPoint);
        }  // of overloaded constructor
예제 #11
0
파일: Cluster.cs 프로젝트: herbfunk/Funky
        }          // of overloaded constructor

        public cluster(double p_Dist, CacheObject obj)
            : this(p_Dist)
        {
            ListPoints.Add(obj.PointPosition);
            MidPoint = obj.PointPosition;
        }          // of overloaded constructor