Giter VIP home page Giter VIP logo

pymcubes's People

Contributors

j6k4m8 avatar pmneila avatar zebastian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymcubes's Issues

box sdf doesn't work

Hello,

I found out that if I use box function as sdf, it creates only 3 sides of cube.

def box():
x, y, z = np.mgrid[:100, :100, :100]

def func(x, y, z):
    b0 = 1
    b1 = 1
    b2 = 1

    q0 = abs(x) - b0
    q1 = abs(y) - b1
    q2 = abs(z) - b2

    d0 = max(q0, 0)
    d1 = max(q1, 0)
    d2 = max(q2, 0)

    d = sqrt(d0*d0 + d1*d1 + d2*d2)

    return d + min(max(q0,max(q1,q2)),0)

vertices2, triangles2 = mcubes.marching_cubes_func(
    (0, 0, 0),
    (99, 99, 99),
    100, 100, 100,
    func, 0.0
)

sdf function is taken from here https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
(I've translated to python code, though I did it on C++ side)

Interpolation for Vertex

I noticed this lib implemented the interpolation for vertex like this:

double mc_isovalue_interpolation(double isovalue, double f1, double f2, double x1, double x2)
{
    if(f2==f1)
        return (x2+x1)/2;
    
    return (x2-x1)*(isovalue-f1)/(f2-f1) + x1;
}

But when I run:

field = np.ones([2, 2, 2]) + 99
field[0][0][0] = 0

vertices1, triangles1 = mcubes.marching_cubes(field, 50)

init = np.ones([2, 2, 2]) + 99
init[0][0][0] = 40

vertices2, triangles2 = mcubes.marching_cubes(field, 50)

The result is like:

vertices1
array([[0.5, 0. , 0. ],
       [0. , 0.5, 0. ],
       [0. , 0. , 0.5]])
vertices2
array([[0.5, 0. , 0. ],
       [0. , 0.5, 0. ],
       [0. , 0. , 0.5]])

It seems that it does not interpolate based on the value of the corner. If there is any bug or I just misunderstood this. 😭

def _build_variable_indices(band: np.ndarray) -> np.ndarray

Hi, I meet a problem, when i run in ubuntu16.04 python2.7.

import numpy as np
import mcubes
Traceback (most recent call last):
File "", line 1, in
File "/home/stu/.local/lib/python2.7/site-packages/mcubes/init.py", line 4, in
from .smoothing import *
File "/home/stu/.local/lib/python2.7/site-packages/mcubes/smoothing.py", line 22
def _build_variable_indices(band: np.ndarray) -> np.ndarray:
^
SyntaxError: invalid syntax

how can I fix this is?

PyMCubes version compatible with Python 2.7

Hey!
I am trying to install a pipeline (IELU Master GitHub) that is written in python 2.7. It is dependent on PyMCubes. Is there a way to obtain a python 2.7 version of your project so that I can use it?

Right now the main error I get is because of the super function (zero arguments provided in python 3.x)

Thanks!

Link error in Windows 10 & VS 2022

I've got 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\bin\HostX86\x86\link.exe' failed with exit code 1120.

I tried pip install PyMCubes and pip install PyMCubes --no-cache-dir with wheel but both give the same result.

I'm in venv and the Python is 3.10.

The compiler messages also same that a lot of warning and
many of _mcubes.obj : error LNK2001 and
3 of pywrapper.obj : error LNK2001.

blender import error

nortikin/sverchok#1549 (comment)
here all description
can load in bash, but not in blender:

  File "/home/ololo/.config/blender/2.78/scripts/addons/sverchok/nodes/generator/script1_lite.py", line 348, in process_script
    exec(self.script_str, locals(), locals())
  File "<string>", line 16, in <module>
ImportError: No module named 'mcubes._mcubes'

PS
installed as sudo pip3.5 install cython pymcubes etc...

marching cube smooth

Hi,
Thank you for your great work! I have one question regarding the mcube smooth operation: is there a degree to which I can control the call on mcubes.smooth(), such as setting a parameter for smoothness?

mcubes/src/_mcubes.cpp:45:10: fatal error: Python.h: Нет такого файла или каталога

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/blender/Developer/build_linux/deps/Release/sqlite/include -I/home/blender/Developer/build_linux/deps/Release/bzip2/include -I/home/blender/Developer/build_linux/deps/Release/lzma/include -I/home/blender/Developer/build_linux/deps/Release/zlib/include -fPIC -fPIC -Imcubes/src -I/home/user/Загрузки/blender-2.91.0-a1d57e3f05f1-linux64/2.91/python/lib/python3.7/site-packages/numpy/core/include -I/home/user/Загрузки/blender-2.91.0-a1d57e3f05f1-linux64/2.91/python/include/python3.7m -c mcubes/src/_mcubes.cpp -o build/temp.linux-x86_64-3.7/mcubes/src/_mcubes.o -std=c++11 -Wall
mcubes/src/_mcubes.cpp:45:10: fatal error: Python.h: Нет такого файла или каталога
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

First example

I think the first example creates a sphere with the surface normals pointing the wrong way. The definition should be:

u = -((X-15)**2 + (Y-15)**2 + (Z-15)2 - 82)

ValueError: vertex or face count are zero: terminating marching cubes

Was trying to extract vertices, faces and triangles from voxel information and was getting this error.

import numpy as np
import mcubes
from marching_cubes import march
import collada
import pymesh
import sys

inp_file = "../datasets/output/surface-recon/result.dat"
x = np.fromfile(inp_file, dtype=np.uint8)
dim = x[:3]
%Extract necessary elements
voxels = x[12:-16]
voxels = voxels.reshape((dim[0], dim[1], dim[2]))
vertices, normals, triangles = march(voxels, 0)

On running the aforementioned script I get:
ValueError: vertex or face count are zero: terminating marching cubes

Installation with 3.10 pip deprecation warning

Hey, thanks a lot for this module!

I've used it successfully with python3.9, however when trying to install for python3.10, I get the following error:

./python3.10 -m pip install --upgrade PyMCubes

Collecting PyMCubes
  Using cached PyMCubes-0.1.2.tar.gz (42 kB)
  Preparing metadata (setup.py) ... done
Installing collected packages: PyMCubes
  DEPRECATION: PyMCubes is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for PyMCubes ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for PyMCubes did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      /home/micha/Software/blender-3.4.0-linux-x64/3.4/python/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      WARNING: The wheel package is not available.
      running install
      /home/micha/Software/blender-3.4.0-linux-x64/3.4/python/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/mcubes
      copying mcubes/torch_smoothing.py -> build/lib.linux-x86_64-cpython-310/mcubes
      copying mcubes/exporter.py -> build/lib.linux-x86_64-cpython-310/mcubes
      copying mcubes/smoothing.py -> build/lib.linux-x86_64-cpython-310/mcubes
      copying mcubes/version.py -> build/lib.linux-x86_64-cpython-310/mcubes
      copying mcubes/__init__.py -> build/lib.linux-x86_64-cpython-310/mcubes
      running build_ext
      building 'mcubes._mcubes' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/mcubes
      creating build/temp.linux-x86_64-cpython-310/mcubes/src
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/src/build_linux/deps/Release/sqlite/include -I/src/build_linux/deps/Release/bzip2/include -I/src/build_linux/deps/Release/lzma/include -I/src/build_linux/deps/Release/zlib/include -fPIC -fPIC -fPIC -Imcubes/src -I/home/micha/Software/blender-3.4.0-linux-x64/3.4/python/lib/python3.10/site-packages/numpy/core/include -I/home/micha/Software/blender-3.4.0-linux-x64/3.4/python/include/python3.10 -c mcubes/src/_mcubes.cpp -o build/temp.linux-x86_64-cpython-310/mcubes/src/_mcubes.o -std=c++11 -Wall
      mcubes/src/_mcubes.cpp:40:10: fatal error: Python.h: No such file or directory
       #include "Python.h"
                ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> PyMCubes

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Using the mentioned flag --use-pep517 seems to be an option, but this then tries to build from source (if I understand correctly) which doesn't work on my system at the moment (because python3.10-dev is not available).

Publish on pypi ?

Hello,

Your implementation of the marching cubes algorithm does a better job than the one in scikit-image which seems consistently to leave holes in the surface. There is another implementation called pythonisosurfaces which uses javascript and is much less easy to call from within python.

Would you consider publishing your implementation on pypi so I can depend on it more easily? I am not asking out of licensing issues, my software is also GPL, but just for ease of distribution.

ValueError: numpy.ufunc size changed, may indicate binary incompatibility.

Problem

The release of 0.1.3 fails to import:

In [1]: import mcubes
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-c29732f53359> in <module>
----> 1 import mcubes

~\anaconda3\lib\site-packages\mcubes\__init__.py in <module>
      1
----> 2 from ._mcubes import marching_cubes, marching_cubes_func
      3 from .exporter import export_mesh, export_obj, export_off
      4 from .smoothing import smooth, smooth_constrained, smooth_gaussian

mcubes\src\_mcubes.pyx in init mcubes._mcubes()

ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 232 from C header, got 216 from PyObject

Environment

Verified on both Windows and Ubuntu.
numpy version: 1.21.4
mcubes version: 0.1.3

Failed to find exporter after installation

Hey, got it to compile and install but still doesn't run

Traceback (most recent call last):
File "generate.py", line 6, in
import mcubes
File "/home/user/local/anaconda3/lib/python3.4/site-packages/PyMCubes-0.0.4-py3.4-linux-x86_64.egg/mcubes/init.py", line 3, in
from exporter import export_mesh
ImportError: No module named 'exporter'

build error

Hi,

I get the following build error:

python setup.py build
Traceback (most recent call last):
  File "setup.py", line 52, in <module>
    ext_modules=cythonize(mcubes_module),
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 818, in cythonize
    aliases=aliases)
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 648, in create_extension_list
    elif isinstance(patterns, basestring) or not isinstance(patterns, collections.Iterable):
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/abc.py", line 144, in __instancecheck__
    return cls.__subclasscheck__(subtype)
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/abc.py", line 180, in __subclasscheck__
    if issubclass(subclass, scls):
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/abc.py", line 180, in __subclasscheck__
    if issubclass(subclass, scls):
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/abc.py", line 161, in __subclasscheck__
    ok = cls.__subclasshook__(subclass)
  File "/Users/bendichter/anaconda/envs/python2/lib/python2.7/site-packages/backports_abc.py", line 66, in __subclasshook__
    mro = C.__mro__
