@Override public ArrayList<Polyline> cutout(Polyline p_polyline){
  ArrayList<Polyline> risul=new ArrayList<Polyline>(3);
  ArrayList<PlaToupleInt> intersection_no=entrance_points(p_polyline);
  PlaPoint first_corner=p_polyline.corner_first();
  boolean first_corner_is_inside=contains_inside(first_corner);
  if (intersection_no.size() == 0) {
    if (first_corner_is_inside)     return risul;
    risul.add(p_polyline);
    return risul;
  }
  LinkedList<Polyline> pieces=new LinkedList<Polyline>();
  int curr_intersection_no=0;
  PlaToupleInt curr_intersection_tuple=intersection_no.get(curr_intersection_no);
  PlaLineInt a_line=p_polyline.plaline(curr_intersection_tuple.v_a);
  PlaLineInt b_line=border_line(curr_intersection_tuple.v_b);
  PlaPoint first_intersection=a_line.intersection(b_line,"what does this do ?");
  if (!first_corner_is_inside) {
    if (!first_corner.equals(first_intersection)) {
      int curr_polyline_intersection_no=curr_intersection_tuple.v_a;
      PlaLineIntAlist curr_lines=new PlaLineIntAlist(curr_polyline_intersection_no + 2);
      p_polyline.alist_append_to(curr_lines,0,curr_polyline_intersection_no + 1);
      curr_lines.add(border_line(curr_intersection_tuple.v_b));
      Polyline curr_piece=new Polyline(curr_lines);
      if (curr_piece.is_valid())       pieces.add(curr_piece);
    }
    ++curr_intersection_no;
  }
  while (curr_intersection_no < intersection_no.size() - 1) {
    curr_intersection_tuple=intersection_no.get(curr_intersection_no);
    PlaToupleInt next_intersection_tuple=intersection_no.get(curr_intersection_no + 1);
    int curr_intersection_no_of_polyline=curr_intersection_tuple.v_a;
    int next_intersection_no_of_polyline=next_intersection_tuple.v_a;
    boolean insert_piece=false;
    for (int index=curr_intersection_no_of_polyline + 1; index < next_intersection_no_of_polyline; ++index) {
      if (is_outside(p_polyline.corner(index))) {
        insert_piece=true;
        break;
      }
    }
    if (insert_piece) {
      int want_len=next_intersection_no_of_polyline - curr_intersection_no_of_polyline + 3;
      PlaLineIntAlist curr_lines=new PlaLineIntAlist(want_len);
      curr_lines.add(border_line(curr_intersection_tuple.v_b));
      p_polyline.alist_append_to(curr_lines,curr_intersection_no_of_polyline,want_len - 2);
      curr_lines.add(border_line(next_intersection_tuple.v_b));
      Polyline curr_piece=new Polyline(curr_lines);
      if (curr_piece.is_valid())       pieces.add(curr_piece);
    }
    curr_intersection_no+=2;
  }
  if (curr_intersection_no <= intersection_no.size() - 1) {
    curr_intersection_tuple=intersection_no.get(curr_intersection_no);
    int curr_polyline_intersection_no=curr_intersection_tuple.v_a;
    int want_len=p_polyline.plaline_len(-curr_polyline_intersection_no + 1);
    PlaLineIntAlist curr_lines=new PlaLineIntAlist(want_len);
    curr_lines.add(border_line(curr_intersection_tuple.v_b));
    p_polyline.alist_append_to(curr_lines,curr_polyline_intersection_no,want_len - 1);
    Polyline curr_piece=new Polyline(curr_lines);
    if (curr_piece.is_valid())     pieces.add(curr_piece);
  }
  risul.ensureCapacity(pieces.size());
  risul.addAll(pieces);
  return risul;
}

