//
        // Acquire the set of atomic regions and OMIT the region given by the inner shape.
        //
        public static List<AtomicRegion> AcquireOpenAtomicRegions(List<Connection> connections, List<Point> innerShapePoints, Figure innerShape)
        {
            List<AtomicRegion> atoms = ConstructAtomicRegions(connections, innerShapePoints, innerShape);

            int foundIndex = -1;
            for (int a = 0; a < atoms.Count; a++)
            {
                ShapeAtomicRegion shapeAtom = atoms[a] as ShapeAtomicRegion;
                if (shapeAtom != null)
                {
                    Polygon shapeAtomPoly = shapeAtom.shape as Polygon;
                    Polygon innerShapePoly = innerShape as Polygon;
                    if (shapeAtomPoly != null && innerShapePoly != null)
                    {
                        if (shapeAtomPoly.HasSamePoints(innerShapePoly)) foundIndex = a;
                    }
                    else if (shapeAtom.shape.StructurallyEquals(innerShape))
                    {
                        foundIndex = a;
                    }
                }
            }

            if (foundIndex == -1)
            {
                throw new Exception("Expected to find the original shape " + innerShape.ToString() + " as atomic region; did not.");
            }

            atoms.RemoveAt(foundIndex);

            return atoms;
        }
Esempio n. 2
0
        public override bool CoordinateCongruent(Figure that)
        {
            Sector thatSector = that as Sector;
            if (thatSector == null) return false;

            return this.theArc.CoordinateCongruent(thatSector.theArc);
        }
Esempio n. 3
0
 public Connection(Point e1, Point e2, ConnectionType t, Figure so)
 {
     endpoint1 = e1;
     endpoint2 = e2;
     type = t;
     segmentOrArc = so;
 }
Esempio n. 4
0
        public static new 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);
        }
Esempio n. 5
0
        // Add a shape to the list which contains this region.
        public virtual void AddOwner(Figure f)
        {
            if (!Utilities.AddStructurallyUnique<Figure>(owners, f)) return;

            // Check if this new atomic region is the outermost owner.
            if (topOwner == null || f.Contains(topOwner)) topOwner = f;
        }
Esempio n. 6
0
        public override bool CoordinateCongruent(Figure that)
        {
            Semicircle thatSemi = that as Semicircle;
            if (thatSemi == null) return false;

            return theCircle.CoordinateCongruent(thatSemi.theCircle);
        }
Esempio n. 7
0
        public static new 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);
        }
Esempio n. 8
0
        //
        // Append parallelograms to appropriate segments.
        //
        public static new 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);
        }
Esempio n. 9
0
        public static new 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);
        }
Esempio n. 10
0
        //
        // Outer minus circle; the circle will only be situation if it touches all sides of the outer figure.
        //
        public static List<FigSynthProblem> SubtractShape(Figure outerShape, List<Connection> conns, List<Point> points)
        {
            List<FigSynthProblem> composed = new List<FigSynthProblem>();
            List<Midpoint> midpoints = outerShape.GetMidpointClauses();

            if (midpoints.Count < 3) return composed;

            //
            // Construct the circle based on the first 3 points.
            //
            Circle circ = Circle.ConstructCircle(midpoints[0].point, midpoints[1].point, midpoints[2].point);

            //
            // Verify that the remaining points lie on the circle.
            //
            for (int p = 4; p < midpoints.Count; p++)
            {
                if (!circ.PointLiesOn(midpoints[p].point)) return composed;
            }

            SubtractionSynth subSynth = new SubtractionSynth(outerShape, circ);

            composed.Add(subSynth);

            return composed;
        }
Esempio n. 11
0
        public static new 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);
        }
Esempio n. 12
0
        public static new 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);
        }
Esempio n. 13
0
        public static new 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 rhombi that don't match the outer shape.
                if (quad.VerifyRhombus() && !quad.HasSamePoints(outerShape as Polygon))
                {
                    Rhombus rhombus = new Rhombus(quad);

                    SubtractionSynth subSynth = new SubtractionSynth(outerShape, rhombus);

                    try
                    {
                        subSynth.SetOpenRegions(FigSynthProblem.AcquireOpenAtomicRegions(conns, rhombus.points, rhombus));
                        composed.Add(subSynth);
                    }
                    catch (Exception) { }

                }
            }

            return FigSynthProblem.RemoveSymmetric(composed);
        }
Esempio n. 14
0
        //
        // A shape within this shape?
        //
        public override bool Contains(Figure that)
        {
            if (that is Circle) return ContainsCircle(that as Circle);
            if (that is Polygon) return ContainsPolygon(that as Polygon);
            if (that is Sector) return ContainsSector(that as Sector);

            return false;
        }
Esempio n. 15
0
        public override bool CoordinateCongruent(Figure that)
        {
            MajorArc thatArc = that as MajorArc;
            if (thatArc == null) return false;

            if (!theCircle.CoordinateCongruent(thatArc.theCircle)) return false;

            return Utilities.CompareValues(this.GetMajorArcMeasureDegrees(), thatArc.GetMajorArcMeasureDegrees());
        }
