Ejemplo n.º 1
0
        public async Task <VerbTestOutputs> Handler(VerbTestInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                // Preload the dependencies (if they exist),
                // so that they are available during model deserialization.
                var asmLocation = this.GetType().Assembly.Location;
                var asmDir      = Path.GetDirectoryName(asmLocation);
                var asmName     = Path.GetFileNameWithoutExtension(asmLocation);
                var depPath     = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

                if (File.Exists(depPath))
                {
                    Console.WriteLine($"Loading dependencies from assembly: {depPath}...");
                    Assembly.LoadFrom(depPath);
                    Console.WriteLine("Dependencies assembly loaded.");
                }

                this.store = new S3ModelStore <VerbTestInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <VerbTestInputs, VerbTestOutputs>(store, VerbTest.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The VerbTest function.
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A VerbTestOutputs instance containing computed results and the model with any new elements.</returns>
        public static VerbTestOutputs Execute(Dictionary <string, Model> inputModels, VerbTestInputs input)
        {
            /// Your code here.
            var            output = new VerbTestOutputs();
            var            sphere = new SphericalSurface(input.SphereCenter.ToVPt(), input.SphereRadius);
            List <Vector3> pts    = new List <Vector3>();

            for (double u = 0; u < 1.0; u += 0.05)
            {
                for (double v = 0; v < 1.0; v += 0.05)
                {
                    var pt = sphere.point(u, v).ToVector3();
                    pts.Add(pt);
                }
            }
            var mesh = sphere.tessellate(new AdaptiveRefinementOptions
            {
                minDivsU = 50,
                minDivsV = 50,
                refine   = false
            }).ToMesh();

            mesh.Material = new Material("White", Colors.White);
            output.Model.AddElement(new MeshElement(mesh, new Material("Shiny", Colors.Red, 0.9, 0.6)));
            output.Model.AddElement(new ModelPoints(pts, BuiltInMaterials.Black));

            var Random = new Random(5);
            var curves = new Array <object>();

            for (var u = 0; u < 4; u++)
            {
                var points  = new Array <object>();
                var ctrlPts = new List <Vector3>();
                for (var v = 0; v < 4; v++)
                {
                    var pt = new Vector3(u * input.Width / 4, v * input.Length / 4, Random.NextDouble() * input.Height);
                    points.push(pt.ToVPt());
                    ctrlPts.Add(pt);
                }
                // output.Model.AddElement(new ModelCurve(new Polyline(ctrlPts)));
                var curve = NurbsCurve.byPoints(points, new haxe.lang.Null <int>(3, true));
                curves.push(curve);
            }
            Console.WriteLine("Done making curves");
            var nurbsSrf = NurbsSurface.byLoftingCurves(curves, new haxe.lang.Null <int>(3, true));

            Console.WriteLine("Done making srf");

            var srfMesh = nurbsSrf.tessellate(new AdaptiveRefinementOptions
            {
                minDivsU = 50,
                minDivsV = 50,
                refine   = false
            }).ToMesh();

            Console.WriteLine("Done making mesh");

            output.Model.AddElement(new MeshElement(srfMesh, new Material("Shiny Blue", Colors.Blue, 0.9, 0.6, null, false, true)));
            return(output);
        }