AttributeError: class Extension has no attribute '__mro__'

OSX

python: Python 2.7.11 |Anaconda custom (x86_64)| (default, Dec 6 2015, 18:57:58)

gcc:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

number of mesh points

Can I specify the number of mesh points? For example,
vertices, triangles = mcubes.marching_cubes(cube, 0.5)
and I hope to get a mesh with 6000 points.

Vertices with no value

Hi,

I discovered the marching cubes algorithm recently and I am trying to use it for surface reconstruction on outdoor environments from lidar. For this, I am calculating a Truncated Signed Distance Field (TSDF) that I send to the marching cubes. However, I don't find a way to assign a neutral value (like a NULL) to cubes that are far from my TSDF to avoid errors in my reconstruction, the problem is that since I am reconstructing a scene scanned from Lidar, I don't have a completely closed scanned object, so when I assign the values to further voxels I make mistakes on the reconstruction since I am propagating the SDF after the borders of my surface.

Hope I explained correctly my problem, don't hesitate to ask if you need more details. Thanks for your help and have a nice day,

Luis

Broken Mesh

Hello, I am trying to covert voxel to mesh with marching cubes.
My code is as the following

vertices, triangles = mcubes.marching_cubes(voxel, 0.5)  
mcubes.export_mesh(vertices, triangles, "gorira.obj", "gorira")  
print("Plotting mesh...")  
mlab.triangular_mesh(
    vertices[:, 0], vertices[:, 1], vertices[:, 2], triangles)
