예제 #1
0
        public async Task <ACADIABeamsFromModelPointsOutputs> Handler(ACADIABeamsFromModelPointsInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                // Preload the dependencies (if they exist),
                // so that they are available during model deserialization.
                var asmLocation = this.GetType().Assembly.Location;
                var asmDir      = Path.GetDirectoryName(asmLocation);
                var asmName     = Path.GetFileNameWithoutExtension(asmLocation);
                var depPath     = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

                if (File.Exists(depPath))
                {
                    Console.WriteLine($"Loading dependencies from assembly: {depPath}...");
                    Assembly.LoadFrom(depPath);
                    Console.WriteLine("Dependencies assembly loaded.");
                }

                this.store = new S3ModelStore <ACADIABeamsFromModelPointsInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <ACADIABeamsFromModelPointsInputs, ACADIABeamsFromModelPointsOutputs>(store, ACADIABeamsFromModelPoints.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
예제 #2
0
        public void RunTest()
        {
            var modPtJson = File.ReadAllText("../../../modelPoints.json");
            var modPoints = JsonConvert.DeserializeObject <Model>(modPtJson);

            var input  = new ACADIABeamsFromModelPointsInputs(20.0, "", "", null, "", "", "");
            var output = ACADIABeamsFromModelPoints.Execute(new Dictionary <string, Model> {
                { "BlobData", modPoints }
            }, input);

            output.Model.ToGlTF("../../../myOutput.gltf", false);
            output.Model.ToGlTF("../../../myOutput.glb", true);
        }
        /// <summary>
        /// The ACADIABeamsFromModelPoints function.
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A ACADIABeamsFromModelPointsOutputs instance containing computed results and the model with any new elements.</returns>
        public static ACADIABeamsFromModelPointsOutputs Execute(Dictionary <string, Model> inputModels, ACADIABeamsFromModelPointsInputs input)
        {
            if (!inputModels.TryGetValue("BlobData", out var internalPtsModel))
            {
                throw new Exception("womp womp model points");
            }
            var pts      = internalPtsModel.AllElementsOfType <ModelPoints>().Where(n => n.Name == "BlobCentroids");
            var modelPts = pts.ToArray()[0];

            var locations = modelPts.Locations;
            var output    = new ACADIABeamsFromModelPointsOutputs(input.Threshold);

            foreach (var l in locations)
            {
                var indices = IndecesToConnectWith(l, input.Threshold, modelPts);

                for (int i = 0; i < indices.Count; i++)
                {
                    var line = new Line(l, locations[indices[i]]);
                    var beam = new Beam(line,
                                        WideFlangeProfileServer.Instance.GetProfileByType(WideFlangeProfileType.W12x279),
                                        BuiltInMaterials.Steel,
                                        0,
                                        0,
                                        0,
                                        null,
                                        false);
                    output.Model.AddElement(beam);
                }
            }
            return(output);
        }