Esempio n. 16
0
 public AtomicRegion()
 {
     ordered = false;
     connections = new List<Connection>();
     owners = new List<Figure>();
     topOwner = null;
     knownAtomic = false;
     polygonalized = null;
     thisArea = -1;
 }
        //
        // All innerShape connections are among the points that lie on the set of given connections.
        // Determine which of this innerShape endpoints lie between the 'outer' set of connections.
        //
        public static List<AtomicRegion> ConstructAtomicRegions(List<Connection> connections, List<Point> innerShapePoints, Figure innerShape)
        {
            List<Point> points;
            List<Segment> segments;
            List<Arc> arcs;
            List<Circle> circles;

            CollectConstituentElements(connections, innerShapePoints, innerShape, out points, out segments, out arcs, out circles);

            // Acquire circle granularity for atomic region finding.
            Dictionary<Circle, int> circGranularity = Circle.AcquireCircleGranularity(circles);

            // Extract the atomic regions.
            return GeometryTutorLib.AtomicRegionIdentifier.AtomicIdentifierMain.AcquireAtomicRegionsFromGraph(points, segments, arcs, circles, circGranularity);
        }
Esempio n. 18
0
        //
        // With appending in this case, we choose the given segment to be the base.
        //
        public static new 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);
        }
Esempio n. 19
0
        public static new 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);
        }
Esempio n. 20
0
        public static new 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);
        }
Esempio n. 21
0
        //
        // With appending in this case, we choose the given segment to be the base.
        //
        public static new 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);
        }
Esempio n. 22
0
 public static new List<FigSynthProblem> AppendShape(Figure outerShape, List<Segment> segments)
 {
     throw new NotImplementedException();
 }
Esempio n. 23
0
 public static new List<FigSynthProblem> SubtractShape(Figure outerShape, List<Connection> conns, List<Point> points)
 {
     throw new NotImplementedException();
 }
Esempio n. 24
0
 //
 // A shape within this shape?
 //
 public virtual bool Contains(Figure that)
 {
     return thisAtomicRegion.Contains(that.GetFigureAsAtomicRegion());
 }
Esempio n. 25
0
 public void AddSuperFigure(Figure f)
 {
     if (!Utilities.HasStructurally<Figure>(superFigures, f)) superFigures.Add(f);
 }
        public List<AtomicRegion> GetAtomicRegionsByFigure(Figure fig)
        {
            List<AtomicRegion> atoms = new List<AtomicRegion>();

            foreach (AtomicRegion atom in atomicRegions)
            {
                ShapeAtomicRegion shapeAtom = atom as ShapeAtomicRegion;
                if (shapeAtom != null)
                {
                    if (fig.Contains(shapeAtom.shape)) atoms.Add(atom);
                }
                else
                {
                    if (fig.Contains(this.allFigurePoints, atom)) atoms.Add(atom);
                }
            }

            return atoms;
        }
        private List<int> GetAtomicRegionIndicesByFigure(Figure fig)
        {
            List<int> atomIndices = new List<int>();

            for (int a = 0; a < atomicRegions.Count; a++)
            {
                ShapeAtomicRegion shapeAtom = atomicRegions[a] as ShapeAtomicRegion;
                if (shapeAtom != null)
                {
                    if (fig.Contains(shapeAtom.shape)) atomIndices.Add(a);
                }
                else
                {
                    if (fig.Contains(this.allFigurePoints, atomicRegions[a])) atomIndices.Add(a);
                }
            }

            return atomIndices;
        }
Esempio n. 28
0
 public static List <FigSynthProblem> SubtractShape(Figure outerShape, List <Connection> conns, List <Point> points)
 {
     throw new NotImplementedException();
 }
Esempio n. 29
0
        public override bool CoordinateCongruent(Figure that)
        {
            Circle thatCirc = that as Circle;
            if (thatCirc == null) return false;

            return Utilities.CompareValues(this.radius, thatCirc.radius);
        }
Esempio n. 30
0
        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));
        }
Esempio n. 31
0
 //
 // A shape within this shape?
 //
 public virtual bool Contains(Figure that)
 {
     return thisAtomicRegion.Contains(that.GetFigureAsAtomicRegion());
 }
Esempio n. 32
0
 public FigureNode(Figure f)
 {
 }
Esempio n. 33
0
 public void AddSubFigure(Figure f) { if (!Utilities.HasStructurally<Figure>(subFigures, f)) subFigures.Add(f); }
Esempio n. 34
0
        //
        // 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));
        }
Esempio n. 35
0
        public static Circle ConstructDefaultCircle()
        {
            int radius = Figure.DefaultSideLength() / 2;

            return(new Circle(origin, radius));
        }
Esempio n. 36
0
 public static List <FigSynthProblem> AppendShape(Figure outerShape, List <Segment> segments)
 {
     throw new NotImplementedException();
 }
Esempio n. 37
0
 public void AddConnection(Point e1, Point e2, ConnectionType t, Figure owner)
 {
     connections.Add(new Connection(e1, e2, t, owner));
 }