print("Done.")  
mlab.show()

The voxel is visualized as
image
However, after marching cubes algorithm, it becomes broken, like this

image

Why does this happen? Does anyone have some ideas about this?

ModuleNotFoundError: No module named 'mcubes._mcubes'

Got the following error

import mcubes
1
----> 2 from ._mcubes import marching_cubes, marching_cubes_func
3 from .exporter import export_mesh, export_obj, export_off
4 from .smoothing import *

ModuleNotFoundError: No module named 'mcubes._mcubes'

installed through pip3 install pymcubes
system: ubuntu 20.04

Build Error

Hello, I'm trying to install PyMCubes through pip, and I get the following output:

C:\Users\Administrator>pip install PyMCubes
Collecting PyMCubes
  Using cached PyMCubes-0.0.6.tar.gz
Building wheels for collected packages: PyMCubes
  Running setup.py bdist_wheel for PyMCubes ... error
  Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "import
 setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-b
uild-de4_f7_s\\PyMCubes\\setup.py';f=getattr(tokenize, 'open', open)(__file__);c
ode=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'
))" bdist_wheel -d C:\Users\ADMINI~1\AppData\Local\Temp\tmp93c1esmzpip-wheel- --
python-tag cp36:
  Warning: Extension name 'mcubes._mcubes' does not match fully qualified name '
