Пример #1
0
        public Sector(Arc a)
        {
            theArc = a;
            radius1 = new Segment(theArc.theCircle.center, theArc.endpoint1);
            radius2 = new Segment(theArc.theCircle.center, theArc.endpoint2);

            thisAtomicRegion = new ShapeAtomicRegion(this);
        }
Пример #2
0
        protected Polygon(List<Segment> segs, List<Point> pts, List<Angle> angs)
        {
            orderedSides = segs;
            points = pts;
            angles = angs;

            thisAtomicRegion = new ShapeAtomicRegion(this);

            this.FigureSynthesizerConstructor();
        }
Пример #3
0
        public override bool Equals(Object obj)
        {
            ShapeAtomicRegion thatAtom = obj as ShapeAtomicRegion;

            if (thatAtom == null)
            {
                return(false);
            }

            return(shape.StructurallyEquals(thatAtom.shape) && base.Equals(obj));
        }
Пример #4
0
        public override bool Contains(AtomicRegion that)
        {
            ShapeAtomicRegion thatAtom = that as ShapeAtomicRegion;

            if (thatAtom != null)
            {
                return(this.shape.Contains(thatAtom.shape));
            }
            else
            {
                return(base.Contains(that));
            }
        }
Пример #5
0
        public Polygon(Segment s1, Segment s2, Segment s3)
        {
            orderedSides = new List<Segment>();
            orderedSides.Add(s1);
            orderedSides.Add(s2);
            orderedSides.Add(s3);

            KeyValuePair<List<Point>, List<Angle>> pair = MakePointsAngle(orderedSides);

            points = pair.Key;
            angles = pair.Value;

            thisAtomicRegion = new ShapeAtomicRegion(this);

            this.FigureSynthesizerConstructor();
        }
Пример #6
0
        public Semicircle(Circle circle, Point e1, Point e2, Point m, List<Point> minorPts, List<Point> majorPts, Segment d)
            : base(circle, e1, e2, minorPts, majorPts)
        {
            diameter = d;
            middlePoint = m;

            if (!circle.DefinesDiameter(diameter))
            {
                System.Diagnostics.Debug.WriteLine("Semicircle constructed without a diameter");
            }

            if (!circle.DefinesDiameter(new Segment(e1, e2)))
            {
                System.Diagnostics.Debug.WriteLine("Semicircle constructed without a diameter");
            }

            thisAtomicRegion = new ShapeAtomicRegion(this);
        }
Пример #7
0
    // Construct the region between a chord and the circle arc:
    //    (|
    //   ( |
    //  (  |
    //   ( |
    //    (|
    //
    private List <AtomicRegion> ConstructBasicLineCircleRegion(Segment chord, Circle circle)
    {
        //
        // Standard
        //
        if (!circle.DefinesDiameter(chord))
        {
            AtomicRegion region = new AtomicRegion();

            Arc theArc = new MinorArc(circle, chord.Point1, chord.Point2);

            region.AddConnection(chord.Point1, chord.Point2, ConnectionType.ARC, theArc);

            region.AddConnection(chord.Point1, chord.Point2, ConnectionType.SEGMENT, chord);

            return(Utilities.MakeList <AtomicRegion>(region));
        }

        //
        // Semi-circles
        //

        Point             midpt   = circle.Midpoint(chord.Point1, chord.Point2);
        Arc               semi1   = new Semicircle(circle, chord.Point1, chord.Point2, midpt, chord);
        ShapeAtomicRegion region1 = new ShapeAtomicRegion(new Sector(semi1));

        Point             opp     = circle.OppositePoint(midpt);
        Arc               semi2   = new Semicircle(circle, chord.Point1, chord.Point2, opp, chord);
        ShapeAtomicRegion region2 = new ShapeAtomicRegion(new Sector(semi2));

        List <AtomicRegion> regions = new List <AtomicRegion>();

        regions.Add(region1);
        regions.Add(region2);

        return(regions);
    }
Пример #8
0
        /// <summary>
        /// Create a new ConcreteSegment. 
        /// </summary>
        /// <param name="p1">A point defining the segment.</param>
        /// <param name="p2">Another point defining the segment.</param>
        public Circle(Point center, double r)
            : base()
        {
            this.center = center;
            radius = r;

            secants = new Dictionary<Segment, Segment>();
            chords = new List<Segment>();
            radii = new List<Segment>();
            diameters = new List<Segment>();
            tangents = new Dictionary<Segment, Segment>();

            inscribedPolys = new List<Polygon>[Polygon.MAX_EXC_POLY_INDEX];
            circumPolys = new List<Polygon>[Polygon.MAX_EXC_POLY_INDEX];
            for (int n = Polygon.MIN_POLY_INDEX; n < Polygon.MAX_EXC_POLY_INDEX; n++)
            {
                inscribedPolys[n] = new List<Polygon>();
                circumPolys[n] = new List<Polygon>();
            }

            pointsOnCircle = new List<Point>();

            minorArcs = new List<MinorArc>();
            majorArcs = new List<MajorArc>();
            minorSectors = new List<Sector>();
            majorSectors = new List<Sector>();

            approxPoints = new List<Point>();
            approxSegments = new List<Segment>();

            Utilities.AddUniqueStructurally(this.center.getSuperFigures(), this);

            thisAtomicRegion = new ShapeAtomicRegion(this);

            this.FigureSynthesizerConstructor();
        }
