diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5bc17c4f2d9a3354aeef30e4f37a830b4ae311c..35ef09af8fe6a5406999d155dc40c6c94cea82db 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: diff --git a/README b/README deleted file mode 100644 index 85e6668c41fd36c131a2bd038b10f9ae712b3420..0000000000000000000000000000000000000000 --- 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 b0b67b162a05465bed35857c1a38c605935a0e40..2f6f93189941339fe3905ad2b696fedf51dc79bb 100644 --- a/README.rst +++ b/README.rst @@ -34,3 +34,4 @@ Online resources * `Source `_ * `Package index `_ * `Mailing list `_ + diff --git a/meshpy/tet.py b/meshpy/tet.py index 113aed600c8a4651cb2bc0af5af209264c3a9519..97ecb19321f45a91cae6cbe741c8aeb2c4d52f69 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 3a5e3851f16ccfa4133c83ad7ec60eb607f06171..fd9783ee9d189b20c2be1d8ee6361ce48ef9bf64 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 fa97ee9356a5aad419981a51c96082efa5f38d85..fa6a65cd8e2faf64738e0897c9f247f0ee769ba1 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 56bb4ca9bdcdd6a02e876cbfff2d15af8e5080d7..184ea3090c4370b970472e8dccf25407ade1fa44 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/predicates.cpp b/src/cpp/predicates.cpp index 0aa253301c9b458414c38ae8d738b8f573db904a..c0ae9683cde2eef7bf50ce0c359d6bc992c9d37d 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 6468509bc291a95e4aec4a4350cdc72e3e4f3e7f..d0f03298f6aa3a04cb06c6395ce4a980a9c4885b 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 ccef59bb85d03e07021842e4a9f875f883138477..0ef3dfb957ac1f4f1efd4101bdc241592d12fbac 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. @@ -792,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); +} /////////////////////////////////////////////////////////////////////////////// // // diff --git a/src/cpp/wrap_tetgen.cpp b/src/cpp/wrap_tetgen.cpp index 2c715b30f351f9db3c1dbb4f02df151cf9f5a1a8..30a34da7e118a5ac936839fd100648e023796410 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 4857345ff410d82e3e55bbd8b022b85c68e9ba25..b4858032be976d5c45239f1d3e44643b44ddfa90 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 0000000000000000000000000000000000000000..6fa270bec3836940cebaa35342ef890f680c1c03 --- /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); +}