Example #1
0
        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];
        }
Example #2
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);
 }
Example #3
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
 protected abstract void Recompute(DGArguments args);
Example #7
0
 // intermediary function you can override to implement caching, etc
 protected virtual void RunRecompute(DGArguments args)
 {
     Recompute(args);
 }
Example #8
0
 public virtual void ForceEvaluate(DGArguments args)
 {
     RunRecompute(args);
 }
Example #9
0
 protected override void Recompute(DGArguments args)
 {
 }
Example #10
0
 public virtual object Evaluate(DGArguments args)
 {
     return(_value);
 }
Example #11
0
        public virtual T Value <T>(DGArguments args)
        {
            object o = source.Evaluate(args);

            return((T)o);
        }
Example #12
0
 public virtual object Evaluate(DGArguments args)
 {
     return(MeshSourceF(args));
 }
Example #13
0
 protected virtual DMesh3 GetReadMesh(DGArguments args)
 {
     RunRecompute(args);
     return(ReadMesh);
 }
 protected virtual DMesh3 GetOffsetMesh(DGArguments args)
 {
     RunRecompute(args);
     return(OffsetMesh);
 }