关键词: Featrue, Vector, Flow, IsTopologicalDirectionNormal 前言:没有想到Featrue流向判断,会有第三个小节,看到蛮多伙伴有参与到这个问题的测试和讨论环节,气氛很棒。 小结:增加 IsTopologicalDirectionNormal 属性的判断。现在程序运行逻辑更加健壮合理。 public Vector DisplayFeatureFlow (RouteFeature routeFeature) { ReadOnlyCollection<BusinessObject> legFeatrues = null ; PipeRun cePiperun = routeFeature.SystemParent as PipeRun; List<BusinessObject> legFeatruesList = new List <BusinessObject>(); int ceFeatureIndex = 0 ; if (routeFeature.Legs.Count > 0 ) { //通过Featrue取Leg legFeatrues = routeFeature.Legs[ 0 ].GetRelationship( "AlongLeg" , "theIJRtePathFeat" ).TargetObjects; legFeatruesList = legFeatrues.ToList(); //获取关系 BusinessObject for_get_IsTopologicalDirectionNormal_property = routeFeature.GetRelationship( "AlongLeg" , "theIJRtePathLeg" ).TargetObjects[ 0 ]; //获取属性 IsTopologicalDirectionNormal_property = for_get_IsTopologicalDirectionNormal_property.GetPropertyValue( "IJRtePathLeg" , "IsTopologicalDirectionNormal" ) as PropertyValueBoolean; } if (legFeatruesList.Count > 0 ) { if (cePiperun.FlowDirection != 1 && cePiperun.FlowDirection != 2 ) { // 除了IN和OUT流向 System.Windows.Forms.MessageBox.Show( "Flow No Require" ); return null ; } //判断拓扑逻辑(与6月13分享比较,新增If判断逻辑) if (IsTopologicalDirectionNormal_property.PropValue == false ) { legFeatruesList.Reverse(); } // 判断流向OUT-1 if (cePiperun.FlowDirection == 1 ) { // OUT—>反转集合 legFeatruesList.Reverse(); ceFeatureIndex = legFeatruesList.IndexOf(routeFeature); } // 判断流向IN-2 else if (cePiperun.FlowDirection == 2 ) { // IN无需调整流向 ceFeatureIndex = legFeatruesList.IndexOf(routeFeature); } foreach ( var item in legFeatruesList) { // 高亮 if (legFeatruesList.IndexOf(item) == ceFeatureIndex – 1 ) { ceHiliterYellowIn.HilitedObjects.Add(item); Thread.Sleep( 50 ); } if (legFeatruesList.IndexOf(item) == ceFeatureIndex + 1 ) { ceHiliterBlueOut.HilitedObjects.Add(item); Thread.Sleep( 50 ); } } } // 以下获取Vector,流向获得向量 int lastKey = legFeatruesList.Count – 1 ; Position positionOrigin = ((RouteFeature)legFeatruesList[ 0 ]).Location; Position positionDestination = ((RouteFeature)legFeatruesList[lastKey]).Location; Vector vector = positionDestination.Subtract(positionOrigin); return vector; }

您需要登录 或注册 后才可以发表评论。