public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralLoadCase(); 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++]; var type = pieces[counter++]; switch (type) { case "DEAD": obj.CaseType = StructuralLoadCaseType.Dead; break; case "LC_VAR_IMP": obj.CaseType = StructuralLoadCaseType.Live; break; case "WIND": obj.CaseType = StructuralLoadCaseType.Wind; break; case "SNOW": obj.CaseType = StructuralLoadCaseType.Snow; break; case "SEISMIC": obj.CaseType = StructuralLoadCaseType.Earthquake; break; case "LC_PERM_SOIL": obj.CaseType = StructuralLoadCaseType.Soil; break; case "LC_VAR_TEMP": obj.CaseType = StructuralLoadCaseType.Thermal; break; default: obj.CaseType = StructuralLoadCaseType.Generic; break; } // Rest is unimportant this.Value = obj; }
public void ParseGWACommand(string GSAUnits, List <GSAMaterialSteel> steels, List <GSAMaterialConcrete> concretes) { if (this.GWACommand == null) { return; } var obj = new Structural1DProperty(); 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 materialType = pieces[counter++]; var materialGrade = pieces[counter++]; if (materialType == "STEEL") { if (steels != null) { var matchingMaterial = steels.Where(m => m.GSAId.ToString() == materialGrade).FirstOrDefault(); obj.MaterialRef = matchingMaterial == null ? null : matchingMaterial.Value.ApplicationId; if (matchingMaterial != null) { this.SubGWACommand.Add(matchingMaterial.GWACommand); } } } else if (materialType == "CONCRETE") { if (concretes != null) { var matchingMaterial = concretes.Where(m => m.GSAId.ToString() == materialGrade).FirstOrDefault(); obj.MaterialRef = matchingMaterial == null ? null : matchingMaterial.Value.ApplicationId; if (matchingMaterial != null) { this.SubGWACommand.Add(matchingMaterial.GWACommand); } } } counter++; // Analysis material var shapeDesc = pieces[counter++]; counter++; // Cost obj = SetDesc(obj, shapeDesc, GSAUnits); this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralLoadTask(); 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++]; //Find task type int.TryParse(pieces[counter++], out int taskRef); var taskRec = Initialiser.Cache.GetGwa("TASK.1", taskRef).First(); obj.TaskType = HelperClass.GetLoadTaskType(taskRec); this.SubGWACommand.Add(taskRec); // Parse description var description = pieces[counter++]; obj.LoadCaseRefs = new List <string>(); obj.LoadFactors = new List <double>(); // TODO: this only parses the super simple linear add descriptions try { var desc = HelperClass.ParseLoadDescription(description); foreach (var t in desc) { switch (t.Item1[0]) { case 'L': obj.LoadCaseRefs.Add(HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), Convert.ToInt32(t.Item1.Substring(1)))); obj.LoadFactors.Add(t.Item2); break; } } } catch { } this.Value = obj; }
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 = HelperClass.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(); var speckleNodeObj = node.Value; if (speckleNodeObj != null) { coordinates.AddRange(speckleNodeObj.Value); this.SubGWACommand.Add(node.GWACommand); } } var temp = new Structural2DVoid( coordinates.ToArray(), color.HexToArgbColor()); obj.Vertices = temp.Vertices; obj.Faces = temp.Faces; obj.Colors = temp.Colors; this.Value = obj; }
//Sending public void ParseGWACommand(List <GSANode> nodes) { if (this.GWACommand == null) { return; } var obj = new Structural0DSpring(); 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(GSASpringProperty).GetGSAKeyword(), Convert.ToInt32(pieces[counter++])); counter++; // Group obj.Value = new List <double>(); var key = pieces[counter++]; if (int.TryParse(key, out int nodeIndex)) { if (nodeIndex > 0) { 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++]); //counter++; // Action // TODO: EL.4 SUPPORT counter++; // Dummy if (counter < pieces.Length) { Member = pieces[counter++]; } this.Value = obj; }
public void ParseGWACommand(List <GSANode> nodes, List <GSAConstructionStage> stages) { if (this.GWACommand == null) { return; } var obj = new StructuralStagedNodalRestraints(); var pieces = this.GWACommand.ListSplit("\t"); var counter = 1; // Skip identifier obj.Name = pieces[counter++]; obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId); //Restraints var restraints = new bool[6]; for (var i = 0; i < 6; i++) { restraints[i] = pieces[counter++] == "1"; } obj.Restraint = new StructuralVectorBoolSix(restraints); var targetNodeRefs = Initialiser.Interface.ConvertGSAList(pieces[counter++], SpeckleGSAInterfaces.GSAEntity.NODE); if (nodes != null) { var targetNodes = nodes .Where(n => targetNodeRefs.Contains(n.GSAId)).ToList(); obj.NodeRefs = targetNodes.Select(n => (string)n.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(targetNodes.Select(n => n.GWACommand)); foreach (var n in targetNodes) { n.ForceSend = true; } } var gwaStageDefGsaIds = pieces[counter++].ListSplit(" "); obj.ConstructionStageRefs = stages.Where(sd => gwaStageDefGsaIds.Any(gwaSDId => gwaSDId == sd.GSAId.ToString())).Select(x => (string)x.Value.ApplicationId).ToList(); this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralBridgeAlignment(); 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[] { '"' }); //TO DO this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralBridgeVehicle(); 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[] { '"' }); //TO DO : replace these defaults with the real thing obj.Width = 0; this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralMaterialSteel(); 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); counter++; // MAT.8 obj.Name = pieces[counter++].Trim(new char[] { '"' }); counter++; // Unlocked obj.YoungsModulus = Convert.ToDouble(pieces[counter++]); obj.PoissonsRatio = Convert.ToDouble(pieces[counter++]); obj.ShearModulus = Convert.ToDouble(pieces[counter++]); obj.Density = Convert.ToDouble(pieces[counter++]); obj.CoeffThermalExpansion = Convert.ToDouble(pieces[counter++]); // Failure strain is found before MAT_CURVE_PARAM.2 var strainIndex = Array.FindIndex(pieces, x => x.StartsWith("MAT_CURVE_PARAM")); if (strainIndex > 0) { obj.MaxStrain = Convert.ToDouble(pieces[strainIndex - 1]); } // Skip to last fourth to last counter = pieces.Count() - 4; obj.YieldStrength = Convert.ToDouble(pieces[counter++]); obj.UltimateStrength = Convert.ToDouble(pieces[counter++]); this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralMaterialConcrete(); var pieces = this.GWACommand.ListSplit("\t"); int commandVersion = 16; int.TryParse(pieces[0].Split(new[] { '.' }).Last(), out commandVersion); var counter = 1; // Skip identifier this.GSAId = Convert.ToInt32(pieces[counter++]); obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId); counter++; // MAT.8 obj.Name = pieces[counter++].Trim(new char[] { '"' }); counter++; // Unlocked obj.YoungsModulus = Convert.ToDouble(pieces[counter++]); obj.PoissonsRatio = Convert.ToDouble(pieces[counter++]); obj.ShearModulus = Convert.ToDouble(pieces[counter++]); obj.Density = Convert.ToDouble(pieces[counter++]); obj.CoeffThermalExpansion = Convert.ToDouble(pieces[counter++]); obj.CompressiveStrength = Convert.ToDouble(pieces[41]); counter = (commandVersion == 16) ? 54 : 52; obj.MaxStrain = Convert.ToDouble(pieces[counter]); counter = (commandVersion == 16) ? 59 : 57; obj.AggragateSize = Convert.ToDouble(pieces[counter]); this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralBridgePath(); 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[] { '"' }); //TO DO: change these defaults for the real thing obj.PathType = StructuralBridgePathType.Lane; obj.Gauge = 0; obj.LeftRailFactor = 0; this.Value = obj; }
public static SpeckleObject ToSpeckle(this GSA1DElementResult dummyObject) { if (Initialiser.Settings.Element1DResults.Count() == 0) { return(new SpeckleNull()); } if (Initialiser.Settings.EmbedResults && !Initialiser.GSASenderObjects.ContainsKey(typeof(GSA1DElement))) { return(new SpeckleNull()); } if (Initialiser.Settings.EmbedResults) { var elements = Initialiser.GSASenderObjects[typeof(GSA1DElement)].Cast <GSA1DElement>().ToList(); var entities = elements.Cast <IGSASpeckleContainer>().ToList(); foreach (var kvp in Initialiser.Settings.Element1DResults) { foreach (var loadCase in Initialiser.Settings.ResultCases) { if (!Initialiser.Interface.CaseExist(loadCase)) { continue; } foreach (var entity in entities) { var id = entity.GSAId; if (entity.Value.Result == null) { entity.Value.Result = new Dictionary <string, object>(); } var resultExport = Initialiser.Interface.GetGSAResult(id, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, loadCase, Initialiser.Settings.ResultInLocalAxis ? "local" : "global", Initialiser.Settings.Result1DNumPosition); if (resultExport == null) { continue; } if (!entity.Value.Result.ContainsKey(loadCase)) { entity.Value.Result[loadCase] = new Structural1DElementResult() { Value = new Dictionary <string, object>() } } ; (entity.Value.Result[loadCase] as Structural1DElementResult).Value[kvp.Key] = resultExport; } } } // Linear interpolate the line values foreach (var entity in entities) { var dX = (entity.Value.Value[3] - entity.Value.Value[0]) / (Initialiser.Settings.Result1DNumPosition + 1); var dY = (entity.Value.Value[4] - entity.Value.Value[1]) / (Initialiser.Settings.Result1DNumPosition + 1); var dZ = (entity.Value.Value[5] - entity.Value.Value[2]) / (Initialiser.Settings.Result1DNumPosition + 1); var interpolatedVertices = new List <double>(); interpolatedVertices.AddRange((entity.Value.Value as List <double>).Take(3)); for (var i = 1; i <= Initialiser.Settings.Result1DNumPosition; i++) { interpolatedVertices.Add(interpolatedVertices[0] + dX * i); interpolatedVertices.Add(interpolatedVertices[1] + dY * i); interpolatedVertices.Add(interpolatedVertices[2] + dZ * i); } interpolatedVertices.AddRange((entity.Value.Value as List <double>).Skip(3).Take(3)); entity.Value.ResultVertices = interpolatedVertices; } } else { Initialiser.GSASenderObjects[typeof(GSA1DElementResult)] = new List <object>(); var results = new List <GSA1DElementResult>(); var keyword = HelperClass.GetGSAKeyword(typeof(GSA1DElement)); var gwa = Initialiser.Cache.GetGwa(keyword); foreach (var kvp in Initialiser.Settings.Element1DResults) { foreach (var loadCase in Initialiser.Settings.ResultCases) { if (!Initialiser.Interface.CaseExist(loadCase)) { continue; } for (var i = 0; i < gwa.Count(); i++) { var record = gwa[i]; var pPieces = record.ListSplit("\t"); if (pPieces[4].ParseElementNumNodes() != 2) { continue; } if (!int.TryParse(pPieces[1], out var id)) { //Could not extract index continue; } var resultExport = Initialiser.Interface.GetGSAResult(id, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, loadCase, Initialiser.Settings.ResultInLocalAxis ? "local" : "global", Initialiser.Settings.Result1DNumPosition); if (resultExport == null || resultExport.Count() == 0) { continue; } var existingRes = results.FirstOrDefault(x => x.Value.TargetRef == id.ToString()); if (existingRes == null) { var newRes = new Structural1DElementResult() { Value = new Dictionary <string, object>(), TargetRef = HelperClass.GetApplicationId(typeof(GSA1DElement).GetGSAKeyword(), id), IsGlobal = !Initialiser.Settings.ResultInLocalAxis, }; newRes.Value[kvp.Key] = resultExport; newRes.GenerateHash(); results.Add(new GSA1DElementResult() { Value = newRes }); } else { existingRes.Value.Value[kvp.Key] = resultExport; } } } } Initialiser.GSASenderObjects[typeof(GSA1DElementResult)].AddRange(results); } return(new SpeckleObject()); }
public void ParseGWACommand(List <GSA2DElement> e2Ds, List <GSA2DMember> m2Ds) { if (this.GWACommand == null) { return; } var obj = new Structural2DThermalLoad(); var pieces = this.GWACommand.ListSplit("\t"); var counter = 1; // Skip identifier obj.Name = pieces[counter++]; obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId); var elementList = pieces[counter++]; obj.ElementRefs = new List <string>(); if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) { var elementId = Initialiser.Interface.ConvertGSAList(elementList, SpeckleGSAInterfaces.GSAEntity.ELEMENT); foreach (var id in elementId) { IGSASpeckleContainer elem = e2Ds.Where(e => e.GSAId == id).FirstOrDefault(); if (elem == null) { continue; } obj.ElementRefs.Add((elem.Value as SpeckleObject).ApplicationId); this.SubGWACommand.Add(elem.GWACommand); } } else { var groupIds = HelperClass.GetGroupsFromGSAList(elementList).ToList(); foreach (var id in groupIds) { var memb2Ds = m2Ds.Where(m => m.Group == id); obj.ElementRefs.AddRange(memb2Ds.Select(m => (string)m.Value.ApplicationId)); this.SubGWACommand.AddRange(memb2Ds.Select(m => m.GWACommand)); } } obj.LoadCaseRef = HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), Convert.ToInt32(pieces[counter++])); var loadingType = pieces[counter++]; switch (loadingType) { case "CONS": obj.TopTemperature = Convert.ToDouble(pieces[counter++]); obj.BottomTemperature = obj.TopTemperature; break; case "DZ": obj.TopTemperature = Convert.ToDouble(pieces[counter++]); obj.BottomTemperature = Convert.ToDouble(pieces[counter++]); break; case "GEN": // GENERALIZE THIS TO AN AVERAGE for (var i = 0; i < 3; i++) { obj.TopTemperature += Convert.ToDouble(pieces[counter++]); obj.BottomTemperature += Convert.ToDouble(pieces[counter++]); } obj.TopTemperature /= 4; obj.BottomTemperature /= 4; break; } this.Value = obj; }
public void ParseGWACommand() { if (this.GWACommand == null) { return; } var obj = new StructuralLoadCombo(); 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++]; // Parse type var description = pieces[counter++]; if (description.Contains("+")) { obj.ComboType = StructuralLoadComboType.LinearAdd; } else if (description.Contains("or")) { obj.ComboType = StructuralLoadComboType.Envelope; } else { obj.ComboType = StructuralLoadComboType.LinearAdd; } obj.LoadTaskRefs = new List <string>(); obj.LoadTaskFactors = new List <double>(); obj.LoadComboRefs = new List <string>(); obj.LoadComboFactors = new List <double>(); // TODO: this only parses the super simple linear add descriptions try { var desc = HelperClass.ParseLoadDescription(description); foreach (var t in desc) { switch (t.Item1[0]) { case 'A': obj.LoadTaskRefs.Add(HelperClass.GetApplicationId(typeof(GSALoadTask).GetGSAKeyword(), Convert.ToInt32(t.Item1.Substring(1)))); obj.LoadTaskFactors.Add(t.Item2); break; case 'C': obj.LoadComboRefs.Add(HelperClass.GetApplicationId(typeof(GSALoadCombo).GetGSAKeyword(), Convert.ToInt32(t.Item1.Substring(1)))); obj.LoadComboFactors.Add(t.Item2); break; } } } catch { } this.Value = obj; }
public void ParseGWACommand(List <GSANode> nodes) { if (this.GWACommand == null) { return; } var obj = new Structural0DLoad(); var pieces = this.GWACommand.ListSplit("\t"); var counter = 1; // Skip identifier obj.Name = pieces[counter++].Trim(new char[] { '"' }); var targetNodeRefs = Initialiser.Interface.ConvertGSAList(pieces[counter++], SpeckleGSAInterfaces.GSAEntity.NODE); if (nodes != null) { var targetNodes = nodes .Where(n => targetNodeRefs.Contains(n.GSAId)).ToList(); obj.NodeRefs = targetNodes.Select(n => (string)n.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(targetNodes.Select(n => n.GWACommand)); foreach (var n in targetNodes) { n.ForceSend = true; } } obj.LoadCaseRef = HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), Convert.ToInt32(pieces[counter++])); var axis = pieces[counter++]; this.Axis = axis == "GLOBAL" ? 0 : Convert.ToInt32(axis); obj.Loading = new StructuralVectorSix(new double[6]); var direction = pieces[counter++].ToLower(); switch (direction.ToUpper()) { case "X": obj.Loading.Value[0] = Convert.ToDouble(pieces[counter++]); break; case "Y": obj.Loading.Value[1] = Convert.ToDouble(pieces[counter++]); break; case "Z": obj.Loading.Value[2] = Convert.ToDouble(pieces[counter++]); break; case "XX": obj.Loading.Value[3] = Convert.ToDouble(pieces[counter++]); break; case "YY": obj.Loading.Value[4] = Convert.ToDouble(pieces[counter++]); break; case "ZZ": obj.Loading.Value[5] = Convert.ToDouble(pieces[counter++]); break; default: // TODO: Error case maybe? break; } this.Value = obj; }
public void ParseGWACommand(List <GSA2DElement> elements, List <GSA2DMember> members) { if (this.GWACommand == null) { return; } var obj = new Structural2DLoad(); var pieces = this.GWACommand.ListSplit("\t"); var counter = 1; // Skip identifier obj.Name = pieces[counter++].Trim(new char[] { '"' }); if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) { var targetElements = Initialiser.Interface.ConvertGSAList(pieces[counter++], SpeckleGSAInterfaces.GSAEntity.ELEMENT); if (elements != null) { var elems = elements.Where(n => targetElements.Contains(n.GSAId)).ToList(); obj.ElementRefs = elems.Select(n => (string)n.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(elems.Select(n => n.GWACommand)); } } else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design) { var targetGroups = HelperClass.GetGroupsFromGSAList(pieces[counter++]); if (members != null) { var membs = members.Where(m => targetGroups.Contains(m.Group)).ToList(); obj.ElementRefs = membs.Select(m => (string)m.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(membs.Select(n => n.GWACommand)); } } obj.LoadCaseRef = HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), Convert.ToInt32(pieces[counter++])); var axis = pieces[counter++]; this.Axis = axis == "GLOBAL" ? 0 : -1;// Convert.ToInt32(axis); // TODO: Assume local if not global obj.AxisType = (axis == "LOCAL") ? StructuralLoadAxisType.Local : StructuralLoadAxisType.Global; counter++; // Type. TODO: Skipping since we're taking the average this.Projected = pieces[counter++] == "YES"; obj.Loading = new StructuralVectorThree(new double[3]); var direction = pieces[counter++].ToLower(); var values = pieces.Skip(counter).Select(p => Convert.ToDouble(p)).ToArray(); switch (direction.ToUpper()) { case "X": obj.Loading.Value[0] = values.Average(); break; case "Y": obj.Loading.Value[1] = values.Average(); break; case "Z": obj.Loading.Value[2] = values.Average(); break; default: // TODO: Error case maybe? break; } this.Value = obj; }
public void ParseGWACommand(List <GSA1DElement> e1Ds, List <GSA2DElement> e2Ds, List <GSA1DMember> m1Ds, List <GSA2DMember> m2Ds) { if (this.GWACommand == null) { return; } var obj = new StructuralConstructionStage(); 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++]; counter++; //Skip colour var elementList = pieces[counter++]; obj.ElementRefs = new List <string>(); if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) { var elementId = Initialiser.Interface.ConvertGSAList(elementList, SpeckleGSAInterfaces.GSAEntity.ELEMENT); foreach (var id in elementId) { IGSASpeckleContainer elem = e1Ds.Where(e => e.GSAId == id).FirstOrDefault(); if (elem == null) { elem = e2Ds.Where(e => e.GSAId == id).FirstOrDefault(); } if (elem == null) { continue; } obj.ElementRefs.Add((elem.Value as SpeckleObject).ApplicationId); this.SubGWACommand.Add(elem.GWACommand); } } else { var groupIds = HelperClass.GetGroupsFromGSAList(elementList).ToList(); foreach (var id in groupIds) { var memb1Ds = m1Ds.Where(m => m.Group == id); var memb2Ds = m2Ds.Where(m => m.Group == id); obj.ElementRefs.AddRange(memb1Ds.Select(m => (string)m.Value.ApplicationId)); obj.ElementRefs.AddRange(memb2Ds.Select(m => (string)m.Value.ApplicationId)); this.SubGWACommand.AddRange(memb1Ds.Select(m => m.GWACommand)); this.SubGWACommand.AddRange(memb2Ds.Select(m => m.GWACommand)); } } counter++; //Skip creep coefficient obj.StageDays = Convert.ToInt32(pieces[counter++]); this.Value = obj; }
public void ParseGWACommand(List<GSA1DElement> elements) { if (elements.Count() < 1) return; var elementsListCopy = new List<GSA1DElement>(elements); var obj = new Structural1DElementPolyline { ApplicationId = HelperClass.GetApplicationId(typeof(GSA1DElementPolyline).GetGSAKeyword(), GSAId), Value = new List<double>(), ElementApplicationId = new List<string>(), ElementType = elementsListCopy.First().Value.ElementType, PropertyRef = elementsListCopy.First().Value.PropertyRef, ZAxis = new List<StructuralVectorThree>(), EndRelease = new List<StructuralVectorBoolSix>(), Offset = new List<StructuralVectorThree>(), ResultVertices = new List<double>() }; if (Initialiser.Settings.Element1DResults.Count > 0 && Initialiser.Settings.EmbedResults) obj.Result = new Dictionary<string, object>(); // Match up coordinates var coordinates = new List<Tuple<string, string>>(); foreach (var e in elementsListCopy) coordinates.Add( new Tuple<string, string>( string.Join(",", (e.Value.Value as List<double>).Take(3).Select(x => Math.Round(x, 4).ToString())), string.Join(",", (e.Value.Value as List<double>).Skip(3).Take(3).Select(x => Math.Round(x, 4).ToString())) )); // Find start coordinate var flatCoordinates = coordinates.SelectMany(x => new List<string>() { x.Item1, x.Item2 }).ToList(); var uniqueCoordinates = flatCoordinates.Where(x => flatCoordinates.Count(y => y == x) == 1).ToList(); var current = uniqueCoordinates[0]; while(coordinates.Count > 0) { var matchIndex = 0; var reverseCoordinates = false; matchIndex = coordinates.FindIndex(x => x.Item1 == current); reverseCoordinates = false; if (matchIndex == -1) { matchIndex = coordinates.FindIndex(x => x.Item2 == current); reverseCoordinates = true; } var element = elementsListCopy[matchIndex]; obj.ElementApplicationId.Add(element.Value.ApplicationId); obj.ZAxis.Add(element.Value.ZAxis); if (obj.Value.Count == 0) { if (!reverseCoordinates) { obj.Value.AddRange((element.Value.Value as List<double>).Take(3)); } else { obj.Value.AddRange((element.Value.Value as List<double>).Skip(3).Take(3)); } } if (!reverseCoordinates) { current = string.Join(",", (element.Value.Value as List<double>).Skip(3).Take(3).Select(x => Math.Round(x, 4).ToString())); obj.Value.AddRange((element.Value.Value as List<double>).Skip(3).Take(3)); obj.EndRelease.AddRange(element.Value.EndRelease); obj.Offset.AddRange(element.Value.Offset); if (Initialiser.Settings.Element1DResults.Count > 0 && Initialiser.Settings.EmbedResults) obj.ResultVertices.AddRange(element.Value.ResultVertices); else obj.ResultVertices.AddRange((element.Value.Value as List<double>)); } else { current = string.Join(",", (element.Value.Value as List<double>).Take(3).Select(x => Math.Round(x, 4).ToString())); obj.Value.AddRange((element.Value.Value as List<double>).Take(3)); obj.EndRelease.Add((element.Value.EndRelease as List<StructuralVectorBoolSix>).Last()); obj.EndRelease.Add((element.Value.EndRelease as List<StructuralVectorBoolSix>).First()); obj.Offset.Add((element.Value.Offset as List<StructuralVectorThree>).Last()); obj.Offset.Add((element.Value.Offset as List<StructuralVectorThree>).First()); if (Initialiser.Settings.Element1DResults.Count > 0 && Initialiser.Settings.EmbedResults) for (int i = element.Value.ResultVertices.Count - 3; i >= 0; i -= 3) obj.ResultVertices.AddRange((element.Value.ResultVertices as List<double>).Skip(i).Take(3)); else { obj.ResultVertices.AddRange((element.Value.Value as List<double>).Skip(3).Take(3)); obj.ResultVertices.AddRange((element.Value.Value as List<double>).Take(3)); } } // Result merging if (obj.Result != null) { try { foreach (string loadCase in element.Value.Result.Keys) { if (!obj.Result.ContainsKey(loadCase)) obj.Result[loadCase] = new Structural1DElementResult() { Value = new Dictionary<string, object>(), IsGlobal = !Initialiser.Settings.ResultInLocalAxis, }; var resultExport = element.Value.Result[loadCase] as Structural1DElementResult; if (resultExport != null) { foreach (var key in resultExport.Value.Keys) { if (!(obj.Result[loadCase] as Structural1DElementResult).Value.ContainsKey(key)) (obj.Result[loadCase] as Structural1DElementResult).Value[key] = new Dictionary<string, object>(resultExport.Value[key] as Dictionary<string, object>); else foreach (var resultKey in ((obj.Result[loadCase] as Structural1DElementResult).Value[key] as Dictionary<string, object>).Keys) { var res = (resultExport.Value[key] as Dictionary<string, object>)[resultKey] as List<double>; if (reverseCoordinates) res.Reverse(); (((obj.Result[loadCase] as Structural1DElementResult).Value[key] as Dictionary<string, object>)[resultKey] as List<double>) .AddRange(res); } } } else { // UNABLE TO MERGE RESULTS obj.Result = null; break; } } } catch { // UNABLE TO MERGE RESULTS obj.Result = null; } } coordinates.RemoveAt(matchIndex); elementsListCopy.RemoveAt(matchIndex); this.SubGWACommand.Add(element.GWACommand); this.SubGWACommand.AddRange(element.SubGWACommand); } this.Value = obj; }
public void ParseGWACommand(List <GSAMaterialSteel> steels, List <GSAMaterialConcrete> concretes) { if (this.GWACommand == null) { return; } var obj = new Structural2DProperty(); 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 counter++; // Type this.IsAxisLocal = pieces[counter++] == "LOCAL"; // Axis counter++; // Analysis material var materialType = pieces[counter++]; var materialGrade = pieces[counter++]; if (materialType == "STEEL") { if (steels != null) { var matchingMaterial = steels.Where(m => m.GSAId.ToString() == materialGrade).FirstOrDefault(); obj.MaterialRef = matchingMaterial == null ? null : matchingMaterial.Value.ApplicationId; if (matchingMaterial != null) { this.SubGWACommand.Add(matchingMaterial.GWACommand); } } } else if (materialType == "CONCRETE") { if (concretes != null) { var matchingMaterial = concretes.Where(m => m.GSAId.ToString() == materialGrade).FirstOrDefault(); obj.MaterialRef = matchingMaterial == null ? null : matchingMaterial.Value.ApplicationId; if (matchingMaterial != null) { this.SubGWACommand.Add(matchingMaterial.GWACommand); } } } counter++; // Analysis material obj.Thickness = Convert.ToDouble(pieces[counter++]); switch (pieces[counter++]) { case "CENTROID": obj.ReferenceSurface = Structural2DPropertyReferenceSurface.Middle; break; case "TOP_CENTRE": obj.ReferenceSurface = Structural2DPropertyReferenceSurface.Top; break; case "BOT_CENTRE": obj.ReferenceSurface = Structural2DPropertyReferenceSurface.Bottom; break; default: obj.ReferenceSurface = Structural2DPropertyReferenceSurface.Middle; break; } // Ignore the rest 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++; // 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 void ParseGWACommand(List <GSANode> nodes, List <GSA2DProperty> props) { if (this.GWACommand == null) { return; } var obj = new Structural2DElementMesh(); 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[] { '"' }); var color = pieces[counter++].ParseGSAColor(); var type = pieces[counter++]; if (type == "SLAB") { obj.ElementType = Structural2DElementType.Slab; } else if (type == "WALL") { obj.ElementType = Structural2DElementType.Wall; } else { obj.ElementType = Structural2DElementType.Generic; } var propertyGSAId = Convert.ToInt32(pieces[counter++]); obj.PropertyRef = HelperClass.GetApplicationId(typeof(GSA2DProperty).GetGSAKeyword(), propertyGSAId); this.Group = Convert.ToInt32(pieces[counter++]); // Keep group for load targetting 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(); coordinates.AddRange(node.Value.Value); this.SubGWACommand.Add(node.GWACommand); } var temp = new Structural2DElementMesh( coordinates.ToArray(), color.HexToArgbColor(), obj.ElementType, obj.PropertyRef, null, null); obj.Vertices = temp.Vertices; obj.Faces = temp.Faces; obj.Colors = temp.Colors; var numFaces = 0; for (var i = 0; i < obj.Faces.Count(); i++) { numFaces++; i += obj.Faces[i] + 3; } counter++; // Orientation node var prop = props.Where(p => p.Value.ApplicationId == obj.PropertyRef).FirstOrDefault(); var axis = HelperClass.Parse2DAxis(coordinates.ToArray(), Convert.ToDouble(pieces[counter++]), prop == null ? false : (prop as GSA2DProperty).IsAxisLocal); obj.Axis = Enumerable.Repeat(axis, numFaces).ToList(); if (prop != null) { this.SubGWACommand.Add(prop.GWACommand); } // Skip to offsets at second to last counter = pieces.Length - 2; Initialiser.Interface.GetGSATotal2DElementOffset(propertyGSAId, Convert.ToDouble(pieces[counter++]), out var offset, out var offsetRec); this.SubGWACommand.Add(offsetRec); obj.Offset = Enumerable.Repeat(offset, numFaces).ToList(); this.Value = obj; }
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 = HelperClass.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 = HelperClass.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 = HelperClass.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; }
public void ParseGWACommand(List <GSA2DElement> elements) { if (elements.Count() < 1) { return; } var obj = new Structural2DElementMesh { ApplicationId = HelperClass.GetApplicationId(typeof(GSA2DElementMesh).GetGSAKeyword(), GSAId), Vertices = new List <double>(), Faces = new List <int>(), ElementApplicationId = new List <string>(), ElementType = elements.First().Value.ElementType, PropertyRef = elements.First().Value.PropertyRef, Axis = new List <StructuralAxis>(), Offset = new List <double>() }; if (Initialiser.Settings.Element2DResults.Count > 0 && Initialiser.Settings.EmbedResults) { obj.Result = new Dictionary <string, object>(); } foreach (var e in elements) { var verticesOffset = obj.Vertices.Count() / 3; obj.Vertices.AddRange(e.Value.Vertices); obj.Faces.Add((e.Value.Faces as List <int>).First()); obj.Faces.AddRange((e.Value.Faces as List <int>).Skip(1).Select(x => x + verticesOffset)); obj.Axis.Add(e.Value.Axis); obj.Offset.Add(e.Value.Offset); obj.ElementApplicationId.Add(e.Value.ApplicationId); // Result merging if (obj.Result != null) { try { foreach (string loadCase in e.Value.Result.Keys) { if (!obj.Result.ContainsKey(loadCase)) { obj.Result[loadCase] = new Structural2DElementResult() { Value = new Dictionary <string, object>(), IsGlobal = !Initialiser.Settings.ResultInLocalAxis, } } ; var resultExport = e.Value.Result[loadCase] as Structural2DElementResult; if (resultExport != null) { foreach (var key in resultExport.Value.Keys) { if (!(obj.Result[loadCase] as Structural2DElementResult).Value.ContainsKey(key)) { (obj.Result[loadCase] as Structural2DElementResult).Value[key] = new Dictionary <string, object>(resultExport.Value[key] as Dictionary <string, object>); } else { foreach (var resultKey in ((obj.Result[loadCase] as Structural2DElementResult).Value[key] as Dictionary <string, object>).Keys) { (((obj.Result[loadCase] as Structural2DElementResult).Value[key] as Dictionary <string, object>)[resultKey] as List <double>) .AddRange((resultExport.Value[key] as Dictionary <string, object>)[resultKey] as List <double>); } } } } else { // UNABLE TO MERGE RESULTS obj.Result = null; break; } } } catch { // UNABLE TO MERGE RESULTS obj.Result = null; } } this.SubGWACommand.Add(e.GWACommand); this.SubGWACommand.AddRange(e.SubGWACommand); } this.Value = obj; }
public void ParseGWACommand(List <GSANode> nodes, List <GSAConstructionStage> stages) { if (this.GWACommand == null) { return; } var obj = new StructuralRigidConstraints(); 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); var masterNodeRef = Convert.ToInt32(pieces[counter++]); var masterNode = nodes.Where(n => n.GSAId == masterNodeRef); if (masterNode.Count() > 0) { this.SubGWACommand.Add(masterNode.First().GWACommand); obj.MasterNodeRef = masterNode.First().Value.ApplicationId; } var constraint = new bool[6]; var linkage = pieces[counter++]; switch (linkage) { case "ALL": case "PIN": constraint = new bool[] { true, true, true, true, true, true }; break; case "XY_PLANE": case "XY_PLANE_PIN": constraint = new bool[] { true, true, false, false, false, true }; break; case "YZ_PLANE": case "YZ_PLANE_PIN": constraint = new bool[] { false, true, true, true, false, false }; break; case "ZX_PLANE": case "ZX_PLANE_PIN": constraint = new bool[] { true, false, true, false, true, false }; break; case "XY_PLATE": case "XY_PLATE_PIN": constraint = new bool[] { false, false, true, true, true, false }; break; case "YZ_PLATE": case "YZ_PLATE_PIN": constraint = new bool[] { true, false, false, false, true, true }; break; case "ZX_PLATE": case "ZX_PLATE_PIN": constraint = new bool[] { false, true, false, true, false, true }; break; default: // Ignore non-diagonal terms of coupled directionsl. // Assume if rotational direction is locked, it is locked for all slave directions. constraint[0] = linkage.Contains("X:X"); constraint[1] = linkage.Contains("Y:Y"); constraint[2] = linkage.Contains("Z:Z"); constraint[3] = linkage.Contains("XX:XX"); constraint[4] = linkage.Contains("YY:YY"); constraint[5] = linkage.Contains("ZZ:ZZ"); break; } obj.Constraint = new StructuralVectorBoolSix(constraint); var targetNodeRefs = Initialiser.Interface.ConvertGSAList(pieces[counter++], SpeckleGSAInterfaces.GSAEntity.NODE); if (nodes != null) { var targetNodes = nodes .Where(n => targetNodeRefs.Contains(n.GSAId)).ToList(); obj.NodeRefs = targetNodes.Select(n => (string)n.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(targetNodes.Select(n => n.GWACommand)); foreach (var n in targetNodes) { n.ForceSend = true; } } var gwaStageDefGsaIds = pieces[counter++].ListSplit(" "); obj.ConstructionStageRefs = stages.Where(sd => gwaStageDefGsaIds.Any(gwaSDId => gwaSDId == sd.GSAId.ToString())).Select(x => (string)x.Value.ApplicationId).ToList(); counter++; // Parent member this.Value = obj; }
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; }
public static SpeckleObject ToSpeckle(this GSANodeResult dummyObject) { if (Initialiser.Settings.NodalResults.Count() == 0) { return(new SpeckleNull()); } if (Initialiser.Settings.EmbedResults && !Initialiser.GSASenderObjects.ContainsKey(typeof(GSANode))) { return(new SpeckleNull()); } if (Initialiser.Settings.EmbedResults) { var nodes = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList(); foreach (var kvp in Initialiser.Settings.NodalResults) { foreach (var loadCase in Initialiser.Settings.ResultCases) { if (!Initialiser.Interface.CaseExist(loadCase)) { continue; } foreach (var node in nodes) { var id = node.GSAId; if (node.Value.Result == null) { node.Value.Result = new Dictionary <string, object>(); } var resultExport = Initialiser.Interface.GetGSAResult(id, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, loadCase, Initialiser.Settings.ResultInLocalAxis ? "local" : "global"); if (resultExport == null || resultExport.Count() == 0) { continue; } if (!node.Value.Result.ContainsKey(loadCase)) { node.Value.Result[loadCase] = new StructuralNodeResult() { Value = new Dictionary <string, object>() }; } (node.Value.Result[loadCase] as StructuralNodeResult).Value[kvp.Key] = resultExport.ToDictionary(x => x.Key, x => (x.Value as List <double>)[0] as object); node.ForceSend = true; } } } } else { Initialiser.GSASenderObjects[typeof(GSANodeResult)] = new List <object>(); var results = new List <GSANodeResult>(); var keyword = HelperClass.GetGSAKeyword(typeof(GSANode)); var indices = Initialiser.Cache.LookupIndices(keyword).Where(i => i.HasValue).Select(i => i.Value).ToList(); foreach (var kvp in Initialiser.Settings.NodalResults) { foreach (var loadCase in Initialiser.Settings.ResultCases) { if (!Initialiser.Interface.CaseExist(loadCase)) { continue; } for (var i = 0; i < indices.Count(); i++) { var id = indices[i]; //var id = 1; //var highestIndex = (int)Initialiser.Interface.RunGWACommand("HIGHEST\t" + keyword); //while (id <= highestIndex) //{ //if ((int)Initialiser.Interface.RunGWACommand("EXIST\t" + keyword + "\t" + id.ToString()) == 1) //{ var resultExport = Initialiser.Interface.GetGSAResult(id, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, loadCase, Initialiser.Settings.ResultInLocalAxis ? "local" : "global"); if (resultExport == null || resultExport.Count() == 0) { id++; continue; } var existingRes = results.FirstOrDefault(x => x.Value.TargetRef == id.ToString()); if (existingRes == null) { var newRes = new StructuralNodeResult() { Value = new Dictionary <string, object>(), TargetRef = HelperClass.GetApplicationId(typeof(GSANode).GetGSAKeyword(), id), IsGlobal = !Initialiser.Settings.ResultInLocalAxis, }; newRes.Value[kvp.Key] = resultExport; newRes.GenerateHash(); results.Add(new GSANodeResult() { Value = newRes }); } else { existingRes.Value.Value[kvp.Key] = resultExport; } //} //id++; } } } Initialiser.GSASenderObjects[typeof(GSANodeResult)].AddRange(results); } return(new SpeckleObject()); }
public void ParseGWACommand(List <GSA1DElement> elements, List <GSA1DMember> members) { if (this.GWACommand == null) { return; } var obj = new Structural1DLoad(); var pieces = this.GWACommand.ListSplit("\t"); var counter = 0; // Skip identifier var identifier = pieces[counter++]; obj.Name = pieces[counter++].Trim(new char[] { '"' }); if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) { var targetElements = Initialiser.Interface.ConvertGSAList(pieces[counter++], SpeckleGSAInterfaces.GSAEntity.ELEMENT); if (elements != null) { var elems = elements.Where(n => targetElements.Contains(n.GSAId)).ToList(); obj.ElementRefs = elems.Select(n => (string)n.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(elems.Select(n => n.GWACommand)); } } else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design) { var targetGroups = HelperClass.GetGroupsFromGSAList(pieces[counter++]); if (members != null) { var membs = members.Where(m => targetGroups.Contains(m.Group)).ToList(); obj.ElementRefs = membs.Select(m => (string)m.Value.ApplicationId).ToList(); this.SubGWACommand.AddRange(membs.Select(n => n.GWACommand)); } } obj.LoadCaseRef = HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), Convert.ToInt32(pieces[counter++])); var axis = pieces[counter++]; this.Axis = axis == "GLOBAL" ? 0 : -1;// Convert.ToInt32(axis); // TODO: Assume local if not global this.Projected = pieces[counter++] == "YES"; obj.Loading = new StructuralVectorSix(new double[6]); var direction = pieces[counter++].ToLower(); double value = 0; // TODO: Only reads UDL load properly if (identifier.Contains("LOAD_BEAM_POINT.2")) { counter++; // Position counter++; // Value value = 0; } else if (identifier.Contains("LOAD_BEAM_UDL.2")) { value = Convert.ToDouble(pieces[counter++]); } else if (identifier.Contains("LOAD_BEAM_LINE.2")) { value = Convert.ToDouble(pieces[counter++]); value += Convert.ToDouble(pieces[counter++]); value /= 2; } else if (identifier.Contains("LOAD_BEAM_PATCH.2")) { counter++; // Position value = Convert.ToDouble(pieces[counter++]); counter++; // Position value += Convert.ToDouble(pieces[counter++]); value /= 2; } else if (identifier.Contains("LOAD_BEAM_TRILIN.2")) { counter++; // Position value = Convert.ToDouble(pieces[counter++]); counter++; // Position value += Convert.ToDouble(pieces[counter++]); value /= 2; } else { value = 0; } 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; case "XX": obj.Loading.Value[3] = value; break; case "YY": obj.Loading.Value[4] = value; break; case "ZZ": obj.Loading.Value[5] = value; break; default: // TODO: Error case maybe? break; } this.Value = obj; }
public static SpeckleObject ToSpeckle(this GSA2DElementResult dummyObject) { if (Initialiser.Settings.Element2DResults.Count() == 0) { return(new SpeckleNull()); } if (Initialiser.Settings.EmbedResults && !Initialiser.GSASenderObjects.ContainsKey(typeof(GSA2DElement))) { return(new SpeckleNull()); } if (Initialiser.Settings.EmbedResults) { var elements = Initialiser.GSASenderObjects[typeof(GSA2DElement)].Cast <GSA2DElement>().ToList(); foreach (var kvp in Initialiser.Settings.Element2DResults) { foreach (var loadCase in Initialiser.Settings.ResultCases) { if (!Initialiser.Interface.CaseExist(loadCase)) { continue; } foreach (var element in elements) { var id = element.GSAId; if (element.Value.Result == null) { element.Value.Result = new Dictionary <string, object>(); } var resultExport = Initialiser.Interface.GetGSAResult(id, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, loadCase, Initialiser.Settings.ResultInLocalAxis ? "local" : "global"); if (resultExport == null || resultExport.Count() == 0) { continue; } if (!element.Value.Result.ContainsKey(loadCase)) { element.Value.Result[loadCase] = new Structural2DElementResult() { Value = new Dictionary <string, object>() } } ; // Let's split the dictionary into xxx_face and xxx_vertex var faceDictionary = resultExport.ToDictionary( x => x.Key, x => new List <double>() { (x.Value as List <double>).Last() } as object); var vertexDictionary = resultExport.ToDictionary( x => x.Key, x => (x.Value as List <double>).Take((x.Value as List <double>).Count - 1).ToList() as object); (element.Value.Result[loadCase] as Structural2DElementResult).Value[kvp.Key + "_face"] = faceDictionary; (element.Value.Result[loadCase] as Structural2DElementResult).Value[kvp.Key + "_vertex"] = vertexDictionary; } } } } else { Initialiser.GSASenderObjects[typeof(GSA2DElementResult)] = new List <object>(); var results = new List <GSA2DElementResult>(); var keyword = HelperClass.GetGSAKeyword(typeof(GSA2DElement)); var gwa = Initialiser.Cache.GetGwa(keyword); foreach (var kvp in Initialiser.Settings.Element2DResults) { foreach (var loadCase in Initialiser.Settings.ResultCases) { if (!Initialiser.Interface.CaseExist(loadCase)) { continue; } for (var i = 0; i < gwa.Count(); i++) { var record = gwa[i]; var pPieces = record.ListSplit("\t"); if (pPieces[4].ParseElementNumNodes() != 3 && pPieces[4].ParseElementNumNodes() != 4) { continue; } if (!int.TryParse(pPieces[1], out var id)) { //Could not extract index continue; } var resultExport = Initialiser.Interface.GetGSAResult(id, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, loadCase, Initialiser.Settings.ResultInLocalAxis ? "local" : "global"); if (resultExport == null) { continue; } // Let's split the dictionary into xxx_face and xxx_vertex var faceDictionary = resultExport.ToDictionary( x => x.Key, x => new List <double>() { (x.Value as List <double>).Last() } as object); var vertexDictionary = resultExport.ToDictionary( x => x.Key, x => (x.Value as List <double>).Take((x.Value as List <double>).Count - 1).ToList() as object); var existingRes = results.FirstOrDefault(x => x.Value.TargetRef == id.ToString()); if (existingRes == null) { var newRes = new Structural2DElementResult() { Value = new Dictionary <string, object>(), TargetRef = HelperClass.GetApplicationId(typeof(GSA2DElement).GetGSAKeyword(), id), IsGlobal = !Initialiser.Settings.ResultInLocalAxis, }; newRes.Value[kvp.Key + "_face"] = faceDictionary; newRes.Value[kvp.Key + "_vertex"] = vertexDictionary; newRes.GenerateHash(); results.Add(new GSA2DElementResult() { Value = newRes }); } else { existingRes.Value.Value[kvp.Key + "_face"] = faceDictionary; existingRes.Value.Value[kvp.Key + "_vertex"] = vertexDictionary; } } } } Initialiser.GSASenderObjects[typeof(GSA2DElementResult)].AddRange(results); } return(new SpeckleObject()); }
public void ParseGWACommand(List <GSANode> nodes, List <GSA1DElement> e1Ds, List <GSA2DElement> e2Ds, List <GSA1DMember> m1Ds, List <GSA2DMember> m2Ds) { if (this.GWACommand == null) { return; } var obj = new StructuralAssembly(); 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[] { '"' }); var targetEntity = pieces[counter++]; var targetList = pieces[counter++]; obj.ElementRefs = new List <string>(); if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) { if (targetEntity == "MEMBER") { var memberList = Initialiser.Interface.ConvertGSAList(targetList, SpeckleGSAInterfaces.GSAEntity.MEMBER); var match1D = e1Ds.Where(e => memberList.Contains(Convert.ToInt32(e.Member))); var match2D = e2Ds.Where(e => memberList.Contains(Convert.ToInt32(e.Member))); obj.ElementRefs.AddRange(match1D.Select(e => (e.Value as SpeckleObject).ApplicationId.ToString())); obj.ElementRefs.AddRange(match2D.Select(e => (e.Value as SpeckleObject).ApplicationId.ToString())); this.SubGWACommand.AddRange(match1D.Select(e => (e as IGSASpeckleContainer).GWACommand)); this.SubGWACommand.AddRange(match2D.Select(e => (e as IGSASpeckleContainer).GWACommand)); } else if (targetEntity == "ELEMENT") { var elementList = Initialiser.Interface.ConvertGSAList(targetList, SpeckleGSAInterfaces.GSAEntity.ELEMENT); var match1D = e1Ds.Where(e => elementList.Contains(e.GSAId)); var match2D = e2Ds.Where(e => elementList.Contains(e.GSAId)); obj.ElementRefs.AddRange(match1D.Select(e => (e.Value as SpeckleObject).ApplicationId.ToString())); obj.ElementRefs.AddRange(match2D.Select(e => (e.Value as SpeckleObject).ApplicationId.ToString())); this.SubGWACommand.AddRange(match1D.Select(e => (e as IGSASpeckleContainer).GWACommand)); this.SubGWACommand.AddRange(match2D.Select(e => (e as IGSASpeckleContainer).GWACommand)); } } else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design) { if (targetEntity == "MEMBER") { var memberList = Initialiser.Interface.ConvertGSAList(targetList, SpeckleGSAInterfaces.GSAEntity.MEMBER); var match1D = m1Ds.Where(e => memberList.Contains(e.GSAId)); var match2D = m2Ds.Where(e => memberList.Contains(e.GSAId)); obj.ElementRefs.AddRange(match1D.Select(e => (e.Value as SpeckleObject).ApplicationId.ToString())); obj.ElementRefs.AddRange(match2D.Select(e => (e.Value as SpeckleObject).ApplicationId.ToString())); this.SubGWACommand.AddRange(match1D.Select(e => (e as IGSASpeckleContainer).GWACommand)); this.SubGWACommand.AddRange(match2D.Select(e => (e as IGSASpeckleContainer).GWACommand)); } else if (targetEntity == "ELEMENT") { //Unlike all other classes, the layer relevant to sending is only determined by looking at a GWA parameter rather than a class attribute. //Once this condition has been met, assign to null so it won't form part of the sender objects list Value = null; return; } } 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 orientationNodeId = Convert.ToInt32(pieces[counter++]); var orientationNode = nodes.Where(n => n.GSAId == orientationNodeId).FirstOrDefault(); this.SubGWACommand.Add(orientationNode.GWACommand); obj.OrientationPoint = new SpecklePoint(orientationNode.Value.Value[0], orientationNode.Value.Value[1], orientationNode.Value.Value[2]); counter++; // Internal topology obj.Width = (Convert.ToDouble(pieces[counter++]) + Convert.ToDouble(pieces[counter++])) / 2; this.Value = obj; }