Ejemplo n.º 1
0
        public void ParseGWACommand()
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural2DLoadPanel();

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

            var counter = 1; // Skip identifier

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

            HelperClass.GetGridPlaneRef(Convert.ToInt32(pieces[counter++]), out int gridPlaneRefRet, out string gridSurfaceRec);
            HelperClass.GetGridPlaneData(gridPlaneRefRet, out int gridPlaneAxis, out double gridPlaneElevation, out string gridPlaneRec);

            this.SubGWACommand.Add(gridSurfaceRec);
            this.SubGWACommand.Add(gridPlaneRec);

            string gwaRec = null;
            var    axis   = HelperClass.Parse0DAxis(gridPlaneAxis, Initialiser.Interface, out gwaRec);

            if (gwaRec != null)
            {
                this.SubGWACommand.Add(gwaRec);
            }
            double elevation = gridPlaneElevation;

            var polylineDescription = "";

            switch (pieces[counter++])
            {
            case "PLANE":
                // TODO: Do not handle for now
                return;

            case "POLYREF":
                var    polylineRef = pieces[counter++];
                string newRec      = null;
                HelperClass.GetPolylineDesc(Convert.ToInt32(polylineRef), out polylineDescription, out newRec);
                this.SubGWACommand.Add(newRec);
                break;

            case "POLYGON":
                polylineDescription = pieces[counter++];
                break;
            }
            var polyVals = HelperClass.ParsePolylineDesc(polylineDescription);

            for (var i = 2; i < polyVals.Length; i += 3)
            {
                polyVals[i] = elevation;
            }

            obj.Value  = HelperClass.MapPointsLocal2Global(polyVals, axis).ToList();
            obj.Closed = true;

            var loadCaseIndex = Convert.ToInt32(pieces[counter++]);

            if (loadCaseIndex > 0)
            {
                obj.LoadCaseRef = HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), loadCaseIndex);
            }

            var            loadAxisId   = 0;
            var            loadAxisData = pieces[counter++];
            StructuralAxis loadAxis;

            if (loadAxisData == "LOCAL")
            {
                loadAxis = axis;
            }
            else
            {
                loadAxisId = loadAxisData == "GLOBAL" ? 0 : Convert.ToInt32(loadAxisData);
                loadAxis   = HelperClass.Parse0DAxis(loadAxisId, Initialiser.Interface, out gwaRec);
                if (gwaRec != null)
                {
                    this.SubGWACommand.Add(gwaRec);
                }
            }
            var projected = pieces[counter++] == "YES";
            var direction = pieces[counter++];
            var value     = Convert.ToDouble(pieces[counter++]);

            obj.Loading = new StructuralVectorThree(new double[3]);
            switch (direction.ToUpper())
            {
            case "X":
                obj.Loading.Value[0] = value;
                break;

            case "Y":
                obj.Loading.Value[1] = value;
                break;

            case "Z":
                obj.Loading.Value[2] = value;
                break;

            default:
                // TODO: Error case maybe?
                break;
            }
            obj.Loading.TransformOntoAxis(loadAxis);

            if (projected)
            {
                var scale = (obj.Loading.Value[0] * axis.Normal.Value[0] +
                             obj.Loading.Value[1] * axis.Normal.Value[1] +
                             obj.Loading.Value[2] * axis.Normal.Value[2]) /
                            (axis.Normal.Value[0] * axis.Normal.Value[0] +
                             axis.Normal.Value[1] * axis.Normal.Value[1] +
                             axis.Normal.Value[2] * axis.Normal.Value[2]);

                obj.Loading = new StructuralVectorThree(axis.Normal.Value[0], axis.Normal.Value[1], axis.Normal.Value[2]);
                obj.Loading.Scale(scale);
            }

            this.Value = obj;
        }