protected override void Recompute(DGArguments args) { System.Console.WriteLine("Reading file..."); ReadMesh = new DMesh3(); string path = CachedValue <string>(0, args); if (!File.Exists(path)) { return; } DMesh3Builder builder = new DMesh3Builder(); StandardMeshReader reader = new StandardMeshReader(); reader.MeshBuilder = builder; IOReadResult result = reader.Read(path, ReadOptions.Defaults); if (result.code != IOCode.Ok) { return; } ReadMesh = builder.Meshes[0]; }
protected virtual T CachedValue <T>(int portIndex, DGArguments args) { if (InputCache[portIndex].timestamp != Inputs[portIndex].Timestamp) { InputCache[portIndex].cache = Inputs[portIndex].Value <object>(args); InputCache[portIndex].timestamp = Inputs[portIndex].Timestamp; System.Console.WriteLine(" {0}.CachedValue {1}:{2} - new timestamp {3}", Name, portIndex, Inputs[portIndex].PortType.ToString(), InputCache[portIndex].timestamp.time); } return((T)InputCache[portIndex].cache); }
protected override void Recompute(DGArguments args) { string path = Inputs[0].Value <string>(args); DMesh3 mesh = Inputs[1].Value <DMesh3>(args); StandardMeshWriter writer = new StandardMeshWriter(); IOWriteResult result = writer.Write(path, new List <WriteMesh>() { new WriteMesh(mesh) }, WriteOptions.Defaults); if (result.code != IOCode.Ok) { // what?? } }
protected override void Recompute(DGArguments args) { OffsetMesh.Copy(CachedValue <DMesh3>(0, args)); double dist = CachedValue <double>(1, args); if (!OffsetMesh.HasVertexNormals) { MeshNormals.QuickCompute(OffsetMesh); } foreach (int vid in OffsetMesh.VertexIndices()) { Vector3d v = OffsetMesh.GetVertex(vid); Vector3d n = OffsetMesh.GetVertexNormal(vid); v += dist * n; OffsetMesh.SetVertex(vid, v); } }
protected override void RunRecompute(DGArguments args) { System.Console.WriteLine("RunRecompute on node {0}", Name); bool found_dirty = false; for (int i = 0; i < InputCache.Length; ++i) { if (InputCache[i].timestamp != Inputs[i].Timestamp) { found_dirty = true; System.Console.WriteLine(" Found dirty at input {0} - type {1} - timestamp {2} vs cache {3}", i, Inputs[i].PortType.ToString(), Inputs[i].Timestamp.time, InputCache[i].timestamp.time); } } System.Console.WriteLine(" done dirty checks - result was {0}", found_dirty); if (found_dirty) { System.Console.WriteLine(" Recomputing on node {0}", Name); Recompute(args); System.Console.WriteLine(" Done on node {0}", Name); } }
protected abstract void Recompute(DGArguments args);
// intermediary function you can override to implement caching, etc protected virtual void RunRecompute(DGArguments args) { Recompute(args); }
public virtual void ForceEvaluate(DGArguments args) { RunRecompute(args); }
protected override void Recompute(DGArguments args) { }
public virtual object Evaluate(DGArguments args) { return(_value); }
public virtual T Value <T>(DGArguments args) { object o = source.Evaluate(args); return((T)o); }
public virtual object Evaluate(DGArguments args) { return(MeshSourceF(args)); }
protected virtual DMesh3 GetReadMesh(DGArguments args) { RunRecompute(args); return(ReadMesh); }
protected virtual DMesh3 GetOffsetMesh(DGArguments args) { RunRecompute(args); return(OffsetMesh); }