Beispiel #1
0
 public static string ToNative(this Structural2DVoid v)
 {
     return(new GSA2DVoid()
     {
         Value = v
     }.SetGWACommand());
 }
 public static string ToNative(this Structural2DVoid v)
 {
     return(SchemaConversion.Helper.ToNativeTryCatch(v, () => new GSA2DVoid()
     {
         Value = v
     }.SetGWACommand()));
 }
        public void ParseGWACommand(List <GSANode> nodes)
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural2DVoid();

            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();

            counter++; // Type
            counter++; // Property
            counter++; // Group

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

            for (var i = 0; i < nodeRefs.Length; i++)
            {
                var node = nodes.Where(n => n.GSAId.ToString() == nodeRefs[i]).FirstOrDefault();
                if (node == null)
                {
                    //TO DO: review how this is possible and prevent it
                    continue;
                }

                var speckleNodeObj = node.Value;
                if (speckleNodeObj != null)
                {
                    coordinates.AddRange(speckleNodeObj.Value);
                    this.SubGWACommand.Add(node.GWACommand);
                }
            }

            var temp = new Structural2DVoid(
                coordinates.Essential(),
                color.HexToArgbColor());

            obj.Vertices = temp.Vertices;
            obj.Faces    = temp.Faces;
            obj.Colors   = temp.Colors;

            this.Value = obj;
        }