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

            var store = new FileModelStore <CoreByLevelsInputs>(root);

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

            // 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 <CoreByLevelsInputs, CoreByLevelsOutputs>(store, CoreByLevels.Execute);
            await l.InvokeAsync(input);
        }
        public void CoreBuildingTest()
        {
            var model   = Model.FromJson(System.IO.File.ReadAllText("../../../../../../TestOutput/Building-01.json"));
            var inputs  = new CoreByLevelsInputs(1.0, 45.0, "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = CoreByLevels.Execute(new Dictionary <string, Model> {
                { "Levels", model }
            }, inputs);

            System.IO.File.WriteAllText("../../../../../../TestOutput/CoreBuilding.json", outputs.model.ToJson());
            outputs.model.ToGlTF("../../../../../../TestOutput/CoreBuilding.glb");
        }
Example #3
0
        public async Task InvokeFunction()
        {
            var store = new FileModelStore <CoreByLevelsInputs>("./", true);

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

            // 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 <CoreByLevelsInputs, CoreByLevelsOutputs>(store, CoreByLevels.Execute);
            var output = await l.InvokeAsync(input);
        }
        public void CoreBuildingTest()
        {
            var model  = Model.FromJson(System.IO.File.ReadAllText(INPUT + "Building-01.json"));
            var inputs =
                new CoreByLevelsInputs(
                    setback: 1.0,
                    rotation: 45.0,
                    "", "", new Dictionary <string, string>(), "", "", "");
            var outputs =
                CoreByLevels.Execute(new Dictionary <string, Model> {
                { "Levels", model }
            }, inputs);

            System.IO.File.WriteAllText(OUTPUT + "CoreBuilding.json", outputs.Model.ToJson());
            outputs.Model.AddElements(model.Elements.Values);
            outputs.Model.ToGlTF(OUTPUT + "CoreBuilding.glb");
        }