Code Monkey home page Code Monkey logo

pygalmesh's Introduction

pygalmesh

Create high-quality meshes with ease.

PyPi Version Anaconda Cloud Packaging status PyPI pyversions DOI GitHub stars Downloads

Discord

gh-actions codecov LGTM Code style: black

pygalmesh is a Python frontend to CGAL's 2D and 3D mesh generation capabilities. pygalmesh makes it easy to create high-quality 2D, 3D volume meshes, periodic volume meshes, and surface meshes.

Examples

2D meshes

CGAL generates 2D meshes from linear constraints.

import numpy as np
import pygalmesh

points = np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]])
constraints = [[0, 1], [1, 2], [2, 3], [3, 0]]

mesh = pygalmesh.generate_2d(
    points,
    constraints,
    max_edge_size=1.0e-1,
    num_lloyd_steps=10,
)
# mesh.points, mesh.cells

The quality of the mesh isn't very good, but can be improved with optimesh.

A simple ball

import pygalmesh

s = pygalmesh.Ball([0, 0, 0], 1.0)
mesh = pygalmesh.generate_mesh(s, max_cell_circumradius=0.2)

# mesh.points, mesh.cells, ...

You can write the mesh with

mesh.write("out.vtk")

You can use any format supported by meshio.

The mesh generation comes with many more options, described here. Try, for example,

mesh = pygalmesh.generate_mesh(
    s, max_cell_circumradius=0.2, odt=True, lloyd=True, verbose=False
)

Other primitive shapes

pygalmesh provides out-of-the-box support for balls, cuboids, ellipsoids, tori, cones, cylinders, and tetrahedra. Try for example

import pygalmesh

s0 = pygalmesh.Tetrahedron(
    [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]
)
mesh = pygalmesh.generate_mesh(
    s0,
    max_cell_circumradius=0.1,
    max_edge_size_at_feature_edges=0.1,
)

Domain combinations

Supported are unions, intersections, and differences of all domains. As mentioned above, however, the sharp intersections between two domains are not automatically handled. Try for example

import pygalmesh

radius = 1.0
displacement = 0.5
s0 = pygalmesh.Ball([displacement, 0, 0], radius)
s1 = pygalmesh.Ball([-displacement, 0, 0], radius)
u = pygalmesh.Difference(s0, s1)

To sharpen the intersection circle, add it as a feature edge polygon line, e.g.,

import numpy as np
import pygalmesh

radius = 1.0
displacement = 0.5
s0 = pygalmesh.Ball([displacement, 0, 0], radius)
s1 = pygalmesh.Ball([-displacement, 0, 0], radius)
u = pygalmesh.Difference(s0, s1)

# add circle
a = np.sqrt(radius**2 - displacement**2)
max_edge_size_at_feature_edges = 0.15
n = int(2 * np.pi * a / max_edge_size_at_feature_edges)
alpha = np.linspace(0.0, 2 * np.pi, n + 1)
alpha[-1] = alpha[0]
circ = a * np.column_stack([np.zeros(n + 1), np.cos(alpha), np.sin(alpha)])

mesh = pygalmesh.generate_mesh(
    u,
    extra_feature_edges=[circ],
    max_cell_circumradius=0.15,
    max_edge_size_at_feature_edges=max_edge_size_at_feature_edges,
    min_facet_angle=25,
    max_radius_surface_delaunay_ball=0.15,
    max_circumradius_edge_ratio=2.0,
)

Note that the length of the polygon legs are kept in sync with max_edge_size_at_feature_edges of the mesh generation. This makes sure that it fits in nicely with the rest of the mesh.

Domain deformations

You can of course translate, rotate, scale, and stretch any domain. Try, for example,

import pygalmesh

s = pygalmesh.Stretch(pygalmesh.Ball([0, 0, 0], 1.0), [1.0, 2.0, 0.0])

mesh = pygalmesh.generate_mesh(s, max_cell_circumradius=0.1)

Extrusion of 2D polygons

pygalmesh lets you extrude any polygon into a 3D body. It even supports rotation alongside!

import pygalmesh

p = pygalmesh.Polygon2D([[-0.5, -0.3], [0.5, -0.3], [0.0, 0.5]])
max_edge_size_at_feature_edges = 0.1
domain = pygalmesh.Extrude(
    p,
    [0.0, 0.0, 1.0],
    0.5 * 3.14159265359,
    max_edge_size_at_feature_edges,
)
mesh = pygalmesh.generate_mesh(
    domain,
    max_cell_circumradius=0.1,
    max_edge_size_at_feature_edges=max_edge_size_at_feature_edges,
    verbose=False,
)

Feature edges are automatically preserved here, which is why an edge length needs to be given to pygalmesh.Extrude.

Rotation bodies

Polygons in the x-z-plane can also be rotated around the z-axis to yield a rotation body.

import pygalmesh

p = pygalmesh.Polygon2D([[0.5, -0.3], [1.5, -0.3], [1.0, 0.5]])
max_edge_size_at_feature_edges = 0.1
domain = pygalmesh.RingExtrude(p, max_edge_size_at_feature_edges)
mesh = pygalmesh.generate_mesh(
    domain,
    max_cell_circumradius=0.1,
    max_edge_size_at_feature_edges=max_edge_size_at_feature_edges,
    verbose=False,
)

Your own custom level set function

If all of the variety is not enough for you, you can define your own custom level set function. You simply need to subclass pygalmesh.DomainBase and specify a function, e.g.,

import pygalmesh


class Heart(pygalmesh.DomainBase):
    def __init__(self):
        super().__init__()

    def eval(self, x):
        return (
            (x[0] ** 2 + 9.0 / 4.0 * x[1] ** 2 + x[2] ** 2 - 1) ** 3
            - x[0] ** 2 * x[2] ** 3
            - 9.0 / 80.0 * x[1] ** 2 * x[2] ** 3
        )

    def get_bounding_sphere_squared_radius(self):
        return 10.0


d = Heart()
mesh = pygalmesh.generate_mesh(d, max_cell_circumradius=0.1)

Note that you need to specify the square of a bounding sphere radius, used as an input to CGAL's mesh generator.

Local refinement

Use generate_mesh with a function (regular or lambda) as max_cell_circumradius. The same goes for max_edge_size_at_feature_edges, max_radius_surface_delaunay_ball, and max_facet_distance.

import numpy as np
import pygalmesh

mesh = pygalmesh.generate_mesh(
    pygalmesh.Ball([0.0, 0.0, 0.0], 1.0),
    min_facet_angle=30.0,
    max_radius_surface_delaunay_ball=0.1,
    max_facet_distance=0.025,
    max_circumradius_edge_ratio=2.0,
    max_cell_circumradius=lambda x: abs(np.sqrt(np.dot(x, x)) - 0.5) / 5 + 0.025,
)

Surface meshes

If you're only after the surface of a body, pygalmesh has generate_surface_mesh for you. It offers fewer options (obviously, max_cell_circumradius is gone), but otherwise works the same way:

import pygalmesh

s = pygalmesh.Ball([0, 0, 0], 1.0)
mesh = pygalmesh.generate_surface_mesh(
    s,
    min_facet_angle=30.0,
    max_radius_surface_delaunay_ball=0.1,
    max_facet_distance=0.1,
)

Refer to CGAL's documentation for the options.

Periodic volume meshes

pygalmesh also interfaces CGAL's 3D periodic mesh generation. Besides a domain, one needs to specify a bounding box, and optionally the number of copies in the output (1, 2, 4, or 8). Example:

import numpy as np
import pygalmesh


class Schwarz(pygalmesh.DomainBase):
    def __init__(self):
        super().__init__()

    def eval(self, x):
        x2 = np.cos(x[0] * 2 * np.pi)
        y2 = np.cos(x[1] * 2 * np.pi)
        z2 = np.cos(x[2] * 2 * np.pi)
        return x2 + y2 + z2


mesh = pygalmesh.generate_periodic_mesh(
    Schwarz(),
    [0, 0, 0, 1, 1, 1],
    max_cell_circumradius=0.05,
    min_facet_angle=30,
    max_radius_surface_delaunay_ball=0.05,
    max_facet_distance=0.025,
    max_circumradius_edge_ratio=2.0,
    number_of_copies_in_output=4,
    # odt=True,
    # lloyd=True,
    verbose=False,
)

Volume meshes from surface meshes

If you have a surface mesh at hand (like elephant.vtu), pygalmesh generates a volume mesh on the command line via

pygalmesh volume-from-surface elephant.vtu out.vtk --cell-size 1.0 --odt

(See pygalmesh volume-from-surface -h for all options.)

In Python, do

import pygalmesh

mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(
    "elephant.vtu",
    min_facet_angle=25.0,
    max_radius_surface_delaunay_ball=0.15,
    max_facet_distance=0.008,
    max_circumradius_edge_ratio=3.0,
    verbose=False,
)

Meshes from INR voxel files

It is also possible to generate meshes from INR voxel files, e.g., here either on the command line

pygalmesh from-inr skull_2.9.inr out.vtu --cell-size 5.0 --odt

(see pygalmesh from-inr -h for all options) or from Python

import pygalmesh

