diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..227d334 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +/data/unittest/* text eol=lf +/data/unittest/*.obj text +/data/unittest/*.pp text +/data/unittest/sphere.ply text +/data/unittest/test_box.ply text \ No newline at end of file diff --git a/README.md b/README.md index b54d6f9..a26e853 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,11 @@ Requirements ------------ You first need to install the `Boost `_ libraries. -You can compile your own local version or simply do on Linux: +You can compile your own local version. + +On Windows/MSVC, you must download and compile it yourself. + +On Linux you can simply install it via: ``` $ sudo apt-get install libboost-dev @@ -38,6 +42,7 @@ $ python3 -m venv --copies my_venv $ source my_venv/bin/activate ``` +#### Linux/MacOS You should then compile and install the ``psbody-mesh`` package using the Makefile. If you are using the system-wide ``Boost`` libraries: @@ -51,15 +56,39 @@ or the libraries locally installed: $ BOOST_ROOT=/path/to/boost/libraries make all ``` +#### Windows +Since Makefile and the linux commands in it does not work on Windows, run the command below instead: +(remember to replace with your path to boost) +``` +pip install --no-deps --install-option="--boost-location=" --verbose --no-cache-dir . +``` + +Note on MeshViewer: Windows users need a special version of PyOpenGL to use the MeshViewer, because the one automatically installed via PYPI does not include the required DLL. + +please download the unofficial PyOpenGL wheel file from [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl), uninstall the original version and install the new one by commands below: + +``` +pip uninstall pyOpenGL +pip install +``` + Testing ------- To run the tests, simply do: +#### Linux/MacOS + ``` $ make tests ``` +#### Windows + +``` +python -m unittest -v +``` + Documentation ------------- diff --git a/mesh/CMakeLists.txt b/mesh/CMakeLists.txt index e8db071..0a49ad4 100644 --- a/mesh/CMakeLists.txt +++ b/mesh/CMakeLists.txt @@ -80,6 +80,20 @@ target_compile_definitions(spatialsearch PRIVATE ${DEFINES_MESH_EXTENSIONS_WITH_CGAL_WITHOUT_LINK}) + +# visibility +python_add_library(TARGET visibility SOURCES + src/py_visibility.cpp + src/visibility.cpp + ) +target_include_directories(visibility PRIVATE + ${libcgalroot}/include + ${NUMPY_INCLUDE_PATH} + ${Boost_INCLUDE_DIRS}) +set_property(TARGET visibility PROPERTY FOLDER "GeometryExt/") +target_compile_definitions(visibility PRIVATE + ${DEFINES_MESH_EXTENSIONS_WITH_CGAL_WITHOUT_LINK}) + # serialization extensions @@ -97,3 +111,4 @@ target_include_directories(loadobj PRIVATE ${NUMPY_INCLUDE_PATH} ${Boost_INCLUDE_DIRS}) set_property(TARGET loadobj PROPERTY FOLDER "SerializationExt/") + diff --git a/mesh/cmake/thirdparty.cmake b/mesh/cmake/thirdparty.cmake index e5ae1ed..fda2dfd 100644 --- a/mesh/cmake/thirdparty.cmake +++ b/mesh/cmake/thirdparty.cmake @@ -26,7 +26,7 @@ find_package(PythonInterp REQUIRED) # numpy execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()" + COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_PATH ERROR_VARIABLE NUMPY_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE diff --git a/mesh/src/visibility.cpp b/mesh/src/visibility.cpp index 052a0b4..ef279d3 100644 --- a/mesh/src/visibility.cpp +++ b/mesh/src/visibility.cpp @@ -44,6 +44,13 @@ typedef AABB_triangle_traits::Point_and_primitive_id Point_and_Primitive_id; typedef CGAL::AABB_tree Tree; typedef Tree::Object_and_primitive_id Object_and_Primitive_id; +// if we are on MSCV, we need to instantiate the extern variable ORIGIN otherwise there will be a linking error +#ifdef _MSC_VER +namespace CGAL { + const CGAL::Origin ORIGIN; +}; +#endif + #include "visibility.h" struct VisibilityTask{ diff --git a/setup.py b/setup.py index bd37400..53e98e4 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,9 @@ def run(self): CGAL_dir_deflate = os.path.abspath(self.build_temp) + if os.name == 'nt': # if on windows, MSVC compiler will look for the Release folder + CGAL_dir_deflate = os.path.join(CGAL_dir_deflate, 'Release') + log.info('[CGAL] deflating cgal from "%s" to "%s"', CGAL_archive, CGAL_dir_deflate) if not os.path.exists(os.path.join(CGAL_dir_deflate, 'CGAL-4.7')): import tarfile @@ -181,8 +184,10 @@ def _get_all_extensions(): except: return [] - # valid only for gcc/clang - extra_args = ['-O3'] + if os.name == 'nt': # assume MSVC on windows + extra_args = [] # optimization is automatically enabled, /Ox not needed + else : + extra_args = ['-O3'] # valid only for gcc/clang import sys if sys.platform.find('linux') > -1: diff --git a/tests/test_mesh.py b/tests/test_mesh.py index 022cda2..e8de804 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -66,10 +66,11 @@ def test_raw_initialization(self): def test_writing_ascii_ply(self): m = Mesh(filename=self.test_ply_path) - (_, tempname) = tempfile.mkstemp() + (handle, tempname) = tempfile.mkstemp() m.write_ply(tempname, ascii=True) with open(tempname, 'r') as f: candidate = f.read() + os.close(handle) os.remove(tempname) with open(self.test_ply_path, 'r') as f: truth = f.read() @@ -77,10 +78,11 @@ def test_writing_ascii_ply(self): def test_writing_bin_ply(self): m = Mesh(filename=self.test_ply_path) - (_, tempname) = tempfile.mkstemp() + (handle, tempname) = tempfile.mkstemp() m.write_ply(tempname) with open(tempname, 'rb') as f: candidate = f.read() + os.close(handle) os.remove(tempname) with open(self.test_bin_ply_path, 'rb') as f: truth = f.read()