From d62a535fd7e60e2ad5b840d977530533c280d741 Mon Sep 17 00:00:00 2001 From: Sylvain Brandel Date: Fri, 13 Jun 2014 16:02:55 +0200 Subject: [PATCH] minor addons in the code, not in the API --- .../include/CGAL/Combinatorial_map.h | 2 +- .../CGAL/Combinatorial_map_insertions.h | 13 ++++++-- .../CGAL/Combinatorial_map_operations.h | 2 ++ .../demo/Linear_cell_complex/MainWindow.cpp | 12 ++++---- .../include/CGAL/Linear_cell_complex.h | 30 +++++++++++-------- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 7047000e18e..e3f74142174 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -1160,7 +1160,7 @@ namespace CGAL { } /// validate the map - void validate_scene() + void validate_attributes() { std::vector marks(dimension+1); for ( int i=0; i<=dimension; ++i) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h index 53abb4cfc78..895562b261d 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h @@ -29,6 +29,7 @@ namespace CGAL /** Insert a vertex in a given edge. * @param amap the used combinatorial map. * @param adart a dart of the edge (!=NULL && !=null_dart_handle). + * @param update_attributes a boolean to update the enabled attributes * @return a dart of the new vertex. */ template @@ -116,6 +117,7 @@ insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart, * once for each inital edge of the facet. * @param amap the used combinatorial map. * @param adart a dart of the facet to triangulate. + * @param update_attributes a boolean to update the enabled attributes * @return A dart incident to the new vertex. */ template < class CMap > @@ -259,8 +261,11 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, amap.unmark(amap.beta(*itd, dim), treated); } if ( *itd!=adart ) - CGAL::internal::Degroup_attribute_functor_run:: - run(&amap, adart, *itd); + if (update_attributes) + { + CGAL::internal::Degroup_attribute_functor_run:: + run(&amap, adart, *itd); + } } CGAL_assertion(amap.is_whole_map_unmarked(treated)); @@ -275,6 +280,7 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, /** Insert a dangling edge in a 2-cell between given by a dart. * @param amap the used combinatorial map. * @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle). + * @param update_attributes a boolean to update the enabled attributes * @return a dart of the new edge, not incident to the vertex of adart1. */ template @@ -398,6 +404,7 @@ bool is_insertable_cell_1_in_cell_2(const CMap& amap, * @param amap the used combinatorial map. * @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle). * @param adart2 a second dart of the facet. If NULL insert a dangling edge. + * @param update_attributes a boolean to update the enabled attributes * @return a dart of the new edge, and not incident to the * same vertex than adart1. */ @@ -487,6 +494,7 @@ insert_cell_1_in_cell_2(CMap& amap, { CGAL::internal::Degroup_attribute_functor_run::run(&amap, d1, d2); } + amap.negate_mark(m1); amap.negate_mark(m2); it1.rewind(); it2.rewind(); @@ -571,6 +579,7 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap, * @param amap the used combinatorial map. * @param afirst iterator on the begining of the path. * @param alast iterator on the end of the path. + * @param update_attributes a boolean to update the enabled attributes * @return a dart of the new 2-cell. */ template diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index 1e852d7093e..021692ef5ee 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -331,6 +331,7 @@ namespace CGAL /** Remove a vertex, and merge eventually both incident edges. * @param amap the used combinatorial map. * @param adart a dart of the vertex to remove. + * @param update_attributes a boolean to update the enabled attributes * @return the number of deleted darts. */ template @@ -449,6 +450,7 @@ namespace CGAL /** Remove an i-cell, 0<=i<=dimension. * @param amap the used combinatorial map. * @param adart a dart of the i-cell to remove. + * @param update_attributes a boolean to update the enabled attributes * @return the number of deleted darts. */ template < class CMap, unsigned int i > diff --git a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp index bb16d485a17..9c498d16cff 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp @@ -1279,7 +1279,7 @@ void MainWindow::onMengerInc() } std::cout << "validate scene..." << std::endl; - scene.lcc->validate_scene(); + scene.lcc->validate_attributes(); } #ifdef CGAL_PROFILE_LCC_DEMO @@ -1701,7 +1701,7 @@ void MainWindow::onMengerDec() if (!mengerUpdateAttributes) { - scene.lcc->validate_scene(); + scene.lcc->validate_attributes(); } #ifdef CGAL_PROFILE_LCC_DEMO @@ -1976,7 +1976,7 @@ void MainWindow::onSierpinskiCarpetInc() std::cout << "BOOST_NO_VARIADIC_TEMPLATES" << " not defined" << std::endl; #endif - scene.lcc->validate_scene(); + scene.lcc->validate_attributes(); // maintenant que la scène est valide, on offre la possibilité de calculer une géométrie qui correspond à un tapis de Sierpinski if (isComputableGeometry) @@ -2747,7 +2747,7 @@ void MainWindow::onSierpinskiCarpetDec() if (!duringConstructionUpdateAttributes) { - scene.lcc->validate_scene(); + scene.lcc->validate_attributes(); } #ifdef CGAL_PROFILE_LCC_DEMO @@ -2931,7 +2931,7 @@ void MainWindow::onSierpinskiTriangleInc() update_volume_list_add(scene.lcc->attribute<3>(sierpinskiTriangleSurfaces[i])); } - scene.lcc->validate_scene(); + scene.lcc->validate_attributes(); } // std::cout << removedTriangles.size() << std::endl; @@ -3153,7 +3153,7 @@ void MainWindow::onSierpinskiTriangleDec() if (!sierpinskiTriangleUpdateAttributes) { - scene.lcc->validate_scene(); + scene.lcc->validate_attributes(); } #ifdef CGAL_PROFILE_LCC_DEMO diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex.h index acfbacf8c9c..bbb5f37bef1 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex.h @@ -350,17 +350,17 @@ namespace CGAL { /** validate the lcc */ - void validate_scene() + void validate_attributes() { - Base::validate_scene(); + Base::validate_attributes(); - // On vérifie que chaque brin a un 0-plongement + // Each dart needs to have a 0-embedding for (typename Dart_range::iterator it(this->darts().begin()), itend(this->darts().end()); it != itend; ++it) { if ( vertex_attribute(it)==null_handle ) { - // sinon on crée un point à l'origine + // If a dart don't have a 0-attribute, we create a Point at the origin set_vertex_attribute(it, create_vertex_attribute(CGAL::ORIGIN)); } } @@ -702,25 +702,27 @@ namespace CGAL { /** Insert a point in a given 1-cell. * @param dh a dart handle to the 1-cell * @param p the point to insert + * @param update_attributes a boolean to update the enabled attributes * @return a dart handle to the new vertex containing p. */ - Dart_handle insert_point_in_cell_1(Dart_handle dh, const Point& p, bool update_attribute) + Dart_handle insert_point_in_cell_1(Dart_handle dh, const Point& p, bool update_attributes) { return CGAL::insert_cell_0_in_cell_1(*this, dh, create_vertex_attribute(p), - update_attribute); + update_attributes); } /** Insert a point in a given 2-cell. * @param dh a dart handle to the 2-cell * @param p the point to insert + * @param update_attributes a boolean to update the enabled attributes * @return a dart handle to the new vertex containing p. */ - Dart_handle insert_point_in_cell_2(Dart_handle dh, const Point& p, bool update_attribute) + Dart_handle insert_point_in_cell_2(Dart_handle dh, const Point& p, bool update_attributes) { Vertex_attribute_handle v = create_vertex_attribute(p); - Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh, v, update_attribute); + Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh, v, update_attributes); if ( first==null_handle ) // If the triangulated facet was made of one dart erase_vertex_attribute(v); @@ -735,6 +737,7 @@ namespace CGAL { /** Insert a point in a given i-cell. * @param dh a dart handle to the i-cell * @param p the point to insert + * @param update_attributes a boolean to update the enabled attributes * @return a dart handle to the new vertex containing p. */ template @@ -748,23 +751,26 @@ namespace CGAL { /** Insert a dangling edge in a given facet. * @param dh a dart of the facet (!=NULL). * @param p the coordinates of the new vertex. + * @param update_attributes a boolean to update the enabled attributes * @return a dart of the new edge, incident to the new vertex. */ Dart_handle insert_dangling_cell_1_in_cell_2(Dart_handle dh, - const Point& p) + const Point& p, + bool update_attributes = true) { return CGAL::insert_dangling_cell_1_in_cell_2 - (*this, dh, create_vertex_attribute(p)); + (*this, dh, create_vertex_attribute(p), update_attributes); } /** Insert a point in a given i-cell. * @param dh a dart handle to the i-cell * @param p the point to insert + * @param update_attributes a boolean to update the enabled attributes * @return a dart handle to the new vertex containing p. */ template - Dart_handle insert_barycenter_in_cell(Dart_handle dh) - { return insert_point_in_cell(dh, barycenter(dh)); } + Dart_handle insert_barycenter_in_cell(Dart_handle dh, bool update_attributes = true) + { return insert_point_in_cell(dh, barycenter(dh), update_attributes); } /** Compute the dual of a Linear_cell_complex. * @param alcc the lcc in which we build the dual of this lcc.