关键词: Featrue, Vector, Flow 问题描述:我们知道Flow参数,是在Run中设置。Feature的两个端点,通过Featrue自身属性,很难查出端点的进出关系。如何判断Feature端点的In,Out逻辑是本次分享的关键点。 核心逻辑在 GetFlowVectorFromPipeFeatrue 方法,40 余行。此方法 会返回一个 Vector 类型数据。这个向量Vector的箭头,就是流向。 感兴趣的伙伴,可以敲到自己的环境里,尝试下。 //显示流向方法 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 ) { legFeatrues = routeFeature.Legs[ 0 ].GetRelationship( "AlongLeg" , "theIJRtePathFeat" ).TargetObjects; legFeatruesList = legFeatrues.ToList(); } if (legFeatruesList.Count > 0 ) { if (cePiperun.FlowDirection != 1 && cePiperun.FlowDirection != 2 ) { //除了IN和OUT流向 System.Windows.Forms.MessageBox.Show( "Flow No Require" ); return null ; } //判断流向OUT-1 else 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; }

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