Esempio n. 1
0
        public void CoreByEnvelopeTest()
        {
            var model   = Model.FromJson(System.IO.File.ReadAllText("../../../../test/envelope1.json"));
            var inputs  = new CoreByEnvelopeInputs(0.15, 0.5, 1.0, 4.0, "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = CoreByEnvelope.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);

            System.IO.File.WriteAllText("../../../../test/CoreByEnvelope1.json", outputs.model.ToJson());
            outputs.model.ToGlTF("../../../../test/CoreByEnvelope1.glb");

            model   = Model.FromJson(System.IO.File.ReadAllText("../../../../test/envelope2.json"));
            inputs  = new CoreByEnvelopeInputs(0.15, 0.5, 1.0, 4.0, "", "", new Dictionary <string, string>(), "", "", "");
            outputs = CoreByEnvelope.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);
            System.IO.File.WriteAllText("../../../../test/CoreByEnvelope2.json", outputs.model.ToJson());
            outputs.model.ToGlTF("../../../../test/CoreByEnvelope2.glb");

            model   = Model.FromJson(System.IO.File.ReadAllText("../../../../test/envelope3.json"));
            inputs  = new CoreByEnvelopeInputs(0.15, 0.5, 1.0, 4.0, "", "", new Dictionary <string, string>(), "", "", "");
            outputs = CoreByEnvelope.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);
            System.IO.File.WriteAllText("../../../../test/CoreByEnvelope3.json", outputs.model.ToJson());
            outputs.model.ToGlTF("../../../../test/CoreByEnvelope3.glb");
        }
Esempio n. 2
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 <CoreByEnvelopeInputs>(root, true);

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

            // 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 <CoreByEnvelopeInputs, CoreByEnvelopeOutputs>(store, CoreByEnvelope.Execute);
            await l.InvokeAsync(input);
        }
        public void CoreByEnvelopeTest()
        {
            var model =
                Model.FromJson(System.IO.File.ReadAllText(INPUT + "Envelope1.json"));
            var inputs = new CoreByEnvelopeInputs(
                percentageArea: 0.15,
                lengthToWidthRatio: 0.5,
                minimumPerimeterOffset: 1.0,
                serviceCorePenthouseHeight: 4.0,
                "", "", new Dictionary <string, string>(), "", "", "");
            var outputs =
                CoreByEnvelope.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);

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

            model =
                Model.FromJson(System.IO.File.ReadAllText(INPUT + "Envelope2.json"));
            inputs =
                new CoreByEnvelopeInputs(
                    percentageArea: 0.15,
                    lengthToWidthRatio: 0.5,
                    minimumPerimeterOffset: 1.0,
                    serviceCorePenthouseHeight: 4.0,
                    "", "", new Dictionary <string, string>(), "", "", "");
            outputs =
                CoreByEnvelope.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);
            System.IO.File.WriteAllText(OUTPUT + "CoreByEnvelope2.json", outputs.Model.ToJson());
            outputs.Model.AddElements(model.Elements.Values);
            outputs.Model.ToGlTF(OUTPUT + "CoreByEnvelope2.glb");

            model =
                Model.FromJson(System.IO.File.ReadAllText(INPUT + "Envelope3.json"));
            inputs =
                new CoreByEnvelopeInputs(
                    percentageArea: 0.15,
                    lengthToWidthRatio: 0.5,
                    minimumPerimeterOffset: 1.0,
                    serviceCorePenthouseHeight: 4.0,
                    "", "", new Dictionary <string, string>(), "", "", "");
            outputs =
                CoreByEnvelope.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);
            System.IO.File.WriteAllText(OUTPUT + "CoreByEnvelope3.json",
                                        outputs.Model.ToJson());
            outputs.Model.AddElements(model.Elements.Values);
            outputs.Model.ToGlTF(OUTPUT + "CoreByEnvelope3.glb");
        }
        public async Task InvokeFunction()
        {
            var store = new FileModelStore <CoreByEnvelopeInputs>("./", true);

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

            // 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 <CoreByEnvelopeInputs, CoreByEnvelopeOutputs>(store, CoreByEnvelope.Execute);
            var output = await l.InvokeAsync(input);
        }