Ejemplo n.º 1
0
            protected Vector2D GetVector(string s, bool autoAdd)
            {
                WktNumList nums = new WktNumList(s);

                if (nums.numbers.Count >= 2)
                {
                    Vector2D v = new Vector2D(nums.numbers[0], nums.numbers[1]);
                    v /= reader.scaleDivider;
                    if (reader.flipYAxis)
                    {
                        v.y = -v.y;
                    }
                    if (nums.label != "")
                    {
                        PrimitiveRenderData.Get(v).Text = nums.label;
                    }
                    v = image.IncermentVec(v);
                    if (autoAdd)
                    {
                        image.Image.Image.Add(v);
                    }
                    return(v);
                }
                return(null);
            }
Ejemplo n.º 2
0
 internal void Clear()
 {
     for (int i = 0; i < primitives.Count; i++)
     {
         PrimitiveRenderData.Get(primitives[i]).isSelected = false;
     }
     primitives.Clear();
 }
Ejemplo n.º 3
0
        public void Execute(IVectorImageProvider imageProvider)
        {
            List <Line2D> lines = Line2DFunctions.TestLineIntersections(imageProvider.CurrImage.GetPrimitives <Line2D>());

            foreach (Line2D l in lines)
            {
                PrimitiveRenderData.Get(l).Color = Colors.Line2DIntersection;
            }
        }
Ejemplo n.º 4
0
 private static void MakeShapesFromSectors(VectorImage image, Dictionary <int, List <Line2D> > sectors)
 {
     foreach (KeyValuePair <int, List <Line2D> > lines in sectors)
     {
         Shape2D shape = Shape2DFunctions.CreateShapesFromLines(lines.Value);
         PrimitiveRenderData.Get(shape).Text = "Sector: " + lines.Key;
         image.Add(shape);
     }
 }
Ejemplo n.º 5
0
        internal void RemoveFromImage(VectorImage img)
        {
            for (int i = 0; i < primitives.Count; i++)
            {
                PrimitiveRenderData.Get(primitives[i]).isSelected = false;
                img.primitives.Remove(primitives[i]);
            }

            primitives.Clear();
        }
Ejemplo n.º 6
0
        internal void TogglePrimitive(Primitive2D p)
        {
            int idx = primitives.IndexOf(p);

            if (idx != -1)
            {
                PrimitiveRenderData.Get(primitives[idx]).isSelected = false;
                primitives.RemoveAt(idx);
            }
            else
            {
                Add(p);
            }
        }
Ejemplo n.º 7
0
        public void Execute(IVectorImageProvider imageProvider)
        {
            bool          hasIntersections = false;
            VectorCloud2D cloud            = new VectorCloud2D(imageProvider.CurrImage.GetPrimitives <Vector2D>());

            for (int i = 0; i < cloud.Count - 2; i++)
            {
                Vector2D v1 = cloud[i];
                Vector2D v2 = cloud[i + 1];
                Vector2D v3 = cloud[i + 2];

                int countEqual = 0;
                if (v1.IsPositionEqual(v2))
                {
                    countEqual++;
                }
                if (v1.IsPositionEqual(v3))
                {
                    countEqual++;
                }
                if (v2.IsPositionEqual(v3))
                {
                    countEqual++;
                }
                bool isJumpLine = countEqual > 0;
                if (isJumpLine)
                {
                    imageProvider.CurrImage.Add(new Line2D(v1, v2));
                    imageProvider.CurrImage.Add(new Line2D(v2, v3));
                    imageProvider.CurrImage.Add(new Line2D(v3, v1));
                }
                else
                {
                    Triangle2D t = new Triangle2D(v1, v2, v3);
                    if (CheckTriangleListIntersection(imageProvider.CurrImage, t))
                    {
                        hasIntersections = true;
                        PrimitiveRenderData.Get(t).Color   = Color.Lime;
                        PrimitiveRenderData.Get(t.a).Color = Color.Lime;
                        PrimitiveRenderData.Get(t.b).Color = Color.Lime;
                        PrimitiveRenderData.Get(t.c).Color = Color.Lime;
                    }
                    imageProvider.CurrImage.Add(t);
                }
            }
            if (hasIntersections)
            {
                MessageBox.Show("Has intersections!!!!!!");
            }
        }
Ejemplo n.º 8
0
        private bool CheckTriangleListIntersection(VectorImage image, Triangle2D triangle)
        {
            bool isIntersecting       = false;
            List <Triangle2D> triList = image.GetPrimitives <Triangle2D>();

            foreach (Triangle2D t in triList)
            {
                if (t.Intersects(triangle))
                {
                    isIntersecting = true;
                    PrimitiveRenderData.Get(t).Color   = Color.Lime;
                    PrimitiveRenderData.Get(t.a).Color = Color.Lime;
                    PrimitiveRenderData.Get(t.b).Color = Color.Lime;
                    PrimitiveRenderData.Get(t.c).Color = Color.Lime;
                }
            }
            return(isIntersecting);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 internal void Add(Primitive2D p)
 {
     PrimitiveRenderData.Get(p).isSelected = true;
     primitives.Add(p);
 }