_mcubes' of 'mcubes/src/_mcubes.pyx'
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\mcubes
  copying mcubes\exporter.py -> build\lib.win-amd64-3.6\mcubes
  copying mcubes\__init__.py -> build\lib.win-amd64-3.6\mcubes
  running build_ext
  building 'mcubes._mcubes' extension
  creating build\temp.win-amd64-3.6
  creating build\temp.win-amd64-3.6\Release
  creating build\temp.win-amd64-3.6\Release\mcubes
  creating build\temp.win-amd64-3.6\Release\mcubes\src
  C:\ProgramData\Anaconda3\Library\mingw-w64\bin\gcc.exe -mdll -O -Wall -DMS_WIN
64 -Imcubes/src -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include
-IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include -c mcubes/
src/_mcubes.cpp -o build\temp.win-amd64-3.6\Release\mcubes\src\_mcubes.o -std=c+
+11
  In file included from C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\in
clude/numpy/ndarraytypes.h:1809:0,
                   from C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\in
clude/numpy/ndarrayobject.h:18,
                   from C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\in
clude/numpy/arrayobject.h:4,
                   from mcubes/src/_mcubes.cpp:518:
  C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include/numpy/npy_1_7_de
precated_api.h:13:79: note: #pragma message: C:\ProgramData\Anaconda3\lib\site-p
ackages\numpy\core\include/numpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Usi
ng deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_A
PI_VERSION
                            "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
")

 ^
  In file included from C:/ProgramData/Anaconda3/Library/mingw-w64/include/c++/5
.3.0/complex:44:0,
                   from mcubes/src/pyarraymodule.h:13,
                   from mcubes/src/pywrapper.h:6,
                   from mcubes/src/_mcubes.cpp:520:
  C:/ProgramData/Anaconda3/Library/mingw-w64/include/c++/5.3.0/cmath:1119:11: er
ror: '::hypot' has not been declared
     using ::hypot;
             ^
  mcubes/src/_mcubes.cpp: In function 'PyTypeObject* __Pyx_ImportType(const char
*, const char*, size_t, int)':
  mcubes/src/_mcubes.cpp:6737:53: warning: unknown conversion type character 'z'
 in format [-Wformat=]
               module_name, class_name, basicsize, size);
                                                       ^
  mcubes/src/_mcubes.cpp:6737:53: warning: unknown conversion type character 'z'
 in format [-Wformat=]
  mcubes/src/_mcubes.cpp:6737:53: warning: too many arguments for format [-Wform
at-extra-args]
  error: command 'C:\\ProgramData\\Anaconda3\\Library\\mingw-w64\\bin\\gcc.exe'
failed with exit status 1

  ----------------------------------------
  Failed building wheel for PyMCubes
  Running setup.py clean for PyMCubes
Failed to build PyMCubes
Installing collected packages: PyMCubes
  Running setup.py install for PyMCubes ... error
    Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "impo
rt setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip
-build-de4_f7_s\\PyMCubes\\setup.py';f=getattr(tokenize, 'open', open)(__file__)
;code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exe
c'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-r6wqmcgl-record\
install-record.txt --single-version-externally-managed --compile:
    Warning: Extension name 'mcubes._mcubes' does not match fully qualified name
 '_mcubes' of 'mcubes/src/_mcubes.pyx'
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\mcubes
    copying mcubes\exporter.py -> build\lib.win-amd64-3.6\mcubes
    copying mcubes\__init__.py -> build\lib.win-amd64-3.6\mcubes
    running build_ext
    building 'mcubes._mcubes' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    creating build\temp.win-amd64-3.6\Release\mcubes
    creating build\temp.win-amd64-3.6\Release\mcubes\src
    C:\ProgramData\Anaconda3\Library\mingw-w64\bin\gcc.exe -mdll -O -Wall -DMS_W
