Skip to main content

Constructive solid geometry on meshes using BSP trees in Cython CSG.

Project description


Cython port of Evan Wallace’s Javascript and Tim Knip raw Python version

What is Cython-CSG

CSG stands for Constructive Solid Geometry. It allow Boolean operations to be made on a 3D object like subtraction.



A simple subtraction is as followed

from _cython_csg import CSG

a = CSG.cube()
b = CSG.cube([0.5, 0.5, 0.0])
c = a - b


A Simple Union would is as followed

from _cython_csg import CSG
a = CSG.sphere(center=[0.5, 0.5, 0.5], radius=0.5, slices=8, stacks=4)
b = CSG.cylinder(start=[0.,0.,0.], end=[1.,0.,0.], radius=0.3, slices=16)

Custom objects

You can make custom object here is a example

from _cython_csg import BSPNode, Polygon, Vertex
v0 = Vertex([0., 0., 0.])
v1 = Vertex([1., 0., 0.])
v2 = Vertex([1., 1., 0.])
p0 = Polygon([v0, v1, v2])
polygons = [p0]
node = BSPNode(polygons)

if you then want to convert it back to a CSG object you can do



To build run

python build
python install

Other Notes

To view the output I would recommend a program like ParaView

Help required

Patches are welcome for the source code or for the documentation

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cython-csg, version 0.5.8
Filename, size File type Python version Upload date Hashes
Filename, size cython-csg-0.5.8.tar.gz (160.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page