Ejemplo n.º 1
0
 private void FillVectorCloud(VectorCloud2D cloud, Line2D l, Rectangle2D bb)
 {
     if (bb.IsInside(l.Start))
     {
         cloud.Add(l.Start);
     }
     if (bb.IsInside(l.End))
     {
         cloud.Add(l.End);
     }
 }
Ejemplo n.º 2
0
        public static VectorCloud2D CreateCirulairCloud(Circle2D c, int count)
        {
            VectorCloud2D pointCloud = new VectorCloud2D();
            Random        r          = new Random();

            for (int i = 0; i < count; i++)
            {
                pointCloud.Add((RandVec2D(r).Normal() * c.radius) + c.center);
            }
            pointCloud.Add(c.center);
            return(pointCloud);
        }
Ejemplo n.º 3
0
 private void FillVectorCloud(VectorCloud2D cloud, Vector2D v, Rectangle2D bb)
 {
     if (bb.IsInside(v))
     {
         cloud.Add(v);
     }
 }
Ejemplo n.º 4
0
        public static void PointInTriangleTest(VectorImage image)
        {
            Triangle2D t = new Triangle2D(new Vector2D(25, 150), new Vector2D(200, 200), new Vector2D(60, 80));

            image.Add(t);
            VectorCloud2D pc = PointCloudCreator.Create(new Rectangle2D(new Vector2D(10, 10), new Vector2D(300, 300)), 500);

            pc.Add(t.a);
            pc.Add(t.b);
            pc.Add(t.c);

            foreach (Vector2D p in pc)
            {
                p.SetData(new PrimitiveRenderData(t.IsInside(p) ? Color.DarkGreen : Color.DarkRed));
            }

            image.Add(pc);
        }
Ejemplo n.º 5
0
            protected override void Read(string s)
            {
                Vector2D v = GetVector(s, false);

                if (v != null)
                {
                    polygon.Add(v);
                }
            }
Ejemplo n.º 6
0
            protected override void Read(string s)
            {
                Vector2D v = GetVector(s, true);

                if (v != null)
                {
                    line.Add(v);
                }
            }
Ejemplo n.º 7
0
        private static VectorCloud2D CreateLinkedVectorCloud(List <Line2D> shapeLineList)
        {
            VectorCloud2D vc = new VectorCloud2D();

            for (int i = 0; i < shapeLineList.Count; i++)
            {
                vc.Add(shapeLineList[i].Start);
            }
            return(vc);
        }
Ejemplo n.º 8
0
        public VectorCloud2D ReadPointCloud(int count)
        {
            VectorCloud2D cloud = new VectorCloud2D();

            for (int i = 0; i < count; i++)
            {
                cloud.Add(ReadPoint());
            }
            return(cloud);
        }
Ejemplo n.º 9
0
        public static VectorCloud2D Create(Rectangle2D rect, int count)
        {
            VectorCloud2D pointCloud = new VectorCloud2D();
            Random        r          = new Random();

            for (int i = 0; i < count; i++)
            {
                pointCloud.Add(RandVec2D(rect, r));
            }
            return(pointCloud);
        }
Ejemplo n.º 10
0
        public static VectorCloud2D CreatSquareCloud(int rowCount, int columnCount)
        {
            VectorCloud2D pointCloud = new VectorCloud2D();
            Random        r          = new Random();

            for (int yy = 0; yy < rowCount; yy++)
            {
                for (int xx = 0; xx < columnCount; xx++)
                {
                    pointCloud.Add(new Vector2D(xx * 10, yy * 10));
                }
            }
            return(pointCloud);
        }
Ejemplo n.º 11
0
        private void ReadPoint(string s)
        {
            string[] strings = s.Split(',');
            double   x       = Single.Parse(strings [0].Trim());
            double   y       = Single.Parse(strings [1].Trim());
            Vector2D v       = new Vector2D(x, y);

            switch (readMode)
            {
            case ReadMode.Absolute:
            {
                cloud.Add(v);
            }
            break;

            case ReadMode.Relative:
            {
                incPoint.Move(v);
                cloud.Add(new Vector2D(incPoint));
            }
            break;
            }
        }
Ejemplo n.º 12
0
        internal static void BuildImage(VectorImage image, LevelReader level, double scale)
        {
            VectorCloud2D vc = new VectorCloud2D();

            for (int i = 0; i < level.vertices.Count; i++)
            {
                vc.Add(new Vector2D(level.vertices[i].x, level.vertices[i].y));
            }

            Dictionary <int, List <Line2D> > sectors = new Dictionary <int, List <Line2D> >();
            List <Line2D> lines = new List <Line2D>();

            foreach (LineDefType l in level.lineDefs)
            {
                Line2D line = new Line2D(vc[l.startVertex], vc[l.endVertex]);

                if (l.IsSecret)
                {
                    PrimitiveRenderData.Get(line).Color = Color.Yellow;
                }
                else if (l.IsTwoSided)
                {
                    PrimitiveRenderData.Get(line).Color = Color.SandyBrown;
                }
                else
                {
                    PrimitiveRenderData.Get(line).Color = Color.Red;
                }

                lines.Add(line);

                AddLineToSector(sectors, level, l.rightSideDef, line);
                AddLineToSector(sectors, level, l.leftSideDef, line);
            }

            image.primitives.AddRange(vc);
            image.primitives.AddRange(lines);

            MakeShapesFromSectors(image, sectors);
        }