Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ Requirements
------------

You first need to install the `Boost <http://www.boost.org>`_ 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
Expand All @@ -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:

Expand All @@ -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 <path_to_your_boost> with your path to boost)
```
pip install --no-deps --install-option="--boost-location=<path_to_your_boost>" --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 <the-name-of-your-wheel-file>
```

Testing
-------

To run the tests, simply do:

#### Linux/MacOS

```
$ make tests
```

#### Windows

```
python -m unittest -v
```

Documentation
-------------

Expand Down
15 changes: 15 additions & 0 deletions mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -97,3 +111,4 @@ target_include_directories(loadobj PRIVATE
${NUMPY_INCLUDE_PATH}
${Boost_INCLUDE_DIRS})
set_property(TARGET loadobj PROPERTY FOLDER "SerializationExt/")

2 changes: 1 addition & 1 deletion mesh/cmake/thirdparty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions mesh/src/visibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ typedef AABB_triangle_traits::Point_and_primitive_id Point_and_Primitive_id;
typedef CGAL::AABB_tree<AABB_triangle_traits> 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{
Expand Down
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,23 @@ 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()
self.assertEqual(candidate, truth)

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()
Expand Down