Exemple #1
0
 public SupportArea Overlap(SupportArea that)
 {
     Debug.Assert(this.Overlaps(that));             // In particular, on same sheet
     return(new SupportArea(sheet,
                            this.colInt.Meet(that.colInt),
                            this.rowInt.Meet(that.rowInt)));
 }
Exemple #2
0
 public override void ForEachSupported(Action <Sheet, int, int> act)
 {
     if (IdempotentForeach && this.Count > alreadyVisited.Count + 1)
     {
         for (int i = 0; i < alreadyVisited.Count; i++)
         {
             SupportArea old = alreadyVisited[i];
             if (this.Overlaps(old))
             {
                 SupportArea overlap = this.Overlap(old);
                 if (overlap.Count == this.Count)                           // contained in old
                 {
                     return;
                 }
                 else if (overlap.Count == old.Count)                           // contains old
                 {
                     alreadyVisited[i] = this;
                     ForEachExcept(overlap, act);
                     return;
                 }
                 else if (this.colInt.Equals(old.colInt) && this.rowInt.Overlaps(old.rowInt))
                 {
                     alreadyVisited[i] = new SupportArea(sheet, this.colInt, this.rowInt.Join(old.rowInt));
                     ForEachExcept(overlap, act);
                     return;
                 }
                 else if (this.rowInt.Equals(old.rowInt) && this.colInt.Overlaps(old.colInt))
                 {
                     alreadyVisited[i] = new SupportArea(sheet, this.colInt.Join(old.colInt), this.rowInt);
                     ForEachExcept(overlap, act);
                     return;
                 }
                 else                           // overlaps, but neither containment nor rectangular union
                 {
                     alreadyVisited.Add(this);
                     ForEachExcept(overlap, act);
                     return;
                 }
             }
         }
         // Large enough but no existing support set overlaps this one
         alreadyVisited.Add(this);
     }
     ForEachInArea(sheet, colInt, rowInt, act);
 }
Exemple #3
0
 private void ForEachExcept(SupportArea overlap, Action <Sheet, int, int> act)
 {
     if (rowInt.min < overlap.rowInt.min)             // North non-empty, columns above overlap
     {
         ForEachInArea(sheet, overlap.colInt, new Interval(rowInt.min, overlap.rowInt.min - 1), act);
     }
     if (overlap.rowInt.max < rowInt.max)             // South non-empty, columns below overlap
     {
         ForEachInArea(sheet, overlap.colInt, new Interval(overlap.rowInt.max + 1, rowInt.max), act);
     }
     if (colInt.min < overlap.colInt.min)             // West non-empty, rows left of overlap
     {
         ForEachInArea(sheet, new Interval(colInt.min, overlap.colInt.min - 1), rowInt, act);
     }
     if (overlap.colInt.max < colInt.max)             // East non-empty, rows right of overlap
     {
         ForEachInArea(sheet, new Interval(overlap.colInt.max + 1, colInt.max), rowInt, act);
     }
 }
Exemple #4
0
		public override void ForEachSupported(Action<Sheet, int, int> act) {
			if (IdempotentForeach && this.Count > alreadyVisited.Count + 1) {
				for (int i = 0; i < alreadyVisited.Count; i++) {
					SupportArea old = alreadyVisited[i];
					if (this.Overlaps(old)) {
						SupportArea overlap = this.Overlap(old);
						if (overlap.Count == this.Count) { // contained in old
							return;
						}
						else if (overlap.Count == old.Count) { // contains old
							alreadyVisited[i] = this;
							ForEachExcept(overlap, act);
							return;
						}
						else if (this.colInt.Equals(old.colInt) && this.rowInt.Overlaps(old.rowInt)) {
							alreadyVisited[i] = new SupportArea(sheet, this.colInt, this.rowInt.Join(old.rowInt));
							ForEachExcept(overlap, act);
							return;
						}
						else if (this.rowInt.Equals(old.rowInt) && this.colInt.Overlaps(old.colInt)) {
							alreadyVisited[i] = new SupportArea(sheet, this.colInt.Join(old.colInt), this.rowInt);
							ForEachExcept(overlap, act);
							return;
						}
						else { // overlaps, but neither containment nor rectangular union
							alreadyVisited.Add(this);
							ForEachExcept(overlap, act);
							return;
						}
					}
				}
				// Large enough but no existing support set overlaps this one
				alreadyVisited.Add(this);
			}
			ForEachInArea(sheet, colInt, rowInt, act);
		}
Exemple #5
0
		private void ForEachExcept(SupportArea overlap, Action<Sheet, int, int> act) {
			if (rowInt.min < overlap.rowInt.min) // North non-empty, columns above overlap
			{
				ForEachInArea(sheet, overlap.colInt, new Interval(rowInt.min, overlap.rowInt.min - 1), act);
			}
			if (overlap.rowInt.max < rowInt.max) // South non-empty, columns below overlap
			{
				ForEachInArea(sheet, overlap.colInt, new Interval(overlap.rowInt.max + 1, rowInt.max), act);
			}
			if (colInt.min < overlap.colInt.min) // West non-empty, rows left of overlap
			{
				ForEachInArea(sheet, new Interval(colInt.min, overlap.colInt.min - 1), rowInt, act);
			}
			if (overlap.colInt.max < colInt.max) // East non-empty, rows right of overlap
			{
				ForEachInArea(sheet, new Interval(overlap.colInt.max + 1, colInt.max), rowInt, act);
			}
		}
Exemple #6
0
		public SupportArea Overlap(SupportArea that) {
			Debug.Assert(this.Overlaps(that)); // In particular, on same sheet
			return new SupportArea(sheet,
								   this.colInt.Meet(that.colInt),
								   this.rowInt.Meet(that.rowInt));
		}
Exemple #7
0
		public bool Overlaps(SupportArea that) {
			return this.sheet == that.sheet
				   && this.colInt.Overlaps(that.colInt) && this.rowInt.Overlaps(that.rowInt);
		}
Exemple #8
0
 public bool Overlaps(SupportArea that)
 {
     return(this.sheet == that.sheet &&
            this.colInt.Overlaps(that.colInt) && this.rowInt.Overlaps(that.rowInt));
 }