コード例 #1
0
ファイル: quad-tree.cpp プロジェクト: sslavian812/quadrotree
   void draw_node(Node<double> *node, cg::visualization::drawer_type & drawer) const
   {

    drawer.set_color(Qt::green);
    drawer.draw_point(node->point, 3);
	
	if(node->children[0] == NULL)
		return;

    drawer.set_color(Qt::white);

    point_2t<double> c = node->boundary.position;
    double d = node->boundary.dimension;

    point_2 p1(c.x + d, c.y+d/2);
    point_2 p2(c.x + d/2, c.y+d);
    point_2 p3(c.x, c.y+d/2);
    point_2 p4(c.x+d/2, c.y);

	drawer.draw_line(p1, p3);
	drawer.draw_line(p2, p4);

	draw_node(node->children[0], drawer);
	draw_node(node->children[1], drawer);
	draw_node(node->children[2], drawer);
	draw_node(node->children[3], drawer);
   }
コード例 #2
0
ファイル: segment_contains_point.cpp プロジェクト: free0u/cg
   void draw(cg::visualization::drawer_type & drawer) const
   {
      drawer.set_color(Qt::white);
      if (current_point_ && cg::contains(t_, *current_point_))
         drawer.set_color(Qt::red);

      drawer.draw_line(t_[0], t_[1]);
   }
コード例 #3
0
ファイル: delaunay.cpp プロジェクト: flevix/cg
    void draw(cg::visualization::drawer_type & drawer) const
    {
        for (triangle_2 tr : trs) {
            drawer.set_color(Qt::red);
            cg::visualization::draw(drawer, tr);

            drawer.set_color(Qt::yellow);
            cg::visualization::draw(drawer, tr.circumcenter(), tr.circumradius());
        }
    }
コード例 #4
0
ファイル: delaunay.cpp プロジェクト: wotopul/cg
 void draw(cg::visualization::drawer_type & drawer) const
 {
    std::for_each(answer.begin(), answer.end(),
       [&](cg::triangle_2 tr)
       {
          drawer.set_color(Qt::white);
          cg::visualization::draw(drawer, tr);
          drawer.set_color(Qt::green);
          cg::visualization::draw(drawer, tr.center(), tr.radius());
       });
 }
コード例 #5
0
   void draw(cg::visualization::drawer_type & drawer) const override
   {
      drawer.set_color(Qt::white);
      if (current_point_ && cg::contains(contour, *current_point_))
         drawer.set_color(Qt::green);

      for (size_t l = 0, lp = contour.size() - 1; l != contour.size(); lp = l++)
         drawer.draw_line(contour[lp], contour[l]);

      if (idx_)
         drawer.draw_point(contour[*idx_], 5);
   }
コード例 #6
0
ファイル: shortestPath.cpp プロジェクト: Igorjan94/cg
 void draw(cg::visualization::drawer_type & drawer) const
 {
     if (count >= 1)
         drawer.draw_point(start, 2);
     if (count == 2)
         drawer.draw_point(finish, 2);
     drawer.set_color(Qt::white);
     for (unsigned int i = 0; i < input_points.size(); i++)
         draw_vector(input_points[i].begin(), input_points[i].end(), drawer);
     draw_vector(contour.begin(), contour.end(), drawer);
     drawer.set_color(Qt::yellow);
     draw_vector(output_points.begin(), output_points.end(), drawer);
 }
コード例 #7
0
ファイル: andrew_hull.cpp プロジェクト: Susak/cg
   void draw(cg::visualization::drawer_type & drawer) const
   {
      drawer.set_color(Qt::white);
      for (point_2 const & p : pts_)
         drawer.draw_point(p);

      drawer.set_color(Qt::green);
      for (size_t lp = ch_size_ - 1, l = 0; l != ch_size_; lp = l++)
      {
         drawer.draw_point(pts_[l], 3);
         drawer.draw_line(pts_[lp], pts_[l]);
      }
   }
コード例 #8
0
   void draw(cg::visualization::drawer_type & drawer) const
   {
      drawer.set_color(Qt::white);
      if (current_point_ && cg::contains(t_, *current_point_))
         drawer.set_color(Qt::green);

      for (size_t l = 0, lp = 2; l != 3; lp = l++)
         drawer.draw_line(t_[lp], t_[l]);

	  if (idx_)
	  {
		  drawer.set_color((rbutton_pressed_)? Qt::red : Qt::yellow);
		  drawer.draw_point(t_[*idx_], 5);
	  }
   }
コード例 #9
0
ファイル: duglas_pecher.cpp プロジェクト: BigBot22/cg
   void draw(cg::visualization::drawer_type & drawer) const
   {
      if (in_building_)
      {
         drawer.set_color(Qt::white);

         for (size_t i = 1; i < points_.size(); ++i)
         {
            drawer.draw_line(points_[i - 1], points_[i]);
         }

         return;
      }

   }
