diff --git a/Doc/changelog.docu b/Doc/changelog.docu index afd885416e5dac443b451791f529873130b76bd8..cc179a95d2464cd843f06ae1090b8d0416a5f65b 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -18,6 +18,7 @@ <ul> <li>legacy vector min max now take const args to avoid matching std implementations</li> <li>Fixed several warnings</li> +<li>Make Previous Halfedge Attribute optional again </li> </ul> <b>Tools</b> diff --git a/src/OpenMesh/Core/Mesh/ArrayItems.hh b/src/OpenMesh/Core/Mesh/ArrayItems.hh index 503fc7359d50e04f1df7289ad35f8a799be5b393..1d1488cdce00abbab3ac5d2be93ff373ff8cdaaa 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<true> HasPrevHalfedge; //-------------------------------------------------------- internal edge type diff --git a/src/OpenMesh/Core/Mesh/AttribKernelT.hh b/src/OpenMesh/Core/Mesh/AttribKernelT.hh index 6e67bc2b101e629eb66a8620dc73b7a0355ca708..10a46c080203a6b8218962fcb8f6a209e54b9501 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<true>, + GenProg::Bool2Type<false> + >::Result HasPrevHalfedge; + + //typedef typename Connectivity::Halfedge Halfedge; typedef typename Connectivity::Edge Edge; typedef typename Connectivity::Face Face; @@ -98,12 +118,6 @@ public: typedef AttribKernelT<MeshItems,Connectivity> AttribKernel; - enum Attribs { - VAttribs = MeshItems::VAttribs, - HAttribs = MeshItems::HAttribs, - EAttribs = MeshItems::EAttribs, - FAttribs = MeshItems::FAttribs - }; typedef VPropHandleT<VertexData> DataVPropHandle; typedef HPropHandleT<HalfedgeData> DataHPropHandle; diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index 133fd41cc064ce35fe6d5896b1695ddeae06ea3b..8b82a407027679019ff7f8edcc9d03775fca0a52 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 0000000000000000000000000000000000000000..d6d5a0c88123c51e9217b7856ab22bc8df79a49a --- /dev/null +++ b/src/Unittests/unittests_traits.cc @@ -0,0 +1,67 @@ +#include <gtest/gtest.h> +#include <Unittests/unittests_common.hh> +#include <iostream> + +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<MeshTraits>; + + + // 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<MeshTraits>; + + + // 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"; +} + +}