예제 #1
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural2DLoadPanel;

            if (load.Loading == null)
            {
                return("");
            }

            var keyword = typeof(GSAGridAreaLoad).GetGSAKeyword();

            //There are no GSA types for these yet so use empty strings for the type names for the index
            var gridSurfaceIndex = Initialiser.Cache.ResolveIndex("GRID_SURFACE.1");
            var gridPlaneIndex   = Initialiser.Cache.ResolveIndex("GRID_PLANE.4");

            var loadCaseIndex = 0;

            try
            {
                loadCaseIndex = Initialiser.Cache.LookupIndex(typeof(GSALoadCase).GetGSAKeyword(), load.LoadCaseRef).Value;
            }
            catch { }

            var axis = HelperClass.Parse2DAxis(load.Value.ToArray());

            // Calculate elevation
            var elevation = (load.Value[0] * axis.Normal.Value[0] +
                             load.Value[1] * axis.Normal.Value[1] +
                             load.Value[2] * axis.Normal.Value[2]) /
                            Math.Sqrt(axis.Normal.Value[0] * axis.Normal.Value[0] +
                                      axis.Normal.Value[1] * axis.Normal.Value[1] +
                                      axis.Normal.Value[2] * axis.Normal.Value[2]);

            // Transform coordinate to new axis
            var transformed = HelperClass.MapPointsGlobal2Local(load.Value.ToArray(), axis);

            var ls = new List <string>();

            var direction = new string[3] {
                "X", "Y", "Z"
            };

            var gwaCommands = new List <string>();

            for (var i = 0; i < load.Loading.Value.Count(); i++)
            {
                if (load.Loading.Value[i] == 0)
                {
                    continue;
                }

                var index = Initialiser.Cache.ResolveIndex(typeof(GSAGridAreaLoad).GetGSAKeyword());

                ls.Clear();
                var subLs = new List <string>();
                for (var j = 0; j < transformed.Count(); j += 3)
                {
                    subLs.Add("(" + transformed[j].ToString() + "," + transformed[j + 1].ToString() + ")");
                }

                ls.AddRange(new string[] {
                    "SET_AT",
                    index.ToString(),
                    keyword + ":" + HelperClass.GenerateSID(load),
                    load.Name == null || load.Name == "" ? " " : load.Name,
                    gridSurfaceIndex.ToString(),
                    "POLYGON",
                    string.Join(" ", subLs),
                    loadCaseIndex.ToString(),
                    "GLOBAL",
                    "NO",
                    direction[i],
                    load.Loading.Value[i].ToString()
                });

                gwaCommands.Add(string.Join("\t", ls));
            }

            ls.Clear();
            ls.AddRange(new[] {
                "SET",
                "GRID_SURFACE.1",
                gridSurfaceIndex.ToString(),
                load.Name == null || load.Name == "" ? " " : load.Name,
                gridPlaneIndex.ToString(),
                "2",    // Dimension of elements to target
                "all",  // List of elements to target
                "0.01", // Tolerance
                "ONE",  // Span option
                "0"
            });         // Span angle
            gwaCommands.Add(string.Join("\t", ls));

            ls.Clear();
            HelperClass.SetAxis(axis, out int planeAxisIndex, out string planeAxisGwa, load.Name);
            if (planeAxisGwa.Length > 0)
            {
                gwaCommands.Add(planeAxisGwa);
            }

            ls.AddRange(new[] {
                "SET",
                "GRID_PLANE.4",
                gridPlaneIndex.ToString(),
                load.Name == null || load.Name == "" ? " " : load.Name,
                "GENERAL", // Type
                planeAxisIndex.ToString(),
                elevation.ToString(),
                "0", // Elevation above
                "0"
            });      // Elevation below
            gwaCommands.Add(string.Join("\t", ls));

            return(string.Join("\n", gwaCommands));
        }