diff --git a/BGL/doc/BGL/Doxyfile.in b/BGL/doc/BGL/Doxyfile.in index b17cf50fe55..95aa22e39c6 100644 --- a/BGL/doc/BGL/Doxyfile.in +++ b/BGL/doc/BGL/Doxyfile.in @@ -8,7 +8,7 @@ INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Euler_operations.h \ ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/split_graph_into_polylines.h \ ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/copy_face_graph.h \ ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Graph_with_descriptor_with_graph.h \ - ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Connected_components_graph.h \ + ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Face_filtered_graph.h \ ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Dual.h \ ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h EXAMPLE_PATH = ${CGAL_Surface_mesh_skeletonization_EXAMPLE_DIR} \ diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index b4cdfa3bde6..3120cb99902 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -316,7 +316,7 @@ user might encounter. - `CGAL::Dual` - `CGAL::Graph_with_descriptor_with_graph` - `CGAL::Graph_with_descriptor_with_graph_property_map` -- `CGAL::Connected_components_graph` +- `CGAL::Face_filtered_graph` ## Helper Functions ## - `CGAL::is_border()` diff --git a/BGL/include/CGAL/boost/graph/Connected_components_graph.h b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h similarity index 63% rename from BGL/include/CGAL/boost/graph/Connected_components_graph.h rename to BGL/include/CGAL/boost/graph/Face_filtered_graph.h index 4ffc7f618a6..53e38049f28 100644 --- a/BGL/include/CGAL/boost/graph/Connected_components_graph.h +++ b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h @@ -16,8 +16,8 @@ // // // Author(s) : Maxime Gimeno -#ifndef CGAL_BOOST_GRAPH_CONNECTED_COMPONENTS_GRAPH_H -#define CGAL_BOOST_GRAPH_CONNECTED_COMPONENTS_GRAPH_H +#ifndef CGAL_BOOST_GRAPH_FACE_FILTERED_GRAPH_H +#define CGAL_BOOST_GRAPH_FACE_FILTERED_GRAPH_H #include #include @@ -37,10 +37,14 @@ namespace CGAL /*! * \ingroup PkgBGLHelper * - * The class `Connected_components_graph` wraps a graph into another graph in such a way that only the specified connected components are seen from the outside. + * The class `Face_filtered_graph` wraps a graph into another graph and act like a mask. It assigns a patch id to each face + * and acts in such a way that only the specified patches are seen from the outside. * * For example, calling `vertices(graph)` will provide the range of vertices belonging to the selected components. * + * The `Face_filtered_graph` enables to either consider each patch independently or a union of some of these patches. + * Such a union of patches must define a manifold mesh. + * * \tparam Graph must be a model of a `FaceListGraph` and `HalfedgeListGraph`. * \tparam FIMap a model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key and `graph_traits::%faces_size_type` as value * \tparam VIMap a model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key and `graph_traits::%vertices_size_type` as value @@ -53,7 +57,7 @@ template::type, typename VIMap = typename boost::property_map::type, typename HIMap = typename boost::property_map::type> -struct Connected_components_graph +struct Face_filtered_graph { typedef boost::graph_traits gt; typedef typename gt::vertex_descriptor vertex_descriptor; @@ -63,7 +67,7 @@ struct Connected_components_graph typedef typename boost::property_traits< FIMap >::value_type face_index_type; typedef typename boost::property_traits< VIMap >::value_type vertex_index_type; typedef typename boost::property_traits< HIMap >::value_type halfedge_index_type; - typedef Connected_components_graph Self; + typedef Face_filtered_graph Self; template void base_iterator_constructor(IndexRangeIterator begin, @@ -94,6 +98,7 @@ struct Connected_components_graph } } } + CGAL_assertion(is_selection_valid()); } template @@ -116,9 +121,10 @@ struct Connected_components_graph } } } + CGAL_assertion(is_selection_valid()); } /*! - * \brief Creates a Connected_components_graph of the connected components of `graph` specified in the range + * \brief Creates a Face_filtered_graph of the patches of `graph` specified in the range * defined by `begin` and `end`. * \tparam FaceComponentMap a model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and @@ -126,11 +132,11 @@ struct Connected_components_graph * \tparam IndexRangeIterator an iterator of a range of `boost::property_traits::%value_type`. * \param graph the graph containing the wanted patches. - * \param fcmap the property_map that assigns a connected component to each face, with + * \param fcmap the property_map that assigns a patch to each face, with `boost::graph_traits::%face_descriptor` as key type and `graph_traits::%faces_size_type` as value type. - * \param begin an interator to the beginning of a range of connected components indices of interest. - * \param end an interator to the element past the end of a range of connected components indices of interest. + * \param begin an interator to the beginning of a range of patches indices of interest. + * \param end an interator to the element past the end of a range of patches indices of interest. * \param fimap the property map that assigns an index to each face, * with boost::graph_traits::%face_descriptor as key type and boost::graph_traits::%faces_size_type as value type * \param vimap the property map that assigns an index to each vertex, @@ -140,7 +146,7 @@ struct Connected_components_graph */ template - Connected_components_graph(const Graph& graph, + Face_filtered_graph(const Graph& graph, FaceComponentMap fcmap, IndexRangeIterator begin, IndexRangeIterator end, @@ -160,7 +166,7 @@ struct Connected_components_graph } template - Connected_components_graph(const Graph& graph, + Face_filtered_graph(const Graph& graph, FaceComponentMap fcmap, IndexRangeIterator begin, IndexRangeIterator end) @@ -172,16 +178,16 @@ struct Connected_components_graph base_iterator_constructor(begin, end, fcmap); } /*! - * \brief Creates a Connected_components_graph of the connected component `pid` of `graph`. + * \brief Creates a Face_filtered_graph of the patch `pid` of `graph`. * * \tparam FaceComponentMap a model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and `graph_traits::%faces_size_type` as value type. * \param graph the graph containing the wanted patch. - * \param fcmap the property_map that assigns a connected component's index to each face, with + * \param fcmap the property_map that assigns a patch's index to each face, with `boost::graph_traits::%face_descriptor` as key type and `graph_traits::%faces_size_type` as value type. - * \param pid the index of the connected component of interest. + * \param pid the index of the patch of interest. * \param fimap the property map that assigns an index to each face, * with boost::graph_traits::%face_descriptor as key type and boost::graph_traits::%faces_size_type as value type * \param vimap the property map that assigns an index to each vertex, @@ -190,7 +196,7 @@ struct Connected_components_graph * with boost::graph_traits::%halfedge_descriptor as key type and boost::graph_traits::%halfedges_size_type as value type */ template - Connected_components_graph(const Graph& graph, + Face_filtered_graph(const Graph& graph, FaceComponentMap fcmap, typename boost::property_traits::value_type pid, #ifdef DOXYGEN_RUNNING @@ -209,7 +215,7 @@ struct Connected_components_graph } template - Connected_components_graph(const Graph& graph, + Face_filtered_graph(const Graph& graph, FaceComponentMap fcmap, typename boost::property_traits::value_type pid) : _graph(const_cast(graph)) @@ -219,9 +225,9 @@ struct Connected_components_graph himap = get(CGAL::halfedge_index, graph); base_constructor(fcmap, pid); } - ///returns a const reference to the graph of the Connected_components_graph. + ///returns a const reference to the graph of the Face_filtered_graph. const Graph& graph()const{ return _graph; } - ///returns a reference to the graph of the Connected_components_graph. + ///returns a reference to the graph of the Face_filtered_graph. Graph& graph(){ return _graph; } ///change the selected component @@ -233,6 +239,7 @@ struct Connected_components_graph vertex_indices.clear(); halfedge_indices.clear(); base_constructor(fcmap, pid); + CGAL_assertion(is_selection_valid()); } /// change the selected components template @@ -244,6 +251,7 @@ struct Connected_components_graph vertex_indices.clear(); halfedge_indices.clear(); base_iterator_constructor(begin, end, fcmap); + CGAL_assertion(is_selection_valid()); } struct Is_simplex_valid { @@ -277,19 +285,19 @@ struct Connected_components_graph { return halfedge_patch[get(himap, h)]; } - ///returns the number of faces contained in the specified connected components + ///returns the number of faces contained in the specified patches typename boost::graph_traits:: faces_size_type number_of_faces()const { return face_patch.count(); } -///returns the number of vertices contained in the specified connected components +///returns the number of vertices contained in the specified patches typename boost::graph_traits:: vertices_size_type number_of_vertices()const { return vertex_patch.count(); } -///returns the number of halfedges contained in the specified connected components +///returns the number of halfedges contained in the specified patches typename boost::graph_traits:: halfedges_size_type number_of_halfedges()const { @@ -341,6 +349,70 @@ struct Connected_components_graph return bind_property_maps(himap, make_property_map(halfedge_indices) ); } + ///returns true if around each vertex of the `Face_filtered_graph`, + /// there is only one set of selected faces. In other words, returns true + /// if all the selected faces around a vertex are consecutive. + bool is_selection_valid() + { + BOOST_FOREACH(vertex_descriptor vd, vertices(*this) ) + { + face_descriptor first_selected = boost::graph_traits::null_face(); + bool first_unselected_found(false), + second_unselected_found(false); + + //find an unselected face, then find the first selected face. + //Find another unselected face, the next selected face must be the first; + //else this is not valid. + halfedge_descriptor hd = halfedge(vd, _graph); + face_descriptor first_tested = boost::graph_traits::null_face(); + while(1) //will break if valid, return false if not valid + { + face_descriptor fd = face(hd, _graph); + + if(first_tested == boost::graph_traits::null_face()) + first_tested = fd; + else if(fd == first_tested ) + { + //if there is no unselected face, break + if(face_patch[get(fimap, fd)] && !first_unselected_found) + break; + //if there is no selected face, break + else if(!face_patch[get(fimap, fd)] && + first_selected == boost::graph_traits::null_face()) + break; + } + + if(fd != boost::graph_traits::null_face()) + { + if(face_patch[get(fimap, fd)]) + { + if(first_unselected_found && + first_selected == boost::graph_traits::null_face()) + { + first_selected = fd; + } + else if(second_unselected_found) + { + if(fd == first_selected) + break; + else + return false; + } + } + else + { + if(first_selected == boost::graph_traits::null_face()) + first_unselected_found = true; + else + second_unselected_found = true; + } + } + hd = next(opposite(hd, _graph), _graph); + } + } + return true; + } + private: Graph& _graph; FIMap fimap; @@ -363,9 +435,9 @@ template -struct graph_traits< CGAL::Connected_components_graph > +struct graph_traits< CGAL::Face_filtered_graph > { - typedef CGAL::Connected_components_graph G; + typedef CGAL::Face_filtered_graph G; typedef boost::graph_traits BGTG; typedef typename BGTG::vertex_descriptor vertex_descriptor; typedef typename BGTG::halfedge_descriptor halfedge_descriptor; @@ -414,8 +486,8 @@ template -struct graph_traits< const CGAL::Connected_components_graph > - : public graph_traits< CGAL::Connected_components_graph > +struct graph_traits< const CGAL::Face_filtered_graph > + : public graph_traits< CGAL::Face_filtered_graph > {}; @@ -428,8 +500,8 @@ template bool -in_CC(const typename boost::graph_traits< Connected_components_graph >::face_descriptor f, - const Connected_components_graph & w) +in_CC(const typename boost::graph_traits< Face_filtered_graph >::face_descriptor f, + const Face_filtered_graph & w) { return w.is_in_cc(f); } @@ -439,8 +511,8 @@ template bool -in_CC(const typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +in_CC(const typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { return w.is_in_cc(h); } @@ -450,8 +522,8 @@ template bool -in_CC(const typename boost::graph_traits< Connected_components_graph >::edge_descriptor e, - const Connected_components_graph & w) +in_CC(const typename boost::graph_traits< Face_filtered_graph >::edge_descriptor e, + const Face_filtered_graph & w) { return w.is_in_cc(halfedge(e, w.graph())); } @@ -461,8 +533,8 @@ template bool -in_CC(const typename boost::graph_traits< Connected_components_graph >::vertex_descriptor v, - const Connected_components_graph & w) +in_CC(const typename boost::graph_traits< Face_filtered_graph >::vertex_descriptor v, + const Face_filtered_graph & w) { return w.is_in_cc(v); } @@ -473,7 +545,7 @@ template typename boost::graph_traits::vertices_size_type -num_vertices(const Connected_components_graph& w) +num_vertices(const Face_filtered_graph& w) { return w.number_of_vertices(); } @@ -483,7 +555,7 @@ template typename boost::graph_traits::edges_size_type -num_edges(const Connected_components_graph& w) +num_edges(const Face_filtered_graph& w) { return w.number_of_halfedges()/2; } @@ -493,13 +565,13 @@ template typename boost::graph_traits::degree_size_type -degree(typename boost::graph_traits >::vertex_descriptor v, - const Connected_components_graph& w) +degree(typename boost::graph_traits >::vertex_descriptor v, + const Face_filtered_graph& w) { CGAL_assertion(in_CC(v, w)); typename boost::graph_traits::degree_size_type v_deg = 0; - typename boost::graph_traits >::halfedge_descriptor h = halfedge(v, w); - typename boost::graph_traits >::halfedge_descriptor hcirc = h; + typename boost::graph_traits >::halfedge_descriptor h = halfedge(v, w); + typename boost::graph_traits >::halfedge_descriptor hcirc = h; do { if(in_CC(hcirc, w)) @@ -514,8 +586,8 @@ template typename boost::graph_traits::degree_size_type -out_degree(typename boost::graph_traits >::vertex_descriptor v, - const Connected_components_graph& w) +out_degree(typename boost::graph_traits >::vertex_descriptor v, + const Face_filtered_graph& w) { CGAL_assertion(in_CC(v, w)); return std::distance(out_edges(v, w).first ,out_edges(v, w).second); @@ -526,8 +598,8 @@ template typename boost::graph_traits::degree_size_type -in_degree(typename boost::graph_traits >::vertex_descriptor v, - const Connected_components_graph& w) +in_degree(typename boost::graph_traits >::vertex_descriptor v, + const Face_filtered_graph& w) { CGAL_assertion(in_CC(v, w)); return std::distance(in_edges(v, w).first ,in_edges(v, w).second); @@ -537,9 +609,9 @@ template -typename boost::graph_traits >::vertex_descriptor -source(typename boost::graph_traits >::edge_descriptor e, - const Connected_components_graph & w) +typename boost::graph_traits >::vertex_descriptor +source(typename boost::graph_traits >::edge_descriptor e, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(e, w)); return source(e, w.graph()); @@ -549,9 +621,9 @@ template -typename boost::graph_traits >::vertex_descriptor -target(typename boost::graph_traits >::edge_descriptor e, - const Connected_components_graph & w) +typename boost::graph_traits >::vertex_descriptor +target(typename boost::graph_traits >::edge_descriptor e, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(e, w)); return target(e, w.graph()); @@ -561,13 +633,13 @@ template -std::pair >::edge_descriptor, bool> -edge(typename boost::graph_traits >::vertex_descriptor u, - typename boost::graph_traits >::vertex_descriptor v, - const Connected_components_graph & w) +std::pair >::edge_descriptor, bool> +edge(typename boost::graph_traits >::vertex_descriptor u, + typename boost::graph_traits >::vertex_descriptor v, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(u, w) && in_CC(v, w)); - typename boost::graph_traits >::edge_descriptor e = edge(u, v, w.graph()).first; + typename boost::graph_traits >::edge_descriptor e = edge(u, v, w.graph()).first; bool res = in_CC(e, w); return std::make_pair(e, res); } @@ -577,13 +649,13 @@ template -CGAL::Iterator_range >::vertex_iterator> -vertices(const Connected_components_graph & w) +CGAL::Iterator_range >::vertex_iterator> +vertices(const Face_filtered_graph & w) { - typedef typename boost::graph_traits >::vertex_iterator vertex_iterator; + typedef typename boost::graph_traits >::vertex_iterator vertex_iterator; typedef typename boost::graph_traits::vertex_iterator g_vertex_iterator; - typename Connected_components_graph ::Is_simplex_valid predicate(&w); + typename Face_filtered_graph ::Is_simplex_valid predicate(&w); g_vertex_iterator b,e; boost::tie(b,e) = vertices(w.graph()); return make_range(vertex_iterator(predicate, b, e), @@ -594,13 +666,13 @@ template -CGAL::Iterator_range >::edge_iterator> -edges(const Connected_components_graph & w) +CGAL::Iterator_range >::edge_iterator> +edges(const Face_filtered_graph & w) { - typedef typename boost::graph_traits >::edge_iterator edge_iterator; + typedef typename boost::graph_traits >::edge_iterator edge_iterator; typedef typename boost::graph_traits::edge_iterator g_edge_iterator; - typename Connected_components_graph ::Is_simplex_valid predicate(&w); + typename Face_filtered_graph ::Is_simplex_valid predicate(&w); g_edge_iterator b,e; boost::tie(b,e) = edges(w.graph()); return make_range(edge_iterator(predicate, b, e), @@ -611,15 +683,15 @@ template -CGAL::Iterator_range >::out_edge_iterator> -out_edges(typename boost::graph_traits >::vertex_descriptor v, - const Connected_components_graph & w) +CGAL::Iterator_range >::out_edge_iterator> +out_edges(typename boost::graph_traits >::vertex_descriptor v, + const Face_filtered_graph & w) { - typedef typename boost::graph_traits >::out_edge_iterator out_edge_iterator; + typedef typename boost::graph_traits >::out_edge_iterator out_edge_iterator; typedef typename boost::graph_traits::out_edge_iterator g_out_edge_iterator; - typename Connected_components_graph ::Is_simplex_valid predicate(&w); + typename Face_filtered_graph ::Is_simplex_valid predicate(&w); g_out_edge_iterator b,e; boost::tie(b,e) = out_edges(v, w.graph()); return make_range(out_edge_iterator(predicate, b, e), @@ -630,15 +702,15 @@ template -CGAL::Iterator_range >::in_edge_iterator> -in_edges(typename boost::graph_traits >::vertex_descriptor v, - const Connected_components_graph & w) +CGAL::Iterator_range >::in_edge_iterator> +in_edges(typename boost::graph_traits >::vertex_descriptor v, + const Face_filtered_graph & w) { - typedef typename boost::graph_traits >::in_edge_iterator in_edge_iterator; + typedef typename boost::graph_traits >::in_edge_iterator in_edge_iterator; typedef typename boost::graph_traits::in_edge_iterator g_in_edge_iterator; - typename Connected_components_graph ::Is_simplex_valid predicate(&w); + typename Face_filtered_graph ::Is_simplex_valid predicate(&w); g_in_edge_iterator b,e; boost::tie(b,e) = in_edges(v, w.graph()); return make_range(in_edge_iterator(predicate, b, e), @@ -652,9 +724,9 @@ template -typename boost::graph_traits< Connected_components_graph >::edge_descriptor -edge(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::edge_descriptor +edge(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(CGAL::in_CC(h, w)); return edge(h, w.graph()); @@ -664,9 +736,9 @@ template -typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor -halfedge(typename boost::graph_traits< Connected_components_graph >::edge_descriptor e, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor +halfedge(typename boost::graph_traits< Face_filtered_graph >::edge_descriptor e, + const Face_filtered_graph & w) { CGAL_assertion(CGAL::in_CC(e, w)); return halfedge(e, w.graph()); @@ -676,20 +748,20 @@ template -typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor -halfedge(typename boost::graph_traits< Connected_components_graph >::vertex_descriptor v, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor +halfedge(typename boost::graph_traits< Face_filtered_graph >::vertex_descriptor v, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(v, w)); - typename boost::graph_traits >::halfedge_descriptor h = halfedge(v, w.graph()); - typename boost::graph_traits >::halfedge_descriptor hcirc = h; + typename boost::graph_traits >::halfedge_descriptor h = halfedge(v, w.graph()); + typename boost::graph_traits >::halfedge_descriptor hcirc = h; do { if(in_CC(hcirc, w)) return hcirc; hcirc = opposite(next(hcirc, w.graph()), w.graph()); }while(hcirc != h); - return boost::graph_traits< CGAL::Connected_components_graph >::null_halfedge(); + return boost::graph_traits< CGAL::Face_filtered_graph >::null_halfedge(); } @@ -697,13 +769,13 @@ template -std::pair >::halfedge_descriptor, bool> -halfedge(typename boost::graph_traits< Connected_components_graph >::vertex_descriptor u, - typename boost::graph_traits< Connected_components_graph >::vertex_descriptor v, - const Connected_components_graph & w) +std::pair >::halfedge_descriptor, bool> +halfedge(typename boost::graph_traits< Face_filtered_graph >::vertex_descriptor u, + typename boost::graph_traits< Face_filtered_graph >::vertex_descriptor v, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(u, w) && in_CC(v, w)); - typename boost::graph_traits >::halfedge_descriptor h = halfedge(u, v, w.graph()).first; + typename boost::graph_traits >::halfedge_descriptor h = halfedge(u, v, w.graph()).first; return std::make_pair(h, in_CC(h, w)); } @@ -712,9 +784,9 @@ template -typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor -opposite(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor +opposite(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(h, w) ); return opposite(h, w.graph()); @@ -724,9 +796,9 @@ template -typename boost::graph_traits< Connected_components_graph >::vertex_descriptor -source(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::vertex_descriptor +source(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(h, w) ); return source(h, w.graph()); @@ -736,9 +808,9 @@ template -typename boost::graph_traits< Connected_components_graph >::vertex_descriptor -target(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::vertex_descriptor +target(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(h, w) ); return target(h, w.graph()); @@ -748,15 +820,15 @@ template -typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor -next(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor +next(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(h, w)); if(in_CC(next(h, w.graph()), w)) return next(h, w.graph()); //act as a border - typedef typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h_d; + typedef typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h_d; BOOST_FOREACH( h_d hcirc, CGAL::halfedges_around_target(target(h, w.graph()), w.graph())) { @@ -765,16 +837,16 @@ next(typename boost::graph_traits< Connected_components_graph >::null_halfedge(); + return boost::graph_traits< CGAL::Face_filtered_graph >::null_halfedge(); } template -typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor -prev(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor +prev(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(in_CC(h, w)); @@ -782,7 +854,7 @@ prev(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h_d; + typedef typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h_d; BOOST_FOREACH(h_d hcirc, CGAL::halfedges_around_source(source(h, w.graph()), w.graph())) { @@ -791,7 +863,7 @@ prev(typename boost::graph_traits< Connected_components_graph >::null_halfedge(); + return boost::graph_traits< CGAL::Face_filtered_graph >::null_halfedge(); } // @@ -802,14 +874,14 @@ template -std::pair >::halfedge_iterator, -typename boost::graph_traits >::halfedge_iterator> -halfedges(const Connected_components_graph & w) +std::pair >::halfedge_iterator, +typename boost::graph_traits >::halfedge_iterator> +halfedges(const Face_filtered_graph & w) { - typedef typename boost::graph_traits >::halfedge_iterator halfedge_iterator; + typedef typename boost::graph_traits >::halfedge_iterator halfedge_iterator; typedef typename boost::graph_traits::halfedge_iterator g_halfedge_iterator; - typename Connected_components_graph ::Is_simplex_valid predicate(&w); + typename Face_filtered_graph ::Is_simplex_valid predicate(&w); std::pair original_halfedges = halfedges(w.graph()); return make_range(halfedge_iterator(predicate, original_halfedges.first, original_halfedges.second), @@ -822,7 +894,7 @@ template typename boost::graph_traits::halfedges_size_type -num_halfedges(const Connected_components_graph & w) +num_halfedges(const Face_filtered_graph & w) { return w.number_of_halfedges(); } @@ -832,24 +904,24 @@ template -typename boost::graph_traits< Connected_components_graph >::face_descriptor -face(typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor h, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::face_descriptor +face(typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor h, + const Face_filtered_graph & w) { CGAL_assertion(CGAL::in_CC(h, w)); if(in_CC(face(h,w.graph()), w)) return face(h,w.graph()); else - return boost::graph_traits< CGAL::Connected_components_graph >::null_face(); + return boost::graph_traits< CGAL::Face_filtered_graph >::null_face(); } template -typename boost::graph_traits< Connected_components_graph >::halfedge_descriptor -halfedge(typename boost::graph_traits< Connected_components_graph >::face_descriptor f, - const Connected_components_graph & w) +typename boost::graph_traits< Face_filtered_graph >::halfedge_descriptor +halfedge(typename boost::graph_traits< Face_filtered_graph >::face_descriptor f, + const Face_filtered_graph & w) { CGAL_assertion(CGAL::in_CC(f, w)); return halfedge(f,w.graph()); @@ -860,13 +932,13 @@ template -Iterator_range >::face_iterator> -faces(const Connected_components_graph & w) +Iterator_range >::face_iterator> +faces(const Face_filtered_graph & w) { - typedef typename boost::graph_traits >::face_iterator face_iterator; + typedef typename boost::graph_traits >::face_iterator face_iterator; typedef typename boost::graph_traits::face_iterator g_face_iterator; - typename Connected_components_graph ::Is_simplex_valid predicate(&w); + typename Face_filtered_graph ::Is_simplex_valid predicate(&w); std::pair original_faces = faces(w.graph()); return make_range(face_iterator(predicate, original_faces.first, original_faces.second), @@ -880,7 +952,7 @@ template typename boost::graph_traits::vertices_size_type -num_faces(const Connected_components_graph & w) +num_faces(const Face_filtered_graph & w) { return w.number_of_faces(); } @@ -891,7 +963,7 @@ template bool -in_CC(const Connected_components_graph & w, bool verbose = false) +in_CC(const Face_filtered_graph & w, bool verbose = false) { return in_CC(w.graph(),verbose); } @@ -902,7 +974,7 @@ template typename boost::property_map::const_type -get(PropertyTag ptag, const Connected_components_graph& w) +get(PropertyTag ptag, const Face_filtered_graph& w) { return get(ptag, w.graph()); } @@ -913,7 +985,7 @@ template typename boost::property_map::type -get(PropertyTag ptag, Connected_components_graph& w) +get(PropertyTag ptag, Face_filtered_graph& w) { return get(ptag, w.graph()); } @@ -923,8 +995,8 @@ template -typename boost::property_map, CGAL::face_index_t >::type -get(CGAL::face_index_t, const Connected_components_graph& w) +typename boost::property_map, CGAL::face_index_t >::type +get(CGAL::face_index_t, const Face_filtered_graph& w) { return w.get_face_index_map(); } @@ -934,8 +1006,8 @@ template -typename boost::property_map, boost::vertex_index_t >::type -get(boost::vertex_index_t, const Connected_components_graph& w) +typename boost::property_map, boost::vertex_index_t >::type +get(boost::vertex_index_t, const Face_filtered_graph& w) { return w.get_vertex_index_map(); } @@ -945,8 +1017,8 @@ template -typename boost::property_map, CGAL::halfedge_index_t >::type -get(CGAL::halfedge_index_t, const Connected_components_graph& w) +typename boost::property_map, CGAL::halfedge_index_t >::type +get(CGAL::halfedge_index_t, const Face_filtered_graph& w) { return w.get_halfedge_index_map(); } @@ -959,7 +1031,7 @@ template typename boost::property_traits::type>::value_type get(PropertyTag ptag, - const Connected_components_graph& w, + const Face_filtered_graph& w, const typename boost::property_traits::type>::key_type& k) { return get(ptag, w.graph(), k); @@ -972,7 +1044,7 @@ template void -put(PropertyTag ptag, const Connected_components_graph& w, +put(PropertyTag ptag, const Face_filtered_graph& w, const typename boost::property_traits::type>::key_type& k, typename boost::property_traits::type>::value_type& v) { @@ -987,7 +1059,7 @@ template -struct property_map,PropertyTag> { +struct property_map,PropertyTag> { typedef typename boost::property_map::type type; typedef typename boost::property_map::const_type const_type; }; @@ -997,7 +1069,7 @@ template -struct graph_has_property, PropertyTag> +struct graph_has_property, PropertyTag> : graph_has_property {}; @@ -1006,7 +1078,7 @@ template -struct property_map, CGAL::face_index_t>{ +struct property_map, CGAL::face_index_t>{ typedef typename CGAL::Property_map_binder< FIMap, typename CGAL::Pointer_property_map< typename boost::property_traits< FIMap >::value_type >::type > type; typedef type const_type; @@ -1016,7 +1088,7 @@ template -struct property_map, boost::vertex_index_t>{ +struct property_map, boost::vertex_index_t>{ typedef typename CGAL::Property_map_binder< VIMap, typename CGAL::Pointer_property_map< typename boost::property_traits< VIMap >::value_type >::type > type; typedef type const_type; @@ -1027,10 +1099,10 @@ template -struct property_map, CGAL::halfedge_index_t>{ +struct property_map, CGAL::halfedge_index_t>{ typedef typename CGAL::Property_map_binder< HIMap, typename CGAL::Pointer_property_map< typename boost::property_traits< HIMap >::value_type >::type > type; typedef type const_type; }; }// namespace boost -#endif // CGAL_BOOST_GRAPH_CONNECTED_COMPONENTS_GRAPH_H +#endif // CGAL_BOOST_GRAPH_FACE_FILTERED_GRAPH_H diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index 29beb28785f..8f68e5469d1 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -87,9 +87,9 @@ create_single_source_cgal_program( "test_Has_member_id.cpp" ) create_single_source_cgal_program( "test_cgal_bgl_named_params.cpp" ) -create_single_source_cgal_program( "test_Connected_components_graph.cpp" ) +create_single_source_cgal_program( "test_Face_filtered_graph.cpp" ) -create_single_source_cgal_program( "graph_concept_Connected_components_graph.cpp" ) +create_single_source_cgal_program( "graph_concept_Face_filtered_graph.cpp" ) diff --git a/BGL/test/BGL/graph_concept_Connected_components_graph.cpp b/BGL/test/BGL/graph_concept_Face_filtered_graph.cpp similarity index 91% rename from BGL/test/BGL/graph_concept_Connected_components_graph.cpp rename to BGL/test/BGL/graph_concept_Face_filtered_graph.cpp index 5db6f9a4ab1..ab8957bfb60 100644 --- a/BGL/test/BGL/graph_concept_Connected_components_graph.cpp +++ b/BGL/test/BGL/graph_concept_Face_filtered_graph.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -8,7 +8,7 @@ typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_mesh SM; -typedef CGAL::Connected_components_graph::face_descriptor , std::size_t> > Adapter; +typedef CGAL::Face_filtered_graph::face_descriptor , std::size_t> > Adapter; typedef boost::graph_traits< Adapter > Traits; typedef Traits::edge_descriptor edge_descriptor; typedef Traits::halfedge_descriptor halfedge_descriptor; diff --git a/BGL/test/BGL/test_Connected_components_graph.cpp b/BGL/test/BGL/test_Face_filtered_graph.cpp similarity index 95% rename from BGL/test/BGL/test_Connected_components_graph.cpp rename to BGL/test/BGL/test_Face_filtered_graph.cpp index eb558dce7ca..9bc178a70a7 100644 --- a/BGL/test/BGL/test_Connected_components_graph.cpp +++ b/BGL/test/BGL/test_Face_filtered_graph.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include "test_Prefix.h" @@ -15,7 +15,7 @@ template void test_halfedge_around_vertex_iterator(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); boost::unordered_map map(CGAL::num_faces(g)); CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -43,7 +43,7 @@ template void test_halfedge_around_face_iterator(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -63,7 +63,7 @@ template void test_edge_iterators(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -89,7 +89,7 @@ template void test_vertex_iterators(Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -119,7 +119,7 @@ template void test_out_edges(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -148,7 +148,7 @@ template void test_in_edges(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -175,7 +175,7 @@ template void test_in_out_edges(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -217,7 +217,7 @@ template void test_edge_find(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -241,7 +241,7 @@ template void test_faces(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -267,7 +267,7 @@ template void test_read(const Graph& g) { typedef typename boost::graph_traits::face_descriptor g_face_descriptor; - typedef CGAL::Connected_components_graph Adapter; + typedef CGAL::Face_filtered_graph Adapter; CGAL_GRAPH_TRAITS_MEMBERS(Adapter); std::map map; CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); @@ -397,10 +397,9 @@ void test_mesh(Adapter fga) int main() { - test(sm_data()); //Make a tetrahedron and test the adapter for a patch that only contains 2 faces - typedef typename CGAL::Connected_components_graph SM_Adapter; + typedef typename CGAL::Face_filtered_graph SM_Adapter; typedef SM::Property_map::face_descriptor , std::size_t> SM_FCCMap; SM* sm = new SM(); CGAL::make_tetrahedron( @@ -433,7 +432,7 @@ main() typedef boost::property_map::type FIMap; typedef boost::property_map::type VIMap; typedef boost::property_map::type HIMap; - typedef typename CGAL::Connected_components_graph Poly_Adapter; + typedef typename CGAL::Face_filtered_graph Poly_Adapter; Polyhedron *poly = new Polyhedron(); CGAL::make_tetrahedron( Point_3(1,1,1), diff --git a/Installation/changes.html b/Installation/changes.html index 90a702237ad..f333407b38d 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -181,7 +181,7 @@ and src/ directories).

