private void FindTerminusForSequence(ref IGSForwardStar FwdStar, int StartNodeId, ref int TerminusPoint, int iInfinityChecker) { if (TerminusPoint > -1) { return; } //iInfinityChecker++; if (iInfinityChecker++ > 5000) { return; } ILongArray iLngArr = FwdStar.get_ToNodes(StartNodeId); int iCnt2 = 0; iCnt2 = iLngArr.Count; IGSLine pGSLine = null; for (int i = 0; i < iCnt2; i++) { int i2 = iLngArr.get_Element(i); bool bIsReversed = FwdStar.GetLine(StartNodeId, i2, ref pGSLine); if (iCnt2 == 1) //this is a terminus/end-line { TerminusPoint = StartNodeId; } FindTerminusForSequence(ref FwdStar, i2, ref TerminusPoint, iInfinityChecker); } }
private bool TraceLines(ref IGSForwardStar FwdStar, int StartNodeId, ref int BranchCount, ref int TracedLinesCount, ref int LoopCount, ref int TerminusCount, ref List<string> FromToLine, ref List<int> FromList, ref List<int> ToList, int iInfinityChecker) { iInfinityChecker++; if (iInfinityChecker > 5000) return false; //(This is a self-calling function.) In this context 5000 downstream lines is like infinity, //so exit gracefully, and avoid probable endless loop. //Possible cause of endless loop? Corrupted data; example, a line with the same from and to point id IVector3D vect = new Vector3DClass(); try { ILongArray iLngArr = FwdStar.get_ToNodes(StartNodeId); //get_ToNodes returns an array of radiated points, not "TO" points in the fabric data model sense int iCnt2 = 0; iCnt2 = iLngArr.Count; if (iCnt2 == 1) TerminusCount++; IGSLine pGSLine = null; for (int i = 0; i < iCnt2; i++) { int i2 = iLngArr.get_Element(i); string sFromTo = StartNodeId.ToString() + "," + i2.ToString(); string sToFrom = i2.ToString() + "," + StartNodeId.ToString(); if (FromToLine.Contains(sFromTo) || FromToLine.Contains(sToFrom)) { if (FromToLine.Contains(sFromTo)) LoopCount++; continue; } if (iCnt2 > 2) BranchCount++; TracedLinesCount++; FromToLine.Add(StartNodeId.ToString() + "," + i2.ToString()); bool bIsReversed = FwdStar.GetLine(StartNodeId, i2, ref pGSLine); if (bIsReversed) { FromList.Add(-StartNodeId); ToList.Add(-i2); vect.PolarSet(pGSLine.Bearing + Math.PI, 0, pGSLine.Distance); //Azimuth of IVector3D is north azimuth radians zero degrees north } else { FromList.Add(StartNodeId); ToList.Add(i2); vect.PolarSet(pGSLine.Bearing, 0, pGSLine.Distance); //Azimuth of IVector3D is north azimuth radians zero degrees north } if (!TraceLines(ref FwdStar, i2, ref BranchCount, ref TracedLinesCount,ref LoopCount, ref TerminusCount, ref FromToLine,ref FromList, ref ToList, iInfinityChecker)) return false; } return true; } catch { return false; } }
private bool TraceLines(ref IGSForwardStar FwdStar, int StartNodeId, ref int BranchCount, ref int TracedLinesCount, ref int LoopCount, ref int TerminusCount, ref List <string> FromToLine, ref List <int> FromList, ref List <int> ToList, int iInfinityChecker) { iInfinityChecker++; if (iInfinityChecker > 5000) { return(false); } //(This is a self-calling function.) In this context 5000 downstream lines is like infinity, //so exit gracefully, and avoid probable endless loop. //Possible cause of endless loop? Corrupted data; example, a line with the same from and to point id IVector3D vect = new Vector3DClass(); try { ILongArray iLngArr = FwdStar.get_ToNodes(StartNodeId); //get_ToNodes returns an array of radiated points, not "TO" points in the fabric data model sense int iCnt2 = 0; iCnt2 = iLngArr.Count; if (iCnt2 == 1) { TerminusCount++; } IGSLine pGSLine = null; for (int i = 0; i < iCnt2; i++) { int i2 = iLngArr.get_Element(i); string sFromTo = StartNodeId.ToString() + "," + i2.ToString(); string sToFrom = i2.ToString() + "," + StartNodeId.ToString(); if (FromToLine.Contains(sFromTo) || FromToLine.Contains(sToFrom)) { if (FromToLine.Contains(sFromTo)) { LoopCount++; } continue; } if (iCnt2 > 2) { BranchCount++; } TracedLinesCount++; FromToLine.Add(StartNodeId.ToString() + "," + i2.ToString()); bool bIsReversed = FwdStar.GetLine(StartNodeId, i2, ref pGSLine); if (bIsReversed) { FromList.Add(-StartNodeId); ToList.Add(-i2); vect.PolarSet(pGSLine.Bearing + Math.PI, 0, pGSLine.Distance); //Azimuth of IVector3D is north azimuth radians zero degrees north } else { FromList.Add(StartNodeId); ToList.Add(i2); vect.PolarSet(pGSLine.Bearing, 0, pGSLine.Distance); //Azimuth of IVector3D is north azimuth radians zero degrees north } if (!TraceLines(ref FwdStar, i2, ref BranchCount, ref TracedLinesCount, ref LoopCount, ref TerminusCount, ref FromToLine, ref FromList, ref ToList, iInfinityChecker)) { return(false); } } return(true); } catch { return(false); } }
private void FindTerminusForSequence(ref IGSForwardStar FwdStar, int StartNodeId, ref int TerminusPoint, int iInfinityChecker) { if (TerminusPoint > -1) return; //iInfinityChecker++; if (iInfinityChecker++ > 5000) return; ILongArray iLngArr = FwdStar.get_ToNodes(StartNodeId); int iCnt2 = 0; iCnt2 = iLngArr.Count; IGSLine pGSLine = null; for (int i = 0; i < iCnt2; i++) { int i2 = iLngArr.get_Element(i); bool bIsReversed = FwdStar.GetLine(StartNodeId, i2, ref pGSLine); if (iCnt2 == 1) //this is a terminus/end-line TerminusPoint = StartNodeId; FindTerminusForSequence(ref FwdStar, i2, ref TerminusPoint, iInfinityChecker); } }