Exemplo n.º 1
0
        protected void GetNextDirection(ref EdgeDirection dir1, ref EdgeDirection dir2)
        {
            Tuple <EdgeDirection, EdgeDirection> res = null;
            bool nextIsRes = false;

            foreach (var d1 in GetPossibleDirections(Node1))
            {
                foreach (var d2 in GetPossibleDirections(Node2))
                {
                    if (res == null)
                    {
                        res = new Tuple <EdgeDirection, EdgeDirection>(d1, d2);
                    }
                    if (nextIsRes)
                    {
                        res = new Tuple <EdgeDirection, EdgeDirection>(d1, d2);
                        goto next;
                    }
                    if (d1 == dir1 && d2 == dir2)
                    {
                        nextIsRes = true;
                    }
                }
            }

next:

            if (res == null)
            {
                res = new Tuple <EdgeDirection, EdgeDirection>(EdgeDirection.None, EdgeDirection.None);
            }

            dir1 = res.Item1;
            dir2 = res.Item2;
        }
Exemplo n.º 2
0
        public IEdge ConnectTo(INode otherNode, EdgeDirection direction)
        {
            Objects.RequireNonNull(otherNode);
            var edge = factory.CreateEdge(this, otherNode, direction);

            return(this.ConnectTo(otherNode, edge));
        }
Exemplo n.º 3
0
 public Edge()
 {
     _source      = -1;
     _destination = -1;
     _weight      = -1;
     _direction   = EdgeDirection.Bidirectional;
 }
Exemplo n.º 4
0
        public override IEdge CreateEdge(INode nodeA, INode nodeB, EdgeDirection direction)
        {
            var edge = new PartitionEdge(nodeA, nodeB, direction, this.baseEntityFactory);

            logger.Trace("Created new edge: {0}", edge);
            return(edge);
        }
Exemplo n.º 5
0
 public Edge(INode nodeA, INode nodeB, EdgeDirection direction, IEntityFactory factory)
     : base(factory)
 {
     this.endA      = nodeA;
     this.endB      = nodeB;
     this.direction = direction;
 }
Exemplo n.º 6
0
 private void CheckDegree(LayoutVertexBase vertex, EdgeDirection direction)
 {
     if (vertex.IsDummy && this.Degree(vertex, direction) > 1)
     {
         throw new InvalidOperationException($"Dummy vertex {vertex} cannot have more than 1 {direction}-edges.");
     }
 }
Exemplo n.º 7
0
        public static Rectangle ShiftRectangleEdge(Rectangle rect, EdgeDirection edgeToMove, int distTomove)
        {
            // Find edge to move
            switch (edgeToMove)
            {
            case EdgeDirection.Left:
                rect.X     -= distTomove;
                rect.Width += distTomove;
                break;

            case EdgeDirection.Right:
                rect.Width += distTomove;
                break;

            case EdgeDirection.Top:
                rect.Y      -= distTomove;
                rect.Height += distTomove;
                break;

            case EdgeDirection.Bottom:
                rect.Height += distTomove;
                break;
            }

            return(rect);
        }
Exemplo n.º 8
0
    static bool CheckEdgeAndAdd(List <Vector2> result, EdgeDirection direction, int x, int y, int tileSize, Color[] pixels)
    {
        while (x >= 0 && y >= 0 && x < tileSize && y < tileSize)
        {
            if (pixels[y * tileSize + x].a > 0.5f)
            {
//				int xMod = Snap( x, tileSize );
//				int yMod = Snap( y, tileSize );

//				Vector2 thisPoint = new Vector2( (float)(xMod) / (float)(tileSize), (float)(yMod) / (float)(tileSize) );
                AddToList(result, Snap(x, tileSize), Snap(y, tileSize), tileSize);
                return(true);
            }
            switch (direction)
            {
            case EdgeDirection.Down:
                y--;
                break;

            case EdgeDirection.Up:
            default:
                y++;
                break;

            case EdgeDirection.Left:
                x--;
                break;

            case EdgeDirection.Right:
                x++;
                break;
            }
        }
        return(false);
    }
