Ejemplo n.º 1
0
        public override GAShape Duplicate(GARepresentation newowner)
        {
            GAShapeFilledPolygon newgap = new GAShapeFilledPolygon(newowner);

            newgap.ShapeColour = this.ShapeColour;

            foreach (PointF p in PolyPoints)
            {
                newgap.PolyPoints.Add(new PointF(p.X, p.Y));
            }
            return(newgap);
        }
Ejemplo n.º 2
0
        public static GAShape CreateRandom(ThreadSafeRandom rd, GAProjectProperties prop, GARepresentation owner)
        {
            List <GAShapeType> lt = new List <GAShapeType>();

            if (prop.UsePoints)
            {
                lt.Add(GAShapeType.Circle);
            }
            if (prop.UseLines)
            {
                lt.Add(GAShapeType.Line);
            }
            if (prop.UseCurves)
            {
                lt.Add(GAShapeType.Curve);
            }
            if (prop.UseFilledPolygons)
            {
                lt.Add(GAShapeType.FilledPolygon);
            }
            if (prop.UseFilledPolycurves)
            {
                lt.Add(GAShapeType.FilledPolycurve);
            }
            //if (prop.UsePaths) lt.Add(GAShapeType.Path);

            if (lt.Count == 0)
            {
                throw new Exception("GASHape.CreateRandom - No Shapes Allowed");
            }

            GAShape output = null;

            switch (lt[rd.Next(lt.Count)])
            {
            case GAShapeType.Circle:
                output = new GAShapeCircle(owner);
                break;

            case GAShapeType.Line:
                output = new GAShapeLine(owner);
                break;

            case GAShapeType.Curve:
                output = new GAShapeCurve(owner);
                break;

            case GAShapeType.FilledPolygon:
                output = new GAShapeFilledPolygon(owner);
                break;

            case GAShapeType.FilledPolycurve:
                output = new GAShapeFilledPolycurve(owner);
                break;

            case GAShapeType.Path:
                output = new GAShapePath(owner);
                break;
            }

            output.Randomize(rd, prop);
            return(output);
        }