コード例 #10
0
ファイル: visibility.cpp プロジェクト: dmekhanikov/cg
 void draw(cg::visualization::drawer_type & drawer) const
 {
     drawer.set_color(Qt::green);
     for (segment_2 s : visibility_segments)
         drawer.draw_line(s[0], s[1]);
     drawer.set_color(Qt::white);
     for (contour_2 c : contours)
     {
         for (auto p = c.begin(); p < c.end(); ++p)
         {
             drawer.draw_point(*p, 5);
             drawer.draw_line(*p, *(++c.circulator(p)));
         }
     }
 }
コード例 #11
0
ファイル: segments_intersect.cpp プロジェクト: BigBot22/cg
   void draw(cg::visualization::drawer_type & drawer) const
   {
      drawer.set_color(Qt::white);
      if (cg::has_intersection(s_[0], s_[1]))
         drawer.set_color(Qt::green);

      for (size_t l = 0; l != 2; l++)
         drawer.draw_line(s_[l][0], s_[l][1]);
	  
	  if (idx_)
	  {
		  drawer.set_color(rbutton_pressed_ ? Qt::red : Qt::yellow);
		  drawer.draw_point(s_[(*idx_).first][(*idx_).second], 5);
	  }
   }
コード例 #12
0
ファイル: fourTangent.cpp プロジェクト: Igorjan94/cg
void draw_contour(contour_2f const& p, cg::visualization::drawer_type & drawer)
{
    if (p.size() <= 1)
         return;
    for (auto a = p.begin(), b = a + 1; b != p.end(); a++, b++)
        drawer.draw_line(*a, *b);
}
コード例 #13
0
ファイル: exam_2401_2.cpp プロジェクト: dvbobrov/cg
   void draw(cg::visualization::drawer_type & drawer) const
   {
      drawer.set_color(Qt::white);

//      drawer.draw_line(s_[0], s_[1]);
      for (size_t l = 0, lp = 2; l != 3; lp = l++)
      {
         drawer.draw_line(t_[lp], t_[l]);
         drawer.draw_line(s_[lp], s_[l]);
      }

      drawer.set_color(Qt::green);
      for (size_t l = 0, lp = int_.size() - 1; l != int_.size(); lp = l++)
      {
          drawer.draw_line(int_[lp], int_[l]);
      }
   }
コード例 #14
0
ファイル: shortestPath.cpp プロジェクト: Igorjan94/cg
void draw_vector(Iter a, Iter c, cg::visualization::drawer_type & drawer)
{
    if (a == c)
        return;
    Iter b = a + 1;
    for (; b != c; a++, b++)
        drawer.draw_line(*a, *b);
}
コード例 #15
0
    void draw(cg::visualization::drawer_type &drawer) const
    {
        drawer.set_color(Qt::red);

        if(have_first_point) {
            drawer.draw_point(first_point, 5);
        }

        if(have_second_point) {
            drawer.draw_point(second_point, 5);
        }

        if(have_first_point && have_second_point) {
            dcel_by_lines->add_line(first_point, second_point);
        }

        drawer.set_color(Qt::blue);
        drow_all_lines(drawer);

    }
コード例 #16
0
   void draw(cg::visualization::drawer_type & drawer) const
   {
      if (in_building)
      {
         drawer.set_color(Qt::white);

         for (size_t i = 1; i < points_.size(); ++i)
         {
            drawer.draw_line(points_[i - 1], points_[i]);
         }

         return;
      }

      cg::contour_2 cont(points_);

      if (!cg::counterclockwise(cont) || !cg::convex(cont))
      {
         drawer.set_color(Qt::yellow);
      } else
      {
         drawer.set_color(cg::convex_contains(cont, *current_point_) ? Qt::green : Qt::red);
      }

      for (size_t i = 1; i < points_.size(); ++i)
      {
         drawer.draw_line(points_[i - 1], points_[i]);
      }

      drawer.draw_line(points_.front(), points_.back());


   }
コード例 #17
0
ファイル: navigation.cpp プロジェクト: dmekhanikov/cg
 void draw(cg::visualization::drawer_type & drawer) const
 {
     drawer.set_color(Qt::red);
     for (point_2 p : points)
         drawer.draw_point(p, 5);
     drawer.set_color(Qt::white);
     for (contour_2 c : contours)
         for (auto j = c.begin(); j < c.end(); ++j)
         {
             auto p = *j;
             drawer.draw_point(p, 5);
             drawer.draw_line(p, *(++c.circulator(j)));
         }
     drawer.set_color(Qt::green);
     for (int i = 0; i < (int) route.size() - 1; i++)
         drawer.draw_line(route[i], route[i + 1]);
 }
