/// <summary> /// Returns a material assigned to this tree /// </summary> public static Material GetTreeMaterial(CTree pTree) { int selectedIndex = pTree.treeIndex; List <CTree> neighbourTrees = CProjectData.Points.treeNormalArray.GetTreesInMaxStepsFrom(pTree.Center, 5); List <Material> assignedMaterials = new List <Material>(); foreach (CTree tree in neighbourTrees) { if (tree.Equals(pTree)) { continue; } assignedMaterials.Add(tree.assignedMaterial); } Material selectedMaterial = GetTreeMaterial(selectedIndex); for (int i = 0; i < materialSet[EMaterial.Tree].Count; i++) { selectedMaterial = GetTreeMaterial(selectedIndex + i); if (!assignedMaterials.Contains(selectedMaterial)) { return(selectedMaterial); } } //CDebug.Warning("No material left to assign. it will be same as neighbour"); return(selectedMaterial); }
public static void ExportTile() { return; if (CTreeManager.Trees.Count == 0) { CDebug.Warning($"CDartTxt: no output created on tile {CProgramStarter.currentTileIndex}"); return; } DateTime start = DateTime.Now; DateTime lastDebug = DateTime.Now; StringBuilder output = new StringBuilder(HEADER_LINE + newLine); for (int i = 0; i < CTreeManager.Trees.Count; i++) { CDebug.Progress(i, CTreeManager.Trees.Count, DEBUG_FREQUENCY, ref lastDebug, start, "Export dart (trees)"); CTree tree = CTreeManager.Trees[i]; string line = GetLine(tree); if (line != null) { output.Append(line + newLine); } } //CDebug.WriteLine(output); WriteToFile(output.ToString()); }
public override void Read(BinaryReader file, uint size) { base.Read(file, size); CDynamicInt count = new CDynamicInt(cr2w); count.Read(file, 1); for (int j = 0; j < count.val; j++) { CArray currenttreebundle = new CArray(cr2w); CHandle treetype = new CHandle(cr2w); treetype.Read(file, 4); currenttreebundle.Name = treetype.Handle; CArray currentTrees = new CArray(cr2w); currentTrees.AddVariable(treetype); CDynamicInt treecount = new CDynamicInt(cr2w); treecount.Read(file, 1); for (int i = 0; i < treecount.val; i++) { CTree tree = new CTree(cr2w); tree.Read(file, 29); currentTrees.AddVariable(tree); } currenttreebundle.AddVariable(currentTrees); Trees.AddVariable(currenttreebundle); } file.BaseStream.Seek(1, SeekOrigin.Current); }
/// <summary> /// Returns true if tree was added /// </summary> public bool AddDetectedTree(CTree pTree, bool pIsPeak) { //if tree is not peak, dont set IsPeak to false, could be a peak from previous tree if (pIsPeak) { IsPeak = true; } if (this.indexInField.Item1 == 171 && this.indexInField.Item1 == 144) { CDebug.WriteLine(); } if (!DetectedTrees.Contains(pTree)) { if (IsDetail && DetectedTrees.Count > 0) { CDebug.Error($"Adding tree to detail field {this} where tree {DetectedTrees[0]} altready is"); } DetectedTrees.Add(pTree); pTree.AddField(this); return(true); } return(false); }
public void Do(string s) { try { ResetAffected(); InitAllSeqs(); NewTrans(); ParseAndExec(s); Commit(); UpdateAffected(); /*/win remove for non-windowed version * if (txt != null && txt.Frm != null) txt.Frm.CmdShowCursor(); * if (!log.Ended()) MsgLn(""); * // remove for non-windowed version */ } catch (Exception e) { grouping = 0; cts = null; swallowing = false; root.nxt = null; root.sub = null; tail = root; InitAllSeqs(); SyncFormToTextAll(); Err(e.Message); if (!(e is ssException)) { throw e; } } }
/// <summary> /// format: type(0) pX pY pZ(0) sX sY sZ rX(0) r(Y) r(Z) /// </summary> private static string GetLine(CTree pTree) { string output = "0 "; ObjParser.Obj treeObj = pTree.assignedRefTreeObj; if (treeObj == null) { return(null); } //get coordinates relative to botleft corner of the area Vector3 treePos = GetMovedPoint(pTree.Center); //in final file Z = height, but here Y = height //changed! output += $"{treePos.X} {treePos.Y} 0 "; //scale will be same at all axix output += $"{treeObj.Scale.X} {treeObj.Scale.Y} {treeObj.Scale.Z} "; //rotation output += $"0 0 {treeObj.Rotation.Y} "; //to know which tree in OBJ is this one bool debugObjName = true; string objName = debugObjName ? " " + pTree.GetObjName() : ""; output += pTree.assignedRefTree.RefTreeTypeName + objName; return(output); }
public void Test() { CTree <int> tree = new CTree <int>(1, 10); var parent2 = tree.AddNode(2, tree.Root); var parent3 = tree.AddNode(3, tree.Root); tree.AddNode(4, parent2); tree.AddNode(5, parent2); tree.AddNode(6, parent3); tree.AddNode(7, parent3); tree.AddNode(8, parent3); _testOutputHelper.WriteLine($"树的节点数量:{tree.Count}"); _testOutputHelper.WriteLine($"树的根节点:{tree.Root.Data}"); _testOutputHelper.WriteLine(""); _testOutputHelper.WriteLine("树的全部节点:"); foreach (var node in tree.GetChilds()) { _testOutputHelper.WriteLine($"节点数据:{node.Data},父节点index:{node.ParentIndex}"); } _testOutputHelper.WriteLine(""); _testOutputHelper.WriteLine($"节点数据为“{parent2.Data}”的子节点为:"); foreach (var node in tree.GetChilds(parent2)) { _testOutputHelper.WriteLine($"节点数据:{node.Data},父节点index:{node.ParentIndex}"); } _testOutputHelper.WriteLine(""); _testOutputHelper.WriteLine($"节点数据为“{parent3.Data}”的子节点为:"); foreach (var node in tree.GetChilds(parent3)) { _testOutputHelper.WriteLine($"节点数据:{node.Data},父节点index:{node.ParentIndex}"); } }
/// <inheritdoc /> public CProcessorState(CTree currentTree, CHeaderFileParser parser, CProcessorStateValues globalValues) { CurrentTree = currentTree; Parser = parser; GlobalValues = globalValues; Values = new CProcessorStateValues(); }
/// <summary> /// Add all (valid/invalid) tree points to the output and main output /// </summary> private static void AddTreePointsTo(ref StringBuilder pOutput, bool pValid, ref DateTime start) { string res; DateTime lastDebug = DateTime.Now; List <CTree> trees = pValid ? CTreeManager.Trees : CTreeManager.InvalidTrees; for (int i = 0; i < trees.Count; i++) { if (CProjectData.backgroundWorker.CancellationPending) { return; } CDebug.Progress(i, trees.Count, DEBUG_FREQUENCY, ref lastDebug, start, "Export las (trees)"); CTree t = trees[i]; //without this there are always invalid trees in the main file at buffer zones if (t.isAtBufferZone) { continue; } res = GetTreeLines(t); //already ends with "newLine" pOutput.Append(res); } //mainOutput.Append(pOutput); }
public static void MarkAsNotTree(CTree pTree) { pTree.notTree = true; //to remove references from arrays DeleteTree(pTree); NotTrees.Add(pTree); }
public CBranch(CTree pTree, int pAngleFrom, int pAngleTo) { tree = pTree; furthestPoint = tree.peak.Center; angleFrom = pAngleFrom; angleTo = pAngleTo; }
void ParseAndExec(string s) { if (swallowing) { if (s == ".") { swallowing = false; if (grouping == 0) { xCmd(root); } } else { stomach.s = stomach.s + Unescape(s) + edDot.txt.Eoln; } } else { scn.Init(s, false); pChar(); if (grouping == 0) { root.nxt = null; root.sub = null; tail = root; } pCmd(); if (grouping == 0) { xCmd(root); } } }
public TreeDlg(CTree p_owner) { InitializeComponent(); Title = "选择"; _owner = p_owner; Content = _owner.Tv; }
public static void DeleteTree(CTree pTree) { if (pTree.treeIndex == 169) { bool i = true; } if (!Trees.Contains(pTree)) { CDebug.Error("Trees dont contain " + pTree); return; } pTree.peakDetailField.RemoveTree(pTree); pTree.peakNormalField.RemoveTree(pTree); foreach (CTreeField field in pTree.detailFields) { field.RemoveTree(pTree); } foreach (CTreeField field in pTree.normalFields) { field.RemoveTree(pTree); } //shouldnt be neccessary //pTree.peakDetailField.RemoveTree(pTree); //pTree.peakNormalField.RemoveTree(pTree); Trees.Remove(pTree); //if(!pTree.treeDetailField.GetDetectedTrees().Contains(pTree)) //{ // CDebug.Error("element " + pTree.treeDetailField + " doesnt contain " + pTree); // return; //} }
/// <summary> /// Returns ratio of tree heights /// </summary> public static float GetScaleRatioTo(CTree pTree, CTree pRefTree) { float treeHeight = pTree.GetTreeHeight(); float refTreeHeight = pRefTree.GetTreeHeight(); float heightRatio = treeHeight / refTreeHeight; return(heightRatio); }
public override CType ToCType(Translator translator) { CTree tree = CreateCType(); foreach (Member member in _members) { tree.Add(member.ToCType(translator), member.Name, member.TopOffset); } return(tree); }
/// <summary> /// If not-tree is very close to some tree then it is probably part of that tree. /// Not-tree will be merged into the closest one. /// </summary> public static void TryMergeNotTrees() { IsMerging = true; DateTime mergeStartTime = DateTime.Now; CDebug.WriteLine("TryMergeNotTrees"); //sort in descending order - trees will be processed from the end NotTrees.Sort((b, a) => b.peak.Center.Z.CompareTo(a.peak.Center.Z)); //TODO: CHECK!!! THIS IS NOT DESCENDING ORDER??? int treeCountBeforeMerge = NotTrees.Count; for (int i = NotTrees.Count - 1; i >= 0; i--) { CTree notTree = NotTrees[i]; //if(notTree.Equals(335)) // CDebug.WriteLine(""); //just debug //List<CTree> closeTrees2 = CProjectData.Points.treeNormalArray. // GetTreesInMaxStepsFrom(notTree.peak.Center, 1); List <CTree> closeTrees = new List <CTree>(); //fisrt try to get a tree on the same detail field CTree t = CProjectData.Points.treeDetailArray. GetFieldContainingPoint(notTree.peak.Center).GetSingleDetectedTree(); if (t != null) { closeTrees.Add(t); } //if no tree is on the same field get some in close distance if (closeTrees.Count == 0) { closeTrees = CProjectData.Points.treeDetailArray. GetTreesInMaxStepsFrom(notTree.peak.Center, 2); } //merge not-tree with the closest tree but only if it is higher. //if not then it is probably some noise above the regular tree if (closeTrees.Count > 0 && closeTrees[0].GetTreeHeight() > notTree.GetTreeHeight() && !notTree.IsLocalMaximum()) { closeTrees[0].MergeWith(notTree); NotTrees.RemoveAt(i); } } IsMerging = false; CDebug.Duration("Not-trees merge", mergeStartTime); CDebug.Count("Number of not-trees merged", treeCountBeforeMerge - Trees.Count); }
/// <summary> /// Merges the lower tree into the higher one. /// First calculates which one is lower. /// Then does the treevalidation. /// </summary> private static CTree MergeTrees(ref CTree pTree1, ref CTree pTree2, bool pValidateRestrictive) { CTree higherTree = pTree1.peak.maxHeight.Z >= pTree2.peak.maxHeight.Z ? pTree1 : pTree2; CTree lowerTree = pTree1.peak.maxHeight.Z < pTree2.peak.maxHeight.Z ? pTree1 : pTree2; MergeTrees(higherTree, lowerTree); higherTree.Validate(pValidateRestrictive); return(higherTree); }
public void Parse() { Root = new CTree(null, null); var parentTree = Root; var globalValues = new CProcessorStateValues(); CProcessorState state = null; CProcessorBase currentProcessor = null; using (var stream = File.OpenText()) { while (!stream.EndOfStream) { var line = stream.ReadLine(); while (!string.IsNullOrWhiteSpace(line)) { if (currentProcessor == null) { foreach (var cProcessor in Processors) { if (cProcessor.CanParse(line)) { state = new CProcessorState(parentTree, this, globalValues); currentProcessor = cProcessor; break; } } } if (currentProcessor != null) { var result = currentProcessor.Parse(line, state); state.CurrentTree = result.CurrentTree; if (result.EndOfProcess) { state = null; currentProcessor = null; } parentTree = result.CurrentTree; line = result.UnParsed; } else { // Skip Line break; } } } } }
/// <summary> /// First finds most defined branch of pOtherTree. /// Then finds the branch on this reference tree which best matches found most defined branch. /// Returns index offset between these branches. /// </summary> private static int GetIndexOffsetBetweenBestMatchBranches(CRefTree pRefTree, CTree pOtherTree) { CBranch mostDefinedBranch = pOtherTree.GetMostDefinedBranch(); CBranch bestMatchBranch = GetBestMatchBranch(pRefTree, mostDefinedBranch); int indexOfMostDefined = pOtherTree.Branches.IndexOf(mostDefinedBranch); int indexOfBestMatch = pRefTree.Branches.IndexOf(bestMatchBranch); int indexOffset = indexOfBestMatch - indexOfMostDefined; return(indexOffset); }
public static float GetTreeRadius(CTree pTree) { float radius = 0; try { radius = GetTreeRadius(pTree.GetTreeHeight()); } catch (Exception) { } return(radius); }
/// <summary> /// Calculates minimal peak distance for given trees to be merged /// </summary> public static float GetMinPeakDistance(CTree pTree1, CTree pTree2) { float treeHeight = Math.Max(pTree1.GetTreeHeight(), pTree2.GetTreeHeight()); float ratio = treeHeight / AVERAGE_TREE_HEIGHT; if (ratio < 1) { return(CParameterSetter.treeExtent); } const float EXTENT_VALUE_STEP = 1.5f; return(GetMinPeakDistance(1) + (ratio - 1) * EXTENT_VALUE_STEP); }
/// <summary> /// Generates point feature representing position of the tree. /// Attributes: /// id, X, Y, height, DBH, AGB, type /// </summary> private static Feature GetTreePosition(CTree pTree, ref StringBuilder pString) { CVector3D globalTreepos = CUtils.GetGlobalPosition(pTree.peak.Center); IPoint myPoint = factory.CreatePoint(new Coordinate(globalTreepos.X, globalTreepos.Y)); AttributesTable attributesTable = new AttributesTable(); attributesTable.Add(ATTR_ID, pTree.treeIndex); pString.Append(pTree.treeIndex + SEP); shpInfoMain.Append(pTree.treeIndex + SEP); attributesTable.Add(ATTR_X, globalTreepos.X.ToString(NUM_FORMAT)); attributesTable.Add(ATTR_Y, globalTreepos.Y.ToString(NUM_FORMAT)); pString.Append(globalTreepos.X.ToString(NUM_FORMAT) + SEP); shpInfoMain.Append(globalTreepos.X.ToString(NUM_FORMAT) + SEP); pString.Append(globalTreepos.Y.ToString(NUM_FORMAT) + SEP); shpInfoMain.Append(globalTreepos.Y.ToString(NUM_FORMAT) + SEP); float treeHeight = pTree.GetTreeHeight(); attributesTable.Add(ATTR_HEIGHT, treeHeight.ToString(NUM_FORMAT)); pString.Append(treeHeight.ToString(NUM_FORMAT) + SEP); shpInfoMain.Append(treeHeight.ToString(NUM_FORMAT) + SEP); if (CParameterSetter.GetBoolSettings(ESettings.calculateDBH)) { double stemDiameter = CBiomassController.GetTreeStemDiameter(treeHeight); attributesTable.Add(ATTR_DBG, stemDiameter.ToString(NUM_FORMAT)); pString.Append(stemDiameter.ToString(NUM_FORMAT) + SEP); shpInfoMain.Append(stemDiameter.ToString(NUM_FORMAT) + SEP); if (CParameterSetter.GetBoolSettings(ESettings.calculateAGB)) { double biomass = CBiomassController.GetTreeBiomass(stemDiameter, treeHeight); attributesTable.Add(ATTR_AGB, biomass.ToString(NUM_FORMAT)); pString.Append(biomass.ToString(NUM_FORMAT) + SEP); shpInfoMain.Append(biomass.ToString(NUM_FORMAT) + SEP); } } //251 - Finalizace produktu //attributesTable.Add(ATTR_TYPE, pTree.assignedRefTree.RefTreeTypeName); //pString.Append(pTree.assignedRefTree.RefTreeTypeName + SEP); Feature feature = new Feature(myPoint, attributesTable); pString.AppendLine(); shpInfoMain.AppendLine(); return(feature); }
CTree PopCmd() { if (cts != null) { CTree t = cts.t; cts = cts.nxt; grouping--; return(t); } else { throw new ssException("unmatched '}'"); } }
/// <summary> /// Deletes the lower tree and merges it into the higher one. /// important! delete has to be done before the merge to prevent deadlock by adding points to new tree during merging /// </summary> public static void MergeTrees(CTree pHigherTree, CTree pLowerTree) { float higherTreeZ = pHigherTree.peak.maxHeight.Z; float lowerTreeZ = pLowerTree.peak.minHeight.Z; if (lowerTreeZ > higherTreeZ) { CDebug.Error("given pHigherTree is lower!"); return; } DeleteTree(pLowerTree); pHigherTree.MergeWith(pLowerTree); }
public static void AddPoint(Vector3 pPoint, int pPointIndex) { //index < 0 = the point was re-added during the tree merging process //(where the index is not passed) - use the last index if (pPointIndex < 0) { pPointIndex = currentPointIndex; } currentPointIndex = pPointIndex; ProcessDebug(pPoint, pPointIndex); pointCounter++; CProjectData.Points.vegeArray.AddPointInField(pPoint); CProjectData.Points.vegeDetailArray.AddPointInField(pPoint); List <CTree> possibleTrees = GetPossibleTreesFor(pPoint, EPossibleTreesMethod.ClosestHigher, false); CTree selectedTree = SelectBestPossibleTree(possibleTrees, pPoint, true); /*if(selectedTree == null && detectMethod == EDetectionMethod.AddFactor2D) * { * CTreeField f = CProjectData.Points.treeDetailArray.GetFieldContainingPoint(pPoint); * List<CTree> treesInHood = f.GetDetectedTreesFromNeighbourhood(); * foreach(CTree tree in treesInHood) * { * selectedTree = tree; * break; * } * }*/ if (selectedTree != null) { selectedTree.AddPoint(pPoint, pPointIndex); } else if (CProjectData.Points.treeDetailArray.GetFieldContainingPoint(pPoint).DetectedTrees.Count > 0) { //new tree cant be created on field where another tree was already detected - shouldnt happen CDebug.Error("trying to create tree on a field where a tree already is"); return; } else { CreateNewTree(pPoint); } }
/// <summary> /// Export file using data from currently loaded trees /// </summary> public static void ExportCurrent() { if (!exportShape) { return; } DateTime start = DateTime.Now; DateTime lastDebug = DateTime.Now; List <IFeature> treePositions = new List <IFeature>(); List <IFeature> treeBorders = new List <IFeature>(); StringBuilder shpInfo = new StringBuilder(); shpInfo.Append(ATTR_ID + SEP); shpInfo.Append(ATTR_X + SEP); shpInfo.Append(ATTR_Y + SEP); //shpInfo.Append(ATTR_AREA + SEP); shpInfo.Append(ATTR_HEIGHT + SEP); shpInfo.Append(ATTR_DBG + SEP); shpInfo.Append(ATTR_AGB); shpInfo.AppendLine(); for (int i = 0; i < CTreeManager.Trees.Count; i++) { CDebug.Progress(i, CTreeManager.Trees.Count, DEBUG_FREQUENCY, ref lastDebug, start, "Export shp (trees)"); CTree tree = CTreeManager.Trees[i]; //tree positions Feature f = GetTreePosition(tree, ref shpInfo); treePositions.Add(f); treePositionsAll.Add(f); //tree borders f = GetTreeBorder(tree); treeBorders.Add(f); treeAreasAll.Add(f); } CLasExporter.WriteToFile(shpInfo, CProjectData.outputTileSubfolder + "shape_info.csv"); if (exportShapeTreePos) { ExportFeatures(treePositions, TREE_POS_FILE, false); } if (exportShapeTreeAreas) { ExportFeatures(treeBorders, TREE_BORDER_FILE, false); } }
/// <summary> /// Calculates factor, showing how much does given point fit to this branch. /// Range = 0-1. 1 = best fit. /// pMerging = uses criterium of pUseDistToPeakDiff (viz GetAddPointFactorInRefTo) /// </summary> public float GetAddPointFactor(Vector3 pPoint, bool pSameBranch, CTree pTreeToMerge = null) { float bestFactor = 0; bool merging = pTreeToMerge != null; Vector3 refPoint1 = furthestPoint; float refPoint1Factor = GetAddPointFactorInRefTo(pPoint, refPoint1, pSameBranch, merging, pTreeToMerge); bestFactor = refPoint1Factor; if (bestFactor > .99f) { return(bestFactor); } if (merging) { Vector3 closestHigher = GetClosestHigherTo(pTreeToMerge.peak.Center); float distToHigher = Vector3.Distance(pPoint, closestHigher); const float maxDistToHigher = 0.5f; float distToHigherFactor = maxDistToHigher / distToHigher; if (distToHigher < maxDistToHigher) { return(1); } float closestHigherFactor = GetAddPointFactorInRefTo(pPoint, closestHigher, pSameBranch, merging, pTreeToMerge); closestHigherFactor = Math.Max(closestHigherFactor, distToHigherFactor); bestFactor = Math.Max(bestFactor, closestHigherFactor); if (bestFactor > .99f) { return(bestFactor); } Vector3?closestLower = GetClosestLowerTo(pTreeToMerge.peak.Center); if (closestLower != null) { float closestLowerFactor = GetAddPointFactorInRefTo(pPoint, (Vector3)closestLower, pSameBranch, merging, pTreeToMerge); bestFactor = Math.Max(bestFactor, closestLowerFactor); if (bestFactor > .99f) { return(bestFactor); } } } return(bestFactor); }
/// <summary> /// Add new tree to tree arrays /// </summary> public void OnTreeCreated(CTree pNewTree, Vector3 pFirstPoint) { CVegeField vegeField = vegeDetailArray.GetFieldContainingPoint(pFirstPoint); CTreeField treeDetailField = treeDetailArray.GetFieldContainingPoint(pFirstPoint); CTreeField treeNormalField = treeNormalArray.GetFieldContainingPoint(pFirstPoint); if (vegeField == null) { CDebug.Error($"Cant create tree. point {pFirstPoint} is OOB!"); return; } treeDetailField.AddDetectedTree(pNewTree, true); treeNormalField.AddDetectedTree(pNewTree, true); pNewTree.peakDetailField = treeDetailField; pNewTree.peakNormalField = treeNormalField; }
/// <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 CTree(string[] tokens, int start, int end) { if (start > end) { throw new Exception("Start index cannot be greater than the end index."); } int i = start; Node preopt = null; while (i <= end) { string token = tokens[i]; Node tempNode; bool subtree = false; if ("(".Equals(token)) { int closeindex = i + 1; int bkpair = 1; for (int j = i + 1; j <= end; j++) { if ("(".Equals(tokens[j])) { bkpair++; } else if (")".Equals(tokens[j])) { bkpair--; } if (bkpair == 0) { closeindex = j; break; } } if (bkpair != 0) { throw new Exception("Invalid bracket pair."); } tempNode = new CTree(tokens, i + 1, closeindex - 1).Root; subtree = true; token = tempNode.Token; i = closeindex + 1; } else { tempNode = new Node(token); i++; } if (Operators.Keys.Contains(token) && !subtree) { if (preopt == null) { tempNode.Left = Root; Root = tempNode; preopt = tempNode; } else { Node prenode = Root; if (Operators[prenode.Token] < Operators[token]) { tempNode.Left = prenode.Right; prenode.Right = tempNode; } else //if (Operators[prenode.Token] > Operators[token]) { tempNode.Left = prenode; Root = tempNode; } /** else { while (prenode.Right != null && prenode.Right.Right != null && Operators[prenode.Right.Token] > Operators[token]) { prenode = prenode.Right; } tempNode.Left = prenode.Right; prenode.Right = tempNode; } * **/ } preopt = tempNode; } else { if (preopt == null) { Root = tempNode; } else if (preopt.Left == null) { preopt.Left = tempNode; } else { preopt.Right = tempNode; } } } }