コード例 #1
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);
        }
コード例 #2
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);
        }