title: UPDATED: CGAL How can I construct an edge between a vertex and the intersections of two beziers?
body: <p>UPDTATE: For anyone else who find this question, and wants a solution.</p>
  <p>After discussing this on the CGAL mailing list, it is clear that the vertex which is the intersections of two Bezier curves cannot be used to construct an edge. Arr_Bezier_curve_traits_2.h does not support it.</p>
  <p>Instead, it was suggested that I might use Arr_algebraic_segment_traits.h, which does not explicitly support Beziers, but does support general polynomials.</p>
  <p>The original question follow:</p>
  <p>Dumb question.</p>
  <p>Using a CGAL Arrangment, I'm trying to construct and edge between a Vertex which is the intersection of two Bezier curves, and a point.</p>
  <p>In this example, when I try to constuct the edge. I'm getting a segfault.
  It works ok if the edge is a degenerate Bezier (the else part of the #if block)</p>
  <pre><code>
  #include &lt;iomanip&gt;
  #include &lt;ios&gt;
  #include &lt;iostream&gt;
  #include &lt;list&gt;
  
  #include &lt;CGAL/basic.h&gt;
  #include &lt;CGAL/Cartesian.h&gt;
  #include &lt;CGAL/Arrangement_2.h&gt;
  #include &lt;CGAL/Arrangement_with_history_2.h&gt;
  #include &lt;CGAL/CORE_algebraic_number_traits.h&gt;
  #include &lt;CGAL/Arr_Bezier_curve_traits_2.h&gt;
  #include &lt;CGAL/Arr_vertical_decomposition_2.h&gt;
  #include &lt;CGAL/Sweep_line_2_algorithms.h&gt;
  
  
  typedef CGAL::CORE_algebraic_number_traits              Nt_traits;
  typedef Nt_traits::Rational                             Rational;
  typedef Nt_traits::Algebraic                            Algebraic;
  
  typedef CGAL::Cartesian&lt;Rational&gt;                       Rat_kernel;
  typedef CGAL::Cartesian&lt;Algebraic&gt;                      Alg_kernel;
  typedef CGAL::Arr_Bezier_curve_traits_2&lt;Rat_kernel, Alg_kernel, Nt_traits&gt;
                                                          Traits_2;
    
  typedef Traits_2::Curve_2                               Bezier_curve_2;
  typedef Traits_2::X_monotone_curve_2                    X_monotone_curve_2;
  
  typedef Alg_kernel::Point_2                             Bezier_alg_point;
  typedef Rat_kernel::Point_2                             Bezier_rat_point;
  typedef Traits_2::Point_2                               Bezier_point;
  typedef Traits_2::X_monotone_curve_2                    Bezier_X_monotone_curve;
  
  typedef Traits_2::Point_2                               Point_2;
  
  typedef CGAL::Arrangement_with_history_2&lt;Traits_2&gt;    Arrangement;
  
  typedef typename Arrangement::Geometry_traits_2 Bezier_traits;
  typedef typename Bezier_traits::Curve_2 Curve_2;
  typedef typename Bezier_traits::X_monotone_curve_2 X_monotone_curve_2;
  
  typedef typename Arrangement::Vertex_const_handle       Vertex_const_handle;
  typedef typename Arrangement::Vertex_handle             Vertex_handle;
  
  typedef typename Arrangement::Halfedge_const_handle     Halfedge_const_handle;
  typedef typename Arrangement::Halfedge_handle           Halfedge_handle;
  
  typedef typename Arrangement::Face_const_handle         Face_const_handle;
  typedef typename Arrangement::Face_handle               Face_handle;
  
  Bezier_curve_2 constructEdge( Bezier_point p1, Bezier_point p2) {
      std::list&lt;Bezier_point&gt; pts;
      pts.push_back(p1);
      pts.push_back(p2);
      return Bezier_curve_2(pts.begin(), pts.end());
  }
  
  Bezier_curve_2 constructEdge( Bezier_point p1, Bezier_point p2, Bezier_point p3) {
      std::list&lt;Bezier_point&gt; pts;
      pts.push_back(p1);
      pts.push_back(p2);
      pts.push_back(p3);
      return Bezier_curve_2(pts.begin(), pts.end());
  }
  
  /*
   * Using a CGAL Arrangment, I'm trying to construct and edge between a Vertex 
   * which is the intersection of two Bezier curves, and a point.
   *
   * In this example, when I try to constuct the edge. I'm getting a segfault.
   * 
   * It works ok if the edge is a degenerate Bezier (the else part of the #if block)
   * 
   */
  
  
  int main(int argc, char* argv[])
  {
      Arrangement arr;
  
      std::list&lt;Bezier_curve_2&gt; curves;
  #if 1   
      curves.push_back( constructEdge( Point_2( -100,0 ), Point_2( 0, 10 ), Point_2( 100, 0 ))); 
      curves.push_back( constructEdge( Point_2( 0,-100 ), Point_2( 10, 0 ), Point_2( 0, 100)));
  #else   
      curves.push_back( constructEdge( Point_2( -100,0 ), Point_2( 100, 0 ))); 
      curves.push_back( constructEdge( Point_2( 0,-100 ), Point_2( 0, 100)));
  #endif  
  
      insert(arr, curves.begin(), curves.end());
  
      typedef std::list&lt;std::pair&lt;Vertex_const_handle,
              std::pair&lt;CGAL::Object, CGAL::Object&gt; &gt; &gt;   Ray_shoot_list;
  
      Ray_shoot_list                     vrs_list;
      typename Ray_shoot_list::iterator  vrs_iter;
      
      CGAL::decompose (arr, std::back_inserter (vrs_list));
  
      std::list&lt;Bezier_curve_2&gt; moreCurves;
      
      for (typename Ray_shoot_list::iterator vv = vrs_list.begin(); vv != vrs_list.end(); vv++) {
          Vertex_handle vertex = arr.non_const_handle( vv-&gt;first );
          std::cerr &lt;&lt; &quot;Vertex &quot; &lt;&lt; vertex-&gt;point() &lt;&lt; &quot; degree &quot; &lt;&lt; vertex-&gt;degree() &lt;&lt; std::endl;
  
          if (vertex-&gt;degree()&gt;1) {
              Point_2 p(1,1);
              std::cerr &lt;&lt; &quot;Inserting new edge from &quot; &lt;&lt; p &lt;&lt; &quot; to &quot; &lt;&lt; vertex-&gt;point() &lt;&lt; std::endl;
              moreCurves.push_back( constructEdge( p, vertex-&gt;point() ) );
              insert(arr, moreCurves.begin(), moreCurves.end());
          }
      }
  
    return 0;
  }
  
  </code></pre>