public void AddJointEdge(construct.Joint joint) { JointEdge jointEdge = new JointEdge(joint); try { if (piecesVertex.ContainsKey(joint.FirstElement.Id) && piecesVertex.ContainsKey(joint.SecondElement.Id)) { jointEdge.PartsVertex.Add(piecesVertex[joint.FirstElement.Id]); jointEdge.PartsVertex.Add(piecesVertex[joint.SecondElement.Id]); piecesVertex[joint.FirstElement.Id].JointsEdge.Add(jointEdge); piecesVertex[joint.SecondElement.Id].JointsEdge.Add(jointEdge); } else { log.Warn(string.Format("The one of requested keys is not in the dictionary of welded parts. Joint #{0}, id:{1}", joint.Number, joint.Id)); } } catch(NullReferenceException e) { log.Error( string.Format("Unable to add the joint #{0}, id:{1} as edge of the pipeline.", joint.Number, joint.Id)); throw e; } }
public List<List<PipelineVertex>> Pathfinder( construct.PartData startPartData, construct.PartData endPartData) { List<List<PipelineVertex>> paths = new List<List<PipelineVertex>>(); Stack<PipelineVertex> stack = new Stack<PipelineVertex>(); try { var startPiece = piecesVertex[startPartData.Id]; var endPiece = piecesVertex[endPartData.Id]; stack.Push(startPiece); List<JointEdge> joints = stack.Peek().JointsEdge; int[] path = new int[this.piecesVertex.Count]; int k = 0; while (stack.Count > 0 && paths.Count < maximumPathsNumber) { while (k < joints.Count) { for (int i = 0; i < jointPartVertexCount; ++i) { if (!stack.Contains(joints[k].PartsVertex[i])) { path[stack.Count - 1] = k; stack.Push(joints[k].PartsVertex[i]); joints = stack.Peek().JointsEdge; k = 0; break; } else if (i == 1) { ++k; } } if (stack.Peek() == endPiece) { paths.Add(stack.ToList<PipelineVertex>()); break; } } if (stack.Count > 1) { stack.Pop(); joints = stack.Peek().JointsEdge; path[stack.Count - 1]++; k = path[stack.Count - 1]; } else break; } } catch (KeyNotFoundException e) { log.Error( string.Format( "The one of requested keys is not in the dictionary of welded parts: start Part #{0}, id:{1}; end Part #{2}, id:{3}", startPartData.Number, startPartData.Id, endPartData.Number, endPartData.Id)); throw e; } return paths; }
public void AddPipelineVertex(construct.PartData partData) { piecesVertex.Add(partData.Id, new PipelineVertex(partData)); }
public PipelineVertex(construct.PartData data) { Data = data; JointsEdge = new List<JointEdge>(); }
public JointEdge(construct.Joint data) { Data = data; PartsVertex = new List<PipelineVertex>(); }
public List<PipelineVertex> RemovalExternalComponents( construct.Joint startJoint, construct.Joint endJoint, List<PipelineVertex> path) { var joints = new construct.Joint[] { startJoint, endJoint }; var parts = new PipelineVertex[] { path.First(), path.Last() }; foreach (var part in parts) { if (part.JointsEdge.Count == 1) { path.Remove(part); } else { foreach (var jointEdge in part.JointsEdge) { if (!joints.Contains<construct.Joint>(jointEdge.Data)) { foreach (var p in jointEdge.PartsVertex) { if (p != part && !path.Contains<PipelineVertex>(p) && path.Contains<PipelineVertex>(part)) { path.Remove(part); } } } } } } return path; }
private string GetWeldDate(construct.Joint joint) { string strDate = string.Empty; var weldResults = joint.JointWeldResults; if (weldResults.Count > 0) { strDate = weldResults.First().Date.Value.ToShortDateString(); } return strDate; }