public GraphNode() { inputs = new SGIO(); outputs = new SGIO(); upStreams = new List <GraphNode>(); downStreams = new List <GraphNode>(); }
public Node() { inputs = new SGIO(); outputs = new SGIO(); upstreams = new List <Node>(); downStreams = new List <Node>(); }
public void Execute(int i) { currentStep = i; SGIO tobeMerged = PreExecution(i); rules[i].Execute(); PostExecution(i, tobeMerged); }
public void ClearStage(int index) { SGIO io = stagedOutputs[index]; foreach (ShapeObject o in io.shapes) { try { GameObject.Destroy(o); } catch { } } }
public void HighlightStepObjectScope(int index) { for (int i = 0; i < stagedOutputs.Count; i++) { SGIO io = stagedOutputs[i]; foreach (ShapeObject o in io.shapes) { o.highlightScope = false; } } foreach (ShapeObject o in stagedOutputs[index].shapes) { o.highlightScope = true; } }
public virtual void Execute(int i) { //------------------------------------ currentStep = i; SGIO tobeMerged = PreExecution(i); //Debug.Log("rule inputSHapes.Count=" + subNodes[i].inputs.shapes.Count); //Debug.Log(string.Format("{0}:step{1} about to execute {2} ",name,i,subNodes[i].name)); subNodes[i].step = i; subNodes[i].Execute(); //------------------------------------ //Debug.Log("rule outputSHapes.Count=" + subNodes[i].outputs.shapes.Count); PostExecution(i, tobeMerged); }
public virtual void PostExecution(int step, SGIO tobeMerged) { SGIO tempOut = new SGIO(); tempOut = SGIO.Merge(subNodes[step].outputs, tobeMerged); if (step >= stagedOutputs.Count) { stagedOutputs.Add(tempOut); } else { stagedOutputs[step] = tempOut; } }
public static SGIO Merge(SGIO io1, SGIO io2) { List <string> names = new List <string>(io1.names); List <ShapeObject> shapes = new List <ShapeObject>(io1.shapes); foreach (string name in io2.names) { if (!names.Contains(name)) { names.Add(name); } } foreach (ShapeObject shape in io2.shapes) { if (!shapes.Contains(shape)) { shapes.Add(shape); } } return(new SGIO(names, shapes)); }
public void PostExecution(int step, SGIO tobeMerged) { SGIO tempOut = new SGIO(); tempOut = SGIO.Merge(rules[step].outputs, tobeMerged); if (step >= stagedOutputs.Count) { stagedOutputs.Add(tempOut); } else { //remove outdated objects foreach (ShapeObject o in stagedOutputs[step].shapes) { if (!tempOut.shapes.Contains(o)) { GameObject.Destroy(o); } } //add additional shape objects foreach (ShapeObject o in tempOut.shapes) { if (!stagedOutputs[step].shapes.Contains(o)) { stagedOutputs[step].shapes.Add(o); } } //add additional names foreach (string n in tempOut.names) { if (!stagedOutputs[step].names.Contains(n)) { stagedOutputs[step].names.Add(n); } } } }
public SGIO PreExecution(int step) { List <ShapeObject> availableShapes; List <ShapeObject> outShapes = new List <ShapeObject>(); SGIO tobeMerged = new SGIO(); //get available shapes if (step == 0) { if (assignedObjects.Count > 0) { rules[0].inputs.shapes = assignedObjects; return(tobeMerged); } availableShapes = inputs.shapes; } else { availableShapes = stagedOutputs[step - 1].shapes; } //select shapes from available shapes base on required names foreach (ShapeObject o in availableShapes) { if (rules[step].inputs.names.Contains(o.name)) { outShapes.Add(o); } else if (!tobeMerged.names.Contains(o.name)) { tobeMerged.names.Add(o.name); } tobeMerged.shapes.Add(o); } rules[step].inputs.shapes = availableShapes; return(tobeMerged); }
public virtual SGIO PreExecution(int step) { List <ShapeObject> availableShapes = new List <ShapeObject>(); List <ShapeObject> outShapes = new List <ShapeObject>(); SGIO tobeMerged = new SGIO(); string txt = string.Format("PreExe step {0}, stg.Count={1}", step, stagedOutputs.Count); //Debug.Log(txt); //get available shapes if (step == 0) { //Debug.Log(string.Format("step==0, inputShapeCount={0} assignedCount={1}", inputs.shapes.Count , assignedObjects.Count)); if (upStreams.Count > 0) { inputs.shapes.Clear(); subNodes[0].inputs.shapes.Clear(); foreach (GraphNode g in upStreams) { foreach (ShapeObject so in g.outputs.shapes) { if (so == null) { string msg = string.Format("grammar is {0}", this.GetType().ToString()); msg += "\ngrammar.catelog=" + this.category.ToString(); msg += "\nGUID=" + this.guid; msg += "\nUpstream=" + ((Grammar)g).guid; msg += " upstream.outputCount=" + g.outputs.shapes.Count; throw new System.Exception(msg); } if (inputs.names.Contains(so.name)) { inputs.shapes.Add(so); so.Show(false); if (subNodes[0].inputs.names.Contains(so.name)) { subNodes[0].inputs.shapes.Add(so); } else { tobeMerged.shapes.Add(so); } } } } //Debug.Log("inputs.shapes.count=" + inputs.shapes.Count); return(tobeMerged); } else if (assignedObjects.Count > 0) { foreach (ShapeObject so in assignedObjects) { so.Show(false); } subNodes[0].inputs.shapes = assignedObjects; return(tobeMerged); } subNodes[0].inputs.shapes = inputs.shapes; return(tobeMerged); } else { availableShapes.AddRange(stagedOutputs[step - 1].shapes); } foreach (ShapeObject o in availableShapes) { try { if (subNodes[step].inputs.names.Contains(o.name)) { outShapes.Add(o); } //if (rules[step].inputs.names.Contains(o.name)) // outShapes.Add(o); else { //Debug.Log(step + " " + rules[step].inputs.names[0] + " name not match " + o.name); if (!tobeMerged.names.Contains(o.name)) { tobeMerged.names.Add(o.name); } tobeMerged.shapes.Add(o); } } catch { //toBeDeleted.Add(o); Debug.Log("TBD found at " + step + "ShapeObject=" + o); } } ////foreach(ShapeObject o in toBeDeleted) ////{ //// availableShapes.Remove(o); ////} subNodes[step].inputs.shapes = outShapes; return(tobeMerged); }