From 509f62e11824e3cfe51826c32718b93b94d13db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 23 Nov 2015 15:54:22 +0100 Subject: [PATCH 1/6] Try to get c++11 on visual studio 2015 --- src/OpenMesh/Core/Geometry/VectorT.hh | 2 +- src/Unittests/unittests_cpp_11_features.cc | 2 +- src/Unittests/unittests_vector_type.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index 5e2aca6f..713637e9 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -60,7 +60,7 @@ // macro expansion and preprocessor defines // don't work properly. -#if (__cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY) +#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY) #include "Vector11T.hh" #else #ifndef DOXYGEN diff --git a/src/Unittests/unittests_cpp_11_features.cc b/src/Unittests/unittests_cpp_11_features.cc index 72915491..f50e0a9c 100644 --- a/src/Unittests/unittests_cpp_11_features.cc +++ b/src/Unittests/unittests_cpp_11_features.cc @@ -53,7 +53,7 @@ class OpenMesh_Triangle : public OpenMeshBase { * ==================================================================== */ -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) /* */ diff --git a/src/Unittests/unittests_vector_type.cc b/src/Unittests/unittests_vector_type.cc index 8ca929ca..7c1dd5a1 100644 --- a/src/Unittests/unittests_vector_type.cc +++ b/src/Unittests/unittests_vector_type.cc @@ -84,7 +84,7 @@ TEST_F(OpenMeshVectorTest, VectorCasting) { } -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) TEST_F(OpenMeshVectorTest, cpp11_constructors) { OpenMesh::Vec3d vec1 { 1.2, 2.0, 3.0 }; From d5e6d413f32df512d1b941ef92d1d90f6383e3ab Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 11:19:53 +0100 Subject: [PATCH 2/6] implement member and non-member swap for VectorT --- src/OpenMesh/Core/Geometry/Vector11T.hh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index eefac1fb..74bd21a0 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -627,6 +627,11 @@ class VectorT { _rhs.values_.begin(), _rhs.values_.end()); } + /// swap with another vector + void swap(VectorT& _other) noexcept(noexcept(std::swap(values_, _other.values_))) { + std::swap(values_, _other.values_); + } + //------------------------------------------------------------ component iterators /// \name Component iterators @@ -694,7 +699,6 @@ Scalar dot(const VectorT& _v1, const VectorT& _v2) { return (_v1 | _v2); } - /// \relates OpenMesh::VectorT /// symmetric version of the cross product template @@ -704,6 +708,14 @@ cross(const VectorT& _v1, const VectorT& _v2) -> return (_v1 % _v2); } +/// \relates OpenMesh::VectorT +/// non-member swap +template +void swap(VectorT& _v1, VectorT& _v2) +noexcept(noexcept(_v1.swap(_v2))) +{ + _v1.swap(_v2); +} //== TYPEDEFS ================================================================= From e36051d57153ac3291568310a342c65d84df5ece Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 11:21:38 +0100 Subject: [PATCH 3/6] brace style --- src/OpenMesh/Core/Geometry/Vector11T.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index 74bd21a0..acd0e11a 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -628,7 +628,8 @@ class VectorT { } /// swap with another vector - void swap(VectorT& _other) noexcept(noexcept(std::swap(values_, _other.values_))) { + void swap(VectorT& _other) + noexcept(noexcept(std::swap(values_, _other.values_))) { std::swap(values_, _other.values_); } @@ -712,8 +713,7 @@ cross(const VectorT& _v1, const VectorT& _v2) -> /// non-member swap template void swap(VectorT& _v1, VectorT& _v2) -noexcept(noexcept(_v1.swap(_v2))) -{ +noexcept(noexcept(_v1.swap(_v2))) { _v1.swap(_v2); } From f907bd9bd518ceb30e8809bd2a21003371089a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 13:55:19 +0100 Subject: [PATCH 4/6] Switch all checks for c++11 to support vs2015 --- src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh | 2 +- src/OpenMesh/Apps/Unsupported/OsgViewer/osgviewer.cc | 2 +- src/OpenMesh/Core/System/mostream.hh | 8 ++++---- src/OpenMesh/Core/Utils/PropertyManager.hh | 4 ++-- src/OpenMesh/Tools/Decimater/DecimaterT.cc | 6 +++--- src/OpenMesh/Tools/Decimater/DecimaterT.hh | 2 +- src/OpenMesh/Tools/Utils/HeapT.hh | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh b/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh index 8b3f11e7..dd54f59d 100644 --- a/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh +++ b/src/OpenMesh/Apps/Decimating/DecimaterViewerWidget.hh @@ -114,7 +114,7 @@ public: typedef Decimater::ModNormalFlippingT< mesh_t >::Handle mod_nf_t; // object types -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) typedef std::unique_ptr< decimater_t > decimater_o; #else typedef std::auto_ptr< decimater_t > decimater_o; diff --git a/src/OpenMesh/Apps/Unsupported/OsgViewer/osgviewer.cc b/src/OpenMesh/Apps/Unsupported/OsgViewer/osgviewer.cc index a3c43e90..c5f8a9d0 100644 --- a/src/OpenMesh/Apps/Unsupported/OsgViewer/osgviewer.cc +++ b/src/OpenMesh/Apps/Unsupported/OsgViewer/osgviewer.cc @@ -131,7 +131,7 @@ public: bool bind( osg::GeometryPtr geo ) { - #if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) + #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) std::unique_ptr obj(new mesh_t); #else std::auto_ptr obj(new mesh_t); diff --git a/src/OpenMesh/Core/System/mostream.hh b/src/OpenMesh/Core/System/mostream.hh index a0367251..f079b454 100644 --- a/src/OpenMesh/Core/System/mostream.hh +++ b/src/OpenMesh/Core/System/mostream.hh @@ -70,7 +70,7 @@ #include #include -#if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) #include #endif @@ -189,7 +189,7 @@ protected: virtual int sync() { // If working on multiple threads, we need to serialize the output correctly (requires c++11 headers) - #if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) + #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) std::lock_guard lck (serializer_); #endif @@ -214,7 +214,7 @@ protected: char c = traits_type::to_char_type(_c); // If working on multiple threads, we need to serialize the output correctly (requires c++11 headers) - #if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) + #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) { std::lock_guard lck (serializer_); buffer_.push_back(c); @@ -264,7 +264,7 @@ private: bool enabled_; // If working on multiple threads, we need to serialize the output correctly (requires c++11 headers) - #if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) + #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) std::mutex serializer_; #endif diff --git a/src/OpenMesh/Core/Utils/PropertyManager.hh b/src/OpenMesh/Core/Utils/PropertyManager.hh index 88b495b0..529ee120 100644 --- a/src/OpenMesh/Core/Utils/PropertyManager.hh +++ b/src/OpenMesh/Core/Utils/PropertyManager.hh @@ -76,7 +76,7 @@ namespace OpenMesh { */ template class PropertyManager { -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) public: PropertyManager(const PropertyManager&) = delete; PropertyManager& operator=(const PropertyManager&) = delete; @@ -148,7 +148,7 @@ class PropertyManager { MeshT &getMesh() const { return *mesh_; } -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) /// Only for pre C++11 compatibility. typedef PropertyManager Proxy; diff --git a/src/OpenMesh/Tools/Decimater/DecimaterT.cc b/src/OpenMesh/Tools/Decimater/DecimaterT.cc index 6dfb489d..f8e3d9f8 100644 --- a/src/OpenMesh/Tools/Decimater/DecimaterT.cc +++ b/src/OpenMesh/Tools/Decimater/DecimaterT.cc @@ -78,7 +78,7 @@ template DecimaterT::DecimaterT(Mesh& _mesh) : BaseDecimaterT(_mesh), mesh_(_mesh), -#if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) heap_(nullptr) #else heap_(NULL) @@ -178,7 +178,7 @@ size_t DecimaterT::decimate(size_t _n_collapses) { // initialize heap HeapInterface HI(mesh_, priority_, heap_position_); -#if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) heap_ = std::unique_ptr(new DeciHeap(HI)); #else heap_ = std::auto_ptr(new DeciHeap(HI)); @@ -279,7 +279,7 @@ size_t DecimaterT::decimate_to_faces(size_t _nv, size_t _nf) { // initialize heap HeapInterface HI(mesh_, priority_, heap_position_); - #if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) + #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) heap_ = std::unique_ptr(new DeciHeap(HI)); #else heap_ = std::auto_ptr(new DeciHeap(HI)); diff --git a/src/OpenMesh/Tools/Decimater/DecimaterT.hh b/src/OpenMesh/Tools/Decimater/DecimaterT.hh index 02d284d4..bb7523a2 100644 --- a/src/OpenMesh/Tools/Decimater/DecimaterT.hh +++ b/src/OpenMesh/Tools/Decimater/DecimaterT.hh @@ -173,7 +173,7 @@ private: //------------------------------------------------------- private data Mesh& mesh_; // heap - #if __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) + #if _MSC_VER >= 1900 || __cplusplus > 199711L || defined( __GXX_EXPERIMENTAL_CXX0X__ ) std::unique_ptr heap_; #else std::auto_ptr heap_; diff --git a/src/OpenMesh/Tools/Utils/HeapT.hh b/src/OpenMesh/Tools/Utils/HeapT.hh index 545cfb5e..47e0b184 100644 --- a/src/OpenMesh/Tools/Utils/HeapT.hh +++ b/src/OpenMesh/Tools/Utils/HeapT.hh @@ -79,7 +79,7 @@ #include "Config.hh" #include #include -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) #include #endif @@ -150,7 +150,7 @@ public: /// Constructor HeapT() : HeapVector() {} -#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if _MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) /// Construct with a given \c HeapIterface. HeapT(HeapInterface _interface) : HeapVector(), interface_(std::move(_interface)) From bc25c5b7335831d5cd654985e1c11d1e28e8f1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 14:42:58 +0100 Subject: [PATCH 5/6] Exit on any error in mac script --- CI/ci-mac.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index fc9b5ea8..caefdeb6 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -1,5 +1,8 @@ #!/bin/bash +#Exit on any error +set -e + LANGUAGE=$1 PATH=$PATH:/opt/local/bin From a04d46d6126d6b1c0aea4ee8fcb09ef54e6aa4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 16:09:22 +0100 Subject: [PATCH 6/6] Enabled python tests on mac --- CI/ci-mac.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index caefdeb6..bc29c2b4 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -28,7 +28,7 @@ fi cd build-release -cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE $OPTIONS ../ +cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON $OPTIONS ../ #build it make @@ -45,6 +45,14 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +# Execute Python unittests +cd Python-Unittests + +rm -f openmesh.so +cp ../Build/python/openmesh.so . +python -m unittest discover -v + +cd .. cd .. cd .. @@ -59,7 +67,7 @@ fi cd build-debug -cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE $OPTIONS ../ +cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON $OPTIONS ../ #build the unit tests make unittests @@ -74,4 +82,9 @@ cd Unittests # Run the unittests ./unittests --gtest_color=yes --gtest_output=xml +# Execute Python unittests +cd Python-Unittests +rm -f openmesh.so +cp ../Build/python/openmesh.so . +python -m unittest discover -v