From 2ec7520d9677cd312dbfafd07d4afc1b7962e38e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 5 Aug 2025 15:36:01 +0100 Subject: [PATCH] BGL: Add Face_around_face_circulator --- BGL/include/CGAL/boost/graph/iterator.h | 49 ++++++++++++++++++++++++- BGL/test/BGL/test_circulator.cpp | 10 +++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/iterator.h b/BGL/include/CGAL/boost/graph/iterator.h index cef4a913cad..e26d7892cbd 100644 --- a/BGL/include/CGAL/boost/graph/iterator.h +++ b/BGL/include/CGAL/boost/graph/iterator.h @@ -871,7 +871,54 @@ private: */ template class Face_around_face_circulator -{}; +#ifndef DOXYGEN_RUNNING + : public boost::iterator_adaptor< + Face_around_face_circulator // Derived + , Halfedge_around_face_circulator // Base + , typename boost::graph_traits::face_descriptor // Value + , Bidirectional_circulator_tag // CategoryOrTraversal + , typename boost::graph_traits::face_descriptor // Reference + > +#endif +{ + internal::Opposite_face fct; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + +public: +#ifndef DOXYGEN_RUNNING + typedef std::size_t size_type; +#endif + + Face_around_face_circulator() + {} + + Face_around_face_circulator(halfedge_descriptor h, const Graph& g) + : Face_around_face_circulator::iterator_adaptor_(Halfedge_around_face_circulator(h,g)), fct(g) + {} + +#ifndef DOXYGEN_RUNNING + + explicit operator bool() const + { + return (! (this->base_reference() == nullptr)); + } + + bool operator== (void*) const + { + return this->base_reference()== nullptr; + } + + bool operator!= (void*) const + { + return this->base_reference()!= nullptr; + } + +private: + friend class boost::iterator_core_access; + typename boost::graph_traits::face_descriptor dereference() const { return fct(*this->base_reference()); } +#endif + +}; /** * \ingroup PkgBGLIterators diff --git a/BGL/test/BGL/test_circulator.cpp b/BGL/test/BGL/test_circulator.cpp index cd0a18cbbe4..58c56bbd6df 100644 --- a/BGL/test/BGL/test_circulator.cpp +++ b/BGL/test/BGL/test_circulator.cpp @@ -18,6 +18,7 @@ typedef GraphTraits::edge_descriptor edge_descriptor; typedef GraphTraits::out_edge_iterator out_edge_iterator; typedef GraphTraits::in_edge_iterator in_edge_iterator; +typedef CGAL::Face_around_face_circulator face_around_face_circulator; typedef CGAL::Halfedge_around_face_circulator halfedge_around_face_circulator; typedef CGAL::Halfedge_around_target_circulator halfedge_around_target_circulator; typedef CGAL::Vertex_around_target_circulator vertex_around_target_circulator; @@ -32,6 +33,7 @@ typedef CGAL::Vertex_around_target_iterator vertex_around_target_ite int main(int argc, char* argv[]) { + BOOST_CONCEPT_ASSERT((CGAL::Concepts::BidirectionalCirculator)); BOOST_CONCEPT_ASSERT((CGAL::Concepts::BidirectionalCirculator)); BOOST_CONCEPT_ASSERT((CGAL::Concepts::BidirectionalCirculator)); BOOST_CONCEPT_ASSERT((CGAL::Concepts::BidirectionalCirculator)); @@ -62,6 +64,14 @@ int main(int argc, char* argv[]) }while(hafc != done); } + { + face_around_face_circulator fafc(hd,P), done(fafc); + + do { + ++fafc; + }while(fafc != done); + } + { halfedge_around_target_circulator havc(hd,P), done(havc); vertex_descriptor vd = target(hd,P);