コード例 #1
0
ファイル: wallOverlap.cpp プロジェクト: HustLion/CuraEngine
void WallOverlapComputation::convertPolygonToList(PolygonRef poly, ListPolygon& result)
{
    for (Point& p : poly) 
    {
        result.push_back(p);
    }
}
コード例 #2
0
ファイル: ListPolyIt.cpp プロジェクト: josefpavlik/CuraEngine
void ListPolyIt::convertPolygonToList(PolygonRef poly, ListPolygon& result)
{
#ifdef DEBUG
    Point last = poly.back();
#endif // DEBUG
    for (Point& p : poly) 
    {
        result.push_back(p);
#ifdef DEBUG
        // usually polygons shouldn't have such degenerate verts
        // in PolygonProximityLinker (where this function is (also) used) it is
        // required to not have degenerate verts, because verts are mapped
        // to links, but if two different verts are at the same place the mapping fails.
        assert(p != last);
        last = p;
#endif // DEBUG
    }
}
コード例 #3
0
ファイル: PolygonTest.cpp プロジェクト: Asuzer/cgal
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;
  }
}
コード例 #4
0
ファイル: PolygonTest.cpp プロジェクト: Asuzer/cgal
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();
}
コード例 #5
0
ファイル: PolygonTest.cpp プロジェクト: Asuzer/cgal
void test_geometric_predicates(ListPolygon& p)
{
  Point point(1.8, 3.133);

  cout << "p.is_simple()          = " << int(p.is_simple()) << endl;
  cout << "p.is_convex()          = " << int(p.is_convex()) << endl;

  CGAL::Orientation orientation = p.orientation();
  cout << "p.orientation()        = ";
  switch (orientation) {
     case CGAL::CLOCKWISE:        cout << "clockwise"; break;
     case CGAL::COUNTERCLOCKWISE: cout << "counter clockwise"; break;
     case CGAL::COLLINEAR:        cout << "collinear"; break;
  }
  cout << endl;

  CGAL::Oriented_side oside  = p.oriented_side(point);
  cout << "p.oriented_side(point) = ";
  switch (oside) {
    case CGAL::ON_NEGATIVE_SIDE:     cout << "on negative side" << endl; break;
    case CGAL::ON_ORIENTED_BOUNDARY: cout << "on oriented boundary" << endl; break;
    case CGAL::ON_POSITIVE_SIDE:     cout << "on positive side" << endl; break;
  }

  cout << "p.bounded_side(point)  = ";
  CGAL::Bounded_side bside   = p.bounded_side(point);
  switch (bside) {
    case CGAL::ON_BOUNDED_SIDE:   cout << "on bounded side" << endl; break;
    case CGAL::ON_BOUNDARY:       cout << "on boundary" << endl; break;
    case CGAL::ON_UNBOUNDED_SIDE: cout << "on unbounded side" << endl; break;
  }

  cout << "p.bbox()               = " << p.bbox() << endl;
  cout << "p.area()               = " << p.area() << endl;
  cout << "*p.left_vertex()       = " << *p.left_vertex() << endl;
  cout << "*p.right_vertex()      = " << *p.right_vertex() << endl;
  cout << "*p.top_vertex()        = " << *p.top_vertex() << endl;
  cout << "*p.bottom_vertex()     = " << *p.bottom_vertex() << endl;
}