当前位置: 首页>>代码示例>>C#>>正文


C# Polyline.PrependPoint方法代码示例

本文整理汇总了C#中Polyline.PrependPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Polyline.PrependPoint方法的具体用法?C# Polyline.PrependPoint怎么用?C# Polyline.PrependPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polyline的用法示例。


在下文中一共展示了Polyline.PrependPoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtendPolylineStartToClusterBoundary

 static void ExtendPolylineStartToClusterBoundary(Polyline poly, ICurve curve) {
     var par = curve.ClosestParameter(poly.Start);
     poly.PrependPoint(curve[par]);
 }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:4,代码来源:SdShortestPath.cs

示例2: RouteEdgeToLocation

        //  int count;

        /// <summary>
        ///
        /// </summary>
        /// <param name="targetLocation"></param>
        /// <returns></returns>
        public EdgeGeometry RouteEdgeToLocation(Point targetLocation) {
            TargetPort = new FloatingPort((ICurve) null, targetLocation); //otherwise route edge to a port would be called
            TargetTightPolyline = null;
            TargetLoosePolyline = null;
            var edgeGeometry = new EdgeGeometry();

            var ls = new LineSegment(SourcePort.Location, targetLocation);

            if (LineCanBeAcceptedForRouting(ls)) {
                _polyline = new Polyline();
                _polyline.AddPoint(ls.Start);
                _polyline.AddPoint(ls.End);
                edgeGeometry.SmoothedPolyline = SmoothedPolyline.FromPoints(_polyline);
                edgeGeometry.Curve = edgeGeometry.SmoothedPolyline.CreateCurve();
                return edgeGeometry;
            }

            //can we do with just two line segments?
            if (SourcePort is CurvePort) {
                ls = new LineSegment(StartPointOfEdgeRouting, targetLocation);
                if (
                    IntersectionsOfLineAndRectangleNodeOverPolyline(ls, ObstacleCalculator.RootOfTightHierarchy).Count ==
                    0) {
                    _polyline = new Polyline();
                    _polyline.AddPoint(SourcePort.Location);
                    _polyline.AddPoint(ls.Start);
                    _polyline.AddPoint(ls.End);
                    //RelaxPolyline();
                    edgeGeometry.SmoothedPolyline = SmoothedPolyline.FromPoints(_polyline);
                    edgeGeometry.Curve = edgeGeometry.SmoothedPolyline.CreateCurve();
                    return edgeGeometry;
                }
            }

            ExtendVisibilityGraphToLocation(targetLocation);

            _polyline = GetShortestPolyline(SourceVisibilityVertex, TargetVisibilityVertex);

            RelaxPolyline();
            if (SourcePort is CurvePort)
                _polyline.PrependPoint(SourcePort.Location);

            edgeGeometry.SmoothedPolyline = SmoothedPolyline.FromPoints(_polyline);
            edgeGeometry.Curve = edgeGeometry.SmoothedPolyline.CreateCurve();
            return edgeGeometry;
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:53,代码来源:InteractiveEdgeRouter.cs

示例3: RouteFromBoundaryPortToFloatingPort

 ICurve RouteFromBoundaryPortToFloatingPort(Polyline targetPortLoosePolyline, bool smooth, out SmoothedPolyline polyline) {
     Point sourcePortLocation = SourcePort.Location;
     Point targetPortLocation = targetPort.Location;
     var ls = new LineSegment(sourcePortLocation, targetPortLocation);
     if (LineCanBeAcceptedForRouting(ls)) {
         polyline = SmoothedPolylineFromTwoPoints(ls.Start, ls.End);
         return ls;
     }
     if (!targetIsInsideOfSourceTightPolyline) {
         //try a variant with two segments
         Point takenOutPoint = TakeBoundaryPortOutsideOfItsLoosePolyline(SourcePort.Curve,
                                                                         ((CurvePort) SourcePort).Parameter,
                                                                         SourceLoosePolyline);
         ls = new LineSegment(takenOutPoint, targetPortLocation);
         if (LineAvoidsTightHierarchy(ls, targetPortLoosePolyline)) {
             polyline = SmoothedPolylineFromTwoPoints(ls.Start, ls.End);
             return ls;
         }
     }
     //we need to route throw the visibility graph
     ExtendVisibilityGraphToLocationOfTargetFloatingPort(targetPortLoosePolyline);
     _polyline = GetShortestPolyline(SourceVisibilityVertex, TargetVisibilityVertex);
     Polyline tmp = SourceTightPolyline;
     if (!targetIsInsideOfSourceTightPolyline)
         //this is done to avoid shorcutting through the source tight polyline             
         SourceTightPolyline = null;
     TryShortcutPolyline();
     SourceTightPolyline = tmp;
     RelaxPolyline();
     _polyline.PrependPoint(sourcePortLocation);
     return SmoothCornersAndReturnCurve(smooth, out polyline);
 }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:32,代码来源:InteractiveEdgeRouter.cs

示例4: RouteFromBoundaryPortToBoundaryPort

        ICurve RouteFromBoundaryPortToBoundaryPort(bool smooth, out SmoothedPolyline smoothedPolyline) {
            Point sourcePortLocation = SourcePort.Location;
            ICurve curve;
            Point targetPortLocation = targetPort.Location;
            var ls = new LineSegment(sourcePortLocation, targetPortLocation);
            if (LineCanBeAcceptedForRouting(ls)) {
                _polyline = new Polyline();
                _polyline.AddPoint(ls.Start);
                _polyline.AddPoint(ls.End);
                smoothedPolyline = SmoothedPolylineFromTwoPoints(ls.Start,ls.End);
                curve = SmoothedPolyline.FromPoints(_polyline).CreateCurve();
            } else {
                //try three variants with two segments
                Point takenOutPoint = TakeBoundaryPortOutsideOfItsLoosePolyline(targetPort.Curve,
                                                                                ((CurvePort) targetPort).Parameter,
                                                                                TargetLoosePolyline);
                ls = new LineSegment(sourcePortLocation, takenOutPoint);
                if (InsideOfTheAllowedConeOfBoundaryPort(takenOutPoint, SourcePort as CurvePort) &&
                    LineAvoidsTightHierarchy(ls, _sourceTightPolyline)) {
                    _polyline = new Polyline();
                    _polyline.AddPoint(ls.Start);
                    _polyline.AddPoint(ls.End);
                    _polyline.AddPoint(targetPortLocation);
                    curve = SmoothCornersAndReturnCurve(smooth, out smoothedPolyline);
                } else {
                    ls = new LineSegment(StartPointOfEdgeRouting, targetPortLocation);
                    if (InsideOfTheAllowedConeOfBoundaryPort(StartPointOfEdgeRouting, TargetPort as CurvePort) &&
                        LineAvoidsTightHierarchy(ls)) {
                        _polyline = new Polyline();
                        _polyline.AddPoint(sourcePortLocation);
                        _polyline.AddPoint(ls.Start);
                        _polyline.AddPoint(ls.End);
                        curve = SmoothCornersAndReturnCurve(smooth, out smoothedPolyline);
                    } else {
                        // we still can make the polyline with two segs when the port sticking segs are intersecting
                        Point x;
                        if (LineSegment.Intersect(sourcePortLocation, StartPointOfEdgeRouting, targetPortLocation,
                                                  takenOutPoint, out x)) {
                            _polyline = new Polyline();
                            _polyline.AddPoint(sourcePortLocation);
                            _polyline.AddPoint(x);
                            _polyline.AddPoint(targetPortLocation);
                            curve = SmoothCornersAndReturnCurve(smooth, out smoothedPolyline);
                        } else if (ApproximateComparer.Close(StartPointOfEdgeRouting, takenOutPoint)) {
                            _polyline = new Polyline();
                            _polyline.AddPoint(sourcePortLocation);
                            _polyline.AddPoint(takenOutPoint);
                            _polyline.AddPoint(targetPortLocation);
                            curve = SmoothCornersAndReturnCurve(smooth, out smoothedPolyline);
                        } else if (LineAvoidsTightHierarchy(new LineSegment(StartPointOfEdgeRouting, takenOutPoint))) {
                            //can we do three segments?
                            _polyline = new Polyline();
                            _polyline.AddPoint(sourcePortLocation);
                            _polyline.AddPoint(StartPointOfEdgeRouting);
                            _polyline.AddPoint(takenOutPoint);
                            _polyline.AddPoint(targetPortLocation);
                            curve = SmoothCornersAndReturnCurve(smooth, out smoothedPolyline);
                        } else {
                            ExtendVisibilityGraphToTargetBoundaryPort(takenOutPoint);
                            _polyline = GetShortestPolyline(SourceVisibilityVertex, TargetVisibilityVertex);
                            
                            Polyline tmpTargetTight;
                            Polyline tmpSourceTight = HideSourceTargetTightsIfNeeded(out tmpTargetTight);
                            TryShortcutPolyline();
                            RecoverSourceTargetTights(tmpSourceTight, tmpTargetTight);

                            RelaxPolyline();

                            _polyline.PrependPoint(sourcePortLocation);
                            _polyline.AddPoint(targetPortLocation);
                            curve = SmoothCornersAndReturnCurve(smooth, out smoothedPolyline);
                        }
                    }
                }
            }
            return curve;
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:77,代码来源:InteractiveEdgeRouter.cs


注:本文中的Polyline.PrependPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。