Пример #1
0
        //
        // 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));
        }
Пример #2
0
        //
        // Perform a - (b - c) =
        //                         1. a - b
        //                         2. b - c
        //
        private static List <FigSynthProblem> ConstructGroupedSubtraction(List <ShapeType> shapes)
        {
            //
            // Construct  a - b
            //
            Figure defaultLargeFigure      = Figure.ConstructDefaultShape(shapes[0]);
            List <FigSynthProblem> aMinusB = SubtractShape(defaultLargeFigure, shapes[1]);

            //
            // For each of the aMinusB problems, the outer bounds is defined by a shape; subtract the new shape.
            //
            List <FigSynthProblem> newSynths = new List <FigSynthProblem>();

            foreach (FigSynthProblem top in aMinusB)
            {
                List <FigSynthProblem> bMinusC = SubtractShape(((top as BinarySynthOperation).rightProblem as UnarySynth).figure, shapes[2]);

                foreach (FigSynthProblem bc in bMinusC)
                {
                    newSynths.Add(FigSynthProblem.AppendFigureSubtraction(top, bc));
                }
            }

            return(newSynths);
        }
Пример #3
0
        //
        // (a + b) - c
        //
        //  First append, then subtract from the entire shape.
        //
        private static List <FigSynthProblem> ConstructAppendThenSubtract(List <ShapeType> shapes)
        {
            //
            // Construct  a + b
            //
            Figure defaultLargeFigure     = Figure.ConstructDefaultShape(shapes[0]);
            List <FigSynthProblem> aPlusB = AddShape(defaultLargeFigure, shapes[1]);

            //
            // For each of the aPlusB problems, the outer bounds is defined by the exterior segments / set of points.
            //
            List <FigSynthProblem> newSynths = new List <FigSynthProblem>();

            foreach (FigSynthProblem top in aPlusB)
            {
                Polygon outerPoly = Polygon.MakePolygon(top.GetExteriorSegments());
                List <FigSynthProblem> xMinusC = SubtractShape(outerPoly, shapes[2]);

                foreach (FigSynthProblem x in xMinusC)
                {
                    newSynths.Add(FigSynthProblem.AppendFigureSubtraction(top, x));
                }
            }

            return(newSynths);
        }
Пример #4
0
        //
        // 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);
        }
        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);
        }
Пример #6
0
        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);
        }