Commit fd68dccf authored by Martin Heistermann's avatar Martin Heistermann

Refactor: Entity tag structs for generic handles and property handles

parent 172ca930
Pipeline #8862 passed with stage
in 5 minutes and 27 seconds
......@@ -108,12 +108,12 @@ public:
}
const OpenVolumeMeshStatus& mesh_status() const {
OpenVolumeMeshHandle h(0);
MeshHandle h(0);
return m_status_[h];
}
OpenVolumeMeshStatus& mesh_status() {
OpenVolumeMeshHandle h(0);
MeshHandle h(0);
return m_status_[h];
}
......
#pragma once
#include <type_traits>
namespace OpenVolumeMesh {
namespace Entity {
struct Vertex {};
struct Edge {};
struct HalfEdge {};
struct Face {};
struct HalfFace {};
struct Cell {};
struct Mesh {};
}
template<typename T>
struct is_entity : std::false_type {};
template<> struct is_entity<Entity::Vertex> : std::true_type {};
template<> struct is_entity<Entity::Edge> : std::true_type {};
template<> struct is_entity<Entity::HalfEdge> : std::true_type {};
template<> struct is_entity<Entity::Face> : std::true_type {};
template<> struct is_entity<Entity::HalfFace> : std::true_type {};
template<> struct is_entity<Entity::Cell> : std::true_type {};
template<> struct is_entity<Entity::Mesh> : std::true_type {};
} // namespace OpenVolumeMesh
......@@ -32,14 +32,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 36 $ *
* $Date: 2012-01-10 18:00:06 +0100 (Di, 10 Jan 2012) $ *
* $LastChangedBy: kremer $ *
* *
\*===========================================================================*/
#include <istream>
#include "OpenVolumeMeshHandle.hh"
......
......@@ -38,6 +38,7 @@
#include <iosfwd>
#include <vector>
#include "Entities.hh"
#include "../System/FunctionalInclude.hh"
#include "../System/Deprecation.hh"
......@@ -86,14 +87,25 @@ private:
int idx_;
};
template<typename EntityTag,
typename = typename std::enable_if<is_entity<EntityTag>::value>::type>
class HandleT : public OpenVolumeMeshHandle
{
public:
using Entity = EntityTag;
explicit HandleT(int _idx = -1) : OpenVolumeMeshHandle(_idx) {}
};
// Default entity handles
class VertexHandle : public OpenVolumeMeshHandle { public: explicit VertexHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgeHandle : public OpenVolumeMeshHandle { public: explicit EdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FaceHandle : public OpenVolumeMeshHandle { public: explicit FaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellHandle : public OpenVolumeMeshHandle { public: explicit CellHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgeHandle : public OpenVolumeMeshHandle { public: explicit HalfEdgeHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFaceHandle : public OpenVolumeMeshHandle { public: explicit HalfFaceHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
using VertexHandle = HandleT<Entity::Vertex>;
using HalfEdgeHandle = HandleT<Entity::HalfEdge>;
using EdgeHandle = HandleT<Entity::Edge>;
using HalfFaceHandle = HandleT<Entity::HalfFace>;
using FaceHandle = HandleT<Entity::Face>;
using CellHandle = HandleT<Entity::Cell>;
using MeshHandle = HandleT<Entity::Mesh>;
// Helper class that is used to decrease all handles
// exceeding a certain threshold
......
......@@ -36,46 +36,26 @@
#pragma once
#include "OpenVolumeMeshHandle.hh"
#include "Entities.hh"
namespace OpenVolumeMesh {
// Defines for property handles
class VertexPropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = VertexHandle;
};
class EdgePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = EdgeHandle;
};
class HalfEdgePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = HalfEdgeHandle;
};
class FacePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = FaceHandle;
};
class HalfFacePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = HalfFaceHandle;
};
class CellPropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = CellHandle;
};
class MeshPropHandle : public OpenVolumeMeshHandle
template<typename EntityTag,
typename = typename std::enable_if<is_entity<EntityTag>::value>::type>
class PropHandleT : public OpenVolumeMeshHandle
{
public:
using Entity = EntityTag;
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = OpenVolumeMeshHandle;
};
using VertexPropHandle = PropHandleT<Entity::Vertex>;
using EdgePropHandle = PropHandleT<Entity::Edge>;
using HalfEdgePropHandle = PropHandleT<Entity::HalfEdge>;
using FacePropHandle = PropHandleT<Entity::Face>;
using HalfFacePropHandle = PropHandleT<Entity::HalfFace>;
using CellPropHandle = PropHandleT<Entity::Cell>;
using MeshPropHandle = PropHandleT<Entity::Mesh>;
} // Namespace OpenVolumeMesh
......@@ -74,7 +74,7 @@ public:
typedef typename PropT::reference reference;
typedef typename PropT::const_reference const_reference;
typedef typename HandleT::EntityHandleT EntityHandleT;
typedef OpenVolumeMesh::HandleT<typename HandleT::Entity> EntityHandleT;
/// Constructor
PropertyPtr(PropT* _ptr, ResourceManager& _resMan, HandleT _handle);
......
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