Пример #9
0
 public ShapeAtomicRegion GetFigureAsAtomicRegion()
 {
     if (thisAtomicRegion == null) thisAtomicRegion = new ShapeAtomicRegion(this);
     return thisAtomicRegion;
 }
Пример #10
0
        public static List<AtomicRegion> GetAtomicRegions(List<Point> figurePoints,
                                                          List<Circle> circles,
                                                          List<Polygon>[] polygons)
        {
            List<AtomicRegion> originalAtoms = new List<AtomicRegion>();
            Dictionary<Circle, int> circGranularity = new Dictionary<Circle, int>();

            //
            // Convert all circles to atomic regions identifying their chord / radii substructure.
            //
            if (circles.Any())
            {
                // Construct the granularity for when we construct arcs.
                circles = new List<Circle>(circles.OrderBy(c => c.radius));
                double currRadius = circles[0].radius;
                int gran = 1;

                foreach (Circle circle in circles)
                {
                    List<AtomicRegion> circleAtoms = circle.Atomize(figurePoints);

                    // Make this circle the owner of the atomic regions.
                    foreach (AtomicRegion atom in circleAtoms)
                    {
                        atom.AddOwner(circle);
                        circle.AddAtomicRegion(atom);
                    }
                    originalAtoms.AddRange(circleAtoms);

                    //
                    // Granularity
                    //
                    if (circle.radius > currRadius) gran++;
                    circGranularity[circle] = gran;
                }
            }

            //
            // Make all of the polygons an atomic region.
            // Also, convert any concave polygon into atoms by extending sides inward.
            //
            for (int n = Polygon.MIN_POLY_INDEX; n < Polygon.MAX_EXC_POLY_INDEX; n++)
            {
                foreach (Polygon poly in polygons[n])
                {
                    // Handle any concave polygons.
                    ConcavePolygon concave = poly as ConcavePolygon;
                    if (concave != null)
                    {
                        List<AtomicRegion> concaveAtoms = concave.Atomize(figurePoints);
                        originalAtoms.AddRange(concaveAtoms);
                        poly.AddAtomicRegions(concaveAtoms);
                    }

                    // Basic polygon: make it a shape atomic region.
                    else
                    {
                        ShapeAtomicRegion shapeAtom = new ShapeAtomicRegion(poly);
                        shapeAtom.AddOwner(poly);
                        originalAtoms.Add(shapeAtom);
                    }
                }
            }

            //
            // Since circles and Concave Polygons were atomized, there may be duplicate atomic regions.
            //
            originalAtoms = RemoveDuplicates(originalAtoms);
            List<AtomicRegion> workingAtoms = new List<AtomicRegion>(originalAtoms);

            //
            // Combine all of the atomic regions together.
            //
            List<AtomicRegion> composed = ComposeAllRegions(figurePoints, workingAtoms, circGranularity);
            composed = RemoveContained(composed);

            //
            // Run the graph-based algorithm one last time to identify any pathological regions (exterior to all shapes).
            //
            // Identify those pathological regions as well as any lost (major arcs).
            //
            List<AtomicRegion> lost = new List<AtomicRegion>();
            List<AtomicRegion> pathological = new List<AtomicRegion>();
            List<AtomicRegion> pathologicalID = IdentifyPathological(figurePoints, composed, circles, circGranularity);
            pathologicalID = RemoveRedundantSemicircle(pathologicalID);
            foreach (AtomicRegion atom in composed)
            {
                if (!pathologicalID.Contains(atom))
                {
                    bool containment = false;
                    foreach (AtomicRegion pathAtom in pathologicalID)
                    {
                        if (atom.Contains(pathAtom))
                        {
                            containment = true;
                            break;
                        }
                    }
                    if (!containment) lost.Add(atom);
                }
            }

            foreach (AtomicRegion atom in pathologicalID)
            {
                if (!composed.Contains(atom)) pathological.Add(atom);
            }

            List<AtomicRegion> finalAtomSet = new List<AtomicRegion>();
            finalAtomSet.AddRange(composed);
            finalAtomSet.AddRange(pathological);

            return finalAtomSet;
        }
Пример #11
0
        // Construct the region between a chord and the circle arc:
        //    (|
        //   ( |
        //  (  |
        //   ( |
        //    (|
        //
        private List<AtomicRegion> ConstructBasicLineCircleRegion(Segment chord, Circle circle)
        {
            //
            // Standard
            //
            if (!circle.DefinesDiameter(chord))
            {
                AtomicRegion region = new AtomicRegion();

                Arc theArc = new MinorArc(circle, chord.Point1, chord.Point2);

                region.AddConnection(chord.Point1, chord.Point2, ConnectionType.ARC, theArc);

                region.AddConnection(chord.Point1, chord.Point2, ConnectionType.SEGMENT, chord);

                return Utilities.MakeList<AtomicRegion>(region);
            }

            //
            // Semi-circles
            //

            Point midpt = circle.Midpoint(chord.Point1, chord.Point2);
            Arc semi1 = new Semicircle(circle, chord.Point1, chord.Point2, midpt, chord);
            ShapeAtomicRegion region1 = new ShapeAtomicRegion(new Sector(semi1));

            Point opp = circle.OppositePoint(midpt);
            Arc semi2 = new Semicircle(circle, chord.Point1, chord.Point2, opp, chord);
            ShapeAtomicRegion region2 = new ShapeAtomicRegion(new Sector(semi2));

            List<AtomicRegion> regions = new List<AtomicRegion>();
            regions.Add(region1);
            regions.Add(region2);

            return regions;
        }