allow custom start for vih_range and voh_range
This commit is contained in:
@@ -60,6 +60,9 @@
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
namespace OpenMesh {
|
||||
|
||||
template <typename> class CirculatorRange;
|
||||
|
||||
namespace Iterators {
|
||||
|
||||
template<class Mesh, class CenterEntityHandle, bool CW>
|
||||
@@ -192,6 +195,8 @@ class GenericCirculatorBaseT {
|
||||
typedef const Mesh* mesh_ptr;
|
||||
typedef const Mesh& mesh_ref;
|
||||
|
||||
template <typename> friend class OpenMesh::CirculatorRange;
|
||||
|
||||
public:
|
||||
GenericCirculatorBaseT() : mesh_(0), lap_counter_(0) {}
|
||||
|
||||
@@ -267,16 +272,18 @@ class GenericCirculatorT : protected GenericCirculatorBaseT<typename GenericCirc
|
||||
typedef typename GenericCirculatorBaseT<Mesh>::mesh_ref mesh_ref;
|
||||
typedef GenericCirculator_ValueHandleFnsT<Mesh, CenterEntityHandle, value_type, CW> GenericCirculator_ValueHandleFns;
|
||||
|
||||
template <typename> friend class OpenMesh::CirculatorRange;
|
||||
|
||||
public:
|
||||
GenericCirculatorT() {}
|
||||
GenericCirculatorT(mesh_ref mesh, CenterEntityHandle start, bool end = false) :
|
||||
GenericCirculatorBaseT<Mesh>(mesh, mesh.halfedge_handle(start), end) {
|
||||
|
||||
GenericCirculatorBaseT<Mesh>(mesh, mesh.halfedge_handle(start), end)
|
||||
{
|
||||
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_);
|
||||
}
|
||||
GenericCirculatorT(mesh_ref mesh, typename Mesh::HalfedgeHandle heh, bool end = false) :
|
||||
GenericCirculatorBaseT<Mesh>(mesh, heh, end) {
|
||||
|
||||
GenericCirculatorBaseT<Mesh>(mesh, heh, end)
|
||||
{
|
||||
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_);
|
||||
}
|
||||
GenericCirculatorT(const GenericCirculatorT &rhs) : GenericCirculatorBaseT<Mesh>(rhs) {}
|
||||
@@ -440,6 +447,8 @@ class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<typename
|
||||
typedef typename GenericCirculatorBaseT<Mesh>::mesh_ref mesh_ref;
|
||||
typedef GenericCirculator_ValueHandleFnsT_DEPRECATED<Mesh, CenterEntityHandle, value_type> GenericCirculator_ValueHandleFns;
|
||||
|
||||
template <typename> friend class OpenMesh::CirculatorRange;
|
||||
|
||||
public:
|
||||
GenericCirculatorT_DEPRECATED() {}
|
||||
GenericCirculatorT_DEPRECATED(mesh_ref mesh, CenterEntityHandle start, bool end = false) :
|
||||
|
||||
@@ -98,8 +98,10 @@ struct CirculatorRangeTraitT
|
||||
using ITER_TYPE = ITER_T;
|
||||
using CENTER_ENTITY_TYPE = CENTER_ENTITY_T;
|
||||
using TO_ENTITYE_TYPE = TO_ENTITY_T;
|
||||
static ITER_TYPE begin(const CONTAINER_TYPE& _container, CENTER_ENTITY_TYPE _ce) { return (_container.*begin_fn)(_ce); }
|
||||
static ITER_TYPE end(const CONTAINER_TYPE& _container, CENTER_ENTITY_TYPE _ce) { return (_container.*end_fn)(_ce); }
|
||||
static ITER_TYPE begin(const CONTAINER_TYPE& _container, CENTER_ENTITY_TYPE _ce) { return (_container.*begin_fn)(_ce); }
|
||||
static ITER_TYPE begin(const CONTAINER_TYPE& _container, HalfedgeHandle _heh, int) { return ITER_TYPE(_container, _heh); }
|
||||
static ITER_TYPE end(const CONTAINER_TYPE& _container, CENTER_ENTITY_TYPE _ce) { return (_container.*end_fn)(_ce); }
|
||||
static ITER_TYPE end(const CONTAINER_TYPE& _container, HalfedgeHandle _heh, int) { return ITER_TYPE(_container, _heh, true); }
|
||||
};
|
||||
|
||||
struct SmartVertexHandle;
|
||||
@@ -1250,12 +1252,26 @@ public:
|
||||
*/
|
||||
ConstVertexIHalfedgeRange vih_range(VertexHandle _vh) const;
|
||||
|
||||
/**
|
||||
* @return The incoming halfedges incident to the specified vertex
|
||||
* as a range object suitable for C++11 range based for loops.
|
||||
* Like vih_range(VertexHandle _heh.to()) but starts iteration at _heh
|
||||
*/
|
||||
ConstVertexIHalfedgeRange vih_range(HalfedgeHandle _heh) const;
|
||||
|
||||
/**
|
||||
* @return The outgoing halfedges incident to the specified vertex
|
||||
* as a range object suitable for C++11 range based for loops.
|
||||
*/
|
||||
ConstVertexOHalfedgeRange voh_range(VertexHandle _vh) const;
|
||||
|
||||
/**
|
||||
* @return The outgoing halfedges incident to the specified vertex
|
||||
* as a range object suitable for C++11 range based for loops.
|
||||
* Like voh_range(VertexHandle _heh.from()) but starts iteration at _heh
|
||||
*/
|
||||
ConstVertexOHalfedgeRange voh_range(HalfedgeHandle _heh) const;
|
||||
|
||||
/**
|
||||
* @return The edges incident to the specified vertex
|
||||
* as a range object suitable for C++11 range based for loops.
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#error Do not include this directly, include instead PolyConnectivity.hh
|
||||
#endif // OPENMESH_POLYCONNECTIVITY_INTERFACE_INCLUDE
|
||||
|
||||
#include <OpenMesh/Core/Mesh/PolyConnectivity.hh> // To help some IDEs
|
||||
#include <OpenMesh/Core/Mesh/IteratorsT.hh>
|
||||
#include <OpenMesh/Core/Mesh/CirculatorsT.hh>
|
||||
|
||||
@@ -99,13 +100,23 @@ class CirculatorRange : public SmartRangeT<CirculatorRange<CirculatorRangeTraitT
|
||||
CirculatorRange(
|
||||
const CONTAINER_TYPE &container,
|
||||
CENTER_ENTITY_TYPE center) :
|
||||
container_(container), center_(center) {}
|
||||
ITER_TYPE begin() const { return CirculatorRangeTraitT::begin(container_, center_); }
|
||||
ITER_TYPE end() const { return CirculatorRangeTraitT::end(container_, center_); }
|
||||
container_(container), heh_()
|
||||
{
|
||||
auto it = CirculatorRangeTraitT::begin(container_, center);
|
||||
heh_ = it.heh_;
|
||||
}
|
||||
|
||||
CirculatorRange(
|
||||
const CONTAINER_TYPE &container,
|
||||
HalfedgeHandle heh, int) :
|
||||
container_(container), heh_(heh) {}
|
||||
|
||||
ITER_TYPE begin() const { return CirculatorRangeTraitT::begin(container_, heh_, 1); }
|
||||
ITER_TYPE end() const { return CirculatorRangeTraitT::end(container_, heh_, 1); }
|
||||
|
||||
private:
|
||||
const CONTAINER_TYPE &container_;
|
||||
CENTER_ENTITY_TYPE center_;
|
||||
HalfedgeHandle heh_;
|
||||
};
|
||||
|
||||
|
||||
@@ -136,10 +147,18 @@ inline PolyConnectivity::ConstVertexIHalfedgeRange PolyConnectivity::vih_range(V
|
||||
return ConstVertexIHalfedgeRange(*this, _vh);
|
||||
}
|
||||
|
||||
inline PolyConnectivity::ConstVertexIHalfedgeRange PolyConnectivity::vih_range(HalfedgeHandle _heh) const {
|
||||
return ConstVertexIHalfedgeRange(*this, opposite_halfedge_handle(_heh), 1);
|
||||
}
|
||||
|
||||
inline PolyConnectivity::ConstVertexOHalfedgeRange PolyConnectivity::voh_range(VertexHandle _vh) const {
|
||||
return ConstVertexOHalfedgeRange(*this, _vh);
|
||||
}
|
||||
|
||||
inline PolyConnectivity::ConstVertexOHalfedgeRange PolyConnectivity::voh_range(HalfedgeHandle _heh) const {
|
||||
return ConstVertexOHalfedgeRange(*this, _heh, 1);
|
||||
}
|
||||
|
||||
inline PolyConnectivity::ConstVertexEdgeRange PolyConnectivity::ve_range(VertexHandle _vh) const {
|
||||
return ConstVertexEdgeRange(*this, _vh);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user