/// <summary> Compare and adjust this item with a higher level item. </summary> /// <param name="item"> The item to compare against. </param> /// <returns> true if this item can be removed otherwise false. </returns> public CompareActions CompareAndAdjustBody(EdgeItem item) { if (item.Level < Level) { // item has a lower level so we don't need to adjust return(CompareActions.None); } if ((item.EdgePosition2 < EdgePosition1) || (item.EdgePosition1 > EdgePosition2)) { // No overlap return(CompareActions.None); } if ((item.EdgePosition2 >= EdgePosition2) && (item.EdgePosition1 <= EdgePosition1)) { // completely overlapped return(CompareActions.Delete); } // partially overlapped so reduce size to only non overlapped if ((EdgePosition1 < item.EdgePosition1) && (EdgePosition2 > item.EdgePosition2)) { return(CompareActions.Split); } if (EdgePosition1 < item.EdgePosition1) { EdgePosition2 = item.EdgePosition1; } else { EdgePosition1 = item.EdgePosition2; } // if size is too small, mark it for delete return((EdgePosition2 - EdgePosition1 < 0) ? CompareActions.Delete : CompareActions.None); }
/// <summary> Copies the given item. </summary> /// <param name="item"> The item. </param> public void Copy(EdgeItem item) { Level = item.Level; EdgePosition1 = item.EdgePosition1; EdgePosition2 = item.EdgePosition2; EdgeLimit1 = item.EdgeLimit1; EdgeLimit2 = item.EdgeLimit2; }
/// <summary> Copies the given item. </summary> /// <param name="item"> The item. </param> public void Copy(EdgeItem item) { this.Level = item.Level; this.EdgePosition1 = item.EdgePosition1; this.EdgePosition2 = item.EdgePosition2; this.EdgeLimit1 = item.EdgeLimit1; this.EdgeLimit2 = item.EdgeLimit2; }
/// <summary> Determine if we can be with the supplied item. </summary> /// <param name="edgeItem"> The edge item to be merged with. </param> /// <param name="alignBoundary"> The align boundary. </param> /// <param name="alignOnLesserEdge"> true to align on lesser edge. </param> /// <returns> true if we can be merged, false if not. </returns> public bool CanBeMerged(EdgeItem edgeItem, double alignBoundary, bool alignOnLesserEdge) { if ((Level - edgeItem.Level > 0) && (Level - edgeItem.Level < alignBoundary)) { return(((edgeItem.EdgeLimit1 >= EdgeLimit1) && (edgeItem.EdgeLimit1 <= EdgeLimit2)) && ((edgeItem.EdgeLimit2 >= EdgeLimit1) && (edgeItem.EdgeLimit2 <= EdgeLimit2) && ((alignOnLesserEdge) || (EdgePosition1 < edgeItem.EdgePosition2)))); } return(false); }
/// <summary> Check for overlap. </summary> /// <param name="index"> Zero-based index of the. </param> /// <param name="edges"> The edges. </param> /// <returns> true if it succeeds, false if it fails. </returns> private CompareActions CheckForOverlap(LinkedListNode <EdgeItem> index, List <EdgeItem> edges) { // compare the current item to the following items (should be greater level) LinkedListNode <EdgeItem> subIndex = index.Next; while (subIndex != null) { switch (index.Value.CompareAndAdjustBody(subIndex.Value)) { // item is no longer neede so request it be deleted case CompareActions.Delete: return(CompareActions.Delete); // item needs to be split into 2 items case CompareActions.Split: // compare split item sizes double w1 = subIndex.Value.EdgePosition1 - index.Value.EdgePosition1; double w2 = index.Value.EdgePosition2 - subIndex.Value.EdgePosition2; if ((w1 < 0) && (w2 < 0)) { // both too small, so delete item instead return(CompareActions.Delete); } if (w1 < 0) { // ignore w1 and use only w2 index.Value.EdgePosition1 = subIndex.Value.EdgePosition2; } else if (w2 < 0) { // ignore w2 and use only w1 index.Value.EdgePosition2 = subIndex.Value.EdgePosition1; } else { // shortened w1 and insert new w2 EdgeItem newItem = new EdgeItem(subIndex.Value.EdgePosition2, index.Value.EdgePosition2, index.Value.Level, this.areaLimit1, this.areaLimit2); index.Value.EdgePosition2 = subIndex.Value.EdgePosition1; index.List.AddAfter(index, newItem); int idx = edges.FindIndex(edge => index.Value == edge); edges.Insert(idx + 1, newItem); } break; } subIndex = subIndex.Next; } return(CompareActions.None); }
/// <summary> Compare and adjust this item with a higher level item. </summary> /// <param name="item"> The item to compare against. </param> /// <returns> true if this item can be removed otherwise false. </returns> public void CompareAndAdjustWing(EdgeItem item) { if (item.Level <= this.Level) { // item has a lower level so we don't need to adjust return; } if ((item.EdgePosition2 < this.EdgeLimit1) || (item.EdgePosition1 > this.EdgeLimit2)) { // No overlap return; } if ((item.EdgePosition2 >= this.EdgeLimit2) && (item.EdgePosition1 <= this.EdgeLimit1)) { // completely overlapped Debug.Assert(false, "This Item should have been deleted already"); return; } // partially overlapped so reduce size to only non overlapped if ((this.EdgeLimit1 < item.EdgePosition1) && (this.EdgeLimit2 > item.EdgePosition2)) { if (this.EdgePosition1 > item.EdgePosition1) { this.EdgeLimit1 = item.EdgePosition2; } else { this.EdgeLimit2 = item.EdgePosition1; } return; } if (this.EdgeLimit1 < item.EdgePosition1) { this.EdgeLimit2 = item.EdgePosition1; } else { this.EdgeLimit1 = item.EdgePosition2; } }
public Project(EdgeItem edge) { this.edge = edge; pointPosition = 0; }
/// <summary> Check for overlap. </summary> /// <param name="index"> Zero-based index of the. </param> /// <param name="edges"> The edges. </param> /// <returns> true if it succeeds, false if it fails. </returns> private CompareActions CheckForOverlap(LinkedListNode<EdgeItem> index, List<EdgeItem> edges) { // compare the current item to the following items (should be greater level) LinkedListNode<EdgeItem> subIndex = index.Next; while(subIndex != null) { switch(index.Value.CompareAndAdjustBody(subIndex.Value)) { // item is no longer neede so request it be deleted case CompareActions.Delete: return CompareActions.Delete; // item needs to be split into 2 items case CompareActions.Split: // compare split item sizes double w1 = subIndex.Value.EdgePosition1 - index.Value.EdgePosition1; double w2 = index.Value.EdgePosition2 - subIndex.Value.EdgePosition2; if((w1 < 0) && (w2 < 0)) { // both too small, so delete item instead return CompareActions.Delete; } if(w1 < 0) { // ignore w1 and use only w2 index.Value.EdgePosition1 = subIndex.Value.EdgePosition2; } else if(w2 < 0) { // ignore w2 and use only w1 index.Value.EdgePosition2 = subIndex.Value.EdgePosition1; } else { // shortened w1 and insert new w2 EdgeItem newItem = new EdgeItem(subIndex.Value.EdgePosition2, index.Value.EdgePosition2, index.Value.Level, _areaLimit1, _areaLimit2); index.Value.EdgePosition2 = subIndex.Value.EdgePosition1; index.List.AddAfter(index, newItem); int idx = edges.FindIndex(edge => index.Value == edge); edges.Insert(idx + 1, newItem); } break; } subIndex = subIndex.Next; } return CompareActions.None; }
/// <summary> Determine if we can be with the supplied item. </summary> /// <param name="edgeItem"> The edge item to be merged with. </param> /// <param name="alignBoundary"> The align boundary. </param> /// <param name="alignOnLesserEdge"> true to align on lesser edge. </param> /// <returns> true if we can be merged, false if not. </returns> public bool CanBeMerged(EdgeItem edgeItem, double alignBoundary, bool alignOnLesserEdge) { if ((Level - edgeItem.Level > 0) && (Level - edgeItem.Level < alignBoundary)) { return ((edgeItem.EdgeLimit1 >= EdgeLimit1) && (edgeItem.EdgeLimit1 <= EdgeLimit2)) && ((edgeItem.EdgeLimit2 >= EdgeLimit1) && (edgeItem.EdgeLimit2 <= EdgeLimit2) && ((alignOnLesserEdge) || (EdgePosition1 < edgeItem.EdgePosition2))); } return false; }
/// <summary> Compare and adjust this item with a higher level item. </summary> /// <param name="item"> The item to compare against. </param> /// <returns> true if this item can be removed otherwise false. </returns> public void CompareAndAdjustWing(EdgeItem item) { if (item.Level <= Level) { // item has a lower level so we don't need to adjust return; } if ((item.EdgePosition2 < EdgeLimit1) || (item.EdgePosition1 > EdgeLimit2)) { // No overlap return; } if ((item.EdgePosition2 >= EdgeLimit2) && (item.EdgePosition1 <= EdgeLimit1)) { // completely overlapped Debug.Assert(false, "This Item should have been deleted already"); return; } // partially overlapped so reduce size to only non overlapped if ((EdgeLimit1 < item.EdgePosition1) && (EdgeLimit2 > item.EdgePosition2)) { if(EdgePosition1 > item.EdgePosition1) { EdgeLimit1 = item.EdgePosition2; } else { EdgeLimit2 = item.EdgePosition1; } return; } if (EdgeLimit1 < item.EdgePosition1) { EdgeLimit2 = item.EdgePosition1; } else { EdgeLimit1 = item.EdgePosition2; } }
/// <summary> Compare and adjust this item with a higher level item. </summary> /// <param name="item"> The item to compare against. </param> /// <returns> true if this item can be removed otherwise false. </returns> public CompareActions CompareAndAdjustBody(EdgeItem item) { if (item.Level < Level) { // item has a lower level so we don't need to adjust return CompareActions.None; } if((item.EdgePosition2 < EdgePosition1) || (item.EdgePosition1 > EdgePosition2)) { // No overlap return CompareActions.None; } if ((item.EdgePosition2 >= EdgePosition2) && (item.EdgePosition1 <= EdgePosition1)) { // completely overlapped return CompareActions.Delete; } // partially overlapped so reduce size to only non overlapped if((EdgePosition1 < item.EdgePosition1) && (EdgePosition2 > item.EdgePosition2)) { return CompareActions.Split; } if (EdgePosition1 < item.EdgePosition1) { EdgePosition2 = item.EdgePosition1; } else { EdgePosition1 = item.EdgePosition2; } // if size is too small, mark it for delete return (EdgePosition2 - EdgePosition1 < 0) ? CompareActions.Delete : CompareActions.None; }
/// <summary> Copy constructor. </summary> /// <param name="item"> The item. </param> public EdgeItem(EdgeItem item) { this.Copy(item); }
public Project(EdgeItem edge, int position) { this.edge = edge; pointPosition = position; }
/// <summary> Copy constructor. </summary> /// <param name="item"> The item. </param> public EdgeItem(EdgeItem item) { Copy(item); }
public Reduce(EdgeItem reduceEdge) { this.reduceEdge = reduceEdge; }