Example #1
0
        //
        // 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);
        }
Example #2
0
        public override FigSynthProblem Copy()
        {
            AdditionSynth copy = new AdditionSynth(this.leftProblem.Copy(), this.rightProblem.Copy());

            copy.SetOpenRegions(new List <AtomicRegion>(this.openRegions));

            return(copy);
        }
Example #3
0
        public override FigSynthProblem Copy()
        {
            AdditionSynth copy = new AdditionSynth(this.leftProblem.Copy(), this.rightProblem.Copy());

            copy.SetOpenRegions(new List<AtomicRegion>(this.openRegions));

            return copy;
        }
Example #4
0
        //
        // 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));
        }
Example #5
0
        //
        // 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);
        }
Example #6
0
        //
        // 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;
        }
Example #7
0
        //
        // 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;
        }