Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 4
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);
        }
Esempio n. 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;
        }
Esempio n. 6
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;
        }