From f7dc91c42b50e0aba60a2eabe51799e2df820c5c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 11 Oct 2018 16:39:51 -0500 Subject: [PATCH 1/5] Add Apple CI --- .gitlab-ci.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5bc17c..35ef09a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,6 @@ Python 3.5: reports: junit: test/pytest.xml - Python 3.7: script: - py_version=3.7 @@ -42,6 +41,20 @@ Python 3.7: reports: junit: test/pytest.xml +Python 2.7 Apple: + script: + - export PY_EXE=python2.7 + - export EXTRA_INSTALL="pybind11 numpy" + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh + - ". ./build-and-test-py-project.sh" + tags: + - python2.7 + - apple + except: + - tags + artifacts: + reports: + junit: test/pytest.xml Documentation: script: -- GitLab From 47870cbb755b3aa5cbe6ab78eebe53a036edcf49 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 11 Oct 2018 16:50:35 -0500 Subject: [PATCH 2/5] Kill extraneous boost header include --- src/cpp/tetgen.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpp/tetgen.h b/src/cpp/tetgen.h index ccef59b..bbcf9ca 100644 --- a/src/cpp/tetgen.h +++ b/src/cpp/tetgen.h @@ -50,7 +50,6 @@ #include #include #include -#include // The types 'intptr_t' and 'uintptr_t' are signed and unsigned integer types, // respectively. They are guaranteed to be the same width as a pointer. -- GitLab From a2734c05dea98e8d03afaeb0dfa710fe6f56f76d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 11 Oct 2018 16:50:50 -0500 Subject: [PATCH 3/5] Delete extra README --- README | 92 ------------------------------------------------------ README.rst | 1 + 2 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index 85e6668..0000000 --- a/README +++ /dev/null @@ -1,92 +0,0 @@ -Thanks for downloading MeshPy! - -WHAT IS THIS? -------------- - -MeshPy enables you to generate quality triangular and tetrahedral meshes for -arbitrary geometric regions, all from within Python. Meshes of this type are -chiefly used in finite-element simulation codes, but also have many other -applications ranging from computer graphics to robotics. - -In order to generate these 2D and 3D meshes, MeshPy provides Python interfaces -to two well-regarded mesh generators, Triangle [1] by J. Shewchuk and TetGen [2] -by Hang Si. - -[1] http://www.cs.cmu.edu/~quake/triangle.html -[2] http://tetgen.berlios.de/ - -MeshPy is based on TetGen 1.4.2 and Triangle 1.6. - -GETTING STARTED ---------------- - -To get started, you need the Boost.Python [1] wrapper generator library -installed. See below for installation instructions. - -After you have installed MeshPy, take a look at the examples in the test/ -subdirectory to see what you can do with MeshPy and how. There is no user -documentation currently, but if you would like to contribute some, -please feel free. In general, you might want to study how Triangle's and -TetGen's C interfaces work--then MeshPy's interface should not be a -surprise. MeshPy makes an attempt to make the two meshing interfaces even -more similar than they already are, by renaming fields called "triangle..." -and "tetrahedron..." into "element...". - -I hope you enjoy using MeshPy. If you use it for your work, I'd be delighted -to hear from you. - -Andreas Kloeckner - -[1] http://www.boost.org/libs/python/doc/ - -INSTALLING BOOST.PYTHON ------------------------ - -(You may skip all this if your distribution ships Boost.Python, which is the case -for Debian and Ubuntu. For the latter two, you just need to install the package -libboost-python-dev, it will pull in all the other dependencies.) - -If you figure you need to build manually, proceed as follows: - -* Download a Boost release from http://www.boost.org/. - -* Download and install Boost.Jam, a build tool, from - -* Build Boost, such as by typing - - bjam -sPYTHON_ROOT=/usr -sPYTHON_VERSION=2.4 \ - -sBUILD="release dynamic multi" - - (You may have to adapt PYTHON_ROOT and PYTHON_VERSION depending on your system.) - -* Check the directory - - boost/bin/boost/libs/python/build/libboost_python.so... - .../gcc/release/shared-linkable-true/threading-multi - - and find libboost_python*.so. (Don't copy the dots from the command - line--they are only there to make the line fit on this page.) Copy these - files to somewhere on your dynamic linker path, for example: - - - /usr/lib - - a directory on LD_LIBRARY_PATH - - or something mentioned in /etc/ld.so.conf. - - You should also create a symbolic link called libboost_python.so - to the main .so file. - -* Run ldconfig. - -INSTALLING MESHPY ------------------ - -Simply run - - su -c "python setup.py install" - -To cut down on compile time in this step, you may edit the variable OPT in the file - - /usr/lib/python2.N/config/Makefile - -and remove the "-g" flag from it. This will cut compile time and memory requirements -for the compile in about half. diff --git a/README.rst b/README.rst index b0b67b1..2f6f931 100644 --- a/README.rst +++ b/README.rst @@ -34,3 +34,4 @@ Online resources * `Source `_ * `Package index `_ * `Mailing list `_ + -- GitLab From db1985554d271c624871be4ac32d6be338ca65df Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 11 Oct 2018 17:23:45 -0500 Subject: [PATCH 4/5] Build as a single wrapper module --- meshpy/tet.py | 4 ++-- meshpy/triangle.py | 4 ++-- setup.py | 24 ++++++++++++------------ src/cpp/foreign_array.hpp | 4 ---- src/cpp/wrap_tetgen.cpp | 6 ++---- src/cpp/wrap_triangle.cpp | 23 ++--------------------- src/cpp/wrapper.cpp | 14 ++++++++++++++ 7 files changed, 34 insertions(+), 45 deletions(-) create mode 100644 src/cpp/wrapper.cpp diff --git a/meshpy/tet.py b/meshpy/tet.py index 113aed6..97ecb19 100644 --- a/meshpy/tet.py +++ b/meshpy/tet.py @@ -1,12 +1,12 @@ from __future__ import absolute_import from __future__ import print_function from meshpy.common import MeshInfoBase, dump_array -import meshpy._tetgen as internals +import meshpy._internals as internals import six from six.moves import range -class MeshInfo(internals.MeshInfo, MeshInfoBase): +class MeshInfo(internals.TetMeshInfo, MeshInfoBase): def set_facets(self, facets, markers=None): """Set a list of simple, single-polygon factes. Unlike :meth:`set_facets_ex`, :meth:`set_facets` does not allow hole and only lets you use a single diff --git a/meshpy/triangle.py b/meshpy/triangle.py index 3a5e385..fd9783e 100644 --- a/meshpy/triangle.py +++ b/meshpy/triangle.py @@ -1,12 +1,12 @@ from __future__ import division from __future__ import absolute_import from meshpy.common import MeshInfoBase, dump_array -import meshpy._triangle as internals +import meshpy._internals as internals from six.moves import range from six.moves import zip -class MeshInfo(internals.MeshInfo, MeshInfoBase): +class MeshInfo(internals.TriMeshInfo, MeshInfoBase): _constituents = [ "points", "point_attributes", "point_markers", "elements", "element_attributes", "element_volumes", diff --git a/setup.py b/setup.py index fa97ee9..fa6a65c 100644 --- a/setup.py +++ b/setup.py @@ -114,7 +114,9 @@ def main(): check_git_submodules() hack_distutils(what_opt=1) - conf = get_config(get_config_schema()) + conf = get_config( + get_config_schema(), + warn_about_no_config=False) triangle_macros = [ ("EXTERNAL_TEST", 1), @@ -181,21 +183,19 @@ def main(): ], ext_modules=[ Extension( - "meshpy._triangle", - ["src/cpp/wrap_triangle.cpp", "src/cpp/triangle.c"], - include_dirs=include_dirs, - define_macros=triangle_macros, - extra_compile_args=conf["CXXFLAGS"], - extra_link_args=conf["LDFLAGS"], - ), - Extension( - "meshpy._tetgen", + "meshpy._internals", [ + "src/cpp/wrapper.cpp", + + "src/cpp/wrap_triangle.cpp", + "src/cpp/triangle.c", + + "src/cpp/wrap_tetgen.cpp", "src/cpp/tetgen.cpp", "src/cpp/predicates.cpp", - "src/cpp/wrap_tetgen.cpp"], + ], include_dirs=include_dirs, - define_macros=tetgen_macros, + define_macros=triangle_macros, extra_compile_args=conf["CXXFLAGS"], extra_link_args=conf["LDFLAGS"], ), diff --git a/src/cpp/foreign_array.hpp b/src/cpp/foreign_array.hpp index 56bb4ca..184ea30 100644 --- a/src/cpp/foreign_array.hpp +++ b/src/cpp/foreign_array.hpp @@ -20,8 +20,6 @@ private: }; -namespace { - class tSizeChangeNotifier; @@ -283,8 +281,6 @@ class tForeignArray : public tReadOnlyForeignArray } }; -} - #endif diff --git a/src/cpp/wrap_tetgen.cpp b/src/cpp/wrap_tetgen.cpp index 2c715b3..30a34da 100644 --- a/src/cpp/wrap_tetgen.cpp +++ b/src/cpp/wrap_tetgen.cpp @@ -262,7 +262,7 @@ namespace #define DEF_METHOD(NAME) \ def(#NAME, &cl::NAME) -PYBIND11_MODULE(_tetgen, m) +void expose_tetgen(pybind11::module &m) { m.def("tetrahedralize", tetrahedralizeWrapper, py::arg("behavior"), py::arg("in"), py::arg("out"), @@ -270,7 +270,7 @@ PYBIND11_MODULE(_tetgen, m) { typedef tMeshInfo cl; - py::class_(m, "MeshInfo") + py::class_(m, "TetMeshInfo") .def(py::init<>()) .def_readonly("points", &cl::Points) .def_readonly("point_attributes", &cl::PointAttributes) @@ -435,8 +435,6 @@ PYBIND11_MODULE(_tetgen, m) ; } - exposePODForeignArray(m, "RealArray"); - exposePODForeignArray(m, "IntArray"); exposeStructureForeignArray(m, "FacetArray"); exposeStructureForeignArray(m, "PolygonArray"); } diff --git a/src/cpp/wrap_triangle.cpp b/src/cpp/wrap_triangle.cpp index 4857345..b485803 100644 --- a/src/cpp/wrap_triangle.cpp +++ b/src/cpp/wrap_triangle.cpp @@ -10,22 +10,6 @@ namespace py = pybind11; using namespace std; -/* -namespace boost { -template <> -inline tForeignArray const volatile * get_pointer(class tForeignArray const volatile *tF) { - return tF; -} - -template <> -inline tForeignArray const volatile * get_pointer(class tForeignArray const volatile *tF) { - return tF; -} -} -*/ - - - struct tMeshInfo : public triangulateio, public noncopyable { public: @@ -239,13 +223,13 @@ void triangulateWrapper(char *options, tMeshInfo &in, -PYBIND11_MODULE(_triangle, m) +void expose_triangle(pybind11::module &m) { m.def("triangulate", triangulateWrapper); { typedef tMeshInfo cl; - py::class_(m, "MeshInfo") + py::class_(m, "TriMeshInfo") .def(py::init<>()) .def_readonly("points", &cl::Points) .def_readonly("point_attributes", &cl::PointAttributes) @@ -280,9 +264,6 @@ PYBIND11_MODULE(_triangle, m) ; } - exposePODForeignArray(m, "RealArray"); - exposePODForeignArray(m, "IntArray"); - { typedef tVertex cl; py::class_(m, "Vertex") diff --git a/src/cpp/wrapper.cpp b/src/cpp/wrapper.cpp new file mode 100644 index 0000000..6fa270b --- /dev/null +++ b/src/cpp/wrapper.cpp @@ -0,0 +1,14 @@ +#include +#include "foreign_array_wrap.hpp" + +void expose_triangle(pybind11::module &m); +void expose_tetgen(pybind11::module &m); + +PYBIND11_MODULE(_internals, m) +{ + exposePODForeignArray(m, "RealArray"); + exposePODForeignArray(m, "IntArray"); + + expose_triangle(m); + expose_tetgen(m); +} -- GitLab From 95de818d7fe8cfe6ca053e89541d08fa4e52c451 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 11 Oct 2018 17:34:14 -0500 Subject: [PATCH 5/5] Provide namespace isolation between the tetgen's and triangle's robust predicates --- src/cpp/predicates.cpp | 4 +++- src/cpp/tetgen.cpp | 3 ++- src/cpp/tetgen.h | 14 ++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cpp/predicates.cpp b/src/cpp/predicates.cpp index 0aa2533..c0ae968 100644 --- a/src/cpp/predicates.cpp +++ b/src/cpp/predicates.cpp @@ -125,6 +125,8 @@ #include "tetgen.h" // Defines the symbol REAL (float or double). +namespace predicates { + #ifdef USE_CGAL_PREDICATES #include typedef CGAL::Exact_predicates_inexact_constructions_kernel cgalEpick; @@ -4713,5 +4715,5 @@ REAL orient4d(REAL* pa, REAL* pb, REAL* pc, REAL* pd, REAL* pe, aheight, bheight, cheight, dheight, eheight, permanent); } - +} diff --git a/src/cpp/tetgen.cpp b/src/cpp/tetgen.cpp index 6468509..d0f0329 100644 --- a/src/cpp/tetgen.cpp +++ b/src/cpp/tetgen.cpp @@ -15,7 +15,8 @@ #include "tetgen.h" -extern void exactdeinit(); +// extern void exactdeinit(); +using namespace predicates; //// io_cxx /////////////////////////////////////////////////////////////////// //// //// diff --git a/src/cpp/tetgen.h b/src/cpp/tetgen.h index bbcf9ca..0ef3dfb 100644 --- a/src/cpp/tetgen.h +++ b/src/cpp/tetgen.h @@ -791,12 +791,14 @@ public: // // /////////////////////////////////////////////////////////////////////////////// -void exactinit(int, int, int, REAL, REAL, REAL); -void exactdeinit(); -REAL orient3d(REAL *pa, REAL *pb, REAL *pc, REAL *pd); -REAL insphere(REAL *pa, REAL *pb, REAL *pc, REAL *pd, REAL *pe); -REAL orient4d(REAL *pa, REAL *pb, REAL *pc, REAL *pd, REAL *pe, - REAL ah, REAL bh, REAL ch, REAL dh, REAL eh); +namespace predicates { + void exactinit(int, int, int, REAL, REAL, REAL); + void exactdeinit(); + REAL orient3d(REAL *pa, REAL *pb, REAL *pc, REAL *pd); + REAL insphere(REAL *pa, REAL *pb, REAL *pc, REAL *pd, REAL *pe); + REAL orient4d(REAL *pa, REAL *pb, REAL *pc, REAL *pd, REAL *pe, + REAL ah, REAL bh, REAL ch, REAL dh, REAL eh); +} /////////////////////////////////////////////////////////////////////////////// // // -- GitLab