示例#1
0
void test_update_operations(const ListPolygon& p,
                            const vector<Point>& pvec)
{
  // test update functions
  ListPolygon q = p;
  VectorPolygon pgn(p.vertices_begin(), p.vertices_end());
  q.reverse_orientation();
  cout << "p after reversing orientation: " << q << endl;

  assert(p==p);
  assert(!(p==q));

  typedef ListPolygon::Vertex_iterator VI;
  typedef ListPolygon::Vertex_circulator VC;
  q=p;
  VI middle = q.vertices_begin();
  ++middle;
  q.set(middle, *middle);

  // test update operations
  q.push_back(Point(2,3));
  q.push_back(Point(middle->x(), middle->y()));

  VC c = q.vertices_circulator();
  q.set(c, *middle);
  q.insert(c, Point(2,3)); 
  q.erase(q.vertices_circulator());

  pgn.push_back(Point(pgn.vertices_begin()->x(), 3));
  pgn.set(pgn.vertices_begin(), Point(pgn.vertices_begin()->x(), 3));

  q.insert(q.vertices_begin(), pvec.begin() + 3, pvec.begin() + 7);

  q.insert(q.vertices_circulator(), pvec.begin() + 3, pvec.begin() + 7);

  q.clear();
}
示例#2
0
void test_iterators(ListPolygon& p, const ListPolygon& q)
{
  typedef ListPolygon::Vertex_circulator VC;
  typedef ListPolygon::Vertex_const_circulator VCC;
  typedef ListPolygon::Vertex_iterator VI;
  typedef ListPolygon::Vertex_const_iterator VCI;
  typedef ListPolygon::Edge_const_circulator EC;
  typedef ListPolygon::Edge_const_iterator EI;

  CGAL::set_ascii_mode(cout);

  {
    VC v = p.vertices_circulator();
    std::iterator_traits<VC>::iterator_category ic1;
    is_input_iterator(ic1);

    VC vstart(v);
    if (v != 0)
      do {
        cout << *v << endl;
        ++v;
      } while (v != vstart);

    for (VI vi = p.vertices_begin(); vi != p.vertices_end(); ++vi)
      cout << *vi << endl;

    EC e = p.edges_circulator();
    std::iterator_traits<VC>::iterator_category ic2;
    is_input_iterator(ic2);

    EC estart(e);
    if (e != 0)
      do {
        cout << *e << endl;
        ++e;
      } while (e != estart);

    for (EI ei = p.edges_begin(); !(p.edges_end() == ei); ++ei) {
      cout << *ei << endl;
      cout << ei->source() << endl;
    }
  }

  //-------------------------------------------------------------------//
  {
    VCC v = q.vertices_circulator();
    std::iterator_traits<VC>::iterator_category ic3;
    is_input_iterator(ic3);

    VCC vstart(v);
    if (v != 0)
      do {
        cout << *v << endl;
        ++v;
      } while (v != vstart);

    for (VCI vi = q.vertices_begin(); vi != q.vertices_end(); ++vi)
      cout << *vi << endl;

    EC e = q.edges_circulator();
    std::iterator_traits<VC>::iterator_category ic4;
    is_input_iterator(ic4);

    EC estart(e);
    if (e != 0)
      do {
        cout << *e << endl;
        ++e;
      } while (e != estart);

    for (EI ei = q.edges_begin(); !(ei == q.edges_end()); ++ei)
      cout << *ei << endl;
  }
}