public void CoreBySketchTest()
        {
            var polygon =
                new Polygon
                (
                    new[]
            {
                new Vector3(5.0, 5.0),
                new Vector3(10.0, 5.0),
                new Vector3(10.0, 10.0),
                new Vector3(5.0, 10.0)
            }
                );
            var model =
                Model.FromJson(System.IO.File.ReadAllText(INPUT + "LevelsByEnvelope.json"));
            var inputs =
                new CoreBySketchInputs(
                    perimeter: polygon,
                    coreHeightAboveRoof: 3.0,
                    "", "", new Dictionary <string, string>(), "", "", "");
            var outputs =
                CoreBySketch.Execute(new Dictionary <string, Model> {
                { "Levels", model }
            }, inputs);

            System.IO.File.WriteAllText(OUTPUT + "CoreBySketch.json", outputs.Model.ToJson());
            outputs.Model.AddElements(model.Elements.Values);
            outputs.Model.ToGlTF(OUTPUT + "CoreBySketch.glb");
        }
예제 #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 <CoreBySketchInputs>(root, true);

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

            // 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 <CoreBySketchInputs, CoreBySketchOutputs>(store, CoreBySketch.Execute);
            await l.InvokeAsync(input);
        }
예제 #3
0
        public void CoreBySketchTest()
        {
            var polygons =
                new Polygon [] {
                new Polygon(new Vector3[] {
                    new Vector3(30.0, 30.0),
                    new Vector3(60.0, 30.0),
                    new Vector3(60.0, 60.0),
                    new Vector3(30.0, 60.0)
                }
                            ),
                new Polygon(new Vector3[] {
                    new Vector3(60.0, 60.0),
                    new Vector3(90.0, 60.0),
                    new Vector3(90.0, 90.0),
                    new Vector3(60.0, 90.0)
                }
                            )
            };
            var model   = Model.FromJson(System.IO.File.ReadAllText("../../../../../../TestOutput/LevelsByEnvelope.json"));
            var inputs  = new CoreBySketchInputs(polygons, 3.0, "", "", new Dictionary <string, string>(), "", "", "");
            var outputs = CoreBySketch.Execute(new Dictionary <string, Model> {
                { "Levels", model }
            }, inputs);

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