コード例 #1
0
        List <SdBoneEdge> RouteOnKnownSourceTargetVertices(Point pathDirection, bool lookingForMonotonePath)
        {
            LowestCostToTarget  = Double.PositiveInfinity;
            ClosestTargetVertex = null;
            while (Queue.Count > 0)
            {
                double   hu;
                SdVertex bestNode = Queue.Dequeue(out hu);
                if (hu >= LowestCostToTarget)
                {
                    continue;
                }
                //update the rest
                for (int i = 0; i < bestNode.OutBoneEdges.Count; i++)
                {
                    var outBoneEdge = bestNode.OutBoneEdges[i];
                    if (outBoneEdge.IsPassable)
                    {
                        ProcessOutcomingBoneEdge(bestNode, outBoneEdge, pathDirection, lookingForMonotonePath);
                    }
                }

                for (int i = 0; i < bestNode.InBoneEdges.Count; i++)
                {
                    var inBoneEdge = bestNode.InBoneEdges[i];
                    if (inBoneEdge.IsPassable)
                    {
                        ProcessIncomingBoneEdge(bestNode, inBoneEdge, pathDirection, lookingForMonotonePath);
                    }
                }
            }

            return(GetPathAndUpdateRelatedCosts());
        }
コード例 #2
0
        void ProcessBoneEdge(SdVertex v, SdVertex queueCandidate, SdBoneEdge boneEdge)
        {
            double newCost = GetEdgeAdditionalCost(boneEdge, v.Cost);

            if (queueCandidate.Cost <= newCost)
            {
                return;
            }
            queueCandidate.Cost     = newCost;
            queueCandidate.PrevEdge = boneEdge;
            if (Queue.ContainsElement(queueCandidate))
            {
                Queue.DecreasePriority(queueCandidate, newCost);
            }
            else
            {
                if (queueCandidate.IsTargetOfRouting)
                {
                    double costToTarget = 0;
                    if (CurrentEdgeGeometry.TargetPort is ClusterBoundaryPort)
                    {
                        costToTarget = LengthCoefficient * (queueCandidate.Point - CurrentEdgeGeometry.TargetPort.Location).Length;
                    }

                    if (newCost + costToTarget < LowestCostToTarget)
                    {
                        LowestCostToTarget  = newCost + costToTarget;
                        ClosestTargetVertex = queueCandidate;
                    }
                    return; //do not enqueue the target vertices
                }
                Enqueue(queueCandidate);
            }
        }
コード例 #3
0
        void SetEdgeGeometryCurve(EdgeGeometry edgeGeometry)
        {
            Polyline poly = new Polyline();
            SdVertex curV = EdgesToRouteSources[edgeGeometry];

            poly.AddPoint(curV.Point);
            foreach (var edge in EdgesToRoutes[edgeGeometry])
            {
                if (edge.SourcePoint == curV.Point)
                {
                    poly.AddPoint(edge.TargetPoint);
                    curV = edge.Target;
                }
                else
                {
                    poly.AddPoint(edge.SourcePoint);
                    curV = edge.Source;
                }
            }

            edgeGeometry.Curve = poly;
            var clusterSourcePort = edgeGeometry.SourcePort as ClusterBoundaryPort;

            if (clusterSourcePort != null)
            {
                ExtendPolylineStartToClusterBoundary(poly, clusterSourcePort.Curve);
            }

            var clusterTargetPort = edgeGeometry.TargetPort as ClusterBoundaryPort;

            if (clusterTargetPort != null)
            {
                ExtendPolylineEndToClusterBoundary(poly, clusterTargetPort.Curve);
            }
        }
コード例 #4
0
        void ProcessIncomingBoneEdge(SdVertex v, SdBoneEdge inBoneEdge, Point pathDirection, bool lookingForMonotonePath)
        {
            Debug.Assert(v == inBoneEdge.Target);
            if (lookingForMonotonePath && pathDirection * (inBoneEdge.SourcePoint - inBoneEdge.TargetPoint) < 0)
            {
                return;
            }

            ProcessBoneEdge(v, inBoneEdge.Source, inBoneEdge);
        }
コード例 #5
0
        void ProcessOutcomingBoneEdge(SdVertex v, SdBoneEdge outBoneEdge, Point pathDirection, bool lookingForMonotonePath)
        {
            Debug.Assert(v == outBoneEdge.Source);
            if (lookingForMonotonePath && pathDirection * (outBoneEdge.TargetPoint - outBoneEdge.SourcePoint) < 0)
            {
                return;
            }

            ProcessBoneEdge(v, outBoneEdge.Target, outBoneEdge);
        }
コード例 #6
0
        void CreateRoutingGraph() {
            vertexArray = new SdVertex[VisibilityGraph.VertexCount];
            int i = 0;
            VisibilityVerticesToSdVerts = new Dictionary<VisibilityVertex, SdVertex>();
            foreach (var v in VisibilityGraph.Vertices()) {
                var sdVert = new SdVertex(v);
                vertexArray[i++] = sdVert;
                VisibilityVerticesToSdVerts[v] = sdVert;
            }

            CreateGraphElements();
        }
コード例 #7
0
        void TryToAssigenTriangleToVertex(CdtTriangle triangle, SdVertex vertex)
        {
            if (vertex.Triangle != null)
            {
                return;
            }

            if (Cdt.PointIsInsideOfTriangle(vertex.Point, triangle))
            {
                vertex.Triangle = triangle;
            }
        }
