From 880555e6573fa137ec9ac5e98365e90eb084a53c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 24 Jun 2020 15:23:26 +0100 Subject: [PATCH 1/3] Add post-increment iterator --- src/pmp/SurfaceMesh.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/pmp/SurfaceMesh.h b/src/pmp/SurfaceMesh.h index 732920c6..61cd1b05 100644 --- a/src/pmp/SurfaceMesh.h +++ b/src/pmp/SurfaceMesh.h @@ -261,6 +261,14 @@ class SurfaceMesh return *this; } + //! post-increment iterator + VertexIterator operator++(int) + { + VertexIterator tmp = *this; + ++(*this); + return tmp; + } + //! pre-decrement iterator VertexIterator& operator--() { @@ -319,6 +327,14 @@ class SurfaceMesh return *this; } + //! post-increment iterator + HalfedgeIterator operator++(int) + { + HalfedgeIterator tmp = *this; + ++(*this); + return tmp; + } + //! pre-decrement iterator HalfedgeIterator& operator--() { @@ -376,6 +392,14 @@ class SurfaceMesh return *this; } + //! post-increment iterator + EdgeIterator operator++(int) + { + EdgeIterator tmp = *this; + ++(*this); + return tmp; + } + //! pre-decrement iterator EdgeIterator& operator--() { @@ -433,6 +457,14 @@ class SurfaceMesh return *this; } + //! post-increment iterator + FaceIterator operator++(int) + { + FaceIterator tmp = *this; + ++(*this); + return tmp; + } + //! pre-decrement iterator FaceIterator& operator--() { From 9f458f4d2078c23a1bb006877ebf2c7601649c5e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 24 Jun 2020 15:36:38 +0100 Subject: [PATCH 2/3] Make Section 'Allocate new elements' public and add function new_edge() --- src/pmp/SurfaceMesh.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pmp/SurfaceMesh.h b/src/pmp/SurfaceMesh.h index 732920c6..56472783 100644 --- a/src/pmp/SurfaceMesh.h +++ b/src/pmp/SurfaceMesh.h @@ -1785,6 +1785,8 @@ class SurfaceMesh }; //!@} + +public: //! \name Allocate new elements //!@{ @@ -1802,6 +1804,26 @@ class SurfaceMesh return Vertex(vertices_size() - 1); } + //! allocate a new edge, resize edge and halfedge properties accordingly. + Halfedge new_edge() + { + if (halfedges_size() == PMP_MAX_INDEX - 1) + { + std::cerr << "new_edge: cannot allocate edge, max. index reached" + << std::endl; + return Halfedge(); + } + + eprops_.push_back(); + hprops_.push_back(); + hprops_.push_back(); + + Halfedge h0(halfedges_size() - 2); + Halfedge h1(halfedges_size() - 1); + + return h0; + } + //! allocate a new edge, resize edge and halfedge properties accordingly. Halfedge new_edge(Vertex start, Vertex end) { @@ -1842,6 +1864,8 @@ class SurfaceMesh } //!@} + +private: //! \name Helper functions //!@{ From a8b4454973274427e2baf3c48fd94001915f4aff Mon Sep 17 00:00:00 2001 From: Daniel Sieger Date: Mon, 17 Aug 2020 12:15:08 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3303a148..7d92316b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project aims to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- Add post-increment iterators and make low level functions to add elements + public. This makes it possible to use CGAL algorithms on a PMP SurfaceMesh. + Thanks to @afabri for contributing the changes! + ## [1.2.1] 2020-05-10 ### Fixed