简体   繁体   中英

python pygalmesh can't make working exemple

I am trying to use pygalmesh for a project of mine. Basically, i need to create a cube and then subtract part of it in tube form. I have a couple of things i can't get to work. First of, i need to create a cube and the function used in pygalmesh is Cuboid as in :

pygalmesh.Cuboid([0, 0, 0], [1, 1, 1])

i tried this exact line of code since i found it in an answer made by the creator of pygalmesh in this post : Volume of 3d shape using numerical integration with scipy

But even with that line, i get the error : RuntimeError: CGAL ERROR: assertion violation! Explanation: Error: the sizing field is null at corner (0 0 0)

I went into the github repo to try and find how the functions works but i can only find the file that says :

from _pygalmesh import Cuboid

and nothing more. How can i create a cube using pygalmesh then? If possible, i would like to find how to work with all type of volume of pygalmesh, currently i can only reproduce the ones in the exemple on github.

Also, in the same post above ( Volume of 3d shape using numerical integration with scipy ) in the answer using pygalmesh, the code uses a line about cell size (cell_size=3.0e-2) around line 10. But every time i try to add this argument to my function mesh, i get the error : TypeError: generate_mesh() got an unexpected keyword argument 'cell_size'

But i am using the same function as he is?

Is there an update removing some functions that i am missing, i am currently using the latest version of pygalmesh. Here is a simple code showing the error for cell size. If I change Ball for Cuboid, i get the Cuboid error instead.

import numpy
import pygalmesh

mesh = pygalmesh.generate_mesh(
    pygalmesh.Ball([0.0, 0.0, 0.0], 25.0), cell_size=3.0e-2
)
print(mesh)
mesh.write("out2.vtk")

Looks like you're using an outdated version of pygalmesh. cell_size has been removed a while ago. Try using max_cell_circumradius or max_edge_size_at_feature_edges .

import numpy
import pygalmesh

mesh = pygalmesh.generate_mesh(
    pygalmesh.Ball([0.0, 0.0, 0.0], 25.0), max_cell_circumradius=1.0e-2
    )
print(mesh)
mesh.write("out.vtk")

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM