From 265ff391e850e18f8da329e488ef4e9011642c67 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 14:17:06 +0100 Subject: [PATCH 01/14] fix c++98 compatibility for Python bridge to VectorT --- src/Python/Vector.hh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Python/Vector.hh b/src/Python/Vector.hh index e3031709..f00c9e6a 100644 --- a/src/Python/Vector.hh +++ b/src/Python/Vector.hh @@ -151,12 +151,21 @@ void expose_vec(const char *_name) { .def("vectorize", &Vector::vectorize, return_internal_reference<>()) .def(self < self) - .def("norm", &Vector::template norm) - .def("length", &Vector::template length) - .def("sqrnorm", &Vector::template sqrnorm) - .def("normalize", &Vector::template normalize, return_internal_reference<>()) - .def("normalized", &Vector::template normalized) - .def("normalize_cond", &Vector::template normalize_cond, return_internal_reference<>()) +#if (__cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY) + .def("norm", &Vector::template norm) + .def("length", &Vector::template length) + .def("sqrnorm", &Vector::template sqrnorm) + .def("normalize", &Vector::template normalize, return_internal_reference<>()) + .def("normalized", &Vector::template normalized) + .def("normalize_cond", &Vector::template normalize_cond, return_internal_reference<>()) +#else + .def("norm", &Vector::norm) + .def("length", &Vector::length) + .def("sqrnorm", &Vector::sqrnorm) + .def("normalize", &Vector::normalize, return_internal_reference<>()) + .def("normalized", &Vector::normalized) + .def("normalize_cond", &Vector::normalize_cond, return_internal_reference<>()) +#endif .def("l1_norm", &Vector::l1_norm) .def("l8_norm", &Vector::l8_norm) From 32d46c239a726298948e513fdc772f217e42e0a5 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 14:42:37 +0100 Subject: [PATCH 02/14] fix linker error --- src/Python/Vector.hh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Python/Vector.hh b/src/Python/Vector.hh index f00c9e6a..227db9e2 100644 --- a/src/Python/Vector.hh +++ b/src/Python/Vector.hh @@ -66,9 +66,6 @@ struct Factory { }; } -template -void defInitMod(class_< OpenMesh::VectorT > &classVector); - template void defInitMod(class_< OpenMesh::VectorT > &classVector) { classVector @@ -189,7 +186,7 @@ void expose_vec(const char *_name) { .staticmethod("vectorized") ; - defInitMod(classVector); + defInitMod(classVector); } } // namespace OpenMesh From baf0efd646e6d01d893ab840f01069c2a3da0031 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 11:19:53 +0100 Subject: [PATCH 03/14] 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 4c609dc6e26161a9a610276d992b7eb773b7035f Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 11:21:38 +0100 Subject: [PATCH 04/14] 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 79ce0a7b92361f33e02590a1c34c9994f935c5c8 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 05/14] 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 b8d304a453c476c717c3fdd26d4c5bc78172c5a5 Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 14:52:40 +0100 Subject: [PATCH 06/14] use correct ifdefs for VS2015 --- src/Python/Vector.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Python/Vector.hh b/src/Python/Vector.hh index 227db9e2..d619e2be 100644 --- a/src/Python/Vector.hh +++ b/src/Python/Vector.hh @@ -148,7 +148,7 @@ void expose_vec(const char *_name) { .def("vectorize", &Vector::vectorize, return_internal_reference<>()) .def(self < self) -#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) .def("norm", &Vector::template norm) .def("length", &Vector::template length) .def("sqrnorm", &Vector::template sqrnorm) From 4ef152ac2ee33248c227dceee2ec0cf09c74364a Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 15:16:41 +0100 Subject: [PATCH 07/14] Python bindings: move definition of dot product to generic implementation --- src/Python/Vector.hh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Python/Vector.hh b/src/Python/Vector.hh index d619e2be..6f6814ab 100644 --- a/src/Python/Vector.hh +++ b/src/Python/Vector.hh @@ -72,9 +72,6 @@ void defInitMod(class_< OpenMesh::VectorT > &classVector) { .def("__init__", make_constructor(&Factory::vec2_default)) .def("__init__", make_constructor(&Factory::vec2_user_defined)) ; - - typedef OpenMesh::VectorT Vector; - def("dot", &Vector::operator|); } template void defInitMod(class_< OpenMesh::VectorT > &classVector) { @@ -85,9 +82,6 @@ void defInitMod(class_< OpenMesh::VectorT > &classVector) { ; def("cross", &Factory::Vector3::operator%); - - typedef OpenMesh::VectorT Vector; - def("dot", &Vector::operator|); } template void defInitMod(class_< OpenMesh::VectorT > &classVector) { @@ -95,9 +89,6 @@ void defInitMod(class_< OpenMesh::VectorT > &classVector) { .def("__init__", make_constructor(&Factory::vec4_default)) .def("__init__", make_constructor(&Factory::vec4_user_defined)) ; - - typedef OpenMesh::VectorT Vector; - def("dot", &Vector::operator|); } /** @@ -149,6 +140,7 @@ void expose_vec(const char *_name) { .def(self < self) #if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY) + .def("dot", &Vector::template operator|) .def("norm", &Vector::template norm) .def("length", &Vector::template length) .def("sqrnorm", &Vector::template sqrnorm) @@ -156,6 +148,7 @@ void expose_vec(const char *_name) { .def("normalized", &Vector::template normalized) .def("normalize_cond", &Vector::template normalize_cond, return_internal_reference<>()) #else + .def("dot", &Vector::operator|) .def("norm", &Vector::norm) .def("length", &Vector::length) .def("sqrnorm", &Vector::sqrnorm) From d5612f16a0c37c07e3823cc88cdc1ceaea55aa2d Mon Sep 17 00:00:00 2001 From: Janis Born Date: Wed, 25 Nov 2015 15:30:57 +0100 Subject: [PATCH 08/14] Python bindings: add C++11 compilation switch for cross product --- src/Python/Vector.hh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Python/Vector.hh b/src/Python/Vector.hh index 6f6814ab..fc453816 100644 --- a/src/Python/Vector.hh +++ b/src/Python/Vector.hh @@ -78,10 +78,15 @@ void defInitMod(class_< OpenMesh::VectorT > &classVector) { classVector .def("__init__", make_constructor(&Factory::vec3_default)) .def("__init__", make_constructor(&Factory::vec3_user_defined)) +#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY) + .def("__mod__", &Factory::Vector3::template operator%) + ; + def("cross", &Factory::Vector3::template operator%); +#else .def("__mod__", &Factory::Vector3::operator%) ; - def("cross", &Factory::Vector3::operator%); +#endif } template void defInitMod(class_< OpenMesh::VectorT > &classVector) { From 9ba99ec8924e46ec5bd739260c5cbb5429c7243c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 16:29:04 +0100 Subject: [PATCH 09/14] Seperate build dirs --- CI/ci-linux.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CI/ci-linux.sh b/CI/ci-linux.sh index 84455a33..5cc7ae22 100755 --- a/CI/ci-linux.sh +++ b/CI/ci-linux.sh @@ -7,30 +7,35 @@ LANGUAGE=$2 set -e OPTIONS="" +BUILDPATH="" if [ "$COMPILER" == "gcc" ]; then echo "Building with GCC"; + BUILDPATH="gcc" elif [ "$COMPILER" == "clang" ]; then OPTIONS="$OPTIONS -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang" echo "Building with CLANG"; + BUILDPATH="clang" fi if [ "$LANGUAGE" == "C++98" ]; then echo "Building with C++98"; + BUILDPATH="$BUILDPATH-cpp98" elif [ "$LANGUAGE" == "C++11" ]; then echo "Building with C++11"; OPTIONS="$OPTIONS -DCMAKE_CXX_FLAGS='-std=c++11' " + BUILDPATH="$BUILDPATH-cpp98" fi ######################################### # Make release build folder -if [ ! -d build-release ]; then - mkdir build-release +if [ ! -d build-release-$BUILDPATH ]; then + mkdir build-release-$BUILDPATH fi -cd build-release +cd build-release-$BUILDPATH cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON $OPTIONS ../ @@ -63,11 +68,11 @@ cd .. # Build Debug version and Unittests ######################################### -if [ ! -d build-debug ]; then - mkdir build-debug +if [ ! -d build-debug-$BUILDPATH ]; then + mkdir build-debug-$BUILDPATH fi -cd build-debug +cd build-debug-$BUILDPATH cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON $OPTIONS ../ From 5e39f4e51c9da21b049527ee1ea2316c154a3964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 16:30:17 +0100 Subject: [PATCH 10/14] Fixed path --- CI/ci-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/ci-linux.sh b/CI/ci-linux.sh index 5cc7ae22..c9ae618d 100755 --- a/CI/ci-linux.sh +++ b/CI/ci-linux.sh @@ -25,7 +25,7 @@ if [ "$LANGUAGE" == "C++98" ]; then elif [ "$LANGUAGE" == "C++11" ]; then echo "Building with C++11"; OPTIONS="$OPTIONS -DCMAKE_CXX_FLAGS='-std=c++11' " - BUILDPATH="$BUILDPATH-cpp98" + BUILDPATH="$BUILDPATH-cpp11" fi ######################################### From 4d03692a3b89119c172be299db5b68d726cbee51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 16:42:17 +0100 Subject: [PATCH 11/14] Wrong directory --- CI/ci-mac.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index bc29c2b4..e1e4773a 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -82,6 +82,8 @@ cd Unittests # Run the unittests ./unittests --gtest_color=yes --gtest_output=xml +cd .. + # Execute Python unittests cd Python-Unittests From a38de238c4661c1fb6fe19762e4a83befc666e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 16:43:18 +0100 Subject: [PATCH 12/14] Missed another path --- CI/ci-mac.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index e1e4773a..c41d4305 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -45,6 +45,7 @@ cd Unittests #execute tests ./unittests --gtest_color=yes --gtest_output=xml +cd .. # Execute Python unittests cd Python-Unittests From ece951ad2f3001e0a921c7470e7c6a84c32d19af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 25 Nov 2015 16:57:39 +0100 Subject: [PATCH 13/14] Wrong directory --- CI/ci-mac.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index c41d4305..daf54fa3 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -55,7 +55,6 @@ python -m unittest discover -v cd .. cd .. -cd .. ######################################### From b081460cb548cfe115c2d37cc7b3f87850a22827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Thu, 26 Nov 2015 08:26:50 +0100 Subject: [PATCH 14/14] Missing make command for python --- CI/ci-mac.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CI/ci-mac.sh b/CI/ci-mac.sh index daf54fa3..863d7a67 100755 --- a/CI/ci-mac.sh +++ b/CI/ci-mac.sh @@ -69,6 +69,9 @@ cd build-debug cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON $OPTIONS ../ +#build it +make + #build the unit tests make unittests