Exemplo n.º 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 <RoomsByLevelsInputs>(root);

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

            // 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 <RoomsByLevelsInputs, RoomsByLevelsOutputs>(store, RoomsByLevels.Execute);
            await l.InvokeAsync(input);
        }
Exemplo n.º 2
0
        public void RoomsByLevelsThreeBay()
        {
            var inputs = new RoomsByLevelsInputs(
                corridorWidth: 7.0,
                roomArea: 100.0,
                "", "", new Dictionary <string, string>(), "", "", "");
            var model   = Model.FromJson(System.IO.File.ReadAllText(INPUT + "modelThreeBay.json"));
            var outputs = RoomsByLevels.Execute(new Dictionary <string, Model> {
                { "Envelope", model }, { "Levels", model }
            }, inputs);

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