Пример #1
0
        //See how index can be simplified with other rectangles
        public ListOperations simplifyByY(ListOperations List, int index)
        {
            for (int i = List.Count() - 1; i >= 0; i--)
            {
                if (i != index) //Wir können nicht ein Rectangle mit sich selber zusammenfassen
                {
                    if ((List[i].getCoord()[2] == List[index].getCoord()[2]) && (List[i].getCoord()[3] == List[index].getCoord()[3]))
                    {
                        if ((Math.Abs(List[i].getCoord()[0] - List[index].getCoord()[1]) == 1) || (Math.Abs(List[i].getCoord()[1] - List[index].getCoord()[0]) == 1))
                        {
                            int minY = List[i].getCoord()[2];
                            int maxY = List[i].getCoord()[3];

                            int minXList  = List[i].getCoord()[0];
                            int minXIndex = List[index].getCoord()[0];
                            int minX      = Math.Min(minXList, minXIndex);

                            int maxXList  = List[i].getCoord()[1];
                            int maxXIndex = List[index].getCoord()[1];
                            int maxX      = Math.Max(maxXList, maxXIndex);

                            Rectangle simplified = new Rectangle(minX, maxX, minY, maxY);

                            if (i > index)
                            {
                                List.RemoveAt(i);
                                List.RemoveAt(index);
                            }
                            else
                            {
                                List.RemoveAt(index);
                                List.RemoveAt(i);
                            }

                            List.Insert(Math.Max(0, List.Count()), simplified);
                            index = Math.Max(0, List.Count() - 1);
                        }
                    }
                }
            }

            return(List);
        }
Пример #2
0
 public void OrRectRegion(Rectangle newRectangle)
 {
     //1) Prüfe auf Kollisionen mit bisherigen Rectangles
     for (int c = In.Count() - 1; c >= 0; c--)
     {
         if (Rectangle.subset(In[c], newRectangle))
         {
             In.RemoveAt(c);
         }
     }
     this.CutOrIn(In, newRectangle, true);
     this.region.RegionRect(In);
 }
Пример #3
0
        //returns \cup_{rectangle in list}(rectanlge \cap intersect)
        public static ListOperations regionListIntersect(ListOperations rectList, Rectangle intersect)
        {
            ListOperations result = new ListOperations();

            foreach (Rectangle item in rectList)
            {
                result.Add(Rectangle.intersection(item, intersect));
                if (result[result.Count() - 1].getInvalid())
                {
                    result.RemoveAt(result.Count() - 1);
                }
            }
            return(result);
        }