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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
build/
dist/
_build/
_generate/
*.so
*.py[cod]
*.egg-info
*.pyd
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "pybind11"]
path = pybind11
url = https://github.com/pybind/pybind11.git
35 changes: 1 addition & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,13 @@ endif()

find_package(OpenMP)


find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})


find_package(pybind11 REQUIRED)
include_directories(${pybind11_INCLUDE_DIRS})


if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()


# set(WINDOWS_EXPORT_ALL_SYMBOLS 1)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1)


include_directories(src)
add_subdirectory(pybind11)

pybind11_add_module(marching_cubes
src/python_wrapper.cpp
Expand All @@ -44,23 +31,3 @@ pybind11_add_module(marching_cubes
src/laplacian_smoothing.cpp)



#################################
# INSTALL THE PYTHON MODULE
#################################

if(NOT DEFINED PYTHON_MODULE_INSTALL_DIR OR PYTHON_MODULE_INSTALL_DIR MATCHES "^$")
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"from distutils.sysconfig import *; print(get_python_lib(1))"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
FILE(TO_CMAKE_PATH ${PYTHON_SITE_PACKAGES} PYTHON_MODULE_INSTALL_DIR)
endif()

SET(PYTHON_MODULE_INSTALL_DIR ${PYTHON_MODULE_INSTALL_DIR}
CACHE PATH "where to install the marching cubres Python package" FORCE)

# this is the install path relative to CMAKE_INSTALL_PREFIX,
# use this in INSTALL() commands to get packaging right
FILE(RELATIVE_PATH PYTHON_MODULE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_MODULE_INSTALL_DIR})

install(TARGETS marching_cubes DESTINATION ${PYTHON_MODULE_INSTALL_DIR})
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.md LICENSE
global-include CMakeLists.txt *.cmake
recursive-include src *
recursive-include pybind11/include *.h
17 changes: 1 addition & 16 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
mkdir build
cd build

set CONFIGURATION=Release

cmake .. -G "%CMAKE_GENERATOR%" ^
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
-DPYTHON_EXECUTABLE="%PYTHON%"

if errorlevel 1 exit 1

cmake --build . --target ALL_BUILD --config %CONFIGURATION%
if errorlevel 1 exit 1

cmake --build . --target INSTALL --config %CONFIGURATION%
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
46 changes: 3 additions & 43 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,3 @@
export CXXFLAGS=""
export CFLAGS=""
export LDFLAGS=""

PY_VER=$(python -c "import sys; print('{}.{}'.format(*sys.version_info[:2]))")
PY_ABIFLAGS=$(python -c "import sys; print('' if sys.version_info.major == 2 else sys.abiflags)")
PY_ABI=${PY_VER}${PY_ABIFLAGS}

# Depending on our platform, shared libraries end with either .so or .dylib
if [[ $(uname) == 'Darwin' ]]; then
DYLIB_EXT=dylib
CC=clang
CXX=clang++
CXXFLAGS="${CFLAGS} -std=c++11 -stdlib=libc++"
else
DYLIB_EXT=so
CC=gcc
CXX=g++
CXXFLAGS="${CFLAGS} -std=c++11"
# enable compilation without CXX abi to stay compatible with gcc < 5 built packages
if [[ ${DO_NOT_BUILD_WITH_CXX11_ABI} == '1' ]]; then
CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 ${CXXFLAGS}"
fi
fi

mkdir build
cd build
cmake ..\
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_PREFIX_PATH=${PREFIX} \
-DPYTHON_EXECUTABLE=${PYTHON} \
-DPYTHON_LIBRARY=${PREFIX}/lib/libpython${PY_ABI}.${DYLIB_EXT} \
-DPYTHON_INCLUDE_DIR=${PREFIX}/include/python${PY_ABI} \
##

make -j${CPU_COUNT}

make install

#cp ${SRC_DIR}/build/marching_cubes*.so ${PREFIX}/lib/python${PY_VER}/site-packages/
#!/bin/bash
unset MACOSX_DEPLOYMENT_TARGET
${PYTHON} setup.py install;
11 changes: 0 additions & 11 deletions conda-recipe/conda_build_config.yaml

This file was deleted.

46 changes: 18 additions & 28 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
package:
name: marching_cubes

{% if GIT_DESCRIBE_NUMBER|int == 0 %}
version: {{GIT_DESCRIBE_TAG}}
{% else %}
# If we're using a non-tagged revision, append '.postN' to the version
version: {{GIT_DESCRIBE_TAG}}.post{{GIT_DESCRIBE_NUMBER}}
{% endif %}

source:
path: ../
name: cmake_example
version: {{ environ.get('GIT_DESCRIBE_TAG', 'dev') }}

build:
number: 0
string: py{{CONDA_PY}}_{{PKG_BUILDNUM}}_h{{PKG_HASH}}_g{{GIT_FULL_HASH[:7]}}
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
{% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0
{% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %}
script_env:
# Control building with CXX11 abi
- DO_NOT_BUILD_WITH_CXX11_ABI # [linux]
- CC
- CXX

source:
git_url: ../

requirements:
build:
- cmake
- python >=2.7
- python {{ python }}
- boost {{ boost }}
- python
- setuptools
- pybind11
- cmake

run:
- python
- boost
# in order to suppor older linux distros after gcc5 switch:
- libstdcxx-ng >={{ libstdcxxng }} # [linux]
- numpy
- vs2015_runtime # [win]

test:
imports:
- marching_cubes
- cmake_example

about:
home: http://ilastik.org
license: BSD (3-clause)
liscense_file: LICENSE
summary: A fast marching cubes implementation in C++ with python bindings.
summary: An example project built with pybind11.
license_file: LICENSE
1 change: 1 addition & 0 deletions pybind11
Submodule pybind11 added at e2b884
67 changes: 67 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import re
import sys
import platform
import subprocess

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion


class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)


class CMakeBuild(build_ext):
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))

if platform.system() == "Windows":
cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < '3.1.0':
raise RuntimeError("CMake >= 3.1.0 is required on Windows")

for ext in self.extensions:
self.build_extension(ext)

def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable]

cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]

if platform.system() == "Windows":
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
build_args += ['--', '/m']
else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['--', '-j2']

env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
self.distribution.get_version())
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)

setup(
name='marching_cubes',
version='0.0.1',
description='Standalone marching cubes implementation and Python bindings',
long_description='',
ext_modules=[CMakeExtension('marching_cubes')],
cmdclass=dict(build_ext=CMakeBuild),
zip_safe=False,
)
8 changes: 4 additions & 4 deletions src/laplacian_smoothing.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "laplacian_smoothing.h"
#include <vector>
// #include <set>
#include <set>
// #include <unordered_set>
#include <iostream>


#include <boost/container/flat_set.hpp>
// #include <boost/container/flat_set.hpp>

typedef std::vector<boost::container::flat_set<size_t>> Adjacency;
//typedef std::vector<std::set<size_t> > Adjacency;
// typedef std::vector<boost::container::flat_set<size_t>> Adjacency;
typedef std::vector<std::set<size_t> > Adjacency;
//typedef std::vector<std::unordered_set<size_t> > Adjacency;
/**
* maps each vertex to all its neighbours
Expand Down