From 6926578b15d681b8f67e1ddce17f7877c5b55afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 18 Jan 2017 18:19:25 +0100 Subject: [PATCH] add reserve to MutableFaceGraph --- BGL/doc/BGL/Concepts/MutableFaceGraph.h | 2 +- .../graph/Graph_with_descriptor_with_graph.h | 9 ++++ BGL/include/CGAL/boost/graph/graph_concepts.h | 2 + .../graph_traits_PolyMesh_ArrayKernelT.h | 11 +++- .../graph/graph_traits_TriMesh_ArrayKernelT.h | 9 ++++ BGL/include/CGAL/boost/graph/helpers.h | 42 --------------- .../boost/graph/internal/Has_member_reserve.h | 45 ---------------- BGL/test/BGL/CMakeLists.txt | 2 - BGL/test/BGL/test_reserve.cpp | 51 ------------------- Installation/changes.html | 10 ++-- .../boost/graph/graph_traits_Polyhedron_3.h | 10 +++- .../boost/graph/graph_traits_Surface_mesh.h | 22 +++----- 12 files changed, 55 insertions(+), 160 deletions(-) delete mode 100644 BGL/include/CGAL/boost/graph/internal/Has_member_reserve.h delete mode 100644 BGL/test/BGL/test_reserve.cpp diff --git a/BGL/doc/BGL/Concepts/MutableFaceGraph.h b/BGL/doc/BGL/Concepts/MutableFaceGraph.h index 464bd6547fa..3bc87c8b33d 100644 --- a/BGL/doc/BGL/Concepts/MutableFaceGraph.h +++ b/BGL/doc/BGL/Concepts/MutableFaceGraph.h @@ -27,6 +27,6 @@ Expression | returns | Description `remove_face(f, g)` | `void` | Removes `f` from the graph. `set_face(h, f, g)` | `void` | Sets the corresponding face of `h` to `f`. `set_halfedge(f, h, g)` | `void` | Sets the corresponding halfedge of `f` to `h`. - +`reserve(g, nv, ne, nf)`| `void` | Called to indicate the expected size of vertices (`nv`), edges (`ed`) and faces (`nf`) */ class MutableFaceGraph{}; diff --git a/BGL/include/CGAL/boost/graph/Graph_with_descriptor_with_graph.h b/BGL/include/CGAL/boost/graph/Graph_with_descriptor_with_graph.h index fb3fbc9f31d..041d1ed67d7 100644 --- a/BGL/include/CGAL/boost/graph/Graph_with_descriptor_with_graph.h +++ b/BGL/include/CGAL/boost/graph/Graph_with_descriptor_with_graph.h @@ -398,6 +398,15 @@ remove_vertex(typename boost::graph_traits< Graph_with_descriptor_with_graph +void +reserve(Graph_with_descriptor_with_graph& w, + typename boost::graph_traits< Graph_with_descriptor_with_graph >::vertices_size_type nv, + typename boost::graph_traits< Graph_with_descriptor_with_graph >::edges_size_type ne, + typename boost::graph_traits< Graph_with_descriptor_with_graph >::faces_size_type nf) +{ + reserve(*w.graph, nv, ne, nf); +} template typename boost::graph_traits< Graph_with_descriptor_with_graph >::edge_descriptor diff --git a/BGL/include/CGAL/boost/graph/graph_concepts.h b/BGL/include/CGAL/boost/graph/graph_concepts.h index e8721aa6344..e0a62f05e14 100644 --- a/BGL/include/CGAL/boost/graph/graph_concepts.h +++ b/BGL/include/CGAL/boost/graph/graph_concepts.h @@ -162,6 +162,8 @@ BOOST_concept(MutableFaceGraph,(G)) remove_face(f, g); set_face(h, f, g); set_halfedge(f, h, g); + int i; + reserve(g, i, i, i); } G g; typename boost::graph_traits::face_descriptor f; diff --git a/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h b/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h index c8036b06b93..cee9d776171 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h @@ -504,7 +504,16 @@ set_halfedge(typename boost::graph_traits >:: sm.set_halfedge_handle(f, h); } - +template +void +reserve(OpenMesh::PolyMesh_ArrayKernelT& tm, + typename boost::graph_traits< OpenMesh::PolyMesh_ArrayKernelT >::vertices_size_type nv, + typename boost::graph_traits< OpenMesh::PolyMesh_ArrayKernelT >::edges_size_type ne, + typename boost::graph_traits< OpenMesh::PolyMesh_ArrayKernelT >::faces_size_type nf) +{ + tm.reserve(nv, ne, nf); +} + // // FaceListGraph // diff --git a/BGL/include/CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h b/BGL/include/CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h index 86b874b2cb5..657a93ea1ba 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h @@ -388,6 +388,15 @@ add_edge(OpenMesh::TriMesh_ArrayKernelT& sm) boost::graph_traits >::null_vertex() ), sm); } +template +void +reserve(OpenMesh::TriMesh_ArrayKernelT& tm, + typename boost::graph_traits< OpenMesh::TriMesh_ArrayKernelT >::vertices_size_type nv, + typename boost::graph_traits< OpenMesh::TriMesh_ArrayKernelT >::edges_size_type ne, + typename boost::graph_traits< OpenMesh::TriMesh_ArrayKernelT >::faces_size_type nf) +{ + tm.reserve(nv, ne, nf); +} // // FaceGraph diff --git a/BGL/include/CGAL/boost/graph/helpers.h b/BGL/include/CGAL/boost/graph/helpers.h index 9bdeb7af92f..4055b6a3152 100644 --- a/BGL/include/CGAL/boost/graph/helpers.h +++ b/BGL/include/CGAL/boost/graph/helpers.h @@ -25,7 +25,6 @@ #include #include #include -#include namespace CGAL { @@ -726,22 +725,6 @@ clear_impl(FaceGraph& g) } } - -template -inline -typename boost::enable_if, void>::type -reserve_impl(FaceGraph& g, T1 nv, T2 ne, T3 nf) -{ - g.reserve(nv, ne, nf); -} - -template -inline -typename boost::disable_if, void>::type -reserve_impl(FaceGraph&, T1, T2, T3) -{ -} - } /** @@ -768,31 +751,6 @@ void clear(FaceGraph& g) CGAL_postcondition(num_faces(g) == 0); } - -/** - * \ingroup PkgBGLHelperFct - * - * If `FaceGraph` has a member function `reserve(nv,ne,nf)`, it will be called. - * Otherwise, nothing will be done. - * - * @tparam FaceGraph model of `MutableHalfedgeGraph` and `MutableFaceGraph` - * - * @param g the graph - * @param nv number of vertices - * @param ne number of edges - * @param nf number of faces - * - **/ -template -void reserve(FaceGraph& g, - typename boost::graph_traits::vertices_size_type nv, - typename boost::graph_traits::edges_size_type ne, - typename boost::graph_traits::faces_size_type nf) -{ - internal::reserve_impl(g,nv, ne, nf); -} - - } // namespace CGAL // Include "Euler_operations.h" at the end, because its implementation diff --git a/BGL/include/CGAL/boost/graph/internal/Has_member_reserve.h b/BGL/include/CGAL/boost/graph/internal/Has_member_reserve.h deleted file mode 100644 index 08e4f4a2ed1..00000000000 --- a/BGL/include/CGAL/boost/graph/internal/Has_member_reserve.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2016 GeometryFactory (France). All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 3 of the License, -// or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// Author(s) : Sebastien Loriot - - -#ifndef CGAL_HAS_MEMBER_RESERVE_H -#define CGAL_HAS_MEMBER_RESERVE_H - -namespace CGAL { -namespace internal { - -template -class Has_member_reserve -{ -private: - template - class check {}; - - template - static char f(check*); - - template - static int f(...); -public: - static const bool value = (sizeof(f(0)) == sizeof(char)); -}; - -} // internal -} // CGAL - -#endif /* CGAL_HAS_MEMBER_RESERVE_H */ diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index 01e195888ca..8ccadec9216 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -77,8 +77,6 @@ create_single_source_cgal_program( "graph_concept_Gwdwg_Surface_mesh.cpp" ) create_single_source_cgal_program( "test_clear.cpp" ) -create_single_source_cgal_program( "test_reserve.cpp" ) - create_single_source_cgal_program( "test_helpers.cpp" ) create_single_source_cgal_program( "test_Has_member_clear.cpp" ) diff --git a/BGL/test/BGL/test_reserve.cpp b/BGL/test/BGL/test_reserve.cpp deleted file mode 100644 index 98d353fa2ba..00000000000 --- a/BGL/test/BGL/test_reserve.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "test_Prefix.h" - -#include - -template -void test() { - Mesh m; - CGAL::reserve(m, 6, 12, 7); -} - -struct MyGraph{}; -struct MyGraphWithReserve{ - bool OK; - MyGraphWithReserve() - : OK(false) - {} - void reserve(int,int,int) - { - OK=true; - } -}; - -namespace boost -{ - template<> - struct graph_traits - { - typedef int vertices_size_type; - typedef int edges_size_type; - typedef int faces_size_type; - }; - template<> - struct graph_traits - : graph_traits - {}; -} - -int main() -{ - test(); - test(); -#if defined(CGAL_USE_OPENMESH) - test(); -#endif - test(); - MyGraphWithReserve g; - assert(!g.OK); - CGAL::reserve(g,1,2,3); - assert(g.OK); - return 0; -} diff --git a/Installation/changes.html b/Installation/changes.html index d047a43cb64..17ffa437699 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -173,6 +173,13 @@ and src/ directories). +

