// // Append subtraction to this current problem. // public static FigSynthProblem AppendAddition(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) { return(null); } if (that is AdditionSynth) { // Verify that the external form of that matches with the LHS of toAppend. Polygon testPoly = Polygon.MakePolygon(that.GetExteriorSegments()); if (!testPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure)) { throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure); } } // Create the new synth object AdditionSynth newSum = new AdditionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure); // The open regions that may be modified consist of a union of regions. List <AtomicRegion> newOpenRegions = new List <AtomicRegion>(that.openRegions); newOpenRegions.AddRange(toAppend.openRegions); newSum.SetOpenRegions(newOpenRegions); return(newSum); }
public override FigSynthProblem Copy() { AdditionSynth copy = new AdditionSynth(this.leftProblem.Copy(), this.rightProblem.Copy()); copy.SetOpenRegions(new List <AtomicRegion>(this.openRegions)); return(copy); }
public override FigSynthProblem Copy() { AdditionSynth copy = new AdditionSynth(this.leftProblem.Copy(), this.rightProblem.Copy()); copy.SetOpenRegions(new List<AtomicRegion>(this.openRegions)); return copy; }
// // A symmetric scenario is one in which: // 1) The inner shapes are congruent // 2) The remaining atomic regions match 1-1. // public override bool IsSymmetricTo(FigSynthProblem that) { AdditionSynth addSynth = that as AdditionSynth; if (addSynth == null) { return(false); } // The atomic regions have to match 1-1 and onto. return(base.IsSymmetricTo(that)); }
// // Used by Square and Rectangle // public static FigSynthProblem MakeAdditionProblem(Figure outerShape, Figure appended) { if (outerShape.Contains(appended) || appended.Contains(outerShape) || outerShape.Overlaps(appended)) { return(null); } AdditionSynth addSynth = new AdditionSynth(outerShape, appended); List <AtomicRegion> atoms = new List <AtomicRegion>(); atoms.Add(outerShape.GetFigureAsAtomicRegion()); atoms.Add(appended.GetFigureAsAtomicRegion()); addSynth.SetOpenRegions(atoms); return(addSynth); }
// // Used by Square and Rectangle // public static FigSynthProblem MakeAdditionProblem(Figure outerShape, Figure appended) { if (outerShape.Contains(appended) || appended.Contains(outerShape) || outerShape.Overlaps(appended)) return null; AdditionSynth addSynth = new AdditionSynth(outerShape, appended); List<AtomicRegion> atoms = new List<AtomicRegion>(); atoms.Add(outerShape.GetFigureAsAtomicRegion()); atoms.Add(appended.GetFigureAsAtomicRegion()); addSynth.SetOpenRegions(atoms); return addSynth; }
// // Append subtraction to this current problem. // public static FigSynthProblem AppendAddition(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) return null; if (that is AdditionSynth) { // Verify that the external form of that matches with the LHS of toAppend. Polygon testPoly = Polygon.MakePolygon(that.GetExteriorSegments()); if (!testPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure)) { throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure); } } // Create the new synth object AdditionSynth newSum = new AdditionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure); // The open regions that may be modified consist of a union of regions. List<AtomicRegion> newOpenRegions = new List<AtomicRegion>(that.openRegions); newOpenRegions.AddRange(toAppend.openRegions); newSum.SetOpenRegions(newOpenRegions); return newSum; }