Esempio n. 1
0
    public static string ToNative(this Structural2DElement el)
    {
      var layer = Initialiser.AppResources.Settings.TargetLayer;

      if (el == null || el.Vertices == null || el.ApplicationId == null)
      {
        return "";
      }

      if (layer == GSATargetLayer.Design)
      {
        return new GSA2DMember() { Value = el }.SetGWACommand();
      }
      if (layer == GSATargetLayer.Analysis && (el.NumFaces() == 1))
      {
        return new GSA2DElement() { Value = el }.SetGWACommand();
      }

      //Reaching this point means it should be treated as a full analytical mesh - where each face creates a new 2D element
      el.Consolidate();

      var elMesh = new Structural2DElementMesh(el.Vertices, el.Faces, el.Colors, el.ElementType, el.PropertyRef,
        new[] { el.Axis }, new[] { el.Offset ?? 0 }, el.ApplicationId, el.GSAMeshSize ?? 0, el.Properties);

      return (new GSA2DElementMesh() { Value = elMesh }).SetGWACommand();
    }
 public static string ToNative(this Structural2DElement mesh)
 {
     return((Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) ? new GSA2DElement()
     {
         Value = mesh
     }.SetGWACommand() : new GSA2DMember()
     {
         Value = mesh
     }.SetGWACommand());
 }
Esempio n. 3
0
        public void ParseGWACommand(List <GSANode> nodes, List <GSA2DProperty> props)
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural2DElement();

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

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = Helper.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++].Trim(new char[] { '"' });
            var color = pieces[counter++].ParseGSAColor();

            var type = pieces[counter++];

            if (color != null)
            {
                obj.Colors = Enumerable.Repeat(color.HexToArgbColor().Value, type.ParseElementNumNodes()).ToList();
            }
            else
            {
                obj.Colors = new List <int>();
            }

            obj.ElementType = Structural2DElementType.Generic;
            var propertyGSAId = Convert.ToInt32(pieces[counter++]);

            obj.PropertyRef = Helper.GetApplicationId(typeof(GSA2DProperty).GetGSAKeyword(), propertyGSAId);
            counter++; // Group

            obj.Vertices = new List <double>();
            obj.Faces    = new List <int>()
            {
                type.ParseElementNumNodes() - 3
            };

            for (var i = 0; i < type.ParseElementNumNodes(); i++)
            {
                var key  = pieces[counter++];
                var node = nodes.Where(n => n.GSAId.ToString() == key).FirstOrDefault();
                obj.Vertices.AddRange(node.Value.Value);
                obj.Faces.Add(i);
                this.SubGWACommand.Add(node.GWACommand);
            }

            counter++; // Orientation node

            var prop = props.Where(p => p.Value.ApplicationId == obj.PropertyRef).FirstOrDefault();

            obj.Axis = Helper.Parse2DAxis(obj.Vertices.ToArray(),
                                          Convert.ToDouble(pieces[counter++]),
                                          prop == null ? false : (prop as GSA2DProperty).IsAxisLocal);
            if (prop != null)
            {
                this.SubGWACommand.Add(prop.GWACommand);
            }

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

                counter += start.Split('K').Length - 1 + end.Split('K').Length - 1;
            }

            counter++; //Ofsset x-start
            counter++; //Ofsset x-end
            counter++; //Ofsset y

            Initialiser.Interface.GetGSATotal2DElementOffset(propertyGSAId, Convert.ToDouble(pieces[counter++]), out var offset, out var offsetRec);
            this.SubGWACommand.Add(offsetRec);

            obj.Offset = offset;

            counter++; // Dummy

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

            this.Value = obj;
        }