示例#1
0
        private void ProcessUnassignedPoints()
        {
            DateTime debugStart         = DateTime.Now;
            DateTime previousDebugStart = DateTime.Now;

            for (int i = 0; i < unassigned.Count; i++)
            {
                if (CProjectData.backgroundWorker.CancellationPending)
                {
                    return;
                }
                CDebug.Progress(i, unassigned.Count, 100000, ref previousDebugStart, debugStart, "ProcessUnassignedPoints");

                if (CProjectData.backgroundWorker.CancellationPending)
                {
                    return;
                }

                Vector3 point = unassigned[i];
                unassignedArray.AddPointInField(point);
                if (CTreeManager.GetDetectMethod() == EDetectionMethod.Balls)
                {
                    ballArray.AddPointInField(point);
                }
            }

            if (CTreeManager.GetDetectMethod() == EDetectionMethod.Balls)
            {
                //unassignedArray.FillArray(); //doesnt make sense

                const bool filterBasedOnheight = false;
                //balls are expected to be in this height above ground
                if (filterBasedOnheight)
                {
                    ballArray.FilterPointsAtHeight(1.8f, 2.7f);
                }

                //add filtered points to detail array
                List <Vector3> filteredPoints = ballArray.GetPoints();
                foreach (Vector3 point in filteredPoints)
                {
                    if (CProjectData.backgroundWorker.CancellationPending)
                    {
                        return;
                    }

                    ballDetailArray.AddPointInField(point);
                }

                List <CBallField> ballFields = new List <CBallField>();

                //vege.Sort((b, a) => a.Z.CompareTo(b.Z)); //sort descending by height

                List <CBallField> sortedFields = ballDetailArray.fields;
                //sortedFields.Sort((a, b) => a.indexInField.Item1.CompareTo(b.indexInField.Item1));
                //sortedFields.Sort((a, b) => a.indexInField.Item2.CompareTo(b.indexInField.Item2));

                sortedFields.OrderBy(a => a.indexInField.Item1).ThenBy(a => a.indexInField.Item2);

                //List<Vector3> mainPoints = new List<Vector3>();

                debugStart         = DateTime.Now;
                previousDebugStart = DateTime.Now;
                //process
                for (int i = 0; i < sortedFields.Count; i++)
                {
                    if (CProjectData.backgroundWorker.CancellationPending)
                    {
                        return;
                    }
                    CDebug.Progress(i, sortedFields.Count, 100000, ref previousDebugStart, debugStart, "Detecting balls");

                    CBallField field = (CBallField)sortedFields[i];
                    field.Detect();
                    if (field.ball != null && field.ball.isValid)
                    {
                        ballFields.Add(field);
                        ballsMainPoints.AddRange(field.ball.GetMainPoints(true));

                        ballsCenters.Add(field.ball.center);
                        ballsCenters.AddRange(CUtils.GetPointCross(field.ball.center));
                        //return;
                        ballsSurface.AddRange(field.ball.GetSurfacePoints());
                    }
                }

                foreach (CBallField field in ballFields)
                {
                    ballPoints.AddRange(field.points);
                }
            }
        }