Exemplo n.º 1
0
        public async Task InvokeFunction()
        {
            var root   = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../../");
            var config = Hypar.Functions.Function.FromJson(File.ReadAllText(Path.Combine(root, "hypar.json")));

            var store = new FileModelStore <SiteBySketchInputs>(root, true);

            // Create an input object with default values.
            var input = new SiteBySketchInputs();

            // Read local input files to populate incoming test data.
            if (config.ModelDependencies != null)
            {
                var modelInputKeys = new Dictionary <string, string>();
                foreach (var dep in config.ModelDependencies)
                {
                    modelInputKeys.Add(dep.Name, $"{dep.Name}.json");
                }
                input.ModelInputKeys = modelInputKeys;
            }

            // Invoke the function.
            // The function invocation uses a FileModelStore
            // which will write the resulting model to disk.
            // You'll find the model at "./model.gltf"
            var l = new InvocationWrapper <SiteBySketchInputs, SiteBySketchOutputs>(store, SiteBySketch.Execute);
            await l.InvokeAsync(input);
        }
Exemplo n.º 2
0
        public async Task InvokeFunction()
        {
            var store = new FileModelStore <SiteBySketchInputs>("./", true);

            // Create an input object with default values.
            var input = new SiteBySketchInputs();

            // Invoke the function.
            // The function invocation uses a FileModelStore
            // which will write the resulting model to disk.
            // You'll find the model at "./model.gltf"
            var l      = new InvocationWrapper <SiteBySketchInputs, SiteBySketchOutputs>(store, SiteBySketch.Execute);
            var output = await l.InvokeAsync(input);
        }
        public void SiteBySketchTest()
        {
            var model   = new Model();
            var polygon =
                new Polygon(
                    new[]
            {
                new Vector3(-46.0, -29.0, 0.0),
                new Vector3(-10.0, -43.0, -0.0),
                new Vector3(33.0, -40.0, -0.0),
                new Vector3(36.0, 71.0, 0.0)
            });
            var inputs =
                new SiteBySketchInputs(polygon, "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = SiteBySketch.Execute(new Dictionary <string, Model> {
                { "Test", model }
            }, inputs);

            System.IO.File.WriteAllText("../../../../../../TestOutput/SiteBySketch.json", outputs.model.ToJson());
            outputs.model.ToGlTF("../../../../../../TestOutput/SiteBySketch.glb");
        }