public string BeginPlatesElement() { string info = ""; List <AttachedMember> attachedmembers = project.joints.SelectMany(a => a.attachedMembers).ToList(); List <AttachedMember> members = attachedmembers.Where(a => a.ElementRAZ.id == id).ToList(); AttachedMember member = members.FirstOrDefault(a => a.isStartPoint == true); if (member != null) { if (member.platefailure == false) { info = "FAILURE"; } } return(info); }
public static void CalculateSawingCuts(Project project, double tol) { foreach (Joint j in project.joints) { double eccentricity = new double(); //Convert eccentricity in meter to milimeter //If warren double the eccentricity if (j.isWarrenEccentricJoint == true) { eccentricity = 2 * j.maxGlobalEccentricity * 1000; } else { eccentricity = j.maxGlobalEccentricity * 1000; } //phi is the angle between the bearing member and the highest ranked connecting member double phi = new double(); List <AttachedMember> connectingMembers = new List <AttachedMember>(); AttachedMember bear = new AttachedMember(); foreach (var con in j.attachedMembers) { BearingMember bearing = new BearingMember(); if (con is BearingMember) { bear = con; } if (con is ConnectingMember) { connectingMembers.Add(con); } } BearingMember BM = j.attachedMembers.OfType <BearingMember>().First(); if (j.IsContinues == false) { if (BM.isStartPoint == true) { BM.ElementRAZ.startCut = ElementRAZ.SawingCut.RightAngledCut; } else { BM.ElementRAZ.endCut = ElementRAZ.SawingCut.RightAngledCut; } } for (int i = 0; i < connectingMembers.Count; i++) { if (i == 0) { double phiDirty = VectorRAZ.AngleBetweenVectors(j.bearingMemberUnitVector, connectingMembers[i].ElementRAZ.line.vector); //phi should be an angle between 90 and 180 degree phi = Math.PI - (Math.Min(phiDirty, (Math.PI - phiDirty))); //Check if the first connecting member is a RightAngledCut or SingleMiterCut //This is checked by whether theta is equal to 90 degrees (1.57 rad) //phi==0 is needed for the midspan T-joint where the value of phi is lost because of some mysterious reason if (Math.Abs(0.5 * Math.PI - phi) < tol || phi == 0 || phi == Math.PI) { //RightAngledCut if (connectingMembers[i].isStartPoint == true) { connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.RightAngledCut; } else { connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.RightAngledCut; } } else { //SingleMiterCut if (connectingMembers[i].isStartPoint == true) { connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.SingleMiterCut; } else { connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.SingleMiterCut; } } } if (i == 1) { // a = half height vertical // b = half height horizontal // h = half height diagonal // theta = angle of selected connecting member to bearingmember // phi = anlge of first connecting member to bearingmember // e = eccntricity double a = connectingMembers[0].ElementRAZ.crossSection.height / 2; double b = bear.ElementRAZ.crossSection.height / 2; double h = connectingMembers[1].ElementRAZ.crossSection.height / 2; double thetaDirty = VectorRAZ.AngleBetweenVectors(j.bearingMemberUnitVector, connectingMembers[1].ElementRAZ.line.vector); //theta should be an angle between 0 and 90 degree double theta = (Math.Min(thetaDirty, Math.PI - thetaDirty)); double hor = ConnectingMember.WebWeldsHorizontalLength(a, b, h, theta, phi, eccentricity); double ver = ConnectingMember.WebWeldsVerticalLength(a, b, h, theta, phi, eccentricity); if (hor != 0.0 && ver != 0.0) { //DoubleMiterCut if (connectingMembers[i].isStartPoint == true) { connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.DoubleMiterCut; } else { connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.DoubleMiterCut; } } else { //SingleMiterCut if (connectingMembers[i].isStartPoint == true) { connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.SingleMiterCut; } else { connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.SingleMiterCut; } } } if (i == 2) { double a = connectingMembers[0].ElementRAZ.crossSection.height / 2; double b = bear.ElementRAZ.crossSection.height / 2; double h = connectingMembers[2].ElementRAZ.crossSection.height / 2; double thetaDirty = VectorRAZ.AngleBetweenVectors(j.bearingMemberUnitVector, connectingMembers[2].ElementRAZ.line.vector); //theta should be an angle between 0 and 90 degree double theta = (Math.Min(thetaDirty, Math.PI - thetaDirty)); double hor = ConnectingMember.WebWeldsHorizontalLength(a, b, h, theta, phi, eccentricity); double ver = ConnectingMember.WebWeldsVerticalLength(a, b, h, theta, phi, eccentricity); if (hor != 0.0 && ver != 0.0) { //DoubleMiterCut if (connectingMembers[i].isStartPoint == true) { connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.DoubleMiterCut; } else { connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.DoubleMiterCut; } } else { //SingleMiterCut if (connectingMembers[i].isStartPoint == true) { connectingMembers[i].ElementRAZ.startCut = ElementRAZ.SawingCut.SingleMiterCut; } else { connectingMembers[i].ElementRAZ.endCut = ElementRAZ.SawingCut.SingleMiterCut; } } } } } }
/// <summary> /// All data is inventised and converted to seperate data needed to calculate individual joints /// </summary> /// <param name="tol">tolerance</param> /// <param name="eccentricity">eccentricity if specified</param> /// <param name="points">points in project</param> /// <param name="elementRAZs">elements of project</param> /// <param name="hierarchy">hierarchy if specified</param> public void CreateJoints(double tol, double eccentricity, List <PointRAZ> points, List <ElementRAZ> elementRAZs, List <Hierarchy> hierarchy) { double tolbox = tol + eccentricity; List <Joint> joints = new List <Joint>(); //iterate over all the points that represent centerpoints of the joint for (int i = 0; i < points.Count; i++) { PointRAZ centerpoint = points[i]; List <VectorRAZ> eccentricityVectors = new List <VectorRAZ>(); List <int> elementIDs = new List <int>(); List <LineRAZ> linesatcenter = new List <LineRAZ>(); List <AttachedMember> attachedMemTemp = new List <AttachedMember>(); List <AttachedMember> attachedMembers = new List <AttachedMember>(); //1. DEFINE JOINTS //iterate over all lines in project foreach (ElementRAZ element in elementRAZs) { //STARTPoints //If fromPoints or startPoints of line fall in the tolerancebox than add lines. if (PointRAZ.ArePointsEqual(tolbox, centerpoint, element.line.Start) && element.line.vector.length > tolbox) { LineRAZ line = element.line; VectorRAZ distancevector = new VectorRAZ(0.0, 0.0, 0.0); double localEccnetricty = 0.0; ConnectingMember connectingMember = new ConnectingMember(element, distancevector, true, line, localEccnetricty); elementIDs.Add(elementRAZs.IndexOf(element)); attachedMemTemp.Add(connectingMember); } //ENDPoints //If toPoints or endPoints of line fall in the tolerancebox than add lines. if (PointRAZ.ArePointsEqual(tolbox, centerpoint, element.line.End) && element.line.vector.length > tolbox) { LineRAZ idealine = LineRAZ.FlipLine(element.line);//in this case of endpoint line needs to be flipped VectorRAZ distancevector = new VectorRAZ(0.0, 0.0, 0.0); double localEccnetricty = 0.0; ConnectingMember connectingMember = new ConnectingMember(element, distancevector, false, idealine, localEccnetricty); elementIDs.Add(elementRAZs.IndexOf(element)); attachedMemTemp.Add(connectingMember); } } //2. ORDER ATTACHEDMEMBERS ACCORDING TO HIERARCHY bool IsContinues = true; //Redistribute attachedMemTemp over BearingMember and ConnectingMember //iterate over hierarchy rank to make sure list is created in a orded way if (!hierarchy.Any()) { //no hierarchy, first member found is an ended bearing member IsContinues = false; //First member is bearing AttachedMember w = attachedMemTemp.First(); BearingMember bearing = new BearingMember(w.ElementRAZ, w.distanceVector, w.isStartPoint, w.ideaLine); attachedMembers.Add(bearing); //Rest of members are connecting members for (int b = 1; b < attachedMemTemp.Count; b++) { attachedMembers.Add(attachedMemTemp[b]); } } else { //hierarchy determined, list will be build based on hierarchy //TODE add code //If only one hierarchy entry defined if (hierarchy.Count == 1) { IsContinues = false; //First member is bearing AttachedMember w = attachedMemTemp.First(); BearingMember bearing = new BearingMember(w.ElementRAZ, w.distanceVector, w.isStartPoint, w.ideaLine); attachedMembers.Add(bearing); //Rest of members are connecting members for (int b = 1; b < attachedMemTemp.Count; b++) { attachedMembers.Add(attachedMemTemp[b]); } } else { for (int rank = 0; rank < 1 + hierarchy.Max(a => a.numberInHierarchy); rank++) { //iterate over attachedMembers of every joint //List<AttachedMember> templist = new List<AttachedMember>(); for (int ibb = 0; ibb < attachedMemTemp.Count; ibb++) { AttachedMember w = attachedMemTemp[ibb]; //if hierarchy if the highest occuring if (w.ElementRAZ.numberInHierarchy == rank && rank == attachedMemTemp.Min(a => a.ElementRAZ.numberInHierarchy)) { BearingMember bearing = new BearingMember(w.ElementRAZ, w.distanceVector, w.isStartPoint, w.ideaLine); attachedMembers.Add(bearing); } if (w.ElementRAZ.numberInHierarchy == rank && rank != attachedMemTemp.Min(a => a.ElementRAZ.numberInHierarchy)) { attachedMembers.Add(w); //temp //templist.Add(attachedMemTemp[ibb]); } } } } //If there is more than one Bearing Member, IsContinues joint List <BearingMember> BM = attachedMembers.OfType <BearingMember>().ToList(); if (BM.Count == 1) { IsContinues = false; } } //3. ADD JOINTS TO PROJECT //CREATE JOINT ADD TO PROJECT //Joint id starts from one, because IDEA counts from one double maxGlobalEccentricity = 0.0; bool WEJ = false; VectorRAZ bearingMemberUnitVector = new VectorRAZ(1.0, 0.0, 0.0); Joint joint = new Joint(this, i + 1, elementIDs, attachedMembers, centerpoint, maxGlobalEccentricity, WEJ, bearingMemberUnitVector, IsContinues); this.joints.Add(joint); } }