public override FigSynthProblem ReplaceUnary(Figure that, FigSynthProblem toSub) { leftProblem = leftProblem.ReplaceUnary(that, toSub); rightProblem = rightProblem.ReplaceUnary(that, toSub); return(this); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { List <Triangle> tris = Triangle.GetTrianglesFromPoints(points); List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Triangle tri in tris) { // Only create right triangles that are NOT the outershape. if (tri.isRightTriangle() && !tri.StructurallyEquals(outerShape)) { RightTriangle rTri = new RightTriangle(tri); SubtractionSynth subSynth = new SubtractionSynth(outerShape, rTri); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rTri.points, rTri)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { // Possible quadrilaterals. List <Quadrilateral> quads = null; if (outerShape is ConcavePolygon) { quads = Quadrilateral.GetQuadrilateralsFromPoints(outerShape as ConcavePolygon, points); } else { quads = Quadrilateral.GetQuadrilateralsFromPoints(points); } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Quadrilateral quad in quads) { // Select only isosceles trapezoids that don't match the outer shape. if (quad.VerifyIsoscelesTrapezoid() && !quad.HasSamePoints(outerShape as Polygon)) { IsoscelesTrapezoid isoTrap = new IsoscelesTrapezoid(quad); SubtractionSynth subSynth = new SubtractionSynth(outerShape, isoTrap); subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, isoTrap.points, isoTrap)); composed.Add(subSynth); } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { // Possible quadrilaterals. List <Quadrilateral> quads = null; if (outerShape is ConcavePolygon) { quads = Quadrilateral.GetQuadrilateralsFromPoints(outerShape as ConcavePolygon, points); } else { quads = Quadrilateral.GetQuadrilateralsFromPoints(points); } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Quadrilateral quad in quads) { // Select only rectangles that don't match the outer shape. if (quad.VerifyRectangle() && !quad.HasSamePoints(outerShape as Polygon)) { Rectangle rect = new Rectangle(quad); SubtractionSynth subSynth = new SubtractionSynth(outerShape, rect); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rect.points, rect)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // Possible triangles. List <Triangle> tris = null; if (outerShape is ConcavePolygon) { tris = Triangle.GetTrianglesFromPoints(outerShape as ConcavePolygon, points); } else { tris = Triangle.GetTrianglesFromPoints(points); } // Check all triangles to determine applicability. foreach (Triangle tri in tris) { // Avoid equilateral, isosceles, and right triangles. if (!tri.IsEquilateral() && !tri.IsIsosceles() && !tri.isRightTriangle() && !tri.StructurallyEquals(outerShape)) { SubtractionSynth subSynth = new SubtractionSynth(outerShape, tri); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, tri.points, tri)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); int length = Figure.DefaultSideLength(); int angle = Figure.DefaultFirstQuadrantNonRightAngle(); foreach (Segment seg in segments) { List <Triangle> tris; MakeTriangles(seg, length, angle, out tris); foreach (Triangle t in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Segment seg in segments) { Rectangle rect1; Rectangle rect2; Rectangle.MakeRectangles(seg, seg.Length, out rect1, out rect2); Square sq1 = new Square(rect1); Square sq2 = new Square(rect2); FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, sq2); if (prob != null) { composed.Add(prob); } prob = Figure.MakeAdditionProblem(outerShape, sq2); if (prob != null) { composed.Add(prob); } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // 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); }
// // With appending in this case, we choose the given segment to be the base. // public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // // Construct the triangles. // foreach (Segment seg in segments) { List <Triangle> tris; IsoscelesTriangle.MakeIsoscelesTriangles(seg, seg.Length, out tris); foreach (Triangle t in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // 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); }
// // If the figure matches this unary, return the problem to sub. // Otherwise return this (which indicates no substitution). // public override FigSynthProblem ReplaceUnary(Figure that, FigSynthProblem toSub) { if (figure.Equals(that)) { return(toSub); } return(this); }
public override FigSynthProblem GetSynthByShape(Figure that) { FigSynthProblem left = leftProblem.GetSynthByShape(that); if (left != null) { return(left); } return(rightProblem.GetSynthByShape(that)); }
// // 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)); }
// // With appending in this case, we choose the given segment to be the base. // public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // Acquire a set of lengths of the given segments. List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // // Acquire the length of the isosceles triangle so that it is longer than the half the distance of the segment. // int newLength = -1; for (newLength = Figure.DefaultSideLength(); ; newLength = Figure.DefaultSideLength()) { bool longEnough = true; foreach (Segment side in segments) { if (newLength < (side.Length / 2.0) + 1) { longEnough = false; break; } } if (longEnough) { break; } } // // Construct the triangles. // foreach (Segment seg in segments) { List <Triangle> tris; MakeIsoscelesTriangles(seg, newLength, out tris); foreach (Triangle t in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, t); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // 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) { UnarySynth unarySynth = that as UnarySynth; if (unarySynth == null) { return(false); } // The outer shapes must be congruent. return(this.figure.CoordinateCongruent(unarySynth.figure)); // The atomic regions have to match 1-1 and onto. // return base.IsSymmetricTo(that); }
// // Append subtraction to this current problem; the subtraction occurs within the inner figure (shape). // public static FigSynthProblem AppendFigureSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) { return(null); } if (that is SubtractionSynth) { // Verify that the outer part of toAppend is a figure in this problem. Figure theShape = (binaryAppend.leftProblem as UnarySynth).figure; FigSynthProblem leftShapeProblem = that.GetSynthByShape(theShape); if (leftShapeProblem == null) { throw new ArgumentException("Shape is not in the given problem: " + theShape); } // // Create the new subtraction node and insert it into the copy. // // Since the 'left' expression was a shape, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(leftShapeProblem, binaryAppend.rightProblem); return(that.Copy().ReplaceUnary(theShape, newSub)); } else if (that is AdditionSynth) { // Verify that the external form of that matches with the LHS of toAppend. Polygon outerPoly = Polygon.MakePolygon(that.GetExteriorSegments()); if (!outerPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure)) { throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Make a copy of that. return(new SubtractionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure)); } else { throw new ArgumentException("Expected Addition or Subtraction; acquired neither."); } }
public List<AtomicRegion> GetRemainingRegionsFromParser(FigSynthProblem problem) { // Acquire all the figures we are subtracting. // false indicates an implied addition at the beginning. List<Figure> figures = problem.CollectSubtractiveFigures(false); // Acquire the remaining atomic regions. List<AtomicRegion> atoms = parser.implied.GetAtomicRegionsNotByFigures(figures); if (Utilities.FIGURE_SYNTHESIZER_DEBUG) { if (atoms.Count == 1) { System.Diagnostics.Debug.WriteLine("Remaining atom area: " + (atoms[0] as ShapeAtomicRegion).shape.CoordinatizedArea()); } } return atoms; }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { // // Acquire a set of lengths of the given segments. // List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // Acquire the length of the rectangle so it is fixed among all appended shapes. // We avoid a square by looping. int newLength = -1; for (newLength = Figure.DefaultSideLength(); lengths.Contains(newLength); newLength = Figure.DefaultSideLength()) { ; } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Segment seg in segments) { Rectangle rect1; Rectangle rect2; MakeRectangles(seg, newLength, out rect1, out rect2); FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, rect1); if (prob != null) { composed.Add(prob); } prob = Figure.MakeAdditionProblem(outerShape, rect2); if (prob != null) { composed.Add(prob); } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // Append parallelograms to appropriate segments. // public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { // Acquire a set of lengths of the given segments. List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // Acquire the length of the rectangle so it is fixed among all appended shapes. // We avoid a rhombus by looping. int newLength = -1; for (newLength = Figure.DefaultSideLength(); lengths.Contains(newLength); newLength = Figure.DefaultSideLength()) { ; } int angle = Figure.DefaultFirstQuadrantNonRightAngle(); // Create the shapes. List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Segment seg in segments) { List <Parallelogram> parallelograms = new List <Parallelogram>(); parallelograms.AddRange(MakeParallelograms(seg, newLength, angle)); foreach (Parallelogram para in parallelograms) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, para); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // Append subtraction to this current problem; the subtraction occurs within one of the open atomic regions. // public static FigSynthProblem AppendAtomicSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) { return(null); } // Verify that the outer part of toAppend is an open atomic region. if (!that.openRegions.Contains(new ShapeAtomicRegion((binaryAppend.leftProblem as UnarySynth).figure))) { throw new ArgumentException("Shape is not an open atomic region: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Since the 'left' expression was an open region, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(that.Copy(), binaryAppend.rightProblem); // Update the open regions to the inner-most shape. newSub.SetOpenRegions(toAppend.openRegions); return(newSub); }
// // A symmetric scenario is one in which: // 1) The inner shapes are congruent // 2) The remaining atomic regions match 1-1. // public virtual bool IsSymmetricTo(FigSynthProblem that) { // The number of atomic shapes is consistent if (this.openRegions.Count != that.openRegions.Count) { return(false); } // We must have a 1-1 mapping of the remaining atomic shapes. This is in terms of congruence. int numRegions = openRegions.Count; bool[] marked = new bool[numRegions]; foreach (AtomicRegion thisAtom in openRegions) { bool foundAtom = false; for (int a = 0; a < numRegions; a++) { if (!marked[a]) { if (thisAtom.CoordinateCongruent(that.openRegions[a])) { marked[a] = true; foundAtom = true; break; } } } if (!foundAtom) { return(false); } } return(true); }
public new static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points) { // Possible triangles. List <Triangle> tris = null; if (outerShape is ConcavePolygon) { tris = Triangle.GetTrianglesFromPoints(outerShape as ConcavePolygon, points); } else { tris = Triangle.GetTrianglesFromPoints(points); } List <FigSynthProblem> composed = new List <FigSynthProblem>(); foreach (Triangle tri in tris) { // Select only parallelograms that don't match the outer shape. if (tri.IsEquilateral() && !tri.StructurallyEquals(outerShape)) { EquilateralTriangle eqTri = new EquilateralTriangle(tri); SubtractionSynth subSynth = new SubtractionSynth(outerShape, eqTri); try { subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, eqTri.points, eqTri)); composed.Add(subSynth); } catch (Exception) { } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
// // 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) { BinarySynthOperation binarySynth = that as BinarySynthOperation; if (binarySynth == null) { return(false); } // The outer shapes must be congruent. if (!this.leftProblem.IsSymmetricTo(binarySynth.leftProblem)) { return(false); } // The outer shapes must be congruent. if (!this.rightProblem.IsSymmetricTo(binarySynth.rightProblem)) { return(false); } // The atomic regions have to match 1-1 and onto. return(base.IsSymmetricTo(that)); }
public new static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments) { List <FigSynthProblem> composed = new List <FigSynthProblem>(); // Acquire a set of lengths of the given segments. // List <int> lengths = new List <int>(); segments.ForEach(s => Utilities.AddUnique <int>(lengths, (int)s.Length)); // Acquire an isosceles triangle by looping. int newLength = -1; for (newLength = Figure.DefaultSideLength(); lengths.Contains(newLength); newLength = Figure.DefaultSideLength()) { ; } foreach (Segment seg in segments) { List <RightTriangle> tris; MakeRightTriangles(seg, newLength, out tris); foreach (RightTriangle rt in tris) { FigSynthProblem prob = Figure.MakeAdditionProblem(outerShape, rt); if (prob != null) { composed.Add(prob); } } } return(FigSynthProblem.RemoveSymmetric(composed)); }
public abstract FigSynthProblem ReplaceUnary(Figure that, FigSynthProblem toSub);
// // Append addition to this current problem; addition is to an exterior segment. // public static FigSynthProblem AppendAtomicAddition(FigSynthProblem that, FigSynthProblem toAppend) { // AdditionSynth // TBC return(new AdditionSynth(that, toAppend)); }
// // Append to an existent problem. // public static List<FigSynthProblem> AddShape(FigSynthProblem problem, ShapeType type) { // Create a polygon based only on exterior segments. Polygon outer = Polygon.MakePolygon(problem.GetExteriorSegments()); // Append the shapes List<FigSynthProblem> newSynths = AddShape(outer, type); // Create the new problems by appending. List<FigSynthProblem> appended = new List<FigSynthProblem>(); foreach (FigSynthProblem synth in newSynths) { appended.Add(FigSynthProblem.AppendAddition(problem, synth)); } return appended; }
private static GeometryTestbed.FigSynthShadedAreaProblem ConstructProblem(FigSynthProblem problem) { GeometryTestbed.FigSynthShadedAreaProblem shadedArea = new GeometryTestbed.FigSynthShadedAreaProblem(true, true); // // Name the problem (uniquely). // shadedArea.SetName("Fig-Synthesized " + (figCounter++)); // // Construct the points. // List<Point> points = problem.CollectPoints(); shadedArea.SetPoints(points); // // Construct the collinear relationships. // List<Segment> segments; List<Collinear> collinear; AcquireCollinearAndSegments(problem.CollectSegments(), points, out segments, out collinear); shadedArea.SetSegments(segments); shadedArea.SetCollinear(collinear); // // Construct circles. // shadedArea.SetCircles(problem.CollectCircles()); // // Invoke the parser. // shadedArea.InvokeParser(); // // Set the wanted atomic regions. // shadedArea.SetWantedRegions(shadedArea.GetRemainingRegionsFromParser(problem)); // // Set the known values. // Acquire all of the givens using constant propagation for each figure construction. // shadedArea.SetKnowns(problem.AcquireKnowns()); // // Set the problem given clauses. // List<GroundedClause> givens = problem.GetGivens(); problem.GetMidpoints().ForEach(m => givens.Add(m)); shadedArea.SetGivens(givens); // // Set the actual area of the solution (area of wanted regions). // shadedArea.SetSolutionArea(problem.GetCoordinateArea()); return shadedArea; }
// // Append addition to this current problem; addition is to an exterior segment. // public static FigSynthProblem AppendAtomicAddition(FigSynthProblem that, FigSynthProblem toAppend) { // AdditionSynth // TBC return new AdditionSynth(that, toAppend); }
// // If the figure matches this unary, return the problem to sub. // Otherwise return this (which indicates no substitution). // public override FigSynthProblem ReplaceUnary(Figure that, FigSynthProblem toSub) { if (figure.Equals(that)) return toSub; return this; }
public abstract FigSynthProblem ReplaceUnary(Figure that, FigSynthProblem toSub);
public BinarySynthOperation(FigSynthProblem ell, FigSynthProblem r) { leftProblem = ell; rightProblem = r; }
// // A symmetric scenario is one in which: // 1) The inner shapes are congruent // 2) The remaining atomic regions match 1-1. // public virtual bool IsSymmetricTo(FigSynthProblem that) { // The number of atomic shapes is consistent if (this.openRegions.Count != that.openRegions.Count) return false; // We must have a 1-1 mapping of the remaining atomic shapes. This is in terms of congruence. int numRegions = openRegions.Count; bool[] marked = new bool[numRegions]; foreach (AtomicRegion thisAtom in openRegions) { bool foundAtom = false; for (int a = 0; a < numRegions; a++) { if (!marked[a]) { if (thisAtom.CoordinateCongruent(that.openRegions[a])) { marked[a] = true; foundAtom = true; break; } } } if (!foundAtom) return false; } return true; }
// // 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) { BinarySynthOperation binarySynth = that as BinarySynthOperation; if (binarySynth == null) return false; // The outer shapes must be congruent. if (!this.leftProblem.IsSymmetricTo(binarySynth.leftProblem)) return false; // The outer shapes must be congruent. if (!this.rightProblem.IsSymmetricTo(binarySynth.rightProblem)) return false; // The atomic regions have to match 1-1 and onto. return base.IsSymmetricTo(that); }
// // Append subtraction to this current problem; the subtraction occurs within the inner figure (shape). // public static FigSynthProblem AppendFigureSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) return null; if (that is SubtractionSynth) { // Verify that the outer part of toAppend is a figure in this problem. Figure theShape = (binaryAppend.leftProblem as UnarySynth).figure; FigSynthProblem leftShapeProblem = that.GetSynthByShape(theShape); if (leftShapeProblem == null) { throw new ArgumentException("Shape is not in the given problem: " + theShape); } // // Create the new subtraction node and insert it into the copy. // // Since the 'left' expression was a shape, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(leftShapeProblem, binaryAppend.rightProblem); return that.Copy().ReplaceUnary(theShape, newSub); } else if (that is AdditionSynth) { // Verify that the external form of that matches with the LHS of toAppend. Polygon outerPoly = Polygon.MakePolygon(that.GetExteriorSegments()); if (!outerPoly.StructurallyEquals((binaryAppend.leftProblem as UnarySynth).figure)) { throw new ArgumentException("Exterior polygons do not match: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Make a copy of that. return new SubtractionSynth(that.Copy(), (binaryAppend.rightProblem as UnarySynth).figure); } else throw new ArgumentException("Expected Addition or Subtraction; acquired neither."); }
// // 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) { UnarySynth unarySynth = that as UnarySynth; if (unarySynth == null) return false; // The outer shapes must be congruent. return this.figure.CoordinateCongruent(unarySynth.figure); // The atomic regions have to match 1-1 and onto. // return base.IsSymmetricTo(that); }
// // Append subtraction to this current problem; the subtraction occurs within one of the open atomic regions. // public static FigSynthProblem AppendAtomicSubtraction(FigSynthProblem that, FigSynthProblem toAppend) { BinarySynthOperation binaryAppend = toAppend as BinarySynthOperation; if (binaryAppend == null) return null; // Verify that the outer part of toAppend is an open atomic region. if (!that.openRegions.Contains(new ShapeAtomicRegion((binaryAppend.leftProblem as UnarySynth).figure))) { throw new ArgumentException("Shape is not an open atomic region: " + (binaryAppend.leftProblem as UnarySynth).figure); } // Since the 'left' expression was an open region, the 'right' is the actual shape we are appending. SubtractionSynth newSub = new SubtractionSynth(that.Copy(), binaryAppend.rightProblem); // Update the open regions to the inner-most shape. newSub.SetOpenRegions(toAppend.openRegions); return newSub; }
public BinarySynthOperation(FigSynthProblem ell, FigSynthProblem r) { leftProblem = ell; rightProblem = r; }
// // 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 SubtractionSynth(FigSynthProblem ell, Figure r) : base(ell, r) { }
// // Perform subtraction with a synthesized problem. // private static List<FigSynthProblem> Subtract(FigSynthProblem synth, ShapeType shapeType) { List<AtomicRegion> openAtoms = synth.GetOpenRegions(); // // Perform subtraction with all open regions with the new shape. // List<FigSynthProblem> newSubs = new List<FigSynthProblem>(); foreach (AtomicRegion atom in openAtoms) { ShapeAtomicRegion shapeAtom = atom as ShapeAtomicRegion; if (shapeAtom != null) { newSubs.AddRange(SubtractShape(shapeAtom.shape, shapeType)); } } // // Combine the existent problem with the newly subtracted region. // List<FigSynthProblem> newSynths = new List<FigSynthProblem>(); foreach (FigSynthProblem newSub in newSubs) { // Makes a copy out of the outer problem and appends the subtraction operation. newSynths.Add(FigSynthProblem.AppendAtomicSubtraction(synth, newSub)); } // // Eliminate symmetric problems. // return FigSynthProblem.RemoveSymmetric(newSynths); }
public AdditionSynth(FigSynthProblem ell, Figure r) : base(ell, r) { }
public override FigSynthProblem ReplaceUnary(Figure that, FigSynthProblem toSub) { leftProblem = leftProblem.ReplaceUnary(that, toSub); rightProblem = rightProblem.ReplaceUnary(that, toSub); return this; }
public SubtractionSynth(FigSynthProblem ell, Figure r) : base(ell, r) { }
public BinarySynthOperation(Figure ell, Figure r) { leftProblem = new UnarySynth(ell); rightProblem = new UnarySynth(r); }
public BinarySynthOperation(FigSynthProblem ell, Figure r) { leftProblem = ell; rightProblem = new UnarySynth(r); }
public BinarySynthOperation(FigSynthProblem ell, Figure r) { leftProblem = ell; rightProblem = new UnarySynth(r); }
public AdditionSynth(FigSynthProblem ell, Figure r) : base(ell, r) { }