Exemplo n.º 1
0
        public void DeleteConnection(CompositorEdgeDescription edge)
        {
            lock (graphLock)
            {
                DirectedWeightedEdge<CompositorNode, CompositorEdgeDescriptionListWrapper> gedge = null;

                throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
        public void AddConnection(CompositorNode begin, CompositorNode end, int begin_slot = 0, int end_slot = 0)
        {
            lock (graphLock)
            {                
                //This f**k is f*****g crazy.... 
                CompositorEdgeDescription desc = new CompositorEdgeDescription();
                desc.InputSlotIndex = end_slot;
                desc.OutputSlotIndex = begin_slot;
                desc.Active = true;
                desc.Input = begin;
                desc.Output = end;
               
                if (begin == null || end == null)
                {
                    Logger.Log.AddLogEntry(LogLevel.Error, "BasicCompositor", Status.Meh);
                    return;
                }
                    
                DirectedWeightedEdge<CompositorNode, CompositorEdgeDescriptionListWrapper> gedge = null;

                DirectedWeightedNode<CompositorNode, CompositorEdgeDescriptionListWrapper> gnode_begin = null;
                DirectedWeightedNode<CompositorNode, CompositorEdgeDescriptionListWrapper> gnode_end = null;

                //Find begin and end node
                _Nodes.ForEach(x => {if(x.Data.ID == begin.ID) gnode_begin = x;});
                _Nodes.ForEach(x =>
                    {
                        if (x.Data.ID == end.ID)
                            gnode_end = x;
                    });

                if (gnode_begin == null || gnode_end == null)
                {
                    Logger.Log.AddLogEntry(LogLevel.Error, "BasicCompositor", Status.BadArgument);
                    return;
                }



                if ((gnode_begin.Data.OutputSlots != null && gnode_begin.Data.OutputSlots.Length <= begin_slot) || 
                    (gnode_end.Data.InputSlots != null && gnode_end.Data.InputSlots.Length <= end_slot))
                {
                    Logger.Log.AddLogEntry(LogLevel.Error, "BasicCompositor", Status.BadArgument);
                    return;
                }
                    
                //Is there an edge with this nodes?
                _Edges.ForEach(x =>
                    {
                        if(x.SourceNode.InstId == gnode_begin.InstId && x.DestinationNode.InstId == gnode_end.InstId)
                            gedge = x;
                    });

                if (gedge == null)
                {
                    CompositorEdgeDescriptionListWrapper wrap = new CompositorEdgeDescriptionListWrapper();
                    wrap.Descriptions.Add(desc);
                    _Edges.Add(_CompositorGraph.AddEdge(gnode_begin, gnode_end, wrap));
                }
                else
                    gedge.Weight.Descriptions.Add(desc);
            }
        }