Commit 3b21aa14 authored by Max Lyon's avatar Max Lyon
Browse files

make smart handles more compatible with mixing old api

parent 81f3fcc2
......@@ -102,7 +102,10 @@ struct CirculatorRangeTraitT
static ITER_TYPE end(const CONTAINER_TYPE& _container, CENTER_ENTITY_TYPE _ce) { return (_container.*end_fn)(_ce); }
};
struct SmartVertexHandle;
struct SmartHalfedgeHandle;
struct SmartEdgeHandle;
struct SmartFaceHandle;
/** \brief Connectivity Class for polygonal meshes
*/
......@@ -180,7 +183,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::VertexHandle;
using ValueHandle = This::HalfedgeHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _heh;}
static ValueHandle toHandle(const Mesh* const /*_mesh*/, This::HalfedgeHandle _heh) { return _heh;}
};
/**
......@@ -219,7 +222,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::VertexHandle;
using ValueHandle = This::FaceHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _mesh->face_handle(_heh); }
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->face_handle(_heh); }
};
/**
......@@ -239,7 +242,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::VertexHandle;
using ValueHandle = This::EdgeHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _mesh->edge_handle(_heh); }
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->edge_handle(_heh); }
};
/**
......@@ -258,7 +261,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::FaceHandle;
using ValueHandle = This::HalfedgeHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _heh; }
static ValueHandle toHandle(const Mesh* const /*_mesh*/, This::HalfedgeHandle _heh) { return _heh; }
};
/**
......@@ -296,7 +299,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::FaceHandle;
using ValueHandle = This::VertexHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _mesh->to_vertex_handle(_heh); }
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->to_vertex_handle(_heh); }
};
/**
......@@ -327,7 +330,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::FaceHandle;
using ValueHandle = This::EdgeHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _mesh->edge_handle(_heh); }
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->edge_handle(_heh); }
};
/**
......@@ -347,7 +350,7 @@ public:
using Mesh = This;
using CenterEntityHandle = This::FaceHandle;
using ValueHandle = This::FaceHandle;
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return _mesh->face_handle(_mesh->opposite_halfedge_handle(_heh)); }
static ValueHandle toHandle(const Mesh* const _mesh, This::HalfedgeHandle _heh) { return static_cast<const ArrayKernel*>(_mesh)->face_handle(_mesh->opposite_halfedge_handle(_heh)); }
};
/**
......@@ -565,6 +568,42 @@ public:
*/
void delete_face(FaceHandle _fh, bool _delete_isolated_vertices=true);
//@}
/** \name Navigation with smart handles to allow usage of old-style navigation with smart handles
*/
//@{
using ArrayKernel::next_halfedge_handle;
using ArrayKernel::prev_halfedge_handle;
using ArrayKernel::opposite_halfedge_handle;
using ArrayKernel::ccw_rotated_halfedge_handle;
using ArrayKernel::cw_rotated_halfedge_handle;
inline SmartHalfedgeHandle next_halfedge_handle (SmartHalfedgeHandle _heh) const;
inline SmartHalfedgeHandle prev_halfedge_handle (SmartHalfedgeHandle _heh) const;
inline SmartHalfedgeHandle opposite_halfedge_handle (SmartHalfedgeHandle _heh) const;
inline SmartHalfedgeHandle ccw_rotated_halfedge_handle(SmartHalfedgeHandle _heh) const;
inline SmartHalfedgeHandle cw_rotated_halfedge_handle (SmartHalfedgeHandle _heh) const;
using ArrayKernel::s_halfedge_handle;
using ArrayKernel::s_edge_handle;
static SmartHalfedgeHandle s_halfedge_handle(SmartEdgeHandle _eh, unsigned int _i);
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(SmartFaceHandle _fh) const;
inline SmartHalfedgeHandle halfedge_handle(SmartVertexHandle _vh) const;
inline SmartEdgeHandle edge_handle(SmartHalfedgeHandle _heh) const;
inline SmartFaceHandle face_handle(SmartHalfedgeHandle _heh) const;
//@}
/** \name Begin and end iterators
......@@ -1482,9 +1521,29 @@ private: // Working storage for add_face()
#include <OpenMesh/Core/Mesh/IteratorsT.hh>
#include <OpenMesh/Core/Mesh/CirculatorsT.hh>
#include <OpenMesh/Core/Mesh/SmartHandles.hh>
namespace OpenMesh {
inline SmartHalfedgeHandle PolyConnectivity::next_halfedge_handle(SmartHalfedgeHandle _heh) const { return _heh.next(); }
inline SmartHalfedgeHandle PolyConnectivity::prev_halfedge_handle(SmartHalfedgeHandle _heh) const { return _heh.prev(); }
inline SmartHalfedgeHandle PolyConnectivity::opposite_halfedge_handle(SmartHalfedgeHandle _heh) const { return _heh.opp(); }
inline SmartHalfedgeHandle PolyConnectivity::ccw_rotated_halfedge_handle(SmartHalfedgeHandle _heh) const { return _heh.prev().opp(); }
inline SmartHalfedgeHandle PolyConnectivity::cw_rotated_halfedge_handle(SmartHalfedgeHandle _heh) const { return _heh.opp().next();}
inline SmartHalfedgeHandle PolyConnectivity::s_halfedge_handle(SmartEdgeHandle _eh, unsigned int _i) { return make_smart(ArrayKernel::s_halfedge_handle(EdgeHandle(_eh), _i), _eh.mesh()); }
inline SmartEdgeHandle PolyConnectivity::s_edge_handle(SmartHalfedgeHandle _heh) { return make_smart(ArrayKernel::s_edge_handle(HalfedgeHandle(_heh)), _heh.mesh()); }
inline SmartHalfedgeHandle PolyConnectivity::halfedge_handle(SmartEdgeHandle _eh, unsigned int _i) const { return _eh.halfedge(_i); }
inline SmartEdgeHandle PolyConnectivity::edge_handle(SmartHalfedgeHandle _heh) const { return _heh.edge(); }
inline SmartHalfedgeHandle PolyConnectivity::halfedge_handle(SmartFaceHandle _fh) const { return _fh.halfedge(); }
inline SmartHalfedgeHandle PolyConnectivity::halfedge_handle(SmartVertexHandle _vh) const { return _vh.halfedge(); }
inline SmartFaceHandle PolyConnectivity::face_handle(SmartHalfedgeHandle _heh) const { return _heh.face(); }
/// Generic class for vertex/halfedge/edge/face ranges.
template <typename RangeTraitT>
class EntityRange : public SmartRangeT<EntityRange<RangeTraitT>, typename RangeTraitT::ITER_TYPE::SmartHandle> {
......
......@@ -125,6 +125,8 @@ struct OPENMESHDLLEXPORT SmartHalfedgeHandle : public SmartBaseHandle, HalfedgeH
SmartVertexHandle to() const;
/// Returns vertex at start of halfedge
SmartVertexHandle from() const;
/// Returns incident edge of halfedge
SmartEdgeHandle edge() const;
/// Returns incident face of halfedge
SmartFaceHandle face() const;
......@@ -273,6 +275,12 @@ inline SmartVertexHandle SmartHalfedgeHandle::from() const
return make_smart(mesh()->from_vertex_handle(*this), mesh());
}
inline SmartEdgeHandle SmartHalfedgeHandle::edge() const
{
assert(mesh() != nullptr);
return make_smart(mesh()->edge_handle(*this), mesh());
}
inline SmartFaceHandle SmartHalfedgeHandle::face() const
{
assert(mesh() != nullptr);
......
......@@ -466,9 +466,12 @@ TEST_F(OpenMeshSmartHandles, Performance)
*/
TEST_F(OpenMeshSmartHandles, MixOldAndNew)
{
for (auto heh : mesh_.halfedges())
for (OpenMesh::SmartHalfedgeHandle heh : mesh_.halfedges())
{
heh = mesh_.opposite_halfedge_handle(heh);
OpenMesh::SmartEdgeHandle eh = OpenMesh::PolyConnectivity::s_edge_handle(heh);
OpenMesh::SmartEdgeHandle eh2 = mesh_.edge_handle(heh);
OpenMesh::SmartFaceHandle fh = mesh_.face_handle(heh);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment