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 <StructureByEnvelopeInputs>(root, true);

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

            // 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 <StructureByEnvelopeInputs, StructureByEnvelopeOutputs>(store, StructureByEnvelope.Execute);
            await l.InvokeAsync(input);
        }
        public void StructureByEnvelopeTest()
        {
            var envModel = Model.FromJson(System.IO.File.ReadAllText(INPUT + "Envelope.json"));
            var lvlModel = Model.FromJson(System.IO.File.ReadAllText(INPUT + "Levels.json"));
            var inputs   = new StructureByEnvelopeInputs(
                gridXAxisInterval: 4.0,
                gridYAxisInterval: 5.0,
                slabEdgeOffset: 1.0,
                displayGrid: false,
                typeOfConstruction: StructureByEnvelopeInputsTypeOfConstruction.Steel,
                bucketName: "",
                uploadsBucket: "",
                modelInputKeys: new Dictionary <string, string>(), gltfKey: "", elementsKey: "", ifcKey: "");
            var outputs = StructureByEnvelope.Execute(
                new Dictionary <string, Model>
            {
                { "Envelope", envModel },
                { "Levels", lvlModel }
            }, inputs);

            System.IO.File.WriteAllText(OUTPUT + "StructureByEnvelope.json", outputs.Model.ToJson());
            outputs.Model.AddElements(envModel.Elements.Values);
            outputs.Model.AddElements(lvlModel.Elements.Values);
            outputs.Model.ToGlTF(OUTPUT + "StructureByEnvelope.glb");
        }
        public void StructureByEnvelopeTest()
        {
            var model   = Model.FromJson(System.IO.File.ReadAllText("../../../../core.json"));
            var inputs  = new StructureByEnvelopeInputs(4.0, 5.0, "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = StructureByEnvelope.Execute(new Dictionary <string, Model> {
                { "envelope", model }
            }, inputs);

            System.IO.File.WriteAllText("../../../../structureCore.json", outputs.Model.ToJson());
            outputs.Model.ToGlTF("../../../../structureCore.glb");

            model   = Model.FromJson(System.IO.File.ReadAllText("../../../../mass.json"));
            inputs  = new StructureByEnvelopeInputs(4.0, 5.0, "", "", new Dictionary <string, string>(), "", "", "");
            outputs = StructureByEnvelope.Execute(new Dictionary <string, Model> {
                { "envelope", model }
            }, inputs);
            System.IO.File.WriteAllText("../../../../structureMass.json", outputs.Model.ToJson());
            outputs.Model.ToGlTF("../../../../structureMass.glb");

            model   = Model.FromJson(System.IO.File.ReadAllText("../../../../story.json"));
            inputs  = new StructureByEnvelopeInputs(4.0, 5.0, "", "", new Dictionary <string, string>(), "", "", "");
            outputs = StructureByEnvelope.Execute(new Dictionary <string, Model> {
                { "envelope", model }
            }, inputs);
            System.IO.File.WriteAllText("../../../../structureStory.json", outputs.Model.ToJson());
            outputs.Model.ToGlTF("../../../../structureStory.glb");
        }
Exemple #4
0
        public void StructureByEnvelopeTest()
        {
            var envModel = Model.FromJson(System.IO.File.ReadAllText(INPUT + "Envelope.json"));
            var lvlModel = Model.FromJson(System.IO.File.ReadAllText(INPUT + "Levels.json"));
            var inputs   = new StructureByEnvelopeInputs(
                gridXAxisInterval: 4.0,
                gridYAxisInterval: 5.0,
                "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = StructureByEnvelope.Execute(
                new Dictionary <string, Model>
            {
                { "Envelope", envModel },
                { "Levels", lvlModel }
            }, inputs);

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