Beispiel #1
0
TEST(orientation, uniform0)
{
   using cg::point_2;
   using cg::contour_2;


   for (size_t cnt_points = 3; cnt_points < 1000; cnt_points++)
   {
      std::vector<point_2> pts = uniform_points(cnt_points);

      auto it = cg::graham_hull(pts.begin(), pts.end());
      pts.resize(std::distance(pts.begin(), it));

      EXPECT_TRUE(cg::counterclockwise(contour_2(pts)));

      std::reverse(pts.begin(), pts.end());
      EXPECT_FALSE(cg::counterclockwise(contour_2(pts)));
   }
}
Beispiel #2
0
   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]);
          }
      }
   }
Beispiel #3
0
 void new_contour()
 {
     contours.push_back(contour_2(std::vector<point_2>()));
 }