/// <summary> /// Compute the label in the appropriate orientation for this DirEdge. /// </summary> private void ComputeDirectedLabel() { Label = new Label(Edge.Label); if (!_isForward) { Label.Flip(); } }
/// <summary> /// Compute the label in the appropriate orientation for this DirEdge. /// </summary> private void ComputeDirectedLabel() { Label = new Label(Edge.Label); if (!_isForward) Label.Flip(); }
/// <summary> /// Insert an edge from one of the noded input graphs. /// Checks edges that are inserted to see if an /// identical edge already exists. /// If so, the edge is not inserted, but its label is merged /// with the existing edge. /// </summary> /// <param name="e">The edge to insert</param> protected void InsertUniqueEdge(Edge e) { var existingEdge = _edgeList.FindEqualEdge(e); // If an identical edge already exists, simply update its label if (existingEdge != null) { var existingLabel = existingEdge.Label; var labelToMerge = e.Label; // check if new edge is in reverse direction to existing edge // if so, must flip the label before merging it if (!existingEdge.IsPointwiseEqual(e)) { labelToMerge = new Label(e.Label); labelToMerge.Flip(); } var depth = existingEdge.Depth; // if this is the first duplicate found for this edge, initialize the depths if (depth.IsNull()) depth.Add(existingLabel); depth.Add(labelToMerge); existingLabel.Merge(labelToMerge); } else { // no matching existing edge was found // add this new edge to the list of edges in this graph _edgeList.Add(e); } }
/// <summary> /// Create a EdgeStub for the edge before the intersection eiCurr. /// The previous intersection is provided /// in case it is the endpoint for the stub edge. /// Otherwise, the previous point from the parent edge will be the endpoint. /// eiCurr will always be an EdgeIntersection, but eiPrev may be null. /// </summary> /// <param name="edge"></param> /// <param name="l"></param> /// <param name="eiCurr"></param> /// <param name="eiPrev"></param> public void CreateEdgeEndForPrev(Edge edge, IList<EdgeEnd> l, EdgeIntersection eiCurr, EdgeIntersection eiPrev) { int iPrev = eiCurr.SegmentIndex; if (eiCurr.Distance == 0.0) { // if at the start of the edge there is no previous edge if (iPrev == 0) return; iPrev--; } Coordinate pPrev = edge.GetCoordinate(iPrev); // if prev intersection is past the previous vertex, use it instead if (eiPrev != null && eiPrev.SegmentIndex >= iPrev) pPrev = eiPrev.Coordinate; Label label = new Label(edge.Label); // since edgeStub is oriented opposite to it's parent edge, have to flip sides for edge label label.Flip(); EdgeEnd e = new EdgeEnd(edge, eiCurr.Coordinate, pPrev, label); l.Add(e); }
/// <summary> /// Inserted edges are checked to see if an identical edge already exists. /// If so, the edge is not inserted, but its label is merged /// with the existing edge. /// </summary> protected void InsertUniqueEdge(Edge e) { //<FIX> MD 8 Oct 03 speed up identical edge lookup // fast lookup Edge existingEdge = _edgeList.FindEqualEdge(e); // If an identical edge already exists, simply update its label if (existingEdge != null) { Label existingLabel = existingEdge.Label; Label labelToMerge = e.Label; // check if new edge is in reverse direction to existing edge // if so, must flip the label before merging it if (!existingEdge.IsPointwiseEqual(e)) { labelToMerge = new Label(e.Label); labelToMerge.Flip(); } existingLabel.Merge(labelToMerge); // compute new depth delta of sum of edges int mergeDelta = DepthDelta(labelToMerge); int existingDelta = existingEdge.DepthDelta; int newDelta = existingDelta + mergeDelta; existingEdge.DepthDelta = newDelta; } else { // no matching existing edge was found // add this new edge to the list of edges in this graph //e.setName(name + edges.size()); _edgeList.Add(e); e.DepthDelta = DepthDelta(e.Label); } }