Add Edge circulators

This commit is contained in:
Janis Born
2023-11-14 07:57:17 +00:00
committed by Jan Möbius
parent 9c5298260d
commit 80d39234fa
15 changed files with 828 additions and 10 deletions

View File

@@ -471,7 +471,7 @@ public:
{ return next_halfedge_handle(opposite_halfedge_handle(_heh)); }
// --- edge connectivity ---
static HalfedgeHandle s_halfedge_handle(EdgeHandle _eh, unsigned int _i)
static HalfedgeHandle s_halfedge_handle(EdgeHandle _eh, unsigned int _i = 0)
{
assert(_i<=1);
return HalfedgeHandle((_eh.idx() << 1) + _i);
@@ -480,7 +480,7 @@ public:
static EdgeHandle s_edge_handle(HalfedgeHandle _heh)
{ return EdgeHandle(_heh.idx() >> 1); }
HalfedgeHandle halfedge_handle(EdgeHandle _eh, unsigned int _i) const
HalfedgeHandle halfedge_handle(EdgeHandle _eh, unsigned int _i = 0) const
{
return s_halfedge_handle(_eh, _i);
}

View File

@@ -44,7 +44,7 @@
//=============================================================================
//
// Vertex and Face circulators for PolyMesh/TriMesh
// Vertex, Face, and Edge circulators for PolyMesh/TriMesh
//
//=============================================================================
@@ -98,6 +98,19 @@ class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::FaceHandle, true>
}
};
template<class Mesh, bool CW>
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::EdgeHandle, CW> {
public:
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->opposite_halfedge_handle(heh);
if (heh == start) ++lap_counter;
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) --lap_counter;
heh = mesh->opposite_halfedge_handle(heh);
}
};
/////////////////////////////////////////////////////////////
// CCW
@@ -150,6 +163,14 @@ class GenericCirculator_DereferenciabilityCheckT<Mesh, typename Mesh::VertexHand
}
};
template<class Mesh>
class GenericCirculator_DereferenciabilityCheckT<Mesh, typename Mesh::EdgeHandle, typename Mesh::FaceHandle> {
public:
inline static bool isDereferenciable(const Mesh *mesh, const typename Mesh::HalfedgeHandle &heh) {
return mesh->face_handle(heh).is_valid();
}
};
template<class Mesh, class CenterEntityHandle, class ValueHandle, bool CW = true>
class GenericCirculator_ValueHandleFnsT {
public:

View File

@@ -379,6 +379,53 @@ public:
typedef FaceFaceCWIter ConstFaceFaceCWIter;
typedef FaceFaceCCWIter ConstFaceFaceCCWIter;
/*
* Edge-centered circulators
*/
struct EdgeVertexTraits
{
using Mesh = This;
using CenterEntityHandle = This::EdgeHandle;
using ValueHandle = This::VertexHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->from_vertex_handle(_heh); }
};
/**
* Enumerate vertices incident to an edge.
*/
typedef Iterators::GenericCirculatorT_DEPRECATED<EdgeVertexTraits> EdgeVertexIter;
struct EdgeHalfedgeTraits
{
using Mesh = This;
using CenterEntityHandle = This::EdgeHandle;
using ValueHandle = This::HalfedgeHandle;
static ValueHandle toHandle(const Mesh* const /* _mesh */, This::HalfedgeHandle _heh) { return _heh; }
};
/**
* Enumerate the halfedges of an edge.
*/
typedef Iterators::GenericCirculatorT_DEPRECATED<EdgeHalfedgeTraits> EdgeHalfedgeIter;
struct EdgeFaceTraits
{
using Mesh = This;
using CenterEntityHandle = This::EdgeHandle;
using ValueHandle = This::FaceHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->face_handle(_heh); }
};
/**
* Enumerate faces incident to an edge.
*/
typedef Iterators::GenericCirculatorT_DEPRECATED<EdgeFaceTraits> EdgeFaceIter;
typedef EdgeVertexIter ConstEdgeVertexIter;
typedef EdgeHalfedgeIter ConstEdgeHalfedgeIter;
typedef EdgeFaceIter ConstEdgeFaceIter;
/*
* Halfedge circulator
*/
@@ -435,6 +482,9 @@ public:
typedef FaceEdgeCWIter FECWIter;
typedef FaceEdgeCCWIter FECWWIter;
typedef FaceFaceIter FFIter;
typedef EdgeVertexIter EVIter;
typedef EdgeHalfedgeIter EHIter;
typedef EdgeFaceIter EFIter;
typedef ConstVertexVertexIter CVVIter;
typedef ConstVertexVertexCWIter CVVCWIter;
@@ -463,6 +513,9 @@ public:
typedef ConstFaceFaceIter CFFIter;
typedef ConstFaceFaceCWIter CFFCWIter;
typedef ConstFaceFaceCCWIter CFFCCWIter;
typedef ConstEdgeVertexIter CEVIter;
typedef ConstEdgeHalfedgeIter CEHIter;
typedef ConstEdgeFaceIter CEFIter;
//@}
public:
@@ -600,14 +653,14 @@ public:
using ArrayKernel::s_halfedge_handle;
using ArrayKernel::s_edge_handle;
static SmartHalfedgeHandle s_halfedge_handle(SmartEdgeHandle _eh, unsigned int _i);
static SmartHalfedgeHandle s_halfedge_handle(SmartEdgeHandle _eh, unsigned int _i = 0);
static SmartEdgeHandle s_edge_handle(SmartHalfedgeHandle _heh);
using ArrayKernel::halfedge_handle;
using ArrayKernel::edge_handle;
using ArrayKernel::face_handle;
inline SmartHalfedgeHandle halfedge_handle(SmartEdgeHandle _eh, unsigned int _i) const;
inline SmartHalfedgeHandle halfedge_handle(SmartEdgeHandle _eh, unsigned int _i = 0) const;
inline SmartHalfedgeHandle halfedge_handle(SmartFaceHandle _fh) const;
inline SmartHalfedgeHandle halfedge_handle(SmartVertexHandle _vh) const;
inline SmartEdgeHandle edge_handle(SmartHalfedgeHandle _heh) const;
@@ -688,7 +741,7 @@ public:
//--- circulators ---
/** \name Vertex and Face circulators
/** \name Vertex, Face, and Edge circulators
*/
//@{
@@ -803,6 +856,20 @@ public:
ConstFaceFaceCWIter cff_cwiter(FaceHandle _fh) const;
/// const face - face circulator
ConstFaceFaceCCWIter cff_ccwiter(FaceHandle _fh) const;
/// edge - vertex circulator
EdgeVertexIter ev_iter(EdgeHandle _eh);
/// edge - halfedge circulator
EdgeHalfedgeIter eh_iter(EdgeHandle _eh);
/// edge - face circulator
EdgeFaceIter ef_iter(EdgeHandle _eh);
/// const edge - vertex circulator
ConstEdgeVertexIter cev_iter(EdgeHandle _eh) const;
/// const edge - halfedge circulator
ConstEdgeHalfedgeIter ceh_iter(EdgeHandle _eh) const;
/// const edge - face circulator
ConstEdgeFaceIter cef_iter(EdgeHandle _eh) const;
// 'begin' circulators
@@ -930,6 +997,20 @@ public:
ConstHalfedgeLoopCWIter chl_cwbegin(HalfedgeHandle _heh) const;
/// const halfedge circulator ccw
ConstHalfedgeLoopCCWIter chl_ccwbegin(HalfedgeHandle _heh) const;
/// edge - vertex circulator
EdgeVertexIter ev_begin(EdgeHandle _eh);
/// edge - halfedge circulator
EdgeHalfedgeIter eh_begin(EdgeHandle _eh);
/// edge - face circulator
EdgeFaceIter ef_begin(EdgeHandle _eh);
/// const edge - vertex circulator
ConstEdgeVertexIter cev_begin(EdgeHandle _eh) const;
/// const edge - halfedge circulator
ConstEdgeHalfedgeIter ceh_begin(EdgeHandle _eh) const;
/// const edge - face circulator
ConstEdgeFaceIter cef_begin(EdgeHandle _eh) const;
// 'end' circulators
@@ -1056,6 +1137,21 @@ public:
ConstHalfedgeLoopCWIter chl_cwend(HalfedgeHandle _heh) const;
/// const face - face circulator ccw
ConstHalfedgeLoopCCWIter chl_ccwend(HalfedgeHandle _heh) const;
/// edge - vertex circulator
EdgeVertexIter ev_end(EdgeHandle _eh);
/// edge - halfedge circulator
EdgeHalfedgeIter eh_end(EdgeHandle _eh);
/// edge - face circulator
EdgeFaceIter ef_end(EdgeHandle _eh);
/// const edge - vertex circulator
ConstEdgeVertexIter cev_end(EdgeHandle _eh) const;
/// const edge - halfedge circulator
ConstEdgeHalfedgeIter ceh_end(EdgeHandle _eh) const;
/// const edge - face circulator
ConstEdgeFaceIter cef_end(EdgeHandle _eh) const;
//@}
/** @name Range based iterators and circulators */
@@ -1178,6 +1274,9 @@ public:
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstFaceHalfedgeIter , FaceHandle , HalfedgeHandle, &PolyConnectivity::cfh_begin , &PolyConnectivity::cfh_end >> ConstFaceHalfedgeRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstFaceEdgeIter , FaceHandle , EdgeHandle , &PolyConnectivity::cfe_begin , &PolyConnectivity::cfe_end >> ConstFaceEdgeRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstFaceFaceIter , FaceHandle , FaceHandle , &PolyConnectivity::cff_begin , &PolyConnectivity::cff_end >> ConstFaceFaceRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstEdgeVertexIter , EdgeHandle , VertexHandle , &PolyConnectivity::cev_begin , &PolyConnectivity::cev_end >> ConstEdgeVertexRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstEdgeHalfedgeIter , EdgeHandle , HalfedgeHandle, &PolyConnectivity::ceh_begin , &PolyConnectivity::ceh_end >> ConstEdgeHalfedgeRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstEdgeFaceIter , EdgeHandle , FaceHandle, &PolyConnectivity::cef_begin , &PolyConnectivity::cef_end >> ConstEdgeFaceRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstHalfedgeLoopIter , HalfedgeHandle, HalfedgeHandle, &PolyConnectivity::chl_begin , &PolyConnectivity::chl_end >> ConstHalfedgeLoopRange;
typedef CirculatorRange<CirculatorRangeTraitT<PolyConnectivity, ConstVertexVertexCWIter , VertexHandle , VertexHandle , &PolyConnectivity::cvv_cwbegin , &PolyConnectivity::cvv_cwend >> ConstVertexVertexCWRange;
@@ -1270,6 +1369,31 @@ public:
*/
ConstFaceFaceRange ff_range(FaceHandle _fh) const;
/**
* @return The vertices incident to the specified edge
* as a range object suitable for C++11 range based for loops.
*/
ConstEdgeVertexRange ev_range(EdgeHandle _eh) const;
/**
* @return The halfedges of the specified edge
* as a range object suitable for C++11 range based for loops.
*/
ConstEdgeHalfedgeRange eh_range(EdgeHandle _eh) const;
/**
* @return The halfedges of the specified edge
* as a range object suitable for C++11 range based for loops.
* Like eh_range(_heh.edge()) but starts iteration at _heh
*/
ConstEdgeHalfedgeRange eh_range(HalfedgeHandle _heh) const;
/**
* @return The faces incident to the specified edge
* as a range object suitable for C++11 range based for loops.
*/
ConstEdgeFaceRange ef_range(EdgeHandle _eh) const;
/**
* @return The halfedges in the face
* as a range object suitable for C++11 range based for loops.
@@ -1313,7 +1437,7 @@ public:
* @return The edges incident to the specified vertex
* as a range object suitable for C++11 range based for loops.
*/
ConstVertexEdgeCWRange ve_cw_range(VertexHandle _vh) const ;
ConstVertexEdgeCWRange ve_cw_range(VertexHandle _vh) const;
/**
* @return The faces incident to the specified vertex
@@ -1420,6 +1544,7 @@ public:
*/
ConstFaceFaceCCWRange ff_ccw_range(FaceHandle _fh) const;
/**
* @return The halfedges in the face
* as a range object suitable for C++11 range based for loops.

View File

@@ -183,6 +183,22 @@ inline PolyConnectivity::ConstFaceFaceRange PolyConnectivity::ff_range(FaceHandl
return ConstFaceFaceRange(*this, _fh);
}
inline PolyConnectivity::ConstEdgeVertexRange PolyConnectivity::ev_range(EdgeHandle _eh) const {
return ConstEdgeVertexRange(*this, _eh);
}
inline PolyConnectivity::ConstEdgeHalfedgeRange PolyConnectivity::eh_range(EdgeHandle _eh) const {
return ConstEdgeHalfedgeRange(*this, _eh);
}
inline PolyConnectivity::ConstEdgeHalfedgeRange PolyConnectivity::eh_range(HalfedgeHandle _heh) const {
return ConstEdgeHalfedgeRange(*this, _heh, 1);
}
inline PolyConnectivity::ConstEdgeFaceRange PolyConnectivity::ef_range(EdgeHandle _eh) const {
return ConstEdgeFaceRange(*this, _eh);
}
inline PolyConnectivity::ConstHalfedgeLoopRange PolyConnectivity::hl_range(HalfedgeHandle _heh) const {
return ConstHalfedgeLoopRange(*this, _heh);
}
@@ -282,6 +298,7 @@ inline PolyConnectivity::ConstFaceFaceCCWRange PolyConnectivity::ff_ccw_range(Fa
return ConstFaceFaceCCWRange(*this, _fh);
}
inline PolyConnectivity::ConstHalfedgeLoopCCWRange PolyConnectivity::hl_ccw_range(HalfedgeHandle _heh) const {
return ConstHalfedgeLoopCCWRange(*this, _heh);
}
@@ -523,6 +540,24 @@ inline PolyConnectivity::ConstFaceFaceCWIter PolyConnectivity::cff_cwiter(ArrayK
inline PolyConnectivity::ConstFaceFaceCCWIter PolyConnectivity::cff_ccwiter(ArrayKernel::FaceHandle _fh) const
{ return ConstFaceFaceCCWIter(*this, _fh); }
inline PolyConnectivity::EdgeVertexIter PolyConnectivity::ev_iter(ArrayKernel::EdgeHandle _eh)
{ return EdgeVertexIter(*this, _eh); }
inline PolyConnectivity::EdgeHalfedgeIter PolyConnectivity::eh_iter(ArrayKernel::EdgeHandle _eh)
{ return EdgeHalfedgeIter(*this, _eh); }
inline PolyConnectivity::EdgeFaceIter PolyConnectivity::ef_iter(ArrayKernel::EdgeHandle _eh)
{ return EdgeFaceIter(*this, _eh); }
inline PolyConnectivity::ConstEdgeVertexIter PolyConnectivity::cev_iter(ArrayKernel::EdgeHandle _eh) const
{ return ConstEdgeVertexIter(*this, _eh); }
inline PolyConnectivity::ConstEdgeHalfedgeIter PolyConnectivity::ceh_iter(ArrayKernel::EdgeHandle _eh) const
{ return ConstEdgeHalfedgeIter(*this, _eh); }
inline PolyConnectivity::ConstEdgeFaceIter PolyConnectivity::cef_iter(ArrayKernel::EdgeHandle _eh) const
{ return ConstEdgeFaceIter(*this, _eh); }
inline PolyConnectivity::VertexVertexIter PolyConnectivity::vv_begin(VertexHandle _vh)
{ return VertexVertexIter(*this, _vh); }
@@ -707,6 +742,27 @@ inline PolyConnectivity::ConstHalfedgeLoopCWIter PolyConnectivity::chl_cwbegin(H
inline PolyConnectivity::ConstHalfedgeLoopCCWIter PolyConnectivity::chl_ccwbegin(HalfedgeHandle _heh) const
{ return ConstHalfedgeLoopCCWIter(*this, _heh); }
inline PolyConnectivity::EdgeVertexIter PolyConnectivity::ev_begin(EdgeHandle _eh)
{ return EdgeVertexIter(*this, _eh); }
inline PolyConnectivity::EdgeHalfedgeIter PolyConnectivity::eh_begin(EdgeHandle _eh)
{ return EdgeHalfedgeIter(*this, _eh); }
inline PolyConnectivity::EdgeFaceIter PolyConnectivity::ef_begin(EdgeHandle _eh)
{ return EdgeFaceIter(*this, _eh); }
inline PolyConnectivity::ConstEdgeVertexIter PolyConnectivity::cev_begin(EdgeHandle _eh) const
{ return ConstEdgeVertexIter(*this, _eh); }
inline PolyConnectivity::ConstEdgeHalfedgeIter PolyConnectivity::ceh_begin(EdgeHandle _eh) const
{ return ConstEdgeHalfedgeIter(*this, _eh); }
inline PolyConnectivity::ConstEdgeFaceIter PolyConnectivity::cef_begin(EdgeHandle _eh) const
{ return ConstEdgeFaceIter(*this, _eh); }
// 'end' circulators
inline PolyConnectivity::VertexVertexIter PolyConnectivity::vv_end(VertexHandle _vh)
@@ -893,6 +949,26 @@ inline PolyConnectivity::ConstHalfedgeLoopCCWIter PolyConnectivity::chl_ccwend(H
{ return ConstHalfedgeLoopCCWIter(*this, _heh, true); }
inline PolyConnectivity::EdgeVertexIter PolyConnectivity::ev_end(EdgeHandle _eh)
{ return EdgeVertexIter(*this, _eh, true); }
inline PolyConnectivity::EdgeHalfedgeIter PolyConnectivity::eh_end(EdgeHandle _eh)
{ return EdgeHalfedgeIter(*this, _eh, true); }
inline PolyConnectivity::EdgeFaceIter PolyConnectivity::ef_end(EdgeHandle _eh)
{ return EdgeFaceIter(*this, _eh, true); }
inline PolyConnectivity::ConstEdgeVertexIter PolyConnectivity::cev_end(EdgeHandle _eh) const
{ return ConstEdgeVertexIter(*this, _eh, true); }
inline PolyConnectivity::ConstEdgeHalfedgeIter PolyConnectivity::ceh_end(EdgeHandle _eh) const
{ return ConstEdgeHalfedgeIter(*this, _eh, true); }
inline PolyConnectivity::ConstEdgeFaceIter PolyConnectivity::cef_end(EdgeHandle _eh) const
{ return ConstEdgeFaceIter(*this, _eh, true); }
inline PolyConnectivity::ConstVertexFaceRange SmartVertexHandle::faces() const { assert(mesh() != nullptr); return mesh()->vf_range (*this); }
inline PolyConnectivity::ConstVertexFaceCWRange SmartVertexHandle::faces_cw() const { assert(mesh() != nullptr); return mesh()->vf_cw_range (*this); }
inline PolyConnectivity::ConstVertexFaceCCWRange SmartVertexHandle::faces_ccw() const { assert(mesh() != nullptr); return mesh()->vf_ccw_range(*this); }
@@ -943,4 +1019,13 @@ inline PolyConnectivity::ConstFaceFaceRange SmartFaceHandle::faces()
inline PolyConnectivity::ConstFaceFaceCWRange SmartFaceHandle::faces_cw() const { assert(mesh() != nullptr); return mesh()->ff_cw_range (*this); }
inline PolyConnectivity::ConstFaceFaceCCWRange SmartFaceHandle::faces_ccw() const { assert(mesh() != nullptr); return mesh()->ff_ccw_range(*this); }
inline PolyConnectivity::ConstEdgeVertexRange SmartEdgeHandle::vertices() const { assert(mesh() != nullptr); return mesh()->ev_range (*this); }
inline PolyConnectivity::ConstEdgeHalfedgeRange SmartEdgeHandle::halfedges() const { assert(mesh() != nullptr); return mesh()->eh_range (*this); }
inline PolyConnectivity::ConstEdgeHalfedgeRange SmartEdgeHandle::halfedges(HalfedgeHandle _heh) const { assert(mesh() != nullptr); return mesh()->eh_range (_heh); }
inline PolyConnectivity::ConstEdgeFaceRange SmartEdgeHandle::faces() const { assert(mesh() != nullptr); return mesh()->ef_range (*this); }
}//namespace OpenMesh

View File

@@ -213,6 +213,15 @@ struct OPENMESHDLLEXPORT SmartEdgeHandle : public SmartBaseHandle, EdgeHandle, S
SmartVertexHandle v0() const;
/// Shorthand for vertex(1)
SmartVertexHandle v1() const;
/// Returns a range of vertices incident to the edge (PolyConnectivity::ev_range())
PolyConnectivity::ConstEdgeVertexRange vertices() const;
/// Returns a range of halfedges of the edge (PolyConnectivity::eh_range())
PolyConnectivity::ConstEdgeHalfedgeRange halfedges() const;
/// Returns a range of halfedges of the edge (PolyConnectivity::eh_range())
PolyConnectivity::ConstEdgeHalfedgeRange halfedges(HalfedgeHandle _heh) const;
/// Returns a range of faces incident to the edge (PolyConnectivity::ef_range())
PolyConnectivity::ConstEdgeFaceRange faces() const;
};
struct OPENMESHDLLEXPORT SmartFaceHandle : public SmartBaseHandle, FaceHandle, SmartHandleStatusPredicates<SmartFaceHandle>, SmartHandleBoundaryPredicate<SmartFaceHandle>
@@ -415,13 +424,13 @@ inline SmartFaceHandle SmartHalfedgeHandle::face() const
return make_smart(mesh()->face_handle(*this), mesh());
}
inline SmartHalfedgeHandle SmartEdgeHandle::halfedge(unsigned int _i) const
inline SmartHalfedgeHandle SmartEdgeHandle::halfedge(unsigned int _i = 0) const
{
assert(mesh() != nullptr);
return make_smart(mesh()->halfedge_handle(*this, _i), mesh());
}
inline SmartHalfedgeHandle SmartEdgeHandle::h(unsigned int _i) const
inline SmartHalfedgeHandle SmartEdgeHandle::h(unsigned int _i = 0) const
{
return halfedge(_i);
}