コード例 #8
0
        void CreateRoutingGraph()
        {
            vertexArray = new SdVertex[VisibilityGraph.VertexCount];
            int i = 0;

            VisibilityVerticesToSdVerts = new Dictionary <VisibilityVertex, SdVertex>();
            foreach (var v in VisibilityGraph.Vertices())
            {
                var sdVert = new SdVertex(v);
                vertexArray[i++] = sdVert;
                VisibilityVerticesToSdVerts[v] = sdVert;
            }

            CreateGraphElements();
        }
コード例 #9
0
        void ProcessOutcomingBoneEdge(SdVertex v, SdBoneEdge outBoneEdge, Point pathDirection, bool lookingForMonotonePath) {
            Debug.Assert(v == outBoneEdge.Source);
            if (lookingForMonotonePath && pathDirection * (outBoneEdge.TargetPoint - outBoneEdge.SourcePoint) < 0) return;

            ProcessBoneEdge(v, outBoneEdge.Target, outBoneEdge);
        }
コード例 #10
0
        void TryToAssigenTriangleToVertex(CdtTriangle triangle, SdVertex vertex) {
            if (vertex.Triangle != null)
                return;

            if (Cdt.PointIsInsideOfTriangle(vertex.Point, triangle))
                vertex.Triangle = triangle;
        }
コード例 #11
0
 void Enqueue(SdVertex simpleSdVertex) {
     Queue.Enqueue(simpleSdVertex, H(simpleSdVertex));
 }
コード例 #12
0
 double H(SdVertex v) {
     return v.Cost + LengthCoefficient * (v.Point - CurrentEdgeGeometry.TargetPort.Location).Length;
 }
コード例 #13
0
        void ProcessBoneEdge(SdVertex v, SdVertex queueCandidate, SdBoneEdge boneEdge) {
            double newCost = GetEdgeAdditionalCost(boneEdge, v.Cost);
            if (queueCandidate.Cost <= newCost) return;
            queueCandidate.Cost = newCost;
            queueCandidate.PrevEdge = boneEdge;
            if (Queue.ContainsElement(queueCandidate))
                Queue.DecreasePriority(queueCandidate, newCost);
            else {
                if (queueCandidate.IsTargetOfRouting) {
                    double costToTarget = 0;
                    if (CurrentEdgeGeometry.TargetPort is ClusterBoundaryPort)
                        costToTarget = LengthCoefficient * (queueCandidate.Point - CurrentEdgeGeometry.TargetPort.Location).Length;

                    if (newCost + costToTarget < LowestCostToTarget) {
                        LowestCostToTarget = newCost + costToTarget;
                        ClosestTargetVertex = queueCandidate;
                    }
                    return; //do not enqueue the target vertices
                }
                Enqueue(queueCandidate);
            }
        }
コード例 #14
0
        void ProcessIncomingBoneEdge(SdVertex v, SdBoneEdge inBoneEdge, Point pathDirection, bool lookingForMonotonePath) {
            Debug.Assert(v == inBoneEdge.Target);
            if (lookingForMonotonePath && pathDirection * (inBoneEdge.SourcePoint - inBoneEdge.TargetPoint) < 0) return;

            ProcessBoneEdge(v, inBoneEdge.Source, inBoneEdge);
        }
コード例 #15
0
 double H(SdVertex v)
 {
     return(v.Cost + LengthCoefficient * (v.Point - CurrentEdgeGeometry.TargetPort.Location).Length);
 }
コード例 #16
0
 void Enqueue(SdVertex simpleSdVertex)
 {
     Queue.Enqueue(simpleSdVertex, H(simpleSdVertex));
 }
コード例 #17
0
 internal SdBoneEdge(VisibilityEdge visibilityEdge, SdVertex source, SdVertex target) {
     VisibilityEdge = visibilityEdge;
     Source = source;
     Target = target;
 }
コード例 #18
0
 internal SdBoneEdge(VisibilityEdge visibilityEdge, SdVertex source, SdVertex target)
 {
     VisibilityEdge = visibilityEdge;
     Source         = source;
     Target         = target;
 }
コード例 #19
0
        List<SdBoneEdge> RouteOnKnownSourceTargetVertices(Point pathDirection, bool lookingForMonotonePath) {
            LowestCostToTarget = Double.PositiveInfinity;
            ClosestTargetVertex = null;
            while (Queue.Count > 0) {
                double hu;
                SdVertex bestNode = Queue.Dequeue(out hu);
                if (hu >= LowestCostToTarget)
                    continue;
                //update the rest
                for (int i = 0; i < bestNode.OutBoneEdges.Count; i++) {
                    var outBoneEdge = bestNode.OutBoneEdges[i];
                    if (outBoneEdge.IsPassable)
                        ProcessOutcomingBoneEdge(bestNode, outBoneEdge, pathDirection, lookingForMonotonePath);
                }

                for (int i = 0; i < bestNode.InBoneEdges.Count; i++) {
                    var inBoneEdge = bestNode.InBoneEdges[i];
                    if (inBoneEdge.IsPassable)
                        ProcessIncomingBoneEdge(bestNode, inBoneEdge, pathDirection, lookingForMonotonePath);
                }
            }

            return GetPathAndUpdateRelatedCosts();
        }