@ Override public ArrayList < Polyline > cutout ( Polyline p_polyline ) { ArrayList < Polyline > risul = new ArrayList < Polyline > ( 3 ) ; ArrayList < PlaToupleInt > intersection_no = entrance_points ( p_polyline ) ; PlaPoint first_corner = p_polyline . corner_first ( ) ; boolean first_corner_is_inside = contains_inside ( first_corner ) ; if ( intersection_no . size ( ) == 0 ) { if ( first_corner_is_inside ) return risul ; risul . add ( p_polyline ) ; return risul ; } LinkedList < Polyline > pieces = new LinkedList < Polyline > ( ) ; int curr_intersection_no = 0 ; PlaToupleInt curr_intersection_tuple = intersection_no . get ( curr_intersection_no ) ; PlaLineInt a_line = p_polyline . plaline ( curr_intersection_tuple . v_a ) ; PlaLineInt b_line = border_line ( curr_intersection_tuple . v_b ) ; PlaPoint first_intersection = a_line . intersection ( b_line , "what does this do ?" ) ; if ( ! first_corner_is_inside ) { if ( ! first_corner . equals ( first_intersection ) ) { int curr_polyline_intersection_no = curr_intersection_tuple . v_a ; PlaLineIntAlist curr_lines = new PlaLineIntAlist ( curr_polyline_intersection_no + 2 ) ; p_polyline . alist_append_to ( curr_lines , 0 , curr_polyline_intersection_no + 1 ) ; curr_lines . add ( border_line ( curr_intersection_tuple . v_b ) ) ; Polyline curr_piece = new Polyline ( curr_lines ) ; if ( curr_piece . is_valid ( ) ) pieces . add ( curr_piece ) ; } ++ curr_intersection_no ; } while ( curr_intersection_no < intersection_no . size ( ) - 1 ) { curr_intersection_tuple = intersection_no . get ( curr_intersection_no ) ; PlaToupleInt next_intersection_tuple = intersection_no . get ( curr_intersection_no + 1 ) ; int curr_intersection_no_of_polyline = curr_intersection_tuple . v_a ; int next_intersection_no_of_polyline = next_intersection_tuple . v_a ; boolean insert_piece = false ; for ( int index = curr_intersection_no_of_polyline + 1 ; index < next_intersection_no_of_polyline ; ++ index ) { if ( is_outside ( p_polyline . corner ( index ) ) ) { insert_piece = true ; break ; } } if ( insert_piece ) { int want_len = next_intersection_no_of_polyline - curr_intersection_no_of_polyline + 3 ; PlaLineIntAlist curr_lines = new PlaLineIntAlist ( want_len ) ; curr_lines . add ( border_line ( curr_intersection_tuple . v_b ) ) ; p_polyline . alist_append_to ( curr_lines , curr_intersection_no_of_polyline , want_len - 2 ) ; curr_lines . add ( border_line ( next_intersection_tuple . v_b ) ) ; Polyline curr_piece = new Polyline ( curr_lines ) ; if ( curr_piece . is_valid ( ) ) pieces . add ( curr_piece ) ; } curr_intersection_no += 2 ; } if ( curr_intersection_no <= intersection_no . size ( ) - 1 ) { curr_intersection_tuple = intersection_no . get ( curr_intersection_no ) ; int curr_polyline_intersection_no = curr_intersection_tuple . v_a ; int want_len = p_polyline . plaline_len ( - curr_polyline_intersection_no + 1 ) ; PlaLineIntAlist curr_lines = new PlaLineIntAlist ( want_len ) ; curr_lines . add ( border_line ( curr_intersection_tuple . v_b ) ) ; p_polyline . alist_append_to ( curr_lines , curr_polyline_intersection_no , want_len - 1 ) ; Polyline curr_piece = new Polyline ( curr_lines ) ; if ( curr_piece . is_valid ( ) ) pieces . add ( curr_piece ) ; } risul . ensureCapacity ( pieces . size ( ) ) ; risul . addAll ( pieces ) ; return risul ; }
cuts out the parts of p_polyline in the interiour of this shape and returns a list of the remaining pieces of p_polyline . pieces completely contained in the border of this shape are not returned .
