Пример #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 <EnvelopeBySketchInputs>(root);

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

            // 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 <EnvelopeBySketchInputs, EnvelopeBySketchOutputs>(store, EnvelopeBySketch.Execute);
            await l.InvokeAsync(input);
        }
Пример #2
0
        public void EnvelopeBySketchTest()
        {
            var model   = new Model();
            var polygon =
                new Polygon
                (
                    new[]
            {
                new Vector3(0.0, 0.0),
                new Vector3(100.0, 0.0),
                new Vector3(100.0, 100.0),
                new Vector3(60.0, 100.0),
                new Vector3(60.0, 30.0),
                new Vector3(40.0, 40.0),
                new Vector3(40.0, 100.0),
                new Vector3(0.0, 100.0)
            }
                );
            var inputs =
                new EnvelopeBySketchInputs(polygon, 80.0, 20.0, 2.0, 100.0, 20.0, "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = EnvelopeBySketch.Execute(new Dictionary <string, Model> {
                { "Envelope", model }
            }, inputs);

            System.IO.File.WriteAllText("../../../../../../TestOutput/EnvelopeBySketch.json", outputs.model.ToJson());
            outputs.model.ToGlTF("../../../../../../TestOutput/EnvelopeBySketch.glb");
        }
Пример #3
0
        public async Task InvokeFunction()
        {
            var store = new FileModelStore <EnvelopeBySketchInputs>("./", true);

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

            // 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 <EnvelopeBySketchInputs, EnvelopeBySketchOutputs>(store, EnvelopeBySketch.Execute);
            var output = await l.InvokeAsync(input);
        }
Пример #4
0
        public void EnvelopeBySketchTest()
        {
            var polygon =
                new Polygon
                (
                    new[]
            {
                new Vector3(6.0, 0.0),
                new Vector3(9.0, 0.0),
                new Vector3(9.0, 4.0),
                new Vector3(13.0, 4.0),
                new Vector3(13.0, 7.0),
                new Vector3(9.0, 7.0),
                new Vector3(9.0, 11.0),
                new Vector3(6.0, 11.0),
                new Vector3(6.0, 7.0),
                new Vector3(2.0, 7.0),
                new Vector3(2.0, 4.0),
                new Vector3(6.0, 4.0)
            });
            var inputs =
                new EnvelopeBySketchInputs(perimeter: polygon,
                                           buildingHeight: 27.0,
                                           foundationDepth: 3.0,
                                           useSetbacks: true,
                                           setbackInterval: 50.0,
                                           setbackDepth: 5.0,
                                           minimumTierArea: 100.0,
                                           bucketName: "",
                                           uploadsBucket: "",
                                           modelInputKeys: new Dictionary <string, string>(),
                                           gltfKey: "",
                                           elementsKey: "",
                                           ifcKey: "");
            var outputs =
                EnvelopeBySketch.Execute(new Dictionary <string, Model> {
                { "Envelope", new Model() }
            }, inputs);

            System.IO.File.WriteAllText(OUTPUT + "EnvelopeBySketch.json", outputs.Model.ToJson());
            outputs.Model.ToGlTF(OUTPUT + "EnvelopeBySketch.glb");
        }