コード例 #1
0
            private IEnumerable <Projection <TValue> > Visit(IVertexBase vertex, Arguments args)
            {
                args.TransformerPath.Push(vertex.Transformer);

                if (vertex == args.Target)
                {
                    yield return(new Projection <TValue> {
                        Value = args.Value, TransformerPath = args.TransformerPath.ToArray()
                    });

                    yield break;
                }

                if ((args.Directions & GraphDirections.Successors) != 0)
                {
                    foreach (Projection <TValue> projection in VisitDirection(vertex, args, GraphDirection.Successors))
                    {
                        yield return(projection);
                    }
                }

                if ((args.Directions & GraphDirections.Predecessors) != 0)
                {
                    foreach (Projection <TValue> projection in VisitDirection(vertex, args, GraphDirection.Predecessors))
                    {
                        yield return(projection);
                    }
                }

                args.TransformerPath.Pop();
            }
コード例 #2
0
            public IEnumerable <Projection <TValue> > Visit(ViewVertex vertex, Arguments args)
            {
                if (CheckDepth(args, vertex))
                {
                    yield break;
                }

                if (args.Raycasting && (!vertex.View.Displayed(drawClient: args.RaycastClient)))// || !_areaContains(vertex.View, args.Value)))
                {
                    yield break;
                }

                if (!args.ViewDepths.ContainsKey(vertex))
                {
                    args.ViewDepths[vertex] = 0;
                }
                args.ViewDepths[vertex]++;

                IVertexBase vertexBase = vertex;

                foreach (Projection <TValue> projection in Visit(vertexBase, args))
                {
                    yield return(projection);

                    if (args.Raycasting)
                    {
                        break;
                    }
                }

                args.ViewDepths[vertex]--;
            }
コード例 #3
0
            public ProjectionBuilder(IVertexBase source, TValue value, ProjectionVisitor <TValue> visitor, ProjectionGraph graph)
            {
                Source = source;
                Value  = value;

                _visitor = visitor;
                _graph   = graph;
            }
コード例 #4
0
            public IEnumerable <Projection <TValue> > Visit(SceneVertex vertex, Arguments args)
            {
                IVertexBase vertexBase = vertex;

                foreach (Projection <TValue> projection in Visit(vertexBase, args))
                {
                    yield return(projection);
                }
            }
コード例 #5
0
            static private IReadOnlyCollection <IEdgeBase> GetNextEdges(IVertexBase vertex, GraphDirection direction)
            {
                switch (direction)
                {
                case GraphDirection.Successors: return(vertex.Successors);

                case GraphDirection.Predecessors: return(vertex.Predecessors);

                default: throw new NotSupportedException();
                }
            }
コード例 #6
0
            public IEnumerable <Projection <TValue> > Visit(IEdgeBase edge, Arguments args, GraphDirection direction)
            {
                args       = new Arguments(args);
                args.Value = Transform(edge, args.Value, direction);

                IVertexBase nextVertex = GetNextVertex(edge, direction);

                foreach (Projection <TValue> projection in nextVertex.Accept(this, args))
                {
                    yield return(projection);
                }
            }
コード例 #7
0
                public Arguments(TValue initialValue, IVertexBase target, bool raycasting, IDrawClient raycastClient, GraphDirections directions, int depthMax, int viewDepthMax)
                {
                    Value         = initialValue;
                    Target        = target;
                    Raycasting    = raycasting;
                    Directions    = directions;
                    DepthMax      = depthMax;
                    ViewDepthMax  = viewDepthMax;
                    RaycastClient = raycastClient;

                    TransformerPath = new Stack <ITransformer>();
                    ViewDepths      = new Dictionary <ViewVertex, int>();
                }
コード例 #8
0
            public IEnumerable <Projection <TValue> > VisitDirection(IVertexBase vertex, Arguments args, GraphDirection direction)
            {
                IReadOnlyCollection <IEdgeBase> nextEdges = GetNextEdges(vertex, direction);

                if (args.Target == null && nextEdges.Count == 0)
                {
                    yield return(new Projection <TValue> {
                        Value = args.Value, TransformerPath = args.TransformerPath.ToArray()
                    });
                }
                else
                {
                    foreach (Projection <TValue> value in nextEdges.Where(x => GetNextVertex(x, direction) != vertex)
                             .OrderBy(x => (GetNextVertex(x, direction) as ViewVertex)?.View.GetSceneNode()?.Depth ?? 0)
                             .SelectMany(x => x.Accept(this, args, direction))
                             .Where(x => args.Target == null || x.TransformerPath[0] == args.Target.Transformer))
                    {
                        yield return(value);
                    }
                }
            }