diff --git a/Doc/changelog.docu b/Doc/changelog.docu
index afd88541..cc179a95 100644
--- a/Doc/changelog.docu
+++ b/Doc/changelog.docu
@@ -18,6 +18,7 @@
- legacy vector min max now take const args to avoid matching std implementations
- Fixed several warnings
+- Make Previous Halfedge Attribute optional again
Tools
diff --git a/src/OpenMesh/Core/Mesh/ArrayItems.hh b/src/OpenMesh/Core/Mesh/ArrayItems.hh
index 503fc735..1d1488cd 100644
--- a/src/OpenMesh/Core/Mesh/ArrayItems.hh
+++ b/src/OpenMesh/Core/Mesh/ArrayItems.hh
@@ -97,6 +97,7 @@ struct ArrayItems
//TODO: should be selected with config.h define
typedef Halfedge_with_prev Halfedge;
+ typedef Halfedge_without_prev HalfedgeNoPrev;
typedef GenProg::Bool2Type HasPrevHalfedge;
//-------------------------------------------------------- internal edge type
diff --git a/src/OpenMesh/Core/Mesh/AttribKernelT.hh b/src/OpenMesh/Core/Mesh/AttribKernelT.hh
index 6e67bc2b..10a46c08 100644
--- a/src/OpenMesh/Core/Mesh/AttribKernelT.hh
+++ b/src/OpenMesh/Core/Mesh/AttribKernelT.hh
@@ -75,10 +75,30 @@ public:
//---------------------------------------------------------------- item types
+ enum Attribs {
+ VAttribs = MeshItems::VAttribs,
+ HAttribs = MeshItems::HAttribs,
+ EAttribs = MeshItems::EAttribs,
+ FAttribs = MeshItems::FAttribs
+ };
+
typedef MeshItems MeshItemsT;
typedef Connectivity ConnectivityT;
typedef typename Connectivity::Vertex Vertex;
- typedef typename Connectivity::Halfedge Halfedge;
+
+ //Define Halfedge based on PrevHalfedge.
+ typedef typename GenProg::IF<
+ (bool)(HAttribs & Attributes::PrevHalfedge),
+ typename Connectivity::Halfedge,
+ typename Connectivity::HalfedgeNoPrev
+ >::Result Halfedge;
+ typedef typename GenProg::IF<
+ (bool)(HAttribs & Attributes::PrevHalfedge),
+ GenProg::Bool2Type,
+ GenProg::Bool2Type
+ >::Result HasPrevHalfedge;
+
+ //typedef typename Connectivity::Halfedge Halfedge;
typedef typename Connectivity::Edge Edge;
typedef typename Connectivity::Face Face;
@@ -98,12 +118,6 @@ public:
typedef AttribKernelT AttribKernel;
- enum Attribs {
- VAttribs = MeshItems::VAttribs,
- HAttribs = MeshItems::HAttribs,
- EAttribs = MeshItems::EAttribs,
- FAttribs = MeshItems::FAttribs
- };
typedef VPropHandleT DataVPropHandle;
typedef HPropHandleT DataHPropHandle;
diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt
index 133fd41c..8b82a407 100644
--- a/src/Unittests/CMakeLists.txt
+++ b/src/Unittests/CMakeLists.txt
@@ -39,6 +39,7 @@ unittests_stripifier.cc
unittests_subdivider_adaptive.cc
unittests_subdivider_uniform.cc
unittests_trimesh_circulator_current_halfedge_handle_replacement.cc
+unittests_traits.cc
unittests_trimesh_circulator_face_edge.cc
unittests_trimesh_circulator_face_face.cc
unittests_trimesh_circulator_face_halfedge.cc
diff --git a/src/Unittests/unittests_traits.cc b/src/Unittests/unittests_traits.cc
new file mode 100644
index 00000000..d6d5a0c8
--- /dev/null
+++ b/src/Unittests/unittests_traits.cc
@@ -0,0 +1,67 @@
+#include
+#include
+#include
+
+namespace {
+
+class OpenMeshPrevHalfedge : public OpenMeshBase {
+
+ protected:
+
+ // This function is called before each test is run
+ virtual void SetUp() {
+
+ // Do some initial stuff with the member data here...
+ }
+
+ // This function is called after all tests are through
+ virtual void TearDown() {
+
+ // Do some final stuff with the member data here...
+ }
+
+ // Member already defined in OpenMeshBase
+ //Mesh mesh_;
+};
+
+/*
+ * ====================================================================
+ * Define tests below
+ * ====================================================================
+ */
+
+/* creates a Halfedge WITHOUT the PrevHalfedge Attribute
+ */
+TEST_F(OpenMeshPrevHalfedge, RemovePrevHalfedge) {
+
+ mesh_.clear();
+
+ struct MeshTraits : OpenMesh::DefaultTraits {
+ HalfedgeAttributes(0);
+ };
+ using MeshT = OpenMesh::TriMesh_ArrayKernelT;
+
+
+ // Check if Prev Halfedge is referenced
+ EXPECT_EQ(12u, sizeof(MeshT::Halfedge) ) << "Wrong size of Halfedge";
+ EXPECT_EQ(0u, MeshT::HasPrevHalfedge::my_bool ) << "Attribute HasPrevHalfedge is wrong";
+}
+
+/* creates a Halfedge WITH the PrevHalfedge Attribute
+ */
+TEST_F(OpenMeshPrevHalfedge, HavePrevHalfedge) {
+
+ mesh_.clear();
+
+ struct MeshTraits : OpenMesh::DefaultTraits {
+ //HalfedgeAttributes(0);
+ };
+ using MeshT = OpenMesh::TriMesh_ArrayKernelT;
+
+
+ // Check if Prev Halfedge is referenced
+ EXPECT_EQ(16u, sizeof(MeshT::Halfedge) ) << "Wrong size of Halfedge";
+ EXPECT_EQ(1u, MeshT::HasPrevHalfedge::my_bool ) << "Attribute HasPrevHalfedge is wrong";
+}
+
+}