Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Sep 18, 2024
1 parent 75e37f4 commit 859c809
Show file tree
Hide file tree
Showing 8 changed files with 1,919 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <boost/assert.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ptr_container/serialize_ptr_vector.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/serialization/base_object.hpp>
#include <vector>

Expand Down Expand Up @@ -241,6 +242,31 @@ class SFCGAL_API Polygon : public Surface {
BOOST_ASSERT(ls != NULL);
_rings.push_back(ls);
}
/**
* Remove all interior rings
*/
inline void
removeInteriorRings()
{
if (_rings.size() > 1) {
_rings.erase(_rings.begin() + 1, _rings.end());
}
}

/**
* Remove the n-th interior ring
* @param n index of the interior ring to remove (0-based)
* @throws std::out_of_range if n is greater than or equal to the number of
* interior rings
*/
inline void
removeInteriorRingN(size_t n)
{
if (n >= numInteriorRings()) {
throw std::out_of_range("Interior ring index out of range");
}
_rings.erase(_rings.begin() + n + 1);
}

inline iterator
begin()
Expand Down Expand Up @@ -300,6 +326,34 @@ class SFCGAL_API Polygon : public Surface {
ar &_rings;
}

/**
* Returns a const iterator to the first interior ring
*/
inline const_iterator
interiorRings_begin() const
{
return _rings.size() > 1 ? _rings.begin() + 1 : _rings.end();
}

/**
* Returns a const iterator to the end of interior rings
*/
inline const_iterator
interiorRings_end() const
{
return _rings.end();
}

/**
* Returns a const range of interior rings
*/
inline boost::iterator_range<const_iterator>
interiorRings() const
{
return boost::make_iterator_range(interiorRings_begin(),
interiorRings_end());
}

private:
/**
* rings forming the polygon (size() >= 1)
Expand Down
22 changes: 22 additions & 0 deletions src/Solid.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@ class SFCGAL_API Solid : public Geometry {
return _shells[n];
}

/**
* Remove all interior shells
*/
inline void
removeInteriorShells()
{
if (_shells.size() > 1) {
_shells.erase(_shells.begin() + 1, _shells.end());
}
}

/**
* Remove the n-th interior shell
*/
inline void
removeInteriorShellN(size_t const &n)
{
if (n < numInteriorShells()) {
_shells.erase(_shells.begin() + n + 1);
}
}

//-- iterators

inline iterator
Expand Down
Loading

0 comments on commit 859c809

Please sign in to comment.