@@ -1184,6 +1184,13 @@ class Gps_on_surface_base_2
11841184
11851185 // accessor for low-level arrangement fonctionalities
11861186 CGAL::Arr_accessor<Aos_2> accessor (*arr);
1187+ // the face field of outer and inner ccb are used in the loop to access the old face an halfedge
1188+ // used to contribute to. These two vectors are used to delay the association to the new face to
1189+ // avoid overwriting a field that is still needed
1190+ typedef std::pair<typename Aos_2::Dcel::Outer_ccb*, typename Aos_2::Dcel::Face*> Outer_ccb_and_face;
1191+ typedef std::pair<typename Aos_2::Dcel::Inner_ccb*, typename Aos_2::Dcel::Face*> Inner_ccb_and_face;
1192+ std::vector<Outer_ccb_and_face> outer_ccb_and_new_face_pairs;
1193+ std::vector<Inner_ccb_and_face> inner_ccb_and_new_face_pairs;
11871194 // update halfedge ccb pointers
11881195 for (Halfedge_iterator itr = arr->halfedges_begin (); itr != arr->halfedges_end (); ++itr)
11891196 {
@@ -1205,11 +1212,12 @@ class Gps_on_surface_base_2
12051212 f = *(face_handles[
12061213 (*uf_faces.find (face_handles[f->id ()]))->id ()
12071214 ]);
1208- if (h->flag ()==ON_INNER_CCB || h-> flag ()==NOT_VISITED )
1215+ if (h->flag ()==ON_INNER_CCB)
12091216 {
1210- typename Aos_2::Dcel::Inner_ccb* inner_ccb = inner_ccbs_to_remove.empty ()?
1217+ bool reuse_inner_ccb = !inner_ccbs_to_remove.empty ();
1218+ typename Aos_2::Dcel::Inner_ccb* inner_ccb = !reuse_inner_ccb?
12111219 accessor.new_inner_ccb ():inner_ccbs_to_remove.back ();
1212- if ( !inner_ccbs_to_remove. empty () ) inner_ccbs_to_remove.pop_back ();
1220+ if ( reuse_inner_ccb ) inner_ccbs_to_remove.pop_back ();
12131221
12141222 Halfedge_handle hstart=h;
12151223 do {
@@ -1219,9 +1227,13 @@ class Gps_on_surface_base_2
12191227 }while (hstart!=h);
12201228 f->add_inner_ccb (inner_ccb,_halfedge (h));
12211229 inner_ccb->set_halfedge (_halfedge (h));
1222- inner_ccb->set_face (f);
1230+ if (!reuse_inner_ccb)
1231+ inner_ccb->set_face (f);
1232+ else
1233+ inner_ccb_and_new_face_pairs.push_back ( std::make_pair (inner_ccb, f) );
12231234 }
12241235 else {
1236+ // we never create more outer ccb than what was available
12251237 CGAL_assertion (!outer_ccbs_to_remove.empty ());
12261238 typename Aos_2::Dcel::Outer_ccb* outer_ccb = outer_ccbs_to_remove.back ();
12271239 outer_ccbs_to_remove.pop_back ();
@@ -1233,11 +1245,17 @@ class Gps_on_surface_base_2
12331245 }while (hstart!=h);
12341246 f->add_outer_ccb (outer_ccb,_halfedge (h));
12351247 outer_ccb->set_halfedge (_halfedge (h));
1236- outer_ccb-> set_face (f );
1248+ outer_ccb_and_new_face_pairs. push_back ( std::make_pair (outer_ccb, f) );
12371249 }
12381250 }
12391251 }
12401252
1253+ // now set the new face for all ccbs
1254+ BOOST_FOREACH (Outer_ccb_and_face& ccb_and_face, outer_ccb_and_new_face_pairs)
1255+ ccb_and_face.first ->set_face (ccb_and_face.second );
1256+ BOOST_FOREACH (Inner_ccb_and_face& ccb_and_face, inner_ccb_and_new_face_pairs)
1257+ ccb_and_face.first ->set_face (ccb_and_face.second );
1258+
12411259 // remove no longer used edges, vertices and faces
12421260 accessor.delete_vertices ( vertices_to_remove );
12431261 accessor.delete_edges ( edges_to_remove );
0 commit comments