示例#1
0
        public static EProcessResult Start()
        {
            CSequenceController.SetValues();

            DateTime startTime = DateTime.Now;

            CProjectData.Init();
            CTreeManager.Init();
            CAnalytics.Init();

            CDartTxt.Init();
            CLasExporter.Init();
            CBiomassController.Init(
                CParameterSetter.GetStringSettings(ESettings.dbh),
                CParameterSetter.GetStringSettings(ESettings.agb));
            CTreeRadiusCalculator.Init();
            CShpController.Init();
            CReftreeManager.Init();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en");

            //GENERAL
            CProjectData.useMaterial     = true;
            CObjExporter.simplePointsObj = false;

            CMaterialManager.Init();

            string[] workerResult = new string[2];
            workerResult[0] = "this string";
            workerResult[1] = "some other string";
            CProjectData.backgroundWorker.ReportProgress(10, workerResult);

            try
            {
                List <string> tiledFiles = CProgramLoader.GetTiledPreprocessedFilePaths();

                tilesCount = tiledFiles.Count;
                int startTile = CParameterSetter.GetIntSettings(ESettings.startIndex);
                if (startTile < 0 || startTile >= tiledFiles.Count)
                {
                    throw new Exception($"Parameter startTile = {startTile}, tiledFiles.Count = {tiledFiles.Count}");
                }

                for (int i = startTile; i < tiledFiles.Count; i++)
                {
                    string         tiledFilePath = tiledFiles[i];
                    EProcessResult tileProcess   = ProcessTile(tiledFilePath, i);
                    if (CProjectData.backgroundWorker.CancellationPending)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                CDebug.Error(
                    $"{Environment.NewLine}exception: {e.Message} {Environment.NewLine}{Environment.NewLine}" +
                    $"StackTrace: {e.StackTrace}{Environment.NewLine}");
                OnException();
                return(EProcessResult.Exception);
            }

            if (CProjectData.backgroundWorker.CancellationPending)
            {
                CDebug.Step(EProgramStep.Cancelled);
                return(EProcessResult.Cancelled);
            }

            CDebug.Step(EProgramStep.ExportMainFiles);
            //TODO: implement this in super class for all controllers
            //dont create the main file if not needed
            if (tilesCount > 1)
            {
                CDartTxt.ExportMain();
                CLasExporter.ExportMain();
                CShpController.ExportMain();
            }
            CBitmapExporter.ExportMain();

            CDebug.Step(EProgramStep.Done);

            if (CSequenceController.IsLastSequence())
            {
                CSequenceController.OnLastSequenceEnd();
                return(EProcessResult.Done);
            }

            CSequenceController.currentConfigIndex++;
            return(Start());
        }
示例#2
0
        public static void ProcessParsedLines(List <Tuple <EClass, Vector3> > parsedLines)
        {
            CAnalytics.loadedPoints = parsedLines.Count;
            CProjectData.Points.AddPointsFromLines(parsedLines);

            CObjPartition.AddGroundArrayObj();

            if (CParameterSetter.GetBoolSettings(ESettings.exportPoints))
            {
                CObjPartition.AddPoints(EClass.Unassigned);
                CObjPartition.AddPoints(EClass.Ground);
                CObjPartition.AddPoints(EClass.Vege);
                CObjPartition.AddPoints(EClass.Building);
            }

            CDebug.Count("Trees", CTreeManager.Trees.Count);

            CTreeManager.CheckAllTrees();

            CDebug.Step(EProgramStep.ValidateTrees1);
            //dont move invalid trees to invalid list yet, some invalid trees will be merged
            CTreeManager.ValidateTrees(false, false);

            //export before merge
            if (CProjectData.exportBeforeMerge)
            {
                CTreeManager.AssignMaterials();                 //call before export

                CObjPartition.AddTrees(true);
                CObjPartition.AddTrees(false);
                CObjPartition.ExportPartition("_noMerge");
                CObjPartition.Init();
                //CObjPartition.AddArray();
            }

            CAnalytics.firstDetectedTrees = CTreeManager.Trees.Count;

            CDebug.Step(EProgramStep.MergeNotTrees1);
            CTreeManager.TryMergeNotTrees();


            CDebug.Step(EProgramStep.MergeTrees1);
            //try merge all (even valid)
            EDetectionMethod detectionMethod = CTreeManager.GetDetectMethod();

            if ((detectionMethod == EDetectionMethod.AddFactor ||
                 detectionMethod == EDetectionMethod.Detection2D
                 ) &&
                CProjectData.tryMergeTrees)
            {
                CTreeManager.TryMergeAllTrees(false);
            }
            CAnalytics.afterFirstMergedTrees = CTreeManager.Trees.Count;

            //validate restrictive
            bool cathegorize = false;

            if (detectionMethod == EDetectionMethod.Detection2D)
            {
                cathegorize = true;
            }

            CDebug.Step(EProgramStep.ValidateTrees2);
            CTreeManager.ValidateTrees(cathegorize, true);

            CDebug.Step(EProgramStep.MergeTrees2);
            if (detectionMethod == EDetectionMethod.AddFactor)
            {
                //merge only invalid
                if (CProjectData.tryMergeTrees2)
                {
                    CTreeManager.TryMergeAllTrees(true);
                }
            }

            //try merging not-trees again after trees were merged
            CDebug.Step(EProgramStep.MergeNotTrees2);
            CTreeManager.TryMergeNotTrees();

            CDebug.Step(EProgramStep.ValidateTrees3);
            if (detectionMethod == EDetectionMethod.AddFactor)
            {
                //validate restrictive
                //cathegorize invalid trees
                CTreeManager.ValidateTrees(true, true, true);
            }

            //todo: just debug
            //CTreeManager.CheckAllTrees();

            CAnalytics.detectedTrees        = CTreeManager.Trees.Count;
            CAnalytics.invalidTrees         = CTreeManager.InvalidTrees.Count;
            CAnalytics.invalidTreesAtBorder = CTreeManager.GetInvalidTreesAtBorderCount();

            CAnalytics.inputAverageTreeHeight = CTreeManager.AVERAGE_TREE_HEIGHT;
            CAnalytics.averageTreeHeight      = CTreeManager.GetAverageTreeHeight();
            CAnalytics.maxTreeHeight          = CTreeManager.MaxTreeHeight;
            CAnalytics.minTreeHeight          = CTreeManager.GetMinTreeHeight();

            CDebug.Count("Trees", CTreeManager.Trees.Count);
            CDebug.Count("InvalidTrees", CTreeManager.InvalidTrees.Count);
            //CProjectData.array.DebugDetectedTrees();

            CTreeManager.AssignMaterials();

            CDebug.Step(EProgramStep.AssignReftrees);
            CReftreeManager.AssignRefTrees();
            if (CParameterSetter.GetBoolSettings(ESettings.exportRefTrees))            //no reason to export when no refTrees were assigned
            {
                //CRefTreeManager.ExportTrees();
                CObjPartition.AddRefTrees();
            }

            CObjPartition.AddTrees(true);
            if (CParameterSetter.GetBoolSettings(ESettings.exportInvalidTrees))
            {
                CObjPartition.AddTrees(false);
            }
        }