/// <summary> /// Add points of given class to the partitions /// </summary> public static void AddPoints(EClass pClass) { for (int x = 0; x < CProjectData.Points.groundArray.arrayXRange; x += partitionStepSize) { for (int y = 0; y < CProjectData.Points.groundArray.arrayYRange; y += partitionStepSize) { List <Vector3> points = new List <Vector3>(); for (int _x = x; _x < x + partitionStepSize; _x++) { for (int _y = y; _y < y + partitionStepSize; _y++) { CField element = CProjectData.Points.GetField(pClass, _x, _y); //CField element = CProjectData.Points.groundArray.GetField(_x, _y); if (element != null) { points.AddRange(element.points); } } } Obj pointsObj = new Obj(GetPointsObjName(pClass)); CObjExporter.AddPointsToObj(ref pointsObj, points); pointsObj.UseMtl = CMaterialManager.GetPointsMaterial(pClass).Name; AddObj(x, y, pointsObj); } } }
/// <summary> /// </summary> private static string GetTreeLines(CTree pTree) { string output = ""; foreach (Vector3 p in pTree.Points) { string color = pTree.isValid ? pTree.assignedMaterial.ToString255() : CMaterialManager.GetInvalidMaterial().ToString255(); //int treeIndex = pTree.isValid ? pTree.assignedRefTree.treeIndex : 0; int treeIndex = pTree.treeIndex; CVector3D globalP = CUtils.GetGlobalPosition(p); output += GetPointLine(globalP, 5, (byte)treeIndex, color) + newLine; } return(output); }
public static void AddTrees(bool pValid) //, bool pFake) { List <Tuple <Tuple <int, int>, CTree> > treesToExport = new List <Tuple <Tuple <int, int>, CTree> >(); bool exportTreeStrucure = CParameterSetter.GetBoolSettings(ESettings.exportTreeStructures); bool exportBoxes = CParameterSetter.GetBoolSettings(ESettings.exportTreeBoxes); if (!exportBoxes && !exportTreeStrucure) { return; } foreach (CTree tree in pValid ? CTreeManager.Trees : CTreeManager.InvalidTrees) { treesToExport.Add(new Tuple <Tuple <int, int>, CTree>(tree.peakNormalField.indexInField, tree)); } //special: add not-trees if (!pValid) { foreach (CTree tree in CTreeManager.NotTrees) { treesToExport.Add(new Tuple <Tuple <int, int>, CTree>(tree.peakNormalField.indexInField, tree)); } } treesToExport.Sort((x, y) => x.Item2.treeIndex.CompareTo(y.Item2.treeIndex)); foreach (Tuple <Tuple <int, int>, CTree> exportTree in treesToExport) { Obj obj = exportTree.Item2.GetObj(exportTreeStrucure, false, exportBoxes); if (!pValid) { obj.UseMtl = CMaterialManager.GetInvalidMaterial().Name; } AddObj(exportTree.Item1, obj); } }
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()); }