IN64 -Imcubes/src -IC:\ProgramData\Anaconda3\lib\site-packages\numpy\core\includ
e -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include -c mcube
s/src/_mcubes.cpp -o build\temp.win-amd64-3.6\Release\mcubes\src\_mcubes.o -std=
c++11
    In file included from C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\
include/numpy/ndarraytypes.h:1809:0,
                     from C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\
include/numpy/ndarrayobject.h:18,
                     from C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\
include/numpy/arrayobject.h:4,
                     from mcubes/src/_mcubes.cpp:518:
    C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\include/numpy/npy_1_7_
deprecated_api.h:13:79: note: #pragma message: C:\ProgramData\Anaconda3\lib\site
-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h(12) : Warning Msg: U
sing deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7
_API_VERSION
                              "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSI
ON")

   ^
    In file included from C:/ProgramData/Anaconda3/Library/mingw-w64/include/c++
/5.3.0/complex:44:0,
                     from mcubes/src/pyarraymodule.h:13,
                     from mcubes/src/pywrapper.h:6,
                     from mcubes/src/_mcubes.cpp:520:
    C:/ProgramData/Anaconda3/Library/mingw-w64/include/c++/5.3.0/cmath:1119:11:
error: '::hypot' has not been declared
       using ::hypot;
               ^
    mcubes/src/_mcubes.cpp: In function 'PyTypeObject* __Pyx_ImportType(const ch
ar*, const char*, size_t, int)':
    mcubes/src/_mcubes.cpp:6737:53: warning: unknown conversion type character '
z' in format [-Wformat=]
                 module_name, class_name, basicsize, size);
                                                         ^
    mcubes/src/_mcubes.cpp:6737:53: warning: unknown conversion type character '
z' in format [-Wformat=]
    mcubes/src/_mcubes.cpp:6737:53: warning: too many arguments for format [-Wfo
rmat-extra-args]
    error: command 'C:\\ProgramData\\Anaconda3\\Library\\mingw-w64\\bin\\gcc.exe
' failed with exit status 1

    ----------------------------------------
Command "C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;
__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-de4_f7_s\\PyMCube
s\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C
:\Users\ADMINI~1\AppData\Local\Temp\pip-r6wqmcgl-record\install-record.txt --sin
gle-version-externally-managed --compile" failed with error code 1 in C:\Users\A
DMINI~1\AppData\Local\Temp\pip-build-de4_f7_s\PyMCubes\

This looks like a Cython problem, but I've updated python, Cython, gcc, and numpy to the most recent versions. I get a similar error if I try to build using py setup.py build instead of pip.

≈EVERY vertex is duplicated?

On a simple example, with iso=0., we're seeing a new vertex listed in verts for almost every time that coordinate is used in faces:

This is the vertex list that is generated, with example annotations (mine)

[array([[ 0.,  0.,  0.],
      [ 1.,  1.,  0.],                      <-- A
      [ 1.,  0.,  1.],                      <-- B
      [ 1.,  6.,  1.],
      [ 0.,  5.,  1.],
      ...
      [ 0.,  7.,  0.],
      [ 0.,  8.,  1.],
      [ 0.,  7.,  0.],
      [ 2.,  1.,  0.],                      <-- C 
      [ 1.,  1.,  0.],                      <-- A
      [ 1.,  0.,  1.],                      <-- B 
      [ 2.,  0.,  1.],
      [ 2.,  2.,  1.],
      [ 2.,  1.,  0.],                      <-- C
      [ 1.,  2.,  0.],
      ...
      [ 3.,  8.,  0.],
      [ 3.,  8.,  0.],
      [ 4.,  9.,  0.]], dtype=float32)]

Multimaterial Capability?

Hi,

I have volume data consisting of different materials with different Feature Ids.

Will PyMCubes work for this type of multimaterial data? For example I would like the isosurface for each Feature Id.

