From e33465fa33e5528b211d9d5bbd752c81f711ae4d Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Mon, 26 Mar 2012 16:07:17 +0000 Subject: [PATCH] Improve the flip edge method (avoid remove and insert edge) --- .../Linear_cell_complex_3_subdivision.cpp | 58 ++++++++++++++++--- .../demo/Linear_cell_complex/MainWindow.cpp | 11 ++-- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp index ef2a0cad28c..17c39cf52dc 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp @@ -75,21 +75,62 @@ private: LCC & mlcc; }; -// Flip an edge, work in any dimension. +// Flip an edge, work only in 2D and 3D Dart_handle flip_edge (LCC & m, Dart_handle d) { - CGAL_assertion (d != NULL && !d->is_free (2)); - + CGAL_assertion ( d!=NULL && !d->is_free(2) ); + CGAL_assertion ( !d->is_free(1) && !d->is_free(0) ); + CGAL_assertion ( !d->beta(2)->is_free(0) && !d->beta(2)->is_free(1) ); + if (!CGAL::is_removable(m,d)) return NULL; - Dart_handle d2 = d->beta(1)->beta(1); - CGAL::remove_cell(m, d); + Dart_handle d1 = d->beta(1); + Dart_handle d2 = d->beta(2)->beta(0); - insert_cell_1_in_cell_2(m, d2, d2->beta(1)->beta(1)); + CGAL_assertion ( !d1->is_free(1) && !d2->is_free(0) ); - return d2->beta (0); + // We isolated the edge + m.set_attribute_of_dart<0>(d, d2->attribute<0>()); + m.set_attribute_of_dart<0>(d->beta(2), d1->beta(1)->attribute<0>()); + if ( !d->is_free(3) ) + { + m.set_attribute_of_dart<0>(d->beta(3),d->beta(2)->attribute<0>() ); + m.set_attribute_of_dart<0>(d->beta(3)->beta(2), d->attribute<0>()); + } + + m.link_beta<1>(d->beta(0), d->beta(2)->beta(1), false); + m.link_beta<0>(d->beta(1), d->beta(2)->beta(0), false); + if ( !d->is_free(3) ) + { + m.link_beta<0>(d->beta(0)->beta(3), d->beta(2)->beta(1)->beta(3), false); + m.link_beta<1>(d->beta(1)->beta(3), d->beta(2)->beta(0)->beta(3), false); + } + + // Then we push the two extremities. + // First extremity + m.link_beta<1>(d, d1->beta(1), false); + if ( !d->is_free(3) ) + m.link_beta<0>(d->beta(3), d1->beta(1)->beta(3), false); + + m.link_beta<0>(d->beta(2), d1, false); + if ( !d->is_free(3) ) + m.link_beta<1>(d->beta(3)->beta(2), d1->beta(3), false); + + // Second extremity + m.link_beta<0>(d, d2->beta(0), false); + if ( !d->is_free(3) ) + m.link_beta<1>(d->beta(3) ,d2->beta(0)->beta(3), false); + + m.link_beta<1>(d->beta(2), d2, false); + if ( !d->is_free(3) ) + m.link_beta<0>(d->beta(3)->beta(2), d2->beta(3), false); + + // CGAL::remove_cell(m, d); + // insert_cell_1_in_cell_2(m, d1, d1->beta(1)->beta(1)); + + return d; } // Subdivide each facet of the lcc by using sqrt(3)-subdivision. @@ -156,9 +197,8 @@ subdivide_lcc_3 (LCC & m) (m.is_marked(d2->beta(3), mark) && m.is_marked(d2->beta(2)->beta(3), mark)))) { - m.negate_mark (mark); // thus new darts will be marked flip_edge (m, d2); - m.negate_mark (mark); + m.mark(d2, mark); } else m.mark (d2, mark); diff --git a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp index 8ce6c2c6456..5c16b830dde 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp @@ -403,16 +403,17 @@ void MainWindow::on_actionClear_triggered(bool msg) scene.lcc->clear (); volumeUid = 1; nbcube=0; - if (msg) - { - statusBar ()->showMessage (QString ("Scene was cleared"), DELAY_STATUSMSG); - emit (sceneChanged ()); - } volumeDartIndex.clear(); volumeProperties.clear(); volumeList->clearContents(); volumeList->setRowCount(0); + + if (msg) + { + statusBar ()->showMessage (QString ("Scene was cleared"), DELAY_STATUSMSG); + emit (sceneChanged ()); + } } void MainWindow::on_actionCompute_Voronoi_3D_triggered ()