CGAL and the Boost Graph Library (BGL)

  • - Add class CGAL::Connected_components_graph that + Add class CGAL::Face_filtered_graph that wraps an existing graph and hide all simplices that are not in the selected connected components.
  • diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 07c73d381ad..c87dd1a0a3e 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -607,10 +607,10 @@ the propagation of a connected component index to cross it. \cgalExample{Polygon_mesh_processing/connected_components_example.cpp} -The second example shows how to use the class template `Connected_components_graph` +The second example shows how to use the class template `Face_filtered_graph` which enables to treat one or several connected components as a face graph. -\cgalExample{Polygon_mesh_processing/connected_components_graph_example.cpp} +\cgalExample{Polygon_mesh_processing/face_filtered_graph_example.cpp} \section PMPDistance Approximate Hausdorff Distance diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index ce29168f6d2..3c535ae0ccf 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -7,7 +7,7 @@ \example Polygon_mesh_processing/point_inside_example.cpp \example Polygon_mesh_processing/triangulate_faces_example.cpp \example Polygon_mesh_processing/connected_components_example.cpp -\example Polygon_mesh_processing/connected_components_graph_example.cpp +\example Polygon_mesh_processing/filtered_face_graph_example.cpp \example Polygon_mesh_processing/polygon_soup_example.cpp \example Polygon_mesh_processing/triangulate_polyline_example.cpp \example Polygon_mesh_processing/refine_fair_example.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 32d5286cd26..f45f1a02ba4 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -90,7 +90,7 @@ create_single_source_cgal_program( "compute_normals_example.cpp" CXX_FEATURES cx create_single_source_cgal_program( "point_inside_example.cpp") create_single_source_cgal_program( "triangulate_faces_example.cpp") create_single_source_cgal_program( "connected_components_example.cpp") -create_single_source_cgal_program( "connected_components_graph_example.cpp") +create_single_source_cgal_program( "face_filtered_graph_example.cpp") create_single_source_cgal_program( "polygon_soup_example.cpp") create_single_source_cgal_program( "triangulate_polyline_example.cpp") create_single_source_cgal_program( "mesh_slicer_example.cpp") diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_graph_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/face_filtered_graph_example.cpp similarity index 94% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_graph_example.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/face_filtered_graph_example.cpp index b26bd1aaf90..62ee6c33d28 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_graph_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/face_filtered_graph_example.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -18,7 +18,7 @@ typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::faces_size_type faces_size_type; typedef Mesh::Property_map FCCmap; - typedef CGAL::Connected_components_graph CCG; + typedef CGAL::Face_filtered_graph CCG; namespace PMP = CGAL::Polygon_mesh_processing; diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp index 37ab72c7b97..806f3bb3c71 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -38,7 +38,7 @@ int main(int argc, char** argv ) // Any other scalar values can be used instead of using SDF values computed using the CGAL function std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map); - typedef CGAL::Connected_components_graph Cc_graph; + typedef CGAL::Face_filtered_graph Cc_graph; //print area of each segment and then put it in a Mesh and print it in an OFF file Cc_graph segment_mesh(mesh, segment_property_map, 0); for(std::size_t id = 0; id < number_of_segments; ++id)