CGAL and the Boost Graph Library (BGL)

+
    +
  • + Breaking change: Addition of a free function reserve() in the concept MutableFaceGraph. + Models provided by CGAL have been updated. +
  • +
@@ -315,9 +322,6 @@ and src/ directories). Add class CGAL::Graph_with_descriptor_with_graph that wraps an existing graph and provides a reference to the said graph to all of its descriptors. -
  • Add the helper function `CGAL::reserve(G,nv,ne,nf)` that enables to reserve - vertices, edges, and faces of a `MutableFaceGraph`. -
  • Cone Based Spanners

      diff --git a/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h index a4b40214e7b..3b6e5d8da97 100644 --- a/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h @@ -444,7 +444,15 @@ num_faces(const CGAL::Polyhedron_3& p) return p.size_of_facets(); } - +template +void +reserve(CGAL::Polyhedron_3& p, + typename boost::graph_traits< CGAL::Polyhedron_3 >::vertices_size_type nv, + typename boost::graph_traits< CGAL::Polyhedron_3 >::edges_size_type ne, + typename boost::graph_traits< CGAL::Polyhedron_3 >::faces_size_type nf) +{ + p.reserve(nv, 2*ne, nf); +} template bool is_valid(const CGAL::Polyhedron_3& p, bool verbose = false) diff --git a/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h b/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h index 8e2a5986e9f..575c6650dc9 100644 --- a/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h +++ b/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h @@ -414,7 +414,7 @@ num_faces(const CGAL::Surface_mesh

      & sm) { return sm.num_faces(); } - + template Iterator_range >::face_iterator> faces(const CGAL::Surface_mesh

      & sm) @@ -435,23 +435,17 @@ add_vertex(const typename boost::graph_traits >::vertex_pr return sm.add_vertex(p); } -/* // MutableGraph -// add a vertex with a default constructed property -template -typename boost::graph_traits >::vertex_descriptor -add_vertex(CGAL::Surface_mesh

      & sm) { - return sm.add_vertex(typename boost::graph_traits >::vertex_property_type()); -} - -template +template void -clear_vertex(typename boost::graph_traits >::vertex_descriptor, - CGAL::Surface_mesh

      &) { - CGAL_assertion(false); +reserve(CGAL::Surface_mesh

      & sm, + typename boost::graph_traits< CGAL::Surface_mesh

      >::vertices_size_type nv, + typename boost::graph_traits< CGAL::Surface_mesh

      >::edges_size_type ne, + typename boost::graph_traits< CGAL::Surface_mesh

      >::faces_size_type nf) +{ + sm.reserve(nv, ne, nf); } - */ template void