Пример #1
0
 /// <summary>
 /// получение количкство точек на декартовой поверхности от двух пространственных 
 /// </summary>
 /// <param name="grafDecart"></param>
 /// <returns></returns>
 public int getCountPoint(Nodes grafDecart)
 {
     int count = getGrafDecart().count();
     for (int y = 0; y < grafDecart.getSizeDecartGrafMatrixY(); y++)
     {
         for (int x = 0; x < grafDecart.getSizeDecartGrafMatrixX(); x++)
         {
             if (grafDecart.getElementDecartGraf(x, y) > 0)
             {
                 if (this.grafDecart.getSizeDecartGrafMatrixX() <= grafDecart.getSizeDecartGrafMatrixX() &&
                     this.grafDecart.getSizeDecartGrafMatrixY() <= grafDecart.getSizeDecartGrafMatrixY())
                 {
                     if (this.grafDecart.getElementDecartGraf(x, y) == 0)
                     {
                         count++;
                     }
                 }
             }
         }
     }
     return count;
 }
Пример #2
0
        //операция объединения
        public static Graph operator +(Graph graf1, Graph graf2)
        {
            Graph graf = graf1.getSize() > graf2.getSize()
                            ? new Graph(graf1.getCountPoint(graf2.getGrafDecart()))
                            : new Graph(graf2.getCountPoint(graf1.getGrafDecart()));

            //заполняю координаты в пространстве
            int grafDecartX = graf1.getGrafDecart().getSizeDecartGrafMatrixX() >
                              graf2.getGrafDecart().getSizeDecartGrafMatrixX()
                                  ? graf1.getGrafDecart().getSizeDecartGrafMatrixX()
                                  : graf2.getGrafDecart().getSizeDecartGrafMatrixX();
            int grafDecartY = graf1.getGrafDecart().getSizeDecartGrafMatrixY() >
                              graf2.getGrafDecart().getSizeDecartGrafMatrixY()
                                  ? graf1.getGrafDecart().getSizeDecartGrafMatrixY()
                                  : graf2.getGrafDecart().getSizeDecartGrafMatrixY();

            Nodes grafDecart = new Nodes(grafDecartX, grafDecartY, false);
            for (int y = 0; y < graf2.getGrafDecart().getSizeDecartGrafMatrixY(); y++)
            {
                for (int x = 0; x < graf2.getGrafDecart().getSizeDecartGrafMatrixX(); x++)
                {
                    grafDecart.setGrafMatrixDecart(x, y, graf2.getGrafDecart().getElementDecartGraf(x, y));
                }
            }

            for (int y = 0; y < graf1.getGrafDecart().getSizeDecartGrafMatrixY(); y++)
            {
                for (int x = 0; x < graf1.getGrafDecart().getSizeDecartGrafMatrixX(); x++)
                {
                    if (grafDecart.getElementDecartGraf(x, y) == 0)
                    {
                        grafDecart.setGrafMatrixDecart(x, y,
                                                       graf1.getGrafDecart().getElementDecartGraf(x, y) > 0
                                                           ? grafDecart.findLastDot() + 1
                                                           : 0);
                    }

                }
            }
            graf.setGrafDecart(grafDecart);

            //заполняю грани в пространстве
            for (int y = 0; y < graf2.getSize(); y++)
            {
                for (int x = 0; x < graf2.getSize(); x++)
                {
                    if (graf2.getCoordinates(x, y))
                    {
                        graf.setCoordinates(x, y, true);
                    }
                }
            }

            for (int y = 0; y < graf1.getGraf().Count; y++)
            {
                for (int x = 0; x < graf1.getGraf().Count; x++)
                {
                    if (graf1.getCoordinates(x, y))
                    {
                        graf.setCoordinates(
                            graf.getGrafDecart().getElementDecartGraf(
                                graf1.getCoordinatePoint(x).getStartCoordinate().getX(),
                                graf1.getCoordinatePoint(x).getStartCoordinate().getY()) - 1,
                            graf.getGrafDecart().getElementDecartGraf(
                                graf1.getCoordinatePoint(y).getStartCoordinate().getX(),
                                graf1.getCoordinatePoint(y).getStartCoordinate().getY()) - 1, true);

                    }
                }
            }

            return graf;
        }