Exemplo n.º 9
0
        private void AddEdge(Task task, Object resource, EdgeDirection direction)
        {
            if (!taskToInt.ContainsKey(task))
            {
                adjacencyList.Add(counterForMapping, new List <int>());
                taskToInt.Add(task, counterForMapping++);
            }
            if (!resourceToInt.ContainsKey(resource))
            {
                adjacencyList.Add(counterForMapping, new List <int>());
                resourceToInt.Add(resource, counterForMapping++);
            }

            if (direction == EdgeDirection.Normal)
            {
                if (SimpleTaskScheduler.IsVerbose)
                {
                    Console.WriteLine("Added edge task " + task.GetHashCode() + " to resource " + resource.GetHashCode());
                }
                AddEdge(taskToInt[task], resourceToInt[resource]);
            }
            else if (direction == EdgeDirection.Inverted)
            {
                if (SimpleTaskScheduler.IsVerbose)
                {
                    Console.WriteLine("Added edge resource " + resource.GetHashCode() + " to task " + task.GetHashCode());
                }
                AddEdge(resourceToInt[resource], taskToInt[task]);
            }
        }
Exemplo n.º 10
0
        private static int[,] EdgeHelperv2(double scale, int[,] im, double threshold, double[,] filter,
                                           double[,] filterT, double fdiv, EdgeDirection direction)
        {
            int[,] result = new int[im.GetLength(0), im.GetLength(1)];
            double[,] b   = new double[im.GetLength(0), im.GetLength(1)];

            double cutoff = 0;
            double tresh  = 0;

            //Sobel approximation to derivative
            var bx = ImageFilter.Filter_double(im, filterT, fdiv);
            var by = ImageFilter.Filter_double(im, filter, fdiv);

            //compute the magnitude
            if (direction == EdgeDirection.horizontal)
            {
                b = by.PowArrayElements(2);
            }
            else if (direction == EdgeDirection.vertical)
            {
                b = bx.PowArrayElements(2);
            }
            else if (direction == EdgeDirection.both || direction == EdgeDirection.def)
            {
                b = bx.PowArrayElements(2).SumArrays(by.PowArrayElements(2));
            }

            else
            {
                Console.WriteLine("Wrong direction");
            }

            if (threshold == 0)
            {
                cutoff = scale * b.Cast <double>().ToArray().Average();
                tresh  = Math.Sqrt(cutoff);
            }
            else
            {
                cutoff = Math.Pow(threshold, 2);
            }

            for (int i = 0; i < im.GetLength(0); i++)
            {
                for (int j = 0; j < im.GetLength(1); j++)
                {
                    if (b[i, j] > cutoff)
                    {
                        result[i, j] = 255;
                    }
                    else
                    {
                        result[i, j] = 0;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 11
0
 public Edge(int source, int destination, int weight = 0,
             EdgeDirection direction = EdgeDirection.Bidirectional)
 {
     _source      = source;
     _destination = destination;
     _weight      = weight;
     _direction   = direction;
 }
Exemplo n.º 12
0
 public static IEnumerable <TEdge> GetEdges <TVertex, TEdge>(
     this IBidirectionalGraph <TVertex, TEdge> graph, TVertex vertex, EdgeDirection edgeDirection)
     where TEdge : IEdge <TVertex>
 {
     return(edgeDirection == EdgeDirection.In
         ? graph.InEdges(vertex)
         : graph.OutEdges(vertex));
 }
Exemplo n.º 13
0
 public static IEnumerable <TVertex> GetNeighbours <TVertex, TEdge>(
     this IBidirectionalGraph <TVertex, TEdge> graph, TVertex vertex, EdgeDirection edgeDirection)
     where TEdge : IEdge <TVertex>
 {
     return(edgeDirection == EdgeDirection.In
         ? graph.GetInNeighbours(vertex)
         : graph.GetOutNeighbours(vertex));
 }
Exemplo n.º 14
0
 public Edge(int id, Node left, Node right, EdgeDirection direction = EdgeDirection.None, int weight = 1)
 {
     Id = id;
     Left = left;
     Right = right;
     Direction = direction;
     Weight = weight;
 }
Exemplo n.º 15
0
 private List <EdgeNodeDto> GetOfficer(List <EdgeDto> edges, EdgeDirection dir)
 {
     if (dir == EdgeDirection.FromCaller)
     {
         var query = from E in edges
                     join off in _database.GetCollection <OfficerDto>("officer").AsQueryable()
                     on E.To equals off.NodeId
                     select new
         {
             OfficerId   = off.NodeId,
             OfficerName = off.Name,
             EdgeFrom    = E.From,
             EdgeTo      = E.To,
             EdgeType    = E.Type,
             EdgeLink    = E.Link
         };
         var results = query.ToList();
         return(results.Select(q => new EdgeNodeDto()
         {
             Edge = new EdgeDto()
             {
                 From = q.EdgeFrom, To = q.EdgeTo, Link = q.EdgeLink
             },
             Node = new NodeDto()
             {
                 Id = q.OfficerId, Label = q.OfficerName, NodeType = NodeType.Officer
             }
         }).ToList());
     }
     else
     {
         var query = from E in edges
                     join off in _database.GetCollection <OfficerDto>("officer").AsQueryable()
                     on E.From equals off.NodeId
                     select new
         {
             OfficerId   = off.NodeId,
             OfficerName = off.Name,
             EdgeFrom    = E.From,
             EdgeTo      = E.To,
             EdgeType    = E.Type,
             EdgeLink    = E.Link
         };
         var results = query.ToList();
         return(results.Select(q => new EdgeNodeDto()
         {
             Edge = new EdgeDto()
             {
                 From = q.EdgeFrom, To = q.EdgeTo, Link = q.EdgeLink
             },
             Node = new NodeDto()
             {
                 Id = q.OfficerId, Label = q.OfficerName, NodeType = NodeType.Officer
             }
         }).ToList());
     }
 }
Exemplo n.º 16
0
        }                                       // TODO: calculate in graph layout pass

        public EdgeConfig(int source, EdgeDirection sourcePosition, int destination, string archetypeName, int weight = 1, int length = 1)
        {
            Source         = source;
            SourcePosition = sourcePosition;
            Destination    = destination;
            Weight         = weight;
            Length         = length;
            Archetype      = archetypeName;
        }
Exemplo n.º 17
0
 public static void ExecuteOnEdgesRecursive <TVertex, TEdge>(this IBidirectionalGraph <TVertex, TEdge> graph,
                                                             TEdge edge, EdgeDirection edgeDirection, Action <TEdge> actionOnEdge)
     where TEdge : IEdge <TVertex>
 {
     actionOnEdge(edge);
     foreach (var nextEdge in graph.GetEdges(edge.GetEndVertex(edgeDirection), edgeDirection))
     {
         graph.ExecuteOnEdgesRecursive(nextEdge, edgeDirection, actionOnEdge);
     }
 }
Exemplo n.º 18
0
 private void RemoveEdge(Task task, Object resource, EdgeDirection direction)
 {
     if (direction == EdgeDirection.Normal)
     {
         RemoveEdge(taskToInt[task], resourceToInt[resource]);
     }
     else if (direction == EdgeDirection.Inverted)
     {
         RemoveEdge(resourceToInt[resource], taskToInt[task]);
     }
 }
Exemplo n.º 19
0
        public static EdgeAttribute Direction(EdgeDirection direction)
        {
            if (!direction.IsValid())
            {
                throw new ArgumentException($"The { nameof(EdgeDirection) } provided must be a valid enum.", nameof(direction));
            }

            var directionStr = direction.AsString().ToLowerInvariant();

            return(new EdgeAttribute("dir", directionStr));
        }
Exemplo n.º 20
0
 public Edge(Vertex Vertex1, Vertex Vertex2, string Type,
             string Relationship, string Comment, int Weight)
 {
     this.Vertex1 = Vertex1;
     this.Vertex2 = Vertex2;
     this.Type = Type;
     this.Relationship = Relationship;
     this.Comment = Comment;            
     this.Weight = Weight;
     this.FeedOfOrigin = "";
     this.Direction = EdgeDirection.Undirected;
 }
Exemplo n.º 21
0
 public static IShortestPathQueryable <ShortestPathData <TVertex, TEdge> > Edge <TVertex, TEdge>(
     this IShortestPathQueryable <ShortestPathData <TVertex, TEdge> > source, string collectionName,
     EdgeDirection direction)
 {
     return(source.Provider.CreateQuery <ShortestPathData <TVertex, TEdge> >(
                Expression.Call(
                    ArangoQueryableExtensions.FindExtention("ShortestPath_Edge_Direction", typeof(TVertex), typeof(TEdge)),
                    source.Expression,
                    Expression.Constant(collectionName),
                    Expression.Constant(direction)
                    )) as IShortestPathQueryable <ShortestPathData <TVertex, TEdge> >);
 }
Exemplo n.º 22
0
        /// <summary> Get direction vector along some edge </summary>
        protected PointF GetDir(Node node, EdgeDirection dir)
        {
            var e = node.GetEdge(dir);

            if (e == null || e == Edge)
            {
                return(PointF.Empty);
            }
            var node2 = e.GetOtherNode(node);
            var res   = node2.LocationF.Sub(node.LocationF).Normalized();

            return(res);
        }
Exemplo n.º 23
0
        public static Pix SobelEdgeFilter(Pix pix, EdgeDirection orientflag = EdgeDirection.All)
        {
            if (pix.Depth != 8)
            {
                pix = Convert.ConvertTo8(pix);
            }
            IntPtr p = LeptonicaNativeApi.Native.pixSobelEdgeFilter(pix.Reference, orientflag);

            if (p == IntPtr.Zero)
            {
                throw new NullReferenceException("failed to edge.");
            }
            return(Pix.Create(p));
        }
Exemplo n.º 24
0
        public IEnumerable <TVertex> GetAdjacentVertices(TVertexId vertexId, EdgeDirection direction,
                                                         EdgePredicate <TVertex, TEdge> edgePredicate = null, bool recursive = false)
        {
            if (!ContainsVertex(vertexId))
            {
                return(Enumerable.Empty <TVertex>());
            }

            var vertexIds = _graph.GetAdjacentVertices(vertexId, direction,
                                                       edge => edgePredicate == null || edgePredicate(GetEdge(edge.Id)),
                                                       recursive);

            return(vertexIds.Select(GetVertex));
        }
Exemplo n.º 25
0
 public void GoNextDirection()
 {
     //find parallel connected edges
     foreach (var d in GetPossibleDirections(Node1, EdgeDirection))
     {
         var e1 = Node1.GetEdge(d);
         var e2 = Node2.GetEdge(d);
         if (e1 != null && e1 != Edge && e2 != null && e2 != Edge)
         {
             EdgeDirection = d;
             break;
         }
     }
 }
Exemplo n.º 26
0
    //List<RaycastHit> GetEdgeLoop(float p_height)
    void GetEdgeLoop(float p_height)
    {
        //Finds an edge loop at height p_height
        RaycastHit        hitDetails;
        Vector3           referenceRay         = new Vector3();
        List <RaycastHit> edgeLoop             = new List <RaycastHit>();
        Vector3           centre               = new Vector3();
        Vector3           pointOnCircumference = new Vector3(); //First ray will be cast to this point
        Vector3           startPoint           = new Vector3();
        Vector3           endPoint             = new Vector3();
        EdgeDirection     firstPointSpot       = (EdgeDirection)Random.Range(0, System.Enum.GetValues(typeof(EdgeDirection)).Length);

        centre   = climbingSurfaceBounds.center;
        centre.y = p_height;

        pointOnCircumference   = frontLeft + frontLeftMultiplier;
        pointOnCircumference.y = p_height;

        Quaternion q;
        Vector3    d;

        referenceRay = pointOnCircumference - centre;

        float i = 0.0f;

        Debug.DrawRay(centre,
                      referenceRay,
                      Color.black,
                      3.0f);

        while (i <= 360.0f)
        {
            //Find the Quaternion corresponding to rotating anything i degree around Y-Axis
            q = Quaternion.AngleAxis(i, Vector3.up);
            //Apply the rotation to the scanner Ray
            d          = q * referenceRay;
            i         += 0.01f;
            startPoint = centre + d;
            endPoint   = centre;
            hitDetails = new RaycastHit();
            //Perform a raycast to find a point and it's normal
            if (Physics.Raycast(startPoint, (endPoint - startPoint), out hitDetails, d.magnitude, climbingSurfaceLayer))
            {
                edgeLoop.Add(hitDetails);
            }
        }

        allEdgeLoops.Add(edgeLoop);
    }
Exemplo n.º 27
0
 protected IEnumerable <EdgeDirection> GetPossibleDirections(Node node, EdgeDirection after)
 {
     for (int add = 1; add <= 4; add++)
     {
         var d = (EdgeDirection)(((int)after + add) % 5);
         if (d != after)
         {
             var e = node.GetEdge(d);
             if (e != null && e != Edge)
             {
                 yield return(d);
             }
         }
     }
 }
Exemplo n.º 28
0
 public Edge(Vertex Vertex1, Vertex Vertex2, string Type,
             string Relationship, string Comment, int Weight,
             int Timestamp, string FeedOfOrigin, EdgeDirection eDirection)
 {
     this.Vertex1 = Vertex1;
     this.Vertex2 = Vertex2;
     this.Type = Type;
     this.Relationship = Relationship;
     this.Comment = Comment;
     this.Weight = Weight;
     this.FeedOfOrigin = FeedOfOrigin;
     if (Timestamp > 0)
         this.Timestamp = DateUtil.ConvertToDateTime(Timestamp);
     this.Direction = eDirection;
 }
Exemplo n.º 29
0
 //查找类型为指定Type的连边: 字面量
 public IEnumerable <Edge> GetEdgesByType(string attribute, EdgeDirection direction)
 {
     if (attribute == null)
     {
         return(new List <Edge>());
     }
     if (direction == EdgeDirection.In)
     {
         return(InBound.Where(x => x.Attribute == attribute));
     }
     if (direction == EdgeDirection.Out)
     {
         return(OutBound.Where(x => x.Attribute == attribute));
     }
     return(new List <Edge>());
 }
Exemplo n.º 30
0
 //查找目标为指定GUID的连边
 public IEnumerable <IEdge> GetEdgesByGuid(string nodeGuid, EdgeDirection direction)
 {
     if (nodeGuid == null)
     {
         return(new List <IEdge>());
     }
     if (direction == EdgeDirection.In)
     {
         return(InBound.Where(x => x.From.Guid == nodeGuid));
     }
     if (direction == EdgeDirection.Out)
     {
         return(OutBound.Where(x => x.To.Guid == nodeGuid));
     }
     return(new List <IEdge>());
 }
Exemplo n.º 31
0
 //查找类型为指定Type的连边
 public IEnumerable <Edge> GetEdgesByType(IEnumerable <Type> types, EdgeDirection direction)
 {
     if (types == null)
     {
         return(new List <Edge>());
     }
     if (direction == EdgeDirection.In)
     {
         return(InBound.Where(x => types.Contains(x.GetType())));
     }
     if (direction == EdgeDirection.Out)
     {
         return(OutBound.Where(x => types.Contains(x.GetType())));
     }
     return(new List <Edge>());
 }
Exemplo n.º 32
0
 //查找目标为指定Name的连边
 public IEnumerable <Edge> GetEdgesByName(string nodeName, EdgeDirection direction)
 {
     if (nodeName == null)
     {
         return(new List <Edge>());
     }
     if (direction == EdgeDirection.In)
     {
         return(InBound.Where(x => x.From.Name == nodeName));
     }
     if (direction == EdgeDirection.Out)
     {
         return(OutBound.Where(x => x.To.Name == nodeName));
     }
     return(new List <Edge>());
 }
Exemplo n.º 33
0
        public static string EdgeDirectionToString(EdgeDirection direction)
        {
            switch (direction)
            {
            case EdgeDirection.Any:
                return("any");

            case EdgeDirection.Inbound:
                return("inbound");

            case EdgeDirection.Outbound:
                return("outbound");

            default:
                throw new InvalidOperationException($"EdgeDirection {direction} binding not found, this is a client bug");
            }
        }
Exemplo n.º 34
0
 /// <summary>
 /// Creates an edge connection between two neighbors. 
 /// </summary>
 /// <param name="currentMapGraphicsTile"></param>
 /// <param name="neighborsMapGraphicsTile"></param>
 /// <param name="edgeDirection"></param>
 private void CreateEdgeConnectionBetweenNeighbors(MapGraphicsTile currentMapGraphicsTile, MapGraphicsTile neighborsMapGraphicsTile, EdgeDirection edgeDirection)
 {
     EdgeConnection edgeConnection = new EdgeConnection(CreateEdgeConnection(edgeDirection),true);
     currentMapGraphicsTile.ShoreEdgePoints.Add(edgeConnection);
     neighborsMapGraphicsTile.ShoreEdgePoints.Add(new EdgeConnection(edgeConnection.TranslateConnectionForNeighbor(), true));
 }
Exemplo n.º 35
0
 public Edge(Point p1, Point p2)
 {
     _points = new[] { p1, p2 };
     direction = new EdgeDirection(this, false);
     inverseDirection = new EdgeDirection(this, true);
 }
Exemplo n.º 36
0
        private int RotationDirection(EdgeDirection previousDirection, EdgeDirection currentDirection)
        {
            if (currentDirection == EdgeDirection.Left && previousDirection == EdgeDirection.Bottom)
                return 1;

            if (currentDirection == EdgeDirection.Bottom && previousDirection == EdgeDirection.Left)
                return -1;

            return currentDirection - previousDirection;
        }
Exemplo n.º 37
0
 public void ReverseEdges()
 {
     _currentDirection = _currentDirection == EdgeDirection.LeftToRight ?
                             EdgeDirection.RightToLeft :
                             EdgeDirection.LeftToRight;
 }
Exemplo n.º 38
0
        internal void RecalculateNextRightDirection()
        {
            var prev = a;
            var curr = b;
            float minAngle = float.PositiveInfinity;
            Edge nextEdge = null;
            foreach (var edge in curr.edges)
            {
                if (edge == this.edge)
                    continue;
                var next = edge.GetInvert(curr);
                var angleClockwise = m.rightAngle(prev.value, curr.value, next.value);
                if (angleClockwise < minAngle)
                {
                    minAngle = angleClockwise;
                    nextEdge = edge;
                }
            }
            if (nextEdge == null) nextEdge = this.edge;

            nextRightDir = nextEdge.GetRightDirection(b);
        }
Exemplo n.º 39
0
    public List<m.polygon> CalculatePolygons(bool withJoin)
    {
        if (withJoin)
            JoinAll();

        var directedLines = new EdgeDirection[edges.Count * 2];
        //Связываем правые стороны векторов
        for (int i = 0; i < edges.Count; i++)
        {
            var edge = edges[i];
            directedLines[i] = edge.direction;
            directedLines[edges.Count + i] = edge.inverseDirection;
            edge.direction.RecalculateNextRightDirection();
            edge.inverseDirection.RecalculateNextRightDirection();
            edge.direction.used = false;
            edge.inverseDirection.used = false;
        }
        //Находим полигоны
        var polygons = new List<m.polygon>();
        for (int i = 0; i < directedLines.Length; i++)
        {
            var dir = directedLines[i];
            if (dir.used)
                continue;

            var path = new List<EdgeDirection>();
            int error = 0;
            while (true)
            {
                dir.used = true;
                path.Add(dir);

                if (dir.nextRightDir.used)//exit
                {
                    var firstIndex = path.IndexOf(dir.nextRightDir);
                    if (firstIndex == -1)
                        break;

                    var polygon = new m.polygon<List<EdgeDirection>> {tag = new List<EdgeDirection>()};
                    for (int j = firstIndex; j < path.Count; j++)
                    {
                        var e = path[j];
                        polygon.points.Add(e.b.value);
                        polygon.tag.Add(e);
                        e.edge.conditionTouchCount = 0;
                    }
                    if (m.area.simplePolygon(polygon.points.Select(x => (Vector2)x).ToArray()) < 0f)
                        polygons.Add(polygon);
                    break;
                }
                dir = dir.nextRightDir;

                if (error >= directedLines.Length)
                {
                    Debug.LogWarning("Error");
                    break;
                }
                error++;
            }

        }
        return polygons;
    }
Exemplo n.º 40
0
        /// <summary>
        ///  Creates a random edge connection
        /// </summary>
        /// <param name="mapGraphicsTile"></param>
        /// <param name="edgeDirection"></param>
        private byte CreateEdgeConnection(EdgeDirection edgeDirection)
        {
            int min = 0;
            int max = 0;

            if (edgeDirection == EdgeDirection.Bottom)
            {
                min = 1;
                max = 3;
            }
            else if (edgeDirection == EdgeDirection.Top)
            {
                min = 7;
                max = 9;
            }
            else if (edgeDirection == EdgeDirection.Right)
            {
                min = 4;
                max = 6;
            }
            else if (edgeDirection == EdgeDirection.Left)
            {
                min = 10;
                max = 12;
            }

            return (byte)rnd.Next(min, max);
        }
Exemplo n.º 41
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="processKey"></param>
 /// <param name="varKey"></param>
 /// <param name="direction"></param>
 public EdgeInfo(string processKey, string varKey, EdgeDirection direction)
 {
     m_proKey = processKey;
     // Set Relation
     if (direction == EdgeDirection.Inward)
     {
         m_direction = EdgeDirection.Inward;
         m_type = LineType.Solid;
     }
     else if (direction == EdgeDirection.None)
     {
         m_direction = EdgeDirection.None;
         m_type = LineType.Dashed;
     }
     else if (direction == EdgeDirection.Outward)
     {
         m_direction = EdgeDirection.Outward;
         m_type = LineType.Solid;
     }
     else
     {
         m_direction = EdgeDirection.Bidirection;
         m_type = LineType.Solid;
     }
     m_varKey = varKey;
 }
Exemplo n.º 42
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="processKey">The key of process.</param>
 /// <param name="er">The reference of EcellObject.</param>
 public EdgeInfo(string processKey, EcellReference er)
 {
     m_proKey = processKey;
     // Set Relation
     int coef = er.Coefficient;
     if (coef < 0)
     {
         m_direction = EdgeDirection.Inward;
         m_type = LineType.Solid;
     }
     else if (coef == 0)
     {
         m_direction = EdgeDirection.None;
         m_type = LineType.Dashed;
     }
     else
     {
         m_direction = EdgeDirection.Outward;
         m_type = LineType.Solid;
     }
     m_varKey = er.Key;
 }
Exemplo n.º 43
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="processKey"></param>
        /// <param name="list"></param>
        /// <param name="er"></param>
        public EdgeInfo(string processKey, List<EcellReference> list, EcellReference er)
        {
            m_isEndNode = CheckEndNode(list);
            bool bidir = CheckBidir(list, er);

            m_proKey = processKey;
            m_varKey = er.Key;
            // Set Relation
            int l_coef = er.Coefficient;
            if (bidir)
            {
                m_direction = EdgeDirection.Bidirection;
                m_type = LineType.Solid;
            }
            else if (l_coef < 0)
            {
                m_direction = EdgeDirection.Inward;
                m_type = LineType.Solid;
            }
            else if (l_coef == 0)
            {
                m_direction = EdgeDirection.None;
                m_type = LineType.Dashed;
            }
            else
            {
                m_direction = EdgeDirection.Outward;
                m_type = LineType.Solid;
            }
        }
Exemplo n.º 44
0
        /// <summary>
        /// Sets the Neighbors Edge Connection based on 
        /// </summary>
        /// <param name="currentMapGraphicsTile"></param>
        /// <param name="neighborsMapGraphicsTile"></param>
        /// <param name="edgeDirection"></param>
        private void GetNeighborsEdgeConnection(MapGraphicsTile currentMapGraphicsTile, MapGraphicsTile neighborsMapGraphicsTile, EdgeDirection edgeDirection)
        {
            if (edgeDirection == EdgeDirection.Top && !neighborsMapGraphicsTile.ShoreEdgePoints.Exists(x => x.EdgePosition > 0 && x.EdgePosition < 3))
            {
                CreateEdgeConnectionBetweenNeighbors(currentMapGraphicsTile, neighborsMapGraphicsTile, edgeDirection);
                currentMapGraphicsTile.TopEdgeType = EdgeType.Both;
            }

            else if (edgeDirection == EdgeDirection.Bottom && !neighborsMapGraphicsTile.ShoreEdgePoints.Exists(x => x.EdgePosition > 6 && x.EdgePosition < 10))
            {
                CreateEdgeConnectionBetweenNeighbors(currentMapGraphicsTile, neighborsMapGraphicsTile, edgeDirection);
                currentMapGraphicsTile.BottomEdgeType = EdgeType.Both;
            }

            else if (edgeDirection == EdgeDirection.Left && !neighborsMapGraphicsTile.ShoreEdgePoints.Exists(x => x.EdgePosition > 3 && x.EdgePosition < 7))
            {
                CreateEdgeConnectionBetweenNeighbors(currentMapGraphicsTile, neighborsMapGraphicsTile, edgeDirection);
                currentMapGraphicsTile.BottomEdgeType = EdgeType.Both;
            }

            else if (edgeDirection == EdgeDirection.Right && !neighborsMapGraphicsTile.ShoreEdgePoints.Exists(x => x.EdgePosition > 9 && x.EdgePosition < 13))
            {
                CreateEdgeConnectionBetweenNeighbors(currentMapGraphicsTile, neighborsMapGraphicsTile, edgeDirection);
                currentMapGraphicsTile.BottomEdgeType = EdgeType.Both;
            }
        }