public void ParseGWACommand(List <GSANode> nodes)
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural1DElement();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++].Trim(new char[] { '"' });
            counter++; // Color

            var type = pieces[counter++];

            if (type == "BEAM")
            {
                obj.ElementType = Structural1DElementType.Beam;
            }
            else if (type == "COLUMN")
            {
                obj.ElementType = Structural1DElementType.Column;
            }
            else if (type == "CANTILEVER")
            {
                obj.ElementType = Structural1DElementType.Cantilever;
            }
            else
            {
                obj.ElementType = Structural1DElementType.Generic;
            }

            obj.PropertyRef = HelperClass.GetApplicationId(typeof(GSA1DProperty).GetGSAKeyword(), Convert.ToInt32(pieces[counter++]));
            this.Group      = Convert.ToInt32(pieces[counter++]); // Keep group for load targetting

            obj.Value = new List <double>();
            var nodeRefs = pieces[counter++].ListSplit(" ");

            for (var i = 0; i < nodeRefs.Length; i++)
            {
                var node = nodes.Where(n => n.GSAId == Convert.ToInt32(nodeRefs[i])).FirstOrDefault();
                obj.Value.AddRange(node.Value.Value);
                this.SubGWACommand.Add(node.GWACommand);
            }

            var orientationNodeRef = pieces[counter++];
            var rotationAngle      = Convert.ToDouble(pieces[counter++]);

            if (orientationNodeRef != "0")
            {
                var node = nodes.Where(n => n.GSAId == Convert.ToInt32(orientationNodeRef)).FirstOrDefault();
                obj.ZAxis = HelperClass.Parse1DAxis(obj.Value.ToArray(),
                                                    rotationAngle, node.Value.ToArray()).Normal as StructuralVectorThree;
                this.SubGWACommand.Add(node.GWACommand);
            }
            else
            {
                obj.ZAxis = HelperClass.Parse1DAxis(obj.Value.ToArray(), rotationAngle).Normal as StructuralVectorThree;
            }

            counter += 9; //Skip to end conditions

            obj.EndRelease = new List <StructuralVectorBoolSix>
            {
                ParseEndReleases(Convert.ToInt32(pieces[counter++])),
                ParseEndReleases(Convert.ToInt32(pieces[counter++]))
            };

            // Skip to offsets at fifth to last
            counter    = pieces.Length - 5;
            obj.Offset = new List <StructuralVectorThree>
            {
                new StructuralVectorThree(new double[3]),
                new StructuralVectorThree(new double[3])
            };

            obj.Offset[0].Value[0] = Convert.ToDouble(pieces[counter++]);
            obj.Offset[1].Value[0] = Convert.ToDouble(pieces[counter++]);

            obj.Offset[0].Value[1] = Convert.ToDouble(pieces[counter++]);
            obj.Offset[1].Value[1] = obj.Offset[0].Value[1];

            obj.Offset[0].Value[2] = Convert.ToDouble(pieces[counter++]);
            obj.Offset[1].Value[2] = obj.Offset[0].Value[2];

            this.Value = obj;
        }
        public void ParseGWACommand(List <GSANode> nodes)
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural1DElement();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId);

            obj.Name = pieces[counter++].Trim(new char[] { '"' });
            counter++; // Colour
            counter++; // Type
            obj.PropertyRef = HelperClass.GetApplicationId(typeof(GSA1DProperty).GetGSAKeyword(), Convert.ToInt32(pieces[counter++]));
            counter++; // Group

            obj.Value = new List <double>();
            for (var i = 0; i < 2; i++)
            {
                var key  = pieces[counter++];
                var node = nodes.Where(n => n.GSAId == Convert.ToInt32(key)).FirstOrDefault();
                obj.Value.AddRange(node.Value.Value);
                this.SubGWACommand.Add(node.GWACommand);
            }

            var orientationNodeRef = pieces[counter++];
            var rotationAngle      = Convert.ToDouble(pieces[counter++]);

            if (orientationNodeRef != "0")
            {
                var node = nodes.Where(n => n.GSAId == Convert.ToInt32(orientationNodeRef)).FirstOrDefault();
                obj.ZAxis = HelperClass.Parse1DAxis(obj.Value.ToArray(),
                                                    rotationAngle, node.Value.Value.ToArray()).Normal as StructuralVectorThree;
                this.SubGWACommand.Add(node.GWACommand);
            }
            else
            {
                obj.ZAxis = HelperClass.Parse1DAxis(obj.Value.ToArray(), rotationAngle).Normal as StructuralVectorThree;
            }


            if (pieces[counter++] != "NO_RLS")
            {
                var start = pieces[counter++];
                var end   = pieces[counter++];

                obj.EndRelease = new List <StructuralVectorBoolSix>
                {
                    new StructuralVectorBoolSix(new bool[6]),
                    new StructuralVectorBoolSix(new bool[6])
                };

                obj.EndRelease[0].Value[0] = ParseEndRelease(start[0], pieces, ref counter);
                obj.EndRelease[0].Value[1] = ParseEndRelease(start[1], pieces, ref counter);
                obj.EndRelease[0].Value[2] = ParseEndRelease(start[2], pieces, ref counter);
                obj.EndRelease[0].Value[3] = ParseEndRelease(start[3], pieces, ref counter);
                obj.EndRelease[0].Value[4] = ParseEndRelease(start[4], pieces, ref counter);
                obj.EndRelease[0].Value[5] = ParseEndRelease(start[5], pieces, ref counter);

                obj.EndRelease[1].Value[0] = ParseEndRelease(end[0], pieces, ref counter);
                obj.EndRelease[1].Value[1] = ParseEndRelease(end[1], pieces, ref counter);
                obj.EndRelease[1].Value[2] = ParseEndRelease(end[2], pieces, ref counter);
                obj.EndRelease[1].Value[3] = ParseEndRelease(end[3], pieces, ref counter);
                obj.EndRelease[1].Value[4] = ParseEndRelease(end[4], pieces, ref counter);
                obj.EndRelease[1].Value[5] = ParseEndRelease(end[5], pieces, ref counter);
            }
            else
            {
                obj.EndRelease = new List <StructuralVectorBoolSix>
                {
                    new StructuralVectorBoolSix(new bool[] { true, true, true, true, true, true }),
                    new StructuralVectorBoolSix(new bool[] { true, true, true, true, true, true })
                };
            }

            obj.Offset = new List <StructuralVectorThree>
            {
                new StructuralVectorThree(new double[3]),
                new StructuralVectorThree(new double[3])
            };

            obj.Offset[0].Value[0] = Convert.ToDouble(pieces[counter++]);
            obj.Offset[1].Value[0] = Convert.ToDouble(pieces[counter++]);

            obj.Offset[0].Value[1] = Convert.ToDouble(pieces[counter++]);
            obj.Offset[1].Value[1] = obj.Offset[0].Value[1];

            obj.Offset[0].Value[2] = Convert.ToDouble(pieces[counter++]);
            obj.Offset[1].Value[2] = obj.Offset[0].Value[2];

            //counter++; // Action // TODO: EL.4 SUPPORT
            counter++; // Dummy

            if (counter < pieces.Length)
            {
                Member = pieces[counter++];
            }

            this.Value = obj;
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural1DLoadLine;

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

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

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

            var loadCaseRef = 0;

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

            var axis = HelperClass.Parse1DAxis(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 subLs = new List <string>();
                for (var j = 0; j < transformed.Count(); j += 3)
                {
                    subLs.Add("(" + transformed[j].ToString() + "," + transformed[j + 1].ToString() + ")");
                }

                ls.Clear();

                var index = Initialiser.Cache.ResolveIndex(typeof(GSAGridLineLoad).GetGSAKeyword(), typeof(GSAGridLineLoad).Name);

                ls.AddRange(new[] {
                    "SET_AT",
                    index.ToString(),
                    keyword + ":" + HelperClass.GenerateSID(load),
                    load.Name == null || load.Name == "" ? " " : load.Name,
                    gridSurfaceIndex.ToString(),
                    "POLYGON",
                    string.Join(" ", subLs),
                    loadCaseRef.ToString(),
                    "GLOBAL",
                    "NO",
                    direction[i],
                    load.Loading.Value[i].ToString(),
                    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(),
                                "1",          // Dimension of elements to target
                                "all",        // List of elements to target
                                "0.01",       // Tolerance
                                "TWO_SIMPLE", // 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));
        }