Many thanks,
Jonathan

How to increase the precision?

I noticed that all the result coordinate of vertices are integral, which caused a low precision in my result. Is there any way to increase precision? Can this module give float results?

Can not compile

python setup.py build >>
running build_py
running build_ext
building 'mcubes._mcubes' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/lib64/python2.6/site-packages/numpy/core/include -I/usr/include/python2.6 -c mcubes/src/_mcubes.c -o build/temp.linux-x86_64-2.6/mcubes/src/_mcubes.o -std=c++11
gcc: mcubes/src/_mcubes.c: No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1

building error

Got an error when tried to build:
"error: command 'C:\Users\zimka\AppData\Local\Programs\Common\Microsoft\V
isual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2"
The same thing with pip install

Full text of errors:

python setup.py build
running build
running build_py
running build_ext
building 'mcubes._mcubes' extension
C:\Users\zimka\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packa
ges\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tpmcubes/src/_mcu
bes.cpp /Fobuild\temp.win32-2.7\Release\mcubes/src/_mcubes.obj
_mcubes.cpp
c:\python27\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(
12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DE
PRECATED_API NPY_1_7_API_VERSION
C:\Users\zimka\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
\VC\Include\xlocale(342) : warning C4530: C++ exception handler used, but unwind
semantics are not enabled. Specify /EHsc
C:\Users\zimka\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packa
ges\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tpmcubes/src/pywr
apper.cpp /Fobuild\temp.win32-2.7\Release\mcubes/src/pywrapper.obj
pywrapper.cpp
c:\python27\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(
12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DE
PRECATED_API NPY_1_7_API_VERSION
C:\Users\zimka\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
\VC\Include\xlocale(342) : warning C4530: C++ exception handler used, but unwind
semantics are not enabled. Specify /EHsc
c:\pymcubes\mcubes\src\marchingcubes.h(29) : error C4430: missing type specifier

  • int assumed. Note: C++ does not support default-int
    mcubes/src/pywrapper.cpp(58) : see reference to function template instan
    tiation 'void mc::marching_cubes<double[3],PythonToCFunc>(const vector3 (&),cons
    t vector3 (&),int,int,int,formula,double,std::vector<_Ty> &,std::vector &)'
    being compiled
    with
    [
    vector3=double [3],
    formula=PythonToCFunc,
    _Ty=double
    ]
    c:\pymcubes\mcubes\src\marchingcubes.h(29) : error C2513: 'int' : no variable de
    clared before '='
    c:\pymcubes\mcubes\src\marchingcubes.h(29) : error C2146: syntax error : missing
    ';' before identifier 'coord_type'
    c:\pymcubes\mcubes\src\marchingcubes.h(29) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(34) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(34) : error C2146: syntax error : missing
    ';' before identifier 'dx'
    c:\pymcubes\mcubes\src\marchingcubes.h(34) : error C2065: 'dx' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(34) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(35) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(35) : error C2146: syntax error : missing
    ';' before identifier 'dy'
    c:\pymcubes\mcubes\src\marchingcubes.h(35) : error C2065: 'dy' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(35) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(36) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(36) : error C2146: syntax error : missing
    ';' before identifier 'dz'
    c:\pymcubes\mcubes\src\marchingcubes.h(36) : error C2065: 'dz' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(36) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(44) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(44) : error C2146: syntax error : missing
    ';' before identifier 'x'
    c:\pymcubes\mcubes\src\marchingcubes.h(44) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(44) : error C2065: 'dx' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(45) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(45) : error C2146: syntax error : missing
    ';' before identifier 'x_dx'
    c:\pymcubes\mcubes\src\marchingcubes.h(45) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(45) : error C2065: 'dx' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(48) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(48) : error C2146: syntax error : missing
    ';' before identifier 'y'
    c:\pymcubes\mcubes\src\marchingcubes.h(48) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(48) : error C2065: 'dy' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(49) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(49) : error C2146: syntax error : missing
    ';' before identifier 'y_dy'
    c:\pymcubes\mcubes\src\marchingcubes.h(49) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(49) : error C2065: 'dy' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(52) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(52) : error C2146: syntax error : missing
    ';' before identifier 'z'
    c:\pymcubes\mcubes\src\marchingcubes.h(52) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(52) : error C2065: 'dz' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(53) : error C2065: 'coord_type' : undecla
    red identifier
    c:\pymcubes\mcubes\src\marchingcubes.h(53) : error C2146: syntax error : missing
    ';' before identifier 'z_dz'
    c:\pymcubes\mcubes\src\marchingcubes.h(53) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(53) : error C2065: 'dz' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(56) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(56) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(56) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(56) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(56) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(56) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(57) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(57) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(57) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(57) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(57) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(57) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(58) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(58) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(58) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(58) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(58) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(58) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(59) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(59) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(59) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(59) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(59) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(59) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(74) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(74) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(74) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(74) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(80) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(80) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(80) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(80) : error C2065: 'y_dy' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(86) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(86) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(86) : error C2065: 'dx' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(86) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(86) : error C2065: 'z_dz' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(94) : error C2065: 'x' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(94) : error C2065: 'y' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(94) : error C2065: 'z' : undeclared ident
    ifier
    c:\pymcubes\mcubes\src\marchingcubes.h(94) : error C2065: 'x_dx' : undeclared id
    entifier
    c:\pymcubes\mcubes\src\marchingcubes.h(104) : error C2065: 'x_dx' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(104) : error C2065: 'y' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(104) : error C2065: 'z' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(104) : error C2065: 'y_dy' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(114) : error C2065: 'x_dx' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(114) : error C2065: 'y_dy' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(114) : error C2065: 'z' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(114) : error C2065: 'x' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(124) : error C2065: 'x' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(124) : error C2065: 'y_dy' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(124) : error C2065: 'z' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(124) : error C2065: 'y' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(134) : error C2065: 'x' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(134) : error C2065: 'y' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(134) : error C2065: 'z_dz' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(134) : error C2065: 'x_dx' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(144) : error C2065: 'x' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(144) : error C2065: 'y_dy' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(144) : error C2065: 'z_dz' : undeclared i
    dentifier
    c:\pymcubes\mcubes\src\marchingcubes.h(144) : error C2065: 'y' : undeclared iden
    tifier
    c:\pymcubes\mcubes\src\marchingcubes.h(144) : fatal error C1003: error count exc
    eeds 100; stopping compilation
    error: command 'C:\Users\zimka\AppData\Local\Programs\Common\Microsoft\V
    isual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2

[Feature] Add to conda-forge

Hi @pmneila,

We depend on PyMCubes in our brainglobe-atlasapi package, which we're looking to put onto conda-forge.

conda-forge doesn't let us add packages unless all dependencies are available through conda-forge itself, so I wanted to ask if you would be OK with us writing the recipe and making PyMCubes available through conda. We would be happy to add you as a maintainer to the resulting conda package too, of course.

Thanks,
Will (@willGraham01)

PyMCubes depends on Cython and Numpy

If i execute

pip3 install PyMCubes

it complains that cython and numpy are missing. I had to install them manually. I believe these dependencies can be installed automatically by pip.

Complex Shapes?

I know we can use simple shapes like spheres

X, Y, Z = np.mgrid[:30, :30, :30]
world = (X-15)**2 + (Y-15)**2 + (Z-15)**2 - 8**2
vertices, triangles = mcubes.marching_cubes(mcubes.smooth(world), 0.5)

But I'm struggling to figure out how to make more advance shape (like terrain). A good idea for games / terrain editors.
I thought making a 3d array (grid) of voxels which is given to mcubes.smooth, but my implementation doesn't get anything rendered.

Currently my implementation looks like:

n = 30
voxels = [[[0 for k in range(n)] for j in range(n)] for i in range(n)]
for vx in range(0, 30):
    for vy in range(0, 30):
        for vz in range(0, 30):
            voxels[vx][vy][vz] = 1

def makeMesh(x, y, z):
    result = 1
    if voxels[x][y][z] == 1:
        result = -1
    return result

vMakeMesh = np.vectorize(makeMesh)

X, Y, Z = np.mgrid[:30, :30, :30]
world = vMakeMesh(X, Y, Z)

vertices, triangles = mcubes.marching_cubes(mcubes.smooth(world), 0.5)

I think my problem is that world does not contain correct data. I think the problem comes from the makeMesh method, or how I fill my voxels array.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.