コード例 #18
0
ファイル: douglas.cpp プロジェクト: BorysMinaiev/cg
   void draw(cg::visualization::drawer_type & drawer) const override
   {
      drawer.set_color(Qt::white);
      drawer.draw_point(*chain.begin(), 5);
      for(auto i = chain.begin() + 1; i != chain.end(); ++i)
      {
         drawer.draw_point(*i, 5);
         drawer.draw_line(*i, *(i-1));
      }
      
      std::vector<point_2> simple;
      douglas_peucker(chain.begin(), chain.end(), eps, back_inserter(simple));

      drawer.set_color(Qt::green);
      drawer.draw_point(*simple.begin(), 5);
      for(auto i = simple.begin() + 1; i != simple.end(); ++i)
      {
         drawer.draw_point(*i, 5);
         drawer.draw_line(*i, *(i-1));
      }
   }
コード例 #19
0
ファイル: minkowski_sum.cpp プロジェクト: dmekhanikov/cg
   void draw(cg::visualization::drawer_type & drawer) const
   {
       for (size_t idx = 0; idx < cur_contour; idx++)
       {
           contour const & cont = conts[idx];
           drawer.set_color(Qt::red);
           if (cg::counterclockwise(cont))
              drawer.set_color(Qt::green);

           for (size_t i = 0; i < cont.size(); i++)
           {
              size_t j = (i + 1) % cont.size();
              cg::point_2 p1 = cont[i], p2 = cont[j];
              drawer.draw_line(p1, p2);
           }
       }
      if (in_building_)
      {
         drawer.set_color(Qt::white);

         for (size_t i = 1; i < conts[cur_contour].size(); ++i)
         {
            drawer.draw_line(conts[cur_contour][i - 1], conts[cur_contour][i]);
         }
      } else
      {
          drawer.set_color(Qt::blue);
          drawer.draw_point(center, 3);
          contour_2 result = minkowski_convex_sum(contour_2(conts[0]), contour_2(reversed));

          for (size_t i = 0; i < result.size(); ++i)
          {
              size_t j = (i + 1) % result.size();
             drawer.draw_line(result[i], result[j]);
          }
      }
   }
コード例 #20
0
 void draw(cg::visualization::drawer_type & drawer) const
 {
     for (point_2 p : points)
     {
         if (cur_vertex && p == *cur_vertex)
             drawer.set_color(Qt::red);
         else
             drawer.set_color(Qt::white);
         drawer.draw_point(p, 5);
     }
     for (triangle_2 t : triangles)
     {
         drawer.set_color(Qt::green);
         for (int j = 0; j < 3; ++j)
             drawer.draw_line(t[j], t[(j + 1) % 3]);
         drawer.set_color(Qt::gray);
         if (auto st = find_triangle(cur_point))
             drawer.draw_circle(get_circumcircle(*st));
     }
 }
コード例 #21
0
   void draw(cg::visualization::drawer_type & drawer) const
   {
      drawer.set_color(Qt::white);
      if (cg::has_intersection(r_, s_))
         drawer.set_color(Qt::green);

      drawer.draw_line(s_[0], s_[1]);
      for(size_t l = 0; l != 2; ++l) {
         drawer.draw_line(r_.corner(l, l), r_.corner(l^1, l));
         drawer.draw_line(r_.corner(l, l), r_.corner(l, l^1));
      }
	  
	   if (idx_) {
         drawer.set_color(rbutton_pressed_ ? Qt::red : Qt::yellow);
         if(on_rect)
            drawer.draw_point(r_.corner((*idx_).first, (*idx_).second), 5);
         else
            drawer.draw_point(s_[(*idx_).first], 5);
	   }
   }
コード例 #22
0
 void drow_all_lines(cg::visualization::drawer_type &drawer) const {
     for(int i = 0; i < dcel_by_lines->lines.size(); i++) {
         drawer.draw_line(dcel_by_lines->lines[i]->first_point, dcel_by_lines->lines[i]->second_point);
     }
 }
コード例 #23
0
ファイル: fourTangent.cpp プロジェクト: Igorjan94/cg
 void draw(cg::visualization::drawer_type & drawer) const
 {
     if (!readyA && a.size() >= 2)
     {
         drawer.set_color(Qt::yellow);
         drawer.draw_point(*a.begin(), MAGIC);
         drawer.set_color(Qt::black);
         drawer.draw_point(*a.begin(), MAGIC - 2);
     }
     if (readyA && !readyB && b.size() >= 2)
     {
         drawer.set_color(Qt::yellow);
         drawer.draw_point(*b.begin(), MAGIC);
         drawer.set_color(Qt::black);
         drawer.draw_point(*b.begin(), MAGIC - 2);
     }
     drawer.set_color(Qt::white);
     draw_contour(a, drawer);
     drawer.set_color(Qt::yellow);
     draw_contour(b, drawer);
     drawer.set_color(Qt::blue);
     for (auto temp : c)
         drawer.draw_line(temp.first, temp.second, 2);
 }