Example #1
0
        //TODO: not practical since it can only return CField and the caller
        // has to cast it to more specific type. Find out more general approach?
        //public CField GetFieldContaining(EArray pClass, bool pNormal, Vector3 pPoint)
        //{
        //	switch(pClass)
        //	{
        //		case EArray.Ground:
        //			if(!pNormal)
        //				break;
        //			return groundArray.GetFieldContainingPoint(pPoint);
        //		case EArray.Vege:
        //			if(pNormal)
        //				break;
        //			return vegeDetailArray.GetFieldContainingPoint(pPoint);
        //		case EArray.Tree:
        //			return pNormal ?
        //				treeNormalArray.GetFieldContainingPoint(pPoint) :
        //				treeDetailArray.GetFieldContainingPoint(pPoint);
        //	}
        //	CDebug.Error($"GetFieldContaining() for class {pClass} - {pNormal} not defined");
        //	return null;
        //}

        private void InitArrays()
        {
            unassignedArray = new CUnassignedArray(NORMAL_STEP, false);

            ballArray       = new CBallArray(NORMAL_STEP, false);
            ballDetailArray = new CBallArray(DETAIL_STEP_BALLS, true);

            groundArray   = new CGroundArray(NORMAL_STEP, false);
            buildingArray = new CVegeArray(NORMAL_STEP, false);
            vegeArray     = new CVegeArray(NORMAL_STEP, false);

            vegeDetailArray = new CVegeArray(DETAIL_STEP, true);

            preprocessDetailArray = new CVegeArray(DETAIL_STEP, true);
            preprocessNormalArray = new CVegeArray(NORMAL_STEP, false);

            treeDetailArray = new CTreeArray(DETAIL_STEP, true);
            treeNormalArray = new CTreeArray(NORMAL_STEP, false);

            CObjPartition.Init();
        }
Example #2
0
        private static EProcessResult ProcessTile(string pTilePath, int pTileIndex)
        {
            //has to reinit first for the correct progress output
            CDebug.ReInit();

            DateTime startTime = DateTime.Now;

            currentTileIndex = pTileIndex;


            List <Tuple <EClass, Vector3> > parsedLines;

            if (CRxpParser.IsRxp)
            {
                CRxpInfo rxpInfo = CRxpParser.ParseFile(pTilePath);
                parsedLines = rxpInfo.ParsedLines;
                //for now we expect only one tile in rxp processing
                CProjectData.currentTileHeader = rxpInfo.Header;
                CProjectData.mainHeader        = rxpInfo.Header;
            }
            else
            {
                string[] lines   = CProgramLoader.GetFileLines(pTilePath);
                bool     linesOk = lines != null && lines.Length > 0 && !string.IsNullOrEmpty(lines[0]);
                if (linesOk && CHeaderInfo.HasHeader(lines[0]))
                {
                    //todo: where to init header?
                    CProjectData.currentTileHeader = new CHeaderInfo(lines);
                }
                else
                {
                    const string noHeaderMsg = "Processed tile has no header";
                    CDebug.Error(noHeaderMsg);
                    throw new Exception(noHeaderMsg);
                }
                parsedLines = CProgramLoader.ParseLines(lines, true);
            }

            //has to be called after currentTileHeader is assigned
            CProjectData.ReInit(pTileIndex);             //has to reinit after each tile is processed
            CTreeManager.Reinit();

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

            CProgramLoader.ProcessParsedLines(parsedLines);

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

            CTreeManager.DebugTrees();

            CDebug.Step(EProgramStep.Export3D);
            CObjPartition.ExportPartition("", "tile" + pTileIndex);

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

            //has to be called after ExportPartition where final folder location is determined
            try
            {
                CDebug.Step(EProgramStep.Bitmap);
                CBitmapExporter.Export(pTileIndex);
            }
            catch (Exception e)
            {
                CDebug.Error("exception: " + e.Message);
            }

            CAnalytics.totalDuration = CAnalytics.GetDuration(startTime);
            CDebug.Duration("total time", startTime);

            CDebug.Step(EProgramStep.Dart);
            CDartTxt.ExportTile();

            CDebug.Step(EProgramStep.Shp);
            CShpController.ExportCurrent();

            CDebug.Step(EProgramStep.Las);
            CLasExporter.ExportTile();

            CDebug.Step(EProgramStep.Analytics);
            CAnalytics.Write(true);

            return(EProcessResult.Done);
        }
Example #3
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);
            }
        }