Skip to content

Commit

Permalink
Merge branch 'develop' into exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dsieger committed Aug 17, 2020
2 parents a60e3e1 + a8b4454 commit 5ba98fc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,9 @@ This project aims to adhere to [Semantic Versioning](https://semver.org/spec/v2.

## 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!
- Add PMP_INSTALL option to CMake.

## [1.2.1] 2020-05-10
Expand Down
58 changes: 58 additions & 0 deletions src/pmp/SurfaceMesh.h
Expand Up @@ -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--()
{
Expand Down Expand Up @@ -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--()
{
Expand Down Expand Up @@ -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--()
{
Expand Down Expand Up @@ -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--()
{
Expand Down Expand Up @@ -1786,6 +1818,8 @@ class SurfaceMesh
};

//!@}

public:
//! \name Allocate new elements
//!@{

Expand All @@ -1805,6 +1839,28 @@ class SurfaceMesh

//! \brief Allocate a new edge, resize edge and halfedge properties accordingly.
//! \throw AllocationException in case of failure to allocate a new edge.
Halfedge new_edge()
{
if (halfedges_size() == PMP_MAX_INDEX - 1)
{
auto what = "SurfaceMesh: cannot allocate edge, max. index reached";
throw AllocationException(what);
}

eprops_.push_back();
hprops_.push_back();
hprops_.push_back();

Halfedge h0(halfedges_size() - 2);
Halfedge h1(halfedges_size() - 1);

return h0;
}

//! \brief Allocate a new edge, resize edge and halfedge properties accordingly.
//! \throw AllocationException in case of failure to allocate a new edge.
//! \param start starting Vertex of the new edge
//! \param end end Vertex of the new edge
Halfedge new_edge(Vertex start, Vertex end)
{
assert(start != end);
Expand Down Expand Up @@ -1843,6 +1899,8 @@ class SurfaceMesh
}

//!@}

private:
//! \name Helper functions
//!@{

Expand Down

0 comments on commit 5ba98fc

Please sign in to comment.