mesh = pygalmesh.generate_from_inr(
    "skull_2.9.inr",
    max_cell_circumradius=5.0,
    verbose=False,
)

Meshes from numpy arrays representing 3D images

pygalmesh can help generating unstructed meshes from 3D numpy int arrays specifying the subdomains. Subdomains with key 0 are not meshed.

import pygalmesh
import numpy as np

x_ = np.linspace(-1.0, 1.0, 50)
y_ = np.linspace(-1.0, 1.0, 50)
z_ = np.linspace(-1.0, 1.0, 50)
x, y, z = np.meshgrid(x_, y_, z_)

vol = np.empty((50, 50, 50), dtype=np.uint8)
idx = x**2 + y**2 + z**2 < 0.5**2
vol[idx] = 1
vol[~idx] = 0

voxel_size = (0.1, 0.1, 0.1)

mesh = pygalmesh.generate_from_array(
    vol, voxel_size, max_facet_distance=0.2, max_cell_circumradius=0.1
)
mesh.write("ball.vtk")

The code below creates a mesh from the 3D breast phantom from Lou et al available here. The phantom comprises four tissue types (background, fat, fibrograndular, skin, vascular tissues). The generated mesh conforms to tissues interfaces.

import pygalmesh
import meshio

with open("MergedPhantom.DAT", "rb") as fid:
    vol = np.fromfile(fid, dtype=np.uint8)

vol = vol.reshape((722, 411, 284))
voxel_size = (0.2, 0.2, 0.2)

mesh = pygalmesh.generate_from_array(
    vol, voxel_size, max_facet_distance=0.2, max_cell_circumradius=1.0
)
mesh.write("breast.vtk")

In addition, we can specify different mesh sizes for each tissue type. The code below sets the mesh size to 1 mm for the skin tissue (label 4), 0.5 mm for the vascular tissue (label 5), and 2 mm for all other tissues (default).

mesh = pygalmesh.generate_from_array(
    vol,
    voxel_size,
    max_facet_distance=0.2,
    max_cell_circumradius={"default": 2.0, 4: 1.0, 5: 0.5},
)
mesh.write("breast_adapted.vtk")

Surface remeshing

pygalmesh can help remeshing an existing surface mesh, e.g., lion-head.off. On the command line, use

pygalmesh remesh-surface lion-head.off out.vtu -e 0.025 -a 25 -s 0.1 -d 0.001

(see pygalmesh remesh-surface -h for all options) or from Python

import pygalmesh

mesh = pygalmesh.remesh_surface(
    "lion-head.off",
    max_edge_size_at_feature_edges=0.025,
    min_facet_angle=25,
    max_radius_surface_delaunay_ball=0.1,
    max_facet_distance=0.001,
    verbose=False,
)

Installation

For installation, pygalmesh needs CGAL and Eigen installed on your system. They are typically available on your Linux distribution, e.g., on Ubuntu

sudo apt install libcgal-dev libeigen3-dev

On MacOS with homebrew,

brew install cgal eigen

After that, pygalmesh can be installed from the Python Package Index, so with

pip install -U pygalmesh

you can install/upgrade.

Troubleshooting

If pygalmesh fails to build due to fatal error: 'Eigen/Dense' file not found you will need to create a symbolic link for Eigen to be detected, e.g.

cd /usr/local/include
sudo ln -sf eigen3/Eigen Eigen

It's possible that eigen3 could be in /usr/include instead of /usr/local/install.

Manual installation

