From 7fb6a57e9086ed916c1c32ae65da76582dc077f7 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 10 Nov 2016 15:20:13 +0100 Subject: [PATCH 1/3] Revert "Export Ngx_Mesh to Python" This reverts commit 9b235b4388aa6d2d7cb59716868924db01dbe455. --- libsrc/meshing/python_mesh.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index cf99678f..07ea777b 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -7,8 +7,6 @@ #include #include #include <../interface/writeuser.hpp> -#include -#include using namespace netgen; @@ -300,10 +298,6 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) py::implicitly_convertible< int, PointIndex>(); - py::class_(m, "Ngx_Mesh") - .def(py::init>()) - .def_property_readonly("ngmesh", &Ngx_Mesh::GetMesh) - ; py::class_>(m, "Mesh") // .def(py::init<>("create empty mesh")) @@ -551,7 +545,6 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) )) ; - py::implicitly_convertible< shared_ptr, Ngx_Mesh >(); typedef MeshingParameters MP; From 5b253c76e017aefc43566f6bdbc9e7e3ba7729ff Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 10 Nov 2016 15:24:35 +0100 Subject: [PATCH 2/3] Add a guard to avoid multiply defined AVX operators on Windows --- libsrc/general/mysimd.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libsrc/general/mysimd.hpp b/libsrc/general/mysimd.hpp index bc00adae..62a87baf 100644 --- a/libsrc/general/mysimd.hpp +++ b/libsrc/general/mysimd.hpp @@ -9,7 +9,9 @@ #include -#ifdef WIN32 +#ifdef WIN32 +#ifndef AVX_OPERATORS_DEFINED +#define AVX_OPERATORS_DEFINED inline __m128d operator- (__m128d a) { return _mm_xor_pd(a, _mm_set1_pd(-0.0)); } inline __m128d operator+ (__m128d a, __m128d b) { return _mm_add_pd(a,b); } inline __m128d operator- (__m128d a, __m128d b) { return _mm_sub_pd(a,b); } @@ -36,6 +38,7 @@ inline __m256d operator-= (__m256d &a, __m256d b) { return a = a-b; } inline __m256d operator*= (__m256d &a, __m256d b) { return a = a*b; } inline __m256d operator/= (__m256d &a, __m256d b) { return a = a/b; } #endif +#endif From 0a9abc1accb55fda767ddbf7018682fdc8695468 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 15 Nov 2016 18:12:51 +0100 Subject: [PATCH 3/3] array iterator to python --- libsrc/general/array.hpp | 1 + libsrc/meshing/python_mesh.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libsrc/general/array.hpp b/libsrc/general/array.hpp index 1429f2c8..69cf2f30 100644 --- a/libsrc/general/array.hpp +++ b/libsrc/general/array.hpp @@ -60,6 +60,7 @@ namespace netgen T operator*() const { return ar[ind]; } T & operator*() { return ar[ind]; } bool operator != (ArrayIterator d2) { return ind != d2.ind; } + bool operator == (ArrayIterator d2) { return ind == d2.ind; } }; diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 07ea777b..7c27092a 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -20,6 +20,7 @@ namespace netgen template void ExportArray (py::module &m) { + using TA = Array; string name = string("Array_") + typeid(T).name(); py::class_>(m, name.c_str()) .def ("__len__", [] ( Array &self ) { return self.Size(); } ) @@ -31,6 +32,9 @@ void ExportArray (py::module &m) return self[i]; }), py::return_value_policy::reference) + .def("__iter__", [] ( TA & self) { + return py::make_iterator (self.begin(),self.end()); + }, py::keep_alive<0,1>()) // keep array alive while iterator is used ; }