For manual installation (if you're a developer or just really keen on getting the bleeding edge version of pygalmesh), there are two possibilities:

  • Get the sources, type python3 setup.py install. This does the trick most the time.
  • As a fallback, there's a CMake-based installation. Simply go cmake /path/to/sources/ and make.

Testing

To run the pygalmesh unit tests, check out this repository and type

pytest

Background

CGAL offers two different approaches for mesh generation:

  1. Meshes defined implicitly by level sets of functions.
  2. Meshes defined by a set of bounding planes.

pygalmesh provides a front-end to the first approach, which has the following advantages and disadvantages:

  • All boundary points are guaranteed to be in the level set within any specified residual. This results in smooth curved surfaces.
  • Sharp intersections of subdomains (e.g., in unions or differences of sets) need to be specified manually (via feature edges, see below), which can be tedious.

On the other hand, the bounding-plane approach (realized by mshr), has the following properties:

  • Smooth, curved domains are approximated by a set of bounding planes, resulting in more of less visible edges.
  • Intersections of domains can be computed automatically, so domain unions etc. have sharp edges where they belong.

See here for other mesh generation tools.

License

This software is available under the GPLv3 license as well as a commercial license. If you'd like to use this software commercially, please contact the author.

pygalmesh's People

Contributors

ad-m avatar es-alexander avatar ginggs avatar ksebaz avatar martingrignard avatar nehaljwani avatar nschloe avatar uvilla 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pygalmesh's Issues

Error "STL can only write triangle cells."

When I run the Periodic volume meshes example from the documentation and try to save it in STL format with meshio with the commande meshio.write("mesh.stl", mesh) I get the error message:

  File "/usr/local/lib/python3.7/dist-packages/meshio/_helpers.py", line 273, in write
    return interface.write(filename, mesh, *args, **_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/meshio/_stl.py", line 139, in write
    ), "STL can only write triangle cells."
AssertionError: STL can only write triangle cells.

Is it an expected result?

Windows 10 support - library link failure

Hello,
TL;DR - does pygalmesh support on windows (10) machines with python 3.6.6?

Here is my experience trying to run it on windows without success :(
after "pip3 install -U pygalmesh without success" failed on my python venv,

  1. I cloned the source code

  2. I installed CGAL (step by step instructions using Vcpkg Library Manager)

  3. I downloaded Eigen and added "EIGEN_INCLUDE_DIR" env variable with the library path.

  4. I ran python setup.py install and it failed on "missing CGAL libraries" , so I modified the setup.py file to be with my installation directory of CGAL: (added code in bold)
    include_dirs=[
    os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/"),
    "C:\dev\vcpkg\installed\x86-windows\include\",
    # Path to pybind11 headers
    get_pybind_include(),
    get_pybind_include(user=True),
    ],

  5. And now I can't overcome the following issue:

LINK : fatal error LNK1181: cannot open input file 'stdc++.lib'
error: command 'D:\Microsoft Visual Studio 2017\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe' failed with exit status 1181

I guess that this is the "libraries" installation part in the file :
libraries=["stdc++", "gmp", "mpfr"]

It seems that I don't really have these libraries, and I'm not sure how to install them.
Not sure if its relevant - but I've found here https://docs.python.org/3/distutils/setupscript.html that I can add library_dirs=[""] to specify where to find these libs (but I don't really have them ...).

I tried to download them using MinGW but not sure how to compile or use them.

The same issue persists with VS 2019 and with gmp or mpfr as the "missing library" if I change their order in the setup.py file.

Any idea how to solve it ?
Many thanks in advance for your help !

Question: Sizing field

Hey, Is it possible to pass a gridded interpolant describing the variation of sizing in the meshing domain? The below example does not work and states:

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

import pygalmesh

# bottom left and top right corner coords
domain = pygalmesh.Cuboid([bbox[0], 0.0, 0.0], [0.0, bbox[3], bbox[5]])

# define a cell_size function based on an interpolant (scipy.regulargriddedInterpolant)
class Field(pygalmesh.SizingFieldBase, fh):
    def eval(self, x):
        return fh(x)


eff = Field(pygalmesh.SizingFieldBase, fh)

# call the generator
mesh = pygalmesh.generate_with_sizing_field(domain, cell_size=eff,)
import meshio

meshio.write("out.vtk", mesh)
print("finished!")

Thanks for any help if possible

import pygalmesh Error

Hi,
I am having some trouble when importing pygalmesh. I work on Ubuntu 16.04 lts . I successfully installed CGAL 4.14 (https://doc.cgal.org/latest/Manual/installation.html) and Eigen (https://bitbucket.org/eigen/eigen/src/default/INSTALL)

pip3 install -U pygalmesh

Collecting pygalmesh
  Using cached https://files.pythonhosted.org/packages/4e/13/aaa7cecd775040d95eaae6e32cb32b7b8dc6dbc08adc950c0bb5fba7bdf9/pygalmesh-0.3.6.tar.gz
Requirement already satisfied, skipping upgrade: meshio in /home/ribeiro/.virtualenvs/flow/lib/python3.6/site-packages (from pygalmesh) (2.3.10)
Requirement already satisfied, skipping upgrade: numpy in /home/ribeiro/.virtualenvs/flow/lib/python3.6/site-packages (from pygalmesh) (1.15.4)
Requirement already satisfied, skipping upgrade: pybind11>=2.2 in /home/ribeiro/.virtualenvs/flow/lib/python3.6/site-packages (from pygalmesh) (2.3.0)
Building wheels for collected packages: pygalmesh
  Building wheel for pygalmesh (setup.py) ... done
  Stored in directory: /home/ribeiro/.cache/pip/wheels/1c/8a/67/e42306208f268f91849bc411cb414e9b70e204c747fa36a76c
Successfully built pygalmesh
Installing collected packages: pygalmesh
Successfully installed pygalmesh-0.3.6

but when I import pygalmesh I get this error :

(env) user@user:~/CGAL-4.14$ python 
Python 3.6.4 (default, Dec 12 2018, 16:31:54) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygalmesh
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ribeiro/.virtualenvs/flow/lib/python3.6/site-packages/pygalmesh/__init__.py", line 4, in <module>
    from _pygalmesh import (
ImportError: /home/ribeiro/.virtualenvs/flow/lib/python3.6/site-packages/_pygalmesh.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN4CGAL7Image_312private_readEP11point_imageNS0_3OwnE
>>> 

Do you have any idea about this error ?
Thank you.

Can not read file when generating surface mesh

When trying to generate a volume mesh from another mesh the following error occurs:

Traceback (most recent call last):
  File "3dmcV3.py", line 49, in <module>
    mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(
  File "/usr/local/lib/python3.8/dist-packages/pygalmesh/main.py", line 197, in generate_volume_mesh_from_surface_mesh
    _generate_from_off(
RuntimeError: Cannot read input file "/tmp/tmpb0f2y371.off"

The file exists and the permissions are valid (-rw-…). The error occurs regardless of the input file (size). I’m running an Debian 10 Container on a Debian based Server.

Is it possible to perform difference on volume meshes?

I noticed that the boolean functionality only works on primitives. Is it possible to perform a difference on arbitrary volume meshes (specifically imported and converted STL files)? My main target is testing fully encapsulated inclusions, but I has of yet been unable to find a package that can support this.

My hope was to be able to aquire 2 meshes via pygalmesh.generate_volume_mesh_from_surface_mesh, and perform a boolean difference on them, but these objects aren't supported for boolean differences. Any pointers here would be greatly appreciated.

Installation and running tests

Hi all,

installed cgal from ubuntu distro, with:

sudo apt install libcgal-dev

An I got this error while compiling pygalmesh:

/usr/include/CGAL/internal/boost/array_binary_tree.hpp:54:28: error: expected template-name before ‘<’ token
         : ::boost::iterator<std::forward_iterator_tag,

I downloaded, compiled, and installed successfully cgal.
I can now compile pygalmesh with:

 cmake -DCGAL_DIR=/home/nicola/local/usr/cgal/ -DCMAKE_BUILD_TYPE=Release ..

I go back to the top level pygalmesh, and run pytest and I get this:

ModuleNotFoundError: No module named '_pygalmesh'

I know I am missing some path, but I cannot figure out which one.

Thanks a lot.

How to generate volume from a set of vertices and triangular faces?

Hi, I looked through the pygalmesh tutorial but haven't been able to find what I'm looking for.

Basically, I have a series of vertices:

verts = [[0.1, 1.,  1. ]  [1.,  1.,  0.1]  [1.,  0.1, 1. ]  [1.,  1.,  1.9]  [1.,  1.9, 1. ]
 [1.9, 1.,  1. ] ]

And triangular faces, which define the vertices composing each faces:

faces = [[ 2,  1,  0]  [ 0,  3,  2]  [ 1,  4,  0]  [ 0,  4,  3]  [ 5,  1,  2]  [ 3,  5,  2]
 [ 5,  4,  1]  [ 4,  5,  3]]

How do I use pygalmesh to find the scalar volume for this object? It isn't clear from the examples how I can do this. Perhaps there is a tutorial I am missing?

Here is a fuller explanation of my project, if interested. Thanks in advance!

Can't build/install the package

Hello.
I've tried to install the package in my ubuntu machine, and got random issues. Tried to reproduce it in Docker (clean build).

The dockerfile U have:

FROM python:3.5
RUN apt update && apt install -y libcgal-dev libeigen3-dev build-essential
RUN pip install -U pip && pip install pygalmesh

docker build . fails with

    Running setup.py install for pygalmesh: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u5fh_256/pygalmesh/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u5fh_256/pygalmesh/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ybrjsj9k/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-u5fh_256/pygalmesh/
    Complete output (18 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/pygalmesh
    copying pygalmesh/__init__.py -> build/lib.linux-x86_64-3.7/pygalmesh
    copying pygalmesh/__about__.py -> build/lib.linux-x86_64-3.7/pygalmesh
    copying pygalmesh/main.py -> build/lib.linux-x86_64-3.7/pygalmesh
    copying pygalmesh/cli.py -> build/lib.linux-x86_64-3.7/pygalmesh
    running build_ext
    building '_pygalmesh' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/eigen3/ -I/usr/local/include/python3.7m -I/root/.local/include/python3.7m -I/usr/local/include/python3.7m -c src/generate.cpp -o build/temp.linux-x86_64-3.7/src/generate.o
    gcc: fatal error: Killed signal terminated program cc1plus
    compilation terminated.
    error: command 'gcc' failed with exit status 1

I also tried python versions 3.6 and 3.7 - same result.

Any ideas what's going on? I don't understand the error message :(

Installation Error

Hi, I'm interested in using this package in my project. I'm using Ubuntu 16.04 and a virtualenv for python 3.5. I have installed libcgal-dev and libeigen3-dev through apt-get. The g++ version I'm using is 5.4.

When I cloned the code and ran CC=g++ python setup.py install, I got errors in the compilation stages. The error message is long, but the first few lines are here:

src/generate.cpp:19:80: error: wrong number of template arguments (1, should be 2)
 typedef CGAL::Mesh_domain_with_polyline_features_3<CGAL::Labeled_mesh_domain_3<K>> Mesh_domain;
                                                                                ^
In file included from /usr/include/CGAL/Implicit_mesh_domain_3.h:34:0,
                 from src/generate.cpp:11:
/usr/include/CGAL/Labeled_mesh_domain_3.h:57:7: note: provided for ‘template<class Function, class BGT> class CGAL::Labeled_mesh_domain_3’
 class Labeled_mesh_domain_3
       ^
src/generate.cpp:19:81: error: template argument 1 is invalid
 typedef CGAL::Mesh_domain_with_polyline_features_3<CGAL::Labeled_mesh_domain_3<K>> Mesh_domain;
                                                                                 ^
In file included from /usr/include/CGAL/Mesh_triangulation_3.h:32:0,
                 from src/generate.cpp:7:
/usr/include/CGAL/Mesh_3/Robust_weighted_circumcenter_filtered_traits_3.h: In instantiation of ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’:
/usr/include/CGAL/Regular_triangulation_3.h:63:9:   required from ‘class CGAL::Regular_triangulation_3<CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >, CGAL::Triangulation_data_structure_3<CGAL::Mesh_vertex_base_3<CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >, int, CGAL::Triangulation_vertex_base_3<CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Compact_mesh_cell_base_3<CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >, int, void>, CGAL::Sequential_tag>, CGAL::Default>’

Some other error messages are here, they are in later stages of the long error message.

src/generate.cpp:27:22:   required from here
/usr/include/CGAL/Regular_triangulation_3.h:63:9: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
   class Regular_triangulation_3
         ^
/usr/include/CGAL/Regular_triangulation_3.h:75:55: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
       Regular_triangulation_cell_base_3<Gt> > >::type Tds;
                                                       ^
/usr/include/CGAL/Regular_triangulation_3.h:77:58: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef Triangulation_3<Gt,Tds,Lock_data_structure_> Tr_Base;
                                                          ^
/usr/include/CGAL/Regular_triangulation_3.h:84:51: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef typename Tr_Base::Concurrency_tag     Concurrency_tag;
                                                   ^
/usr/include/CGAL/Regular_triangulation_3.h:85:51: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef typename Tr_Base::Lock_data_structure Lock_data_structure;
                                                   ^
/usr/include/CGAL/Regular_triangulation_3.h:87:51: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef typename Tr_Base::Vertex_handle       Vertex_handle;
                                                   ^
/usr/include/CGAL/Regular_triangulation_3.h:88:51: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef typename Tr_Base::Cell_handle         Cell_handle;
                                                   ^
/usr/include/CGAL/Regular_triangulation_3.h:89:51: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef typename Tr_Base::Vertex              Vertex;
                                                   ^
/usr/include/CGAL/Regular_triangulation_3.h:90:51: error: no type named ‘Weighted_point_3’ in ‘struct CGAL::Robust_weighted_circumcenter_filtered_traits_3<CGAL::internal_kernel_traits::Dummy_kernel<int> >’
     typedef typename Tr_Base::Cell                Cell;

Do you have any idea about anything wrong that I did? If I delete CC=g++, the error messages are similar. Thanks a lot!

Installation error

System: Ubuntu 14.04
Try to install by following but failed:
sudo apt install libcgal-dev libeigen3-dev (SUCCESS)
pip install -U pygalmesh (FAILED)

Do you have any idea about this?

Complete info:

bwang31@bwang31-PoreSim:~$ pip install -U pygalmesh
Collecting pygalmesh
Using cached pygalmesh-0.2.2.tar.gz
Requirement already up-to-date: numpy in ./Software/ENTER/lib/python3.6/site-packages (from pygalmesh)
Requirement already up-to-date: pybind11>=2.2 in ./Software/ENTER/lib/python3.6/site-packages (from pygalmesh)
Requirement already up-to-date: pipdate in ./Software/ENTER/lib/python3.6/site-packages (from pygalmesh)
Requirement already up-to-date: requests in ./Software/ENTER/lib/python3.6/site-packages (from pipdate->pygalmesh)
Requirement already up-to-date: appdirs in ./Software/ENTER/lib/python3.6/site-packages (from pipdate->pygalmesh)
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in ./Software/ENTER/lib/python3.6/site-packages (from requests->pipdate->pygalmesh)
Requirement already up-to-date: idna<2.7,>=2.5 in ./Software/ENTER/lib/python3.6/site-packages (from requests->pipdate->pygalmesh)
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in ./Software/ENTER/lib/python3.6/site-packages (from requests->pipdate->pygalmesh)
Requirement already up-to-date: certifi>=2017.4.17 in ./Software/ENTER/lib/python3.6/site-packages (from requests->pipdate->pygalmesh)
Building wheels for collected packages: pygalmesh
Running setup.py bdist_wheel for pygalmesh ... error
Complete output from command /home/bwang31/Software/ENTER/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-hijtiy17/pygalmesh/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmpb0tqrbuhpip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pygalmesh
copying pygalmesh/about.py -> build/lib.linux-x86_64-3.6/pygalmesh
copying pygalmesh/init.py -> build/lib.linux-x86_64-3.6/pygalmesh
running build_ext
building '_pygalmesh' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -B /home/bwang31/Software/ENTER/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/eigen3/ -I/home/bwang31/Software/ENTER/include/python3.6m -I/home/bwang31/.local/include/python3.6m -I/home/bwang31/Software/ENTER/include/python3.6m -c src/generate.cpp -o build/temp.linux-x86_64-3.6/src/generate.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/include/c++/4.8/array:35:0,
from src/domain.hpp:5,
from src/generate.hpp:4,
from src/generate.cpp:3:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the
^
In file included from src/generate.hpp:4:0,
from src/generate.cpp:3:
src/domain.hpp:15:27: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default]
virtual ~DomainBase() = default;
^
src/domain.hpp:19:14: error: ‘array’ in namespace ‘std’ does not name a type
eval(const std::array<double, 3> & x) const = 0;
^
src/domain.hpp:19:19: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
eval(const std::array<double, 3> & x) const = 0;
^
src/domain.hpp:19:24: error: expected ‘,’ or ‘...’ before ‘<’ token
eval(const std::array<double, 3> & x) const = 0;
^
src/domain.hpp:26:27: error: ‘array’ is not a member of ‘std’
std::vector<std::vector<std::array<double, 3>>>
^
src/domain.hpp:26:27: error: ‘array’ is not a member of ‘std’
src/domain.hpp:26:49: error: template argument 1 is invalid
std::vector<std::vector<std::array<double, 3>>>
^
src/domain.hpp:26:49: error: template argument 2 is invalid
src/domain.hpp:27:18: error: template argument 1 is invalid
get_features() const
^
src/domain.hpp:27:18: error: template argument 2 is invalid
src/domain.hpp:28:3: error: expected unqualified-id before ‘{’ token
{
^
In file included from /usr/include/CGAL/Uncertain.h:28:0,
from /usr/include/CGAL/assertions.h:344,
from /usr/include/CGAL/basic.h:42,
from /usr/include/CGAL/Cartesian/Cartesian_base.h:28,
from /usr/include/CGAL/Simple_cartesian.h:28,
from /usr/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:28,
from src/generate.cpp:5:
/usr/include/c++/4.8/typeinfo:39:37: error: expected ‘}’ before end of line
#pragma GCC visibility push(default)
^
/usr/include/c++/4.8/typeinfo:39:37: error: expected unqualified-id before end of line
/usr/include/c++/4.8/typeinfo:39:37: error: expected ‘}’ before end of line
/usr/include/c++/4.8/typeinfo:39:37: error: expected declaration before end of line
error: command 'gcc' failed with exit status 1


Failed building wheel for pygalmesh
Running setup.py clean for pygalmesh
Failed to build pygalmesh
Installing collected packages: pygalmesh
Running setup.py install for pygalmesh ... error
Complete output from command /home/bwang31/Software/ENTER/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-hijtiy17/pygalmesh/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-qsf7xh4c-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pygalmesh
copying pygalmesh/about.py -> build/lib.linux-x86_64-3.6/pygalmesh
copying pygalmesh/init.py -> build/lib.linux-x86_64-3.6/pygalmesh
running build_ext
building '_pygalmesh' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -B /home/bwang31/Software/ENTER/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/eigen3/ -I/home/bwang31/Software/ENTER/include/python3.6m -I/home/bwang31/.local/include/python3.6m -I/home/bwang31/Software/ENTER/include/python3.6m -c src/generate.cpp -o build/temp.linux-x86_64-3.6/src/generate.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/include/c++/4.8/array:35:0,
from src/domain.hpp:5,
from src/generate.hpp:4,
from src/generate.cpp:3:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the
^
In file included from src/generate.hpp:4:0,
from src/generate.cpp:3:
src/domain.hpp:15:27: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default]
virtual ~DomainBase() = default;
^
src/domain.hpp:19:14: error: ‘array’ in namespace ‘std’ does not name a type
eval(const std::array<double, 3> & x) const = 0;
^
src/domain.hpp:19:19: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
eval(const std::array<double, 3> & x) const = 0;
^
src/domain.hpp:19:24: error: expected ‘,’ or ‘...’ before ‘<’ token
eval(const std::array<double, 3> & x) const = 0;
^
src/domain.hpp:26:27: error: ‘array’ is not a member of ‘std’
std::vector<std::vector<std::array<double, 3>>>
^
src/domain.hpp:26:27: error: ‘array’ is not a member of ‘std’
src/domain.hpp:26:49: error: template argument 1 is invalid
std::vector<std::vector<std::array<double, 3>>>
^
src/domain.hpp:26:49: error: template argument 2 is invalid
src/domain.hpp:27:18: error: template argument 1 is invalid
get_features() const
^
src/domain.hpp:27:18: error: template argument 2 is invalid
src/domain.hpp:28:3: error: expected unqualified-id before ‘{’ token
{
^
In file included from /usr/include/CGAL/Uncertain.h:28:0,
from /usr/include/CGAL/assertions.h:344,
from /usr/include/CGAL/basic.h:42,
from /usr/include/CGAL/Cartesian/Cartesian_base.h:28,
from /usr/include/CGAL/Simple_cartesian.h:28,
from /usr/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:28,
from src/generate.cpp:5:
/usr/include/c++/4.8/typeinfo:39:37: error: expected ‘}’ before end of line
#pragma GCC visibility push(default)
^
/usr/include/c++/4.8/typeinfo:39:37: error: expected unqualified-id before end of line
/usr/include/c++/4.8/typeinfo:39:37: error: expected ‘}’ before end of line
/usr/include/c++/4.8/typeinfo:39:37: error: expected declaration before end of line
error: command 'gcc' failed with exit status 1

----------------------------------------

Command "/home/bwang31/Software/ENTER/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-hijtiy17/pygalmesh/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-qsf7xh4c-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-hijtiy17/pygalmesh/

Segfault when joining two cuboids

I'm trying to join two cuboids to create a backwards facing step.
Unfortunately I get a segfault when I run the code below.
This is on macOS 10.13.4 with Python 3.6.5, cgal 4.12 from brew and pygalmesh v0.2.4.

import pygalmesh

c1 = pygalmesh.Cuboid([0., 1., 0.], [1.0, 2.0, 1.0])
c2 = pygalmesh.Cuboid([1., 0., 0.], [10., 2., 1.])
u = pygalmesh.Union([c1, c2])
pygalmesh.generate_mesh(
        u, 'out.mesh', cell_size=0.1, edge_size=0.1
        )

I had to apply this patch to get it to install, but that shouldn't be relevant.

diff --git a/setup.py b/setup.py
index 73bbac0..7fadc74 100644
--- a/setup.py
+++ b/setup.py
@@ -42,13 +42,14 @@ ext_modules = [Extension(
         ],
     language='c++',
     include_dirs=[
+        '/usr/local/Cellar/eigen/3.3.4/include/eigen3/',
         '/usr/include/eigen3/',
         # Path to pybind11 headers
         get_pybind_include(),
         get_pybind_include(user=True)
         ],
     libraries=['CGAL', 'gmp', 'mpfr'],
-    # extra_compile_args=['-std=c++11']
+    extra_compile_args=['-std=c++11']
     )]

 setup(

Eigen

Hi,
I'm having trouble with pip install of pygalmesh. I get the error "Cannot open include file: 'Eigen/Dense': No such file or directory" could you please give me some guidance on how I can "install" Eigen3 so I can get this to work please?

add LICENCE to sdist

As has been notified in conda-forge/staged-recipes#11457, it seems that the pygalmesh sdist uploaded to pypi does not contain the LICENCE file. Would it be possible to include it so that the conda-forge build satisfies their standards?

A possible way to achieve this would be to modify setup.cfg like so (source):

[metadata]
long_description = file: README.md, LICENSE

If @nschloe is ok, I can propose a PR to do that.
Best regards,

Florian

Git Actions CI

I was comparing the difference in the CI scripts for Github Actions and CircleCi.

Shouldn't line 33 of /.github/workflows/ci.yml read

        sudo apt-get install -y libeigen3-dev python3-pip clang

rather then

        sudo apt-get install -y libcgal-dev libeigen3-dev python3-pip clang

Install pygalmesh with pip

@nschloe is it possible to install pygalmesh with pip?

I tried to install the library in my virtual environment but I got the following error related to Eigen:

pip install pygalmesh
Collecting pygalmesh
  Downloading pygalmesh-0.6.6.tar.gz (1.2 MB)
     |████████████████████████████████| 1.2 MB 1.3 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy in c:\users\ttsesm\desktop\dev\radiosity\r_venv\lib\site-packages (from pygalmesh) (1.18.4)
Requirement already satisfied: meshio<5.0.0,>=4.0.0 in c:\users\ttsesm\desktop\dev\radiosity\r_venv\lib\site-packages (from pygalmesh) (4.0.13)
Collecting pybind11>=2.2
  Using cached pybind11-2.5.0-py2.py3-none-any.whl (296 kB)
Collecting importlib-metadata
  Downloading importlib_metadata-1.6.1-py2.py3-none-any.whl (31 kB)
Collecting zipp>=0.5
  Downloading zipp-3.1.0-py3-none-any.whl (4.9 kB)
Building wheels for collected packages: pygalmesh
  Building wheel for pygalmesh (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\ttsesm\desktop\dev\radiosity\r_venv\scripts\python.exe' 'c:\users\ttsesm\desktop\dev\radiosity\r_venv\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\TTSESM~1\AppData\Local\Temp\tmpnblj1rex'
       cwd: C:\Users\TTsesm\AppData\Local\Temp\pip-install-a_xxu6aj\pygalmesh
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.8
  creating build\lib.win-amd64-3.8\pygalmesh
  copying pygalmesh\main.py -> build\lib.win-amd64-3.8\pygalmesh
  copying pygalmesh\__about__.py -> build\lib.win-amd64-3.8\pygalmesh
  copying pygalmesh\__init__.py -> build\lib.win-amd64-3.8\pygalmesh
  creating build\lib.win-amd64-3.8\pygalmesh\_cli
  copying pygalmesh\_cli\helpers.py -> build\lib.win-amd64-3.8\pygalmesh\_cli
  copying pygalmesh\_cli\_inr.py -> build\lib.win-amd64-3.8\pygalmesh\_cli
  copying pygalmesh\_cli\_remesh_surface.py -> build\lib.win-amd64-3.8\pygalmesh\_cli
  copying pygalmesh\_cli\_volume_from_surface.py -> build\lib.win-amd64-3.8\pygalmesh\_cli
  copying pygalmesh\_cli\__init__.py -> build\lib.win-amd64-3.8\pygalmesh\_cli
  running build_ext
  building '_pygalmesh' extension
  creating build\temp.win-amd64-3.8
  creating build\temp.win-amd64-3.8\Release
  creating build\temp.win-amd64-3.8\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/eigen3/ -IC:\Users\TTsesm\AppData\Local\Temp\pip-build-env-7oe_x64z\normal\Lib\site-packages\pybind11\include -IC:\Users\TTsesm\AppData\Local\T
emp\pip-build-env-7oe_x64z\normal\Lib\site-packages\pybind11\include -Ic:\users\ttsesm\desktop\dev\radiosity\r_venv\include -IC:\Users\TTsesm\AppData\Local\Programs\Python\Python38\include -IC:\Users\TTsesm\AppData\Local\Programs\Python\Python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio
\2019\Community\VC\Tools\MSVC\14.26.28801\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86
)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpsrc/generate.cpp /Fobuild\temp.win-amd64-3.8\Rele
ase\src/generate.obj -std=c++14
  cl : Command line warning D9002 : ignoring unknown option '-std=c++14'
  generate.cpp
  C:\Users\TTsesm\AppData\Local\Temp\pip-install-a_xxu6aj\pygalmesh\src\domain.hpp(4): fatal error C1083: Cannot open include file: 'Eigen/Dense': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for pygalmesh
Failed to build pygalmesh
ERROR: Could not build wheels for pygalmesh which use PEP 517 and cannot be installed directly

[Question] Size function/field

Hi,

First I would like to thank you for this really useful package.

I'm considering to use it in a FEM pipeline to generate multimaterial models based on volume images. To achieve this task, I'm currently using generate_from_inr() function.

For now it works like a charm but I'm wondering if it would be possible to prodive it with a size function for the facets size or the cell size. For instance, I have a big smooth area that I know would be ok with a much lower facet size but I still need to use a small value of this parameter to make sure that smaller parts are meshed properly. It would be great to be able to provide a volume image or a function giving the facet size for each voxel of the reference image.

This functionality already exists in CGAL (3.5.2 Different Sizing Field for Different Subdomains) but I don't see anything similar in pygalmesh.
Is it possible using your package?

Thanks!

setup.py is hard to evaluate

I admit pygalmesh is a good tool,but I also want to point it out that your setup.py is so ........If you want more people to use it for convenience,maybe you could do better.

importlib dependency not taken properly into account (windows)

Following yesterday's work regarding conda-forge builds, I tried out the newly added build on windows this morning.
Here's what I did:

conda create -n test_pygalmesh python=3.7
conda activate test_pygalmesh
conda install -c conda-forge pygalmesh

This works well. I then do python -c "import pygalmesh" which raises an error:

(test_pygalmesh) C:\>python -c "import pygalmesh"
Traceback (most recent call last):
  File "C:\Anaconda3\envs\test_pygalmesh\lib\site-packages\pygalmesh\__about__.py", line 3, in <module>
    from importlib import metadata
ImportError: cannot import name 'metadata' from 'importlib' (C:\Anaconda3\envs\test_pygalmesh\lib\importlib\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Anaconda3\envs\test_pygalmesh\lib\site-packages\pygalmesh\__init__.py", line 25, in <module>
    from .__about__ import __version__
  File "C:\Anaconda3\envs\test_pygalmesh\lib\site-packages\pygalmesh\__about__.py", line 5, in <module>
    import importlib_metadata as metadata
ModuleNotFoundError: No module named 'importlib_metadata'

When checking for the existence of a module called importlib_metadata, I cannot find any.

Doing pip install importlib-metadata fixes the issue. Notice that the pip install requires a hyphen instead of an underscore when installing. Could that be the reason?

Error when generating surface mesh from custom superellipsoid function

Hi, I'm trying to generate a surface mesh from a superellipsoid function:

import pygalmesh
import meshio

class SQ(pygalmesh.DomainBase):
    def __init__(self):
        super().__init__()

    def eval(self, x):
        l4 = 0.5
        l5 = 0.5
        return (x[0]**(2./l5) + x[1]**(2./l5))**(l5/l4) + x[2]**(2./l4) - 1

    def get_bounding_sphere_squared_radius(self):
        return 10

d = SQ()

mesh = pygalmesh.generate_surface_mesh(
    d,
    angle_bound=10,
    radius_bound=0.1,
    distance_bound=0.1
)

meshio.write("out.obj", mesh)

By varying the parameters l4 and l5 between 0.1 and 2, the shape of the superellipsoid should vary according to the following image:

By using values in [0.1,1] everything works perfectly and I can generate correct surface meshes.

However, if I use values >1 I get the following error:

line 160, in generate_surface_mesh
    _generate_surface_mesh(
RuntimeError: Unable to cast Python instance to C++ type (compile in debug mode for details)

Do you see the reason for this?

Thank you for your work!

Installation failure

Hello,

I have some trouble with pygalmesh installation. I work on Ubuntu 18.04. I successfully installed CGAL and Eigen, but when I try

pip3 install -U pygalmesh

I get the following error message.

I also tried by cloning the sources and using python3 setup.py install but I got
this error message.

The CMake installation provided went into the same error.

Finally, I thought that the problem may come from my version of CGAL, so I cloned a more recent version of CGAL. I added

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(CGAL REQUIRED)
include(${CGAL_USE_FILE})

to CMakeLists.txt and did cmake -DCGAL_DIR=$HOME/Downloads/cgal. Then the make command successfully ended with

[100%] Linking CXX shared module pygalmesh.cpython-36m-x86_64-linux-gnu.so
[100%] Built target pygalmesh

but when I try pytest it stills tell me that there is no module named pygalmesh.
(I precise that I have no knowledge in CMake, so this last try is quite experimental)

Do you have any idea where this installation problem could come from ?
Thank you in advance for your help.

module 'pygalmesh' has no attribute 'generate_surface_mesh'

Hi
Thanks for this pygalmesh which provide a surface mesh generator for our project.
I am intend to run the pygalmesh under conda environment, but after I install the pygalmesh through pip/pip3 I can not use the pygalmesh when I edit and compile the code in a IDE, I use spyder. It gives me the error:

Traceback (most recent call last):

  File "<ipython-input-1-108614fff67b>", line 1, in <module>
    runfile('/home/jason/CUDA/Pymesh/pygalmesh.py', wdir='/home/jason/CUDA/Pymesh')

  File "/usr/local/anaconda3/envs/pymesh2/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "/usr/local/anaconda3/envs/pymesh2/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/home/jason/CUDA/Pymesh/pygalmesh.py", line 8, in <module>
    import pygalmesh

  File "/home/jason/CUDA/Pymesh/pygalmesh.py", line 9, in <module>
    pygalmesh.generate_surface_mesh()

AttributeError: module 'pygalmesh' has no attribute 'generate_surface_mesh'`

Seems every attribute under pygalmesh can not be used like Ball, generate_mesh. etc.
Then I build the pygalmesh from the source and run the pytest, it returns several error:

ImportError while importing test module '/home/jason/Downloads/pygalmesh-0.4.0/test/test_periodic.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
pygalmesh-0.4.0/test/test_periodic.py:3: in <module>
    import pygalmesh
/usr/local/anaconda3/envs/pymesh2/lib/python3.6/site-packages/pygalmesh/__init__.py:4: in <module>
    from _pygalmesh import (
E   ImportError: /usr/local/anaconda3/envs/pymesh2/lib/python3.6/site-packages/_pygalmesh.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN4CGAL7Image_312private_readEP11point_imageNS0_3OwnE

Seems it has some problem to import pygalmesh properly.
I tried different version of pygalmesh from version 0.4.0 to 0.3.0, they all give this error. would you please give me some advice.

thanks

Problem installing pygalmesh 0.4.0

I face a persistent issue while trying to install pygalmesh 0.4.0 on Google Colabs, with libcgal-dev:amd64 (4.11-2build1) and libeigen3-dev (3.3.4-4) installed.
The full log of the installation failure is here :
https://colab.research.google.com/drive/1URJt2v-k73DpVqXj3n-_5mU5tilBZWNp
As a side note, I have the same issue on my Mac (macOS Mojave).
It looks like the root of the problem is in the interface with CGAL -- but this is clearly beyond my debugging abilities.
Any idea of how to correctly install pyglamesh in these environments?

License

Hi,

First of all that's great to see a CGAL wrapper with a nice logo :) .

I create this issue because this page is somehow misleading when it claims that the license is MIT. While you are free to release your code under the license you want, the CGAL license must still be respected. That is the end product is GPL-3+ and not MIT.

Could you please try to make it more obvious for the users ?

Compile error on install

Hello,

I get the error messages below when trying to install pygalmesh with

pip3 install -U pygalmesh

Probably it is some issue with the gcc compiler or the selection of the c++11 standard by the compiler. Could you state explicitly which gcc version is necessary and sufficient to build pygalmesh correctly? What can I do to overcome this error? (I am using Ubuntu 16.04 LTS).

(python3sci) juergen@regulus:~/python/pythonlab$ pip3 install -U pygalmesh
Collecting pygalmesh
  Using cached https://files.pythonhosted.org/packages/78/75/a9c03fa76890ec2f1eab766d144493f691e846cf76e17fd17c9464dbcf7e/pygalmesh-0.4.0.tar.gz
Requirement already satisfied, skipping upgrade: meshio in /home/juergen/venv/python3sci/lib/python3.5/site-packages (from pygalmesh) (3.2.8)
Requirement already satisfied, skipping upgrade: numpy in /home/juergen/venv/python3sci/lib/python3.5/site-packages (from pygalmesh) (1.17.3)
Requirement already satisfied, skipping upgrade: pybind11>=2.2 in /home/juergen/venv/python3sci/lib/python3.5/site-packages (from pygalmesh) (2.4.3)
Installing collected packages: pygalmesh
    Running setup.py install for pygalmesh ... error
    ERROR: Command errored out with exit status 1:
     command: /home/juergen/venv/python3sci/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ggy2m2er/pygalmesh/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ggy2m2er/pygalmesh/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-udvfkg68/install-record.txt --single-version-externally-managed --compile --install-headers /home/juergen/venv/python3sci/include/site/python3.5/pygalmesh
         cwd: /tmp/pip-install-ggy2m2er/pygalmesh/
    Complete output (69 lines):
    /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/pygalmesh
    copying pygalmesh/cli.py -> build/lib.linux-x86_64-3.5/pygalmesh
    copying pygalmesh/main.py -> build/lib.linux-x86_64-3.5/pygalmesh
    copying pygalmesh/__init__.py -> build/lib.linux-x86_64-3.5/pygalmesh
    copying pygalmesh/__about__.py -> build/lib.linux-x86_64-3.5/pygalmesh
    running build_ext
    building '_pygalmesh' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/eigen3/ -I/home/juergen/venv/python3sci/include/site/python3.5 -I/home/juergen/venv/python3sci/include/site/python3.5 -I/home/juergen/venv/python3sci/include -I/usr/include/python3.5m -c src/generate.cpp -o build/temp.linux-x86_64-3.5/src/generate.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /usr/include/c++/5/array:35:0,
                     from src/domain.hpp:5,
                     from src/generate.hpp:4,
                     from src/generate.cpp:3:
    /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support \
      ^
    In file included from src/generate.cpp:3:0:
    src/generate.hpp:45:5: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
         const std::shared_ptr<pygalmesh::SizingFieldBase> & cell_size = nullptr,
         ^
    In file included from src/generate.hpp:4:0,
                     from src/generate.cpp:3:
    src/domain.hpp:16:27: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
       virtual ~DomainBase() = default;
                               ^
    src/domain.hpp:20:19: error: ‘array’ in namespace ‘std’ does not name a template type
       eval(const std::array<double, 3> & x) const = 0;
                       ^
    src/domain.hpp:20:24: error: expected ‘,’ or ‘...’ before ‘<’ token
       eval(const std::array<double, 3> & x) const = 0;
                            ^
    src/domain.hpp:27:27: error: ‘array’ is not a member of ‘std’
       std::vector<std::vector<std::array<double, 3>>>
                               ^
    src/domain.hpp:27:27: error: ‘array’ is not a member of ‘std’
    src/domain.hpp:27:49: error: template argument 1 is invalid
       std::vector<std::vector<std::array<double, 3>>>
                                                     ^
    src/domain.hpp:27:49: error: template argument 2 is invalid
    src/domain.hpp:28:18: error: template argument 1 is invalid
       get_features() const
                      ^
    src/domain.hpp:28:18: error: template argument 2 is invalid
    src/domain.hpp:29:3: error: expected unqualified-id before ‘{’ token
       {
       ^
    In file included from /usr/include/CGAL/Uncertain.h:28:0,
                     from /usr/include/CGAL/assertions.h:344,
                     from /usr/include/CGAL/basic.h:42,
                     from /usr/include/CGAL/Cartesian/Cartesian_base.h:28,
                     from /usr/include/CGAL/Simple_cartesian.h:28,
                     from /usr/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:28,
                     from src/generate.cpp:5:
    /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line
    /usr/include/c++/5/typeinfo:39:37: error: expected unqualified-id before end of line
    /usr/include/c++/5/typeinfo:39:37: error: expected ‘}’ before end of line
    /usr/include/c++/5/typeinfo:39:37: error: expected declaration before end of line
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/juergen/venv/python3sci/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ggy2m2er/pygalmesh/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ggy2m2er/pygalmesh/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-udvfkg68/install-record.txt --single-version-externally-managed --compile --install-headers /home/juergen/venv/python3sci/include/site/python3.5/pygalmesh Check the logs for full command output.
(python3sci) juergen@regulus:~/python/pythonlab$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(python3sci) juergen@regulus:~/python/pythonlab$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


error in test_inr.py

This 0.3.5 test error in test/test_inr.py is reproducible on Debian with CGAL 4.13-1+b2:

    def test_inr():
        helpers.download("liver.inr", "c69513a79231881942a86df56d41090e")
        mesh = pygalmesh.generate_from_inr("/tmp/liver.inr", cell_size=5.0, verbose=False)
    
        tol = 1.0e-3
        assert abs(max(mesh.points[:, 0]) - 2.385709228515625e02) < tol
        assert abs(min(mesh.points[:, 0]) - 3.307421875000000e01) < tol
        assert abs(max(mesh.points[:, 1]) - 1.947126770019531e02) < tol
        assert abs(min(mesh.points[:, 1]) - 2.314493751525879e01) < tol
        assert abs(max(mesh.points[:, 2]) - 1.957076873779297e02) < tol
        assert abs(min(mesh.points[:, 2]) - 1.365468883514404e01) < tol
     
        vol = sum(helpers.compute_volumes(mesh.points, mesh.cells["tetra"]))
 
    >  assert abs(vol - 1.759106599498153e06) < tol

    E       assert 1.9967572691384703 < 0.001
    E        +  where 1.9967572691384703 = abs((1759104.6027408838 - 1759106.599498153))

test/test_inr.py:21: AssertionError

https://ci.debian.net/data/autopkgtest/testing/amd64/p/pygalmesh/2552856/log.gz

Error on installation

Hello, I am trying to install pygalmesh on my mac (10.14.6) and I get the following error.

pip install pygalmesh
Collecting pygalmesh
  Using cached pygalmesh-0.6.1.tar.gz (1.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Collecting meshio<5.0.0,>=4.0.0
  Using cached meshio-4.0.10-py3-none-any.whl (127 kB)
Collecting pybind11>=2.2
  Using cached pybind11-2.4.3-py2.py3-none-any.whl (150 kB)
Requirement already satisfied: importlib-metadata in ./anaconda3/lib/python3.6/site-packages (from pygalmesh) (1.5.0)
Requirement already satisfied: numpy in ./anaconda3/lib/python3.6/site-packages (from pygalmesh) (1.18.1)
Requirement already satisfied: zipp>=0.5 in ./anaconda3/lib/python3.6/site-packages (from importlib-metadata->pygalmesh) (2.2.0)
Building wheels for collected packages: pygalmesh
  Building wheel for pygalmesh (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/krishna/anaconda3/bin/python /Users/krishna/anaconda3/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/fy/d8s3_7313m94sdpmk1m4gdzm0000gp/T/tmplu5m9rot
       cwd: /private/var/folders/fy/d8s3_7313m94sdpmk1m4gdzm0000gp/T/pip-install-j98374t0/pygalmesh
  Complete output (28 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.6
  creating build/lib.macosx-10.9-x86_64-3.6/pygalmesh
  copying pygalmesh/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh
  copying pygalmesh/__about__.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh
  copying pygalmesh/main.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh
  creating build/lib.macosx-10.9-x86_64-3.6/pygalmesh/_cli
  copying pygalmesh/_cli/_remesh_surface.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh/_cli
  copying pygalmesh/_cli/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh/_cli
  copying pygalmesh/_cli/_volume_from_surface.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh/_cli
  copying pygalmesh/_cli/helpers.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh/_cli
  copying pygalmesh/_cli/_inr.py -> build/lib.macosx-10.9-x86_64-3.6/pygalmesh/_cli
  running build_ext
  building '_pygalmesh' extension
  creating build/temp.macosx-10.9-x86_64-3.6
  creating build/temp.macosx-10.9-x86_64-3.6/src
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/krishna/anaconda3/include -arch x86_64 -I/Users/krishna/anaconda3/include -arch x86_64 -I/usr/include/eigen3/ -I/Users/krishna/anaconda3/include -I/Users/krishna/anaconda3/include -I/Users/krishna/anaconda3/include/python3.6m -c src/generate.cpp -o build/temp.macosx-10.9-x86_64-3.6/src/generate.o
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
  In file included from src/generate.hpp:4:0,
                   from src/generate.cpp:3:
  src/domain.hpp:4:23: fatal error: Eigen/Dense: No such file or directory
   #include <Eigen/Dense>
                         ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pygalmesh
Failed to build pygalmesh
ERROR: Could not build wheels for pygalmesh which use PEP 517 and cannot be installed directly

support for periodic geometries

If I understood correctly, pygalmesh currently does not support periodic domains.

I've been generating a periodic geometry using CGAL in C++. That works well enough, but it would be interesting to compare it (whether by quality of mesh, or ease of coding) against a periodic mesh generated by pygalmesh.

Import STL and intersect with plane?

Hello, I just found your lib, which seems very promising.
Is it possible to import a mesh from an STL file?
I do need to intersect it with a plane and am looking for an appropriate lib.

Thanks for your reply.

reading .msh when it contains binary sections.

When reading a .msh file version 4.1, when the file contains a section
in the form of binary lines (for example, $Parametrizations"), an error
occurs when reading them in utf-8 encoding.

Example
file: https://goodok.github.io/data/ellipsoid.msh

import meshio

fn = 'ellipsoid.msh'
mesh = meshio.read(fn)
print(mesh)

Output

/home/.virtualenvs/aaaaa/lib/python3.6/site-packages/meshio/msh_io/msh4_1.py in read_buffer(f, is_ascii, data_size)
     85                 #except UnicodeDecodeError:
     86                 #    pass
---> 87                 line = f.readline().decode("utf-8").strip()
     88 
     89     cell_data = cell_data_from_raw(cells, cell_data_raw)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 16: invalid start byte

Versions:
meshio: 2.3.10
MeshFormat: 4.1 1 8
created by gmsh: 4.4.0
python3.6

Error installing pygalmesh on the linux subsystem for windows/ Ubuntu 18.04 with pip3 install

Hi, I get the following error when installing pygalmesh on the linux subsystem for windows/ Ubuntu 18.04 when installing with the command sudo pip3 install -U pygalmesh

 /usr/include/CGAL/Kernel_traits.h:44:12: note: candidate: constexpr CGAL::internal_kernel_traits::Dummy_kernel<int>::FT::FT()
         struct FT{};
                ^~
    /usr/include/CGAL/Kernel_traits.h:44:12: note:   candidate expects 0 arguments, 1 provided
    /usr/include/CGAL/Kernel_traits.h:44:12: note: candidate: constexpr CGAL::internal_kernel_traits::Dummy_kernel<int>::FT::FT(const CGAL::internal_kernel_traits::Dummy_kernel<int>::FT&)
    /usr/include/CGAL/Kernel_traits.h:44:12: note:   no known conversion for argument 1 from ‘int’ to ‘const CGAL::internal_kernel_traits::Dummy_kernel<int>::FT&’
    /usr/include/CGAL/Kernel_traits.h:44:12: note: candidate: constexpr CGAL::internal_kernel_traits::Dummy_kernel<int>::FT::FT(CGAL::internal_kernel_traits::Dummy_kernel<int>::FT&&)
    /usr/include/CGAL/Kernel_traits.h:44:12: note:   no known conversion for argument 1 from ‘int’ to ‘CGAL::internal_kernel_traits::Dummy_kernel<int>::FT&&’
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kk2eolk1/pygalmesh/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ib292r06-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-kk2eolk1/pygalmesh/

polygon soup orientation not checked for volume meshing

When a surface mesh is remeshed using remesh-surface, the result is saved without proper orientation. cgal also does this. When loading this surface into a polyhedron instance for volume meshing, the loading fails (In my case always).

A solution for volume meshing is to read the points and polygons from file separately and then call CGAL::Polygon_mesh_processing::orient_polygon_soup() and CGAL::Polygon_mesh_processing::polygon_soup_to polygon_mesh () when a bad orientation is found, or do it always.

How to choose certain label in 3d array for meshing?

Dear PyGalMesh team!
Thank you for this wonderful package! Really grateful for all the effort went to it!

I'm slightly confused by this example: https://github.com/nschloe/pygalmesh#meshes-from-numpy-array-representing-3d-images.
It says that
The phantom comprises four tissue types (background, fat, fibrograndular, skin, vascular tissues). The generated mesh conforms to tissues interfaces.

So what if I would like to build a mesh only for fat - how would I instruct this interface to do so?
It's fine for me to edit array - I just don't know how.

My current array is uint8 with 3 types - pore space (labeled with 0), material space (labeled with 1) and some fluid (labeled with 2). How would I create a mesh only for material?

Excuse me for my luck of knowledge - I'm very new to meshing - was working in different physics all my life - now switching to a new domain.

Thanks in Advance!

Trouble installing on Windows

Hi, thanks to the contributors to this repository, I have cleared some hurdles in my installation of pygalmesh. However, more remain.

So far, the process has been simply a process of finding things to download to get one step further in the installation. Currently, I'm hung up on

  /Users/User/usr/vcpkg/installed/x86-windows/include/CGAL/Mesh_3/Is_mesh_domain_field_3.h(25): fatal error C1083: Cannot open include file: 'boost/callable_traits/is_invocable.hpp': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.22.27905\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

I wasn't aware that boost was a dependency for pygalmesh. A simple google search turns up: https://www.boost.org/doc/libs/?view=category_metaprogramming&sort=boost-version

I'm new to this, so sorry if the steps are blindingly easy to you.

test_inr.py now fails

test_inr.py has recently started failing in Debian tests:

    def test_inr():
        this_dir = os.path.dirname(os.path.abspath(__file__))
        mesh = pygalmesh.generate_from_inr(
            os.path.join(this_dir, "meshes", "skull_2.9.inr"), cell_size=5.0, verbose=False
        )
    
        tol = 2.0e-3
        ref = [2.031053e02, 3.739508e01, 2.425594e02, 2.558910e01, 2.300883e02, 1.775010e00]
        assert abs(max(mesh.points[:, 0]) - ref[0]) < tol * ref[0]
        assert abs(min(mesh.points[:, 0]) - ref[1]) < tol * ref[1]
        assert abs(max(mesh.points[:, 1]) - ref[2]) < tol * ref[2]
        assert abs(min(mesh.points[:, 1]) - ref[3]) < tol * ref[3]
        assert abs(max(mesh.points[:, 2]) - ref[4]) < tol * ref[4]
>       assert abs(min(mesh.points[:, 2]) - ref[5]) < tol * ref[5]
E       assert 0.0294994218444824 < (0.002 * 1.77501)
E        +  where 0.0294994218444824 = abs((1.7455106 - 1.77501))
E        +    where 1.7455106 = min(array([115.045494, 116.24661 , 122.3319  , ...,  63.492596, 101.66734 ,\n       169.07079 ], dtype=float32))

test/test_inr.py:20: AssertionError

see https://ci.debian.net/data/autopkgtest/unstable/amd64/p/pygalmesh/4327742/log.gz
https://ci.debian.net/packages/p/pygalmesh/unstable/amd64/

It's the same version of pygalmesh as used when the same test passed previously. Not clear what has changed to trigger the failure now.

Polylines to protect?

As I was using surface to volume mesh, I discovered that the algorithm currently doesn't do a very good job at conserving straight lines. I looked in the code to see if there's any compatibility CGAL's polylines to protect, but couldn't find anything. Is there support for this? Is this in progress?

How to specify label to mesh in 3D array example?

Dear PyGalMesh team!
Thank you for this wonderful package! Really grateful for all the effort went to it!

I'm slightly confused by this example: https://github.com/nschloe/pygalmesh#meshes-from-numpy-array-representing-3d-images.
It says that
The phantom comprises four tissue types (background, fat, fibrograndular, skin, vascular tissues). The generated mesh conforms to tissues interfaces.

So what if I would like to build a mesh only for fat - how would I instruct this interface to do so?
It's fine for me to edit array - I just don't know how.

My current array is uint8 with 3 types - pore space (labeled with 0), material space (labeled with 1) and some fluid (labeled with 2). How would I create a mesh only for material?

Excuse me for my luck of knowledge - I'm very new to meshing - was working in different physics all my life - now switching to a new domain.

Thanks in Advance!

ImportError: cannot import name '__copyright__' from 'pygalmesh.__about__'

_cli/helpers.py strives to import __copyright__ from __about__, but there is no such symbol.

Detected by unit tests:

ERROR: pygalmesh._cli (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: pygalmesh._cli
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/build/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build/pygalmesh/_cli/__init__.py", line 1, in <module>
    from ._inr import inr
  File "/home/build/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build/pygalmesh/_cli/_inr.py", line 6, in <module>
    from .helpers import _get_version_text
  File "/home/build/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build/pygalmesh/_cli/helpers.py", line 5, in <module>
    from ..__about__ import __copyright__, __version__
ImportError: cannot import name '__copyright__' from 'pygalmesh.__about__' (/home/build/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build/pygalmesh/__about__.py)

pygalmesh-volume-from-surface triggers DistributionNotFound exception

I just noticed the /usr/bin/pygalmesh-volume-from-surface utility

It doesn't work in a Debian installation (0.3.3-2), generating a pipdate DistributionNotFound exception:

$ pygalmesh-volume-from-surface 
Traceback (most recent call last):
  File "/usr/bin/pygalmesh-volume-from-surface", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3191, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3175, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3204, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pipdate' distribution was not found and is required by pygalmesh

Does some configuration setting need to be set?

pip install fails for missing README

(Ebeneezer)# pip install frentos
Collecting frentos
  Using cached frentos-0.1.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/69/p1yp189j2370p9k2cfwffcww0000gn/T/pip-build-5RqjG6/frentos/setup.py", line 46, in <module>
        long_description=read('README.rst'),
      File "/private/var/folders/69/p1yp189j2370p9k2cfwffcww0000gn/T/pip-build-5RqjG6/frentos/setup.py", line 16, in read
        encoding='utf-8'
      File "/Users/jehammel/src/Ebeneezer/lib/python2.7/codecs.py", line 884, in open
        file = __builtin__.open(filename, mode, buffering)
    IOError: [Errno 2] No such file or directory: '/private/var/folders/69/p1yp189j2370p9k2cfwffcww0000gn/T/pip-build-5RqjG6/frentos/README.rst'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/69/p1yp189j2370p9k2cfwffcww0000gn/T/pip-build-5RqjG6/frentos/

I was mostly checking out the project for curiousity, but thought you should know.

building with CGAL 5

pygalmesh needs some help to build against CGAL 5, which is now header-only.

Dropping the CGAL libraries themselves is easy enough. (I guess you'd want the build able to work with both CGAL 4 or 5)

But then there's a more subtle problem (on Debian unstable). setup.py seems to be invoking gcc to compile the extensions, but the files are C++. setup.py does refer to C++, but nevertheless the build proceeds with x86_64-linux-gnu-gcc instead of x86_64-linux-gnu-g++.

Consequently when running tests,

   dh_auto_test -O--buildsystem=pybuild
I: pybuild base:217: cd /home/projects/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build; python3.8 -m unittest discover -v 
pygalmesh (unittest.loader._FailedTest) ... ERROR

======================================================================
ERROR: pygalmesh (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: pygalmesh
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/projects/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build/pygalmesh/__init__.py", line 2, in <module>
    from _pygalmesh import (
ImportError: /home/projects/pygalmesh/.pybuild/cpython3_3.8_pygalmesh/build/_pygalmesh.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE

The missing symbol is in libstdc++.so.

Force the use of system installed CGAL instead of user installed?

Hello,

While installing the package with pip, I run into many (many!) errors and I noticed that to build the wheel, it was the /usr/local folder that was search for CGAL libraries.

And indeed, I installed some CGAL stuff there while I was trying to compile it from sources a time ago.

In between, I also installed the CGAL libraries using apt, namely these;

libcgal-demo - C++ library for computational geometry (demos)
libcgal-dev - C++ library for computational geometry (development files)
libcgal-qt5-13 - C++ library for computational geometry (support for Qt5)
libcgal-qt5-dev - C++ library for computational geometry (development files, support for Qt5)
libcgal13 - C++ library for computational geometry
cgal - cgal-4.13-latest

I want now to tell pip to install pygalmesh using the libraries installed by apt in /usr/lib instead of the ones found in /usr/local/lib.

Is this possible?

Environment:

I'm on Ubuntu 18.04 64bit: 5.3.0-26-generic x86_64 GNU/Linux
My python is: Python 3.6.9 (default, Nov 7 2019, 10:44:02)
And pygalmesh found by pip is: pygalmesh (0.5.0) - Python frontend to CGAL's 3D mesh generation capabilities

Thanks.

Repeatable Meshes

Each time pygalmesh creates a mesh, that mesh is unique. This can make things difficult if it is used to generate meshes in, for example, an automated testing environment.

CGAL supports setting its initial seed:
CGAL/cgal#4376

If this property was controllable in pygalmesh one could ensure the meshes generated were identical.

Currently the workaround is just to generate a mesh and save it with meshio.

Autopkgtest failure on big-endian (s390x)

I see the autokpgtest failure below in Ubuntu 19.10 on s390x, with meshio 3.1.6,

From http://autopkgtest.ubuntu.com/packages/p/pygalmesh/eoan/s390x

___________________________ test_volume_from_surface ___________________________

    def test_volume_from_surface():
        this_dir = os.path.dirname(os.path.abspath(__file__))
        mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(
            os.path.join(this_dir, "meshes", "elephant.vtu"),
            facet_angle=25.0,
            facet_size=0.15,
            facet_distance=0.008,
            cell_radius_edge_ratio=3.0,
>           verbose=False,
        )

test/test_volume_from_surface.py:15: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3/dist-packages/pygalmesh/main.py:188: in generate_volume_mesh_from_surface_mesh
    mesh = meshio.read(filename)
/usr/lib/python3/dist-packages/meshio/_helpers.py:192: in read
    return format_to_reader[file_format].read(filename)
/usr/lib/python3/dist-packages/meshio/_vtu.py:321: in read
    reader = VtuReader(filename)
/usr/lib/python3/dist-packages/meshio/_vtu.py:194: in __init__
    pts = self.read_data(data_array)
/usr/lib/python3/dist-packages/meshio/_vtu.py:308: in read_data
    data = self.read_binary(c.text.strip(), c.attrib["type"])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <meshio._vtu.VtuReader object at 0x3ffa2b92948>
data = 'AwAAAACAAAAoBAAAeXEAAA9yAAAzBAAAeJw8XHc81f/3r09GRdGS0k5pSSkl4aBSKZJVWmiIhMhOJSHZe8/svfc4d7ruNa+9ZZSsprSM373q++sPPR7XX...uFv5c5XRYTm8O/FHr9SXzuyj+SBUzg1t2MvzofniXICMS/m44AbhYvyj/JjjKHSV2Xv0cAN4sXC8O/zbBR1m8mvr8hWcAEbt3Jv/Flogip28k/XHIkXw=='
data_type = 'Float64'

    def read_binary(self, data, data_type):
        # first read the the block size; it determines the size of the header
        dtype = vtu_to_numpy_type[self.header_type]
        num_bytes_per_item = numpy.dtype(dtype).itemsize
        num_chars = num_bytes_to_num_base64_chars(num_bytes_per_item)
        byte_string = base64.b64decode(data[:num_chars])[:num_bytes_per_item]
        num_blocks = numpy.frombuffer(byte_string, dtype)[0]
    
        # read the entire header
        num_header_items = 3 + num_blocks
        num_header_bytes = num_bytes_per_item * num_header_items
        num_header_chars = num_bytes_to_num_base64_chars(num_header_bytes)
        byte_string = base64.b64decode(data[:num_header_chars])
>       header = numpy.frombuffer(byte_string, dtype)
E       ValueError: buffer size must be a multiple of element size

/usr/lib/python3/dist-packages/meshio/_vtu.py:270: ValueError

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.