Package: petrify
A library for constructing, importing, visualizing, modifying, and exporting
three-dimensional geometry and toolpaths. Designed for CAD / CAM applications.To get started with this library, we recommend walking through the demos below.
Each notebook contains links to our comprehensive class and method-leveldocumentation.Online DemoThanks to the magic ofbinder, you can try out petrify online. We have demos
for several core petrify features:Construction of many basicsolids.Methods for definingadvancedsolids.Combiningmultiple solids into a single complex solid.Settingvisualproperties on solids to create the above logo.Have patience; notebooks on binder can take up to a minute to start. Due to a
(possible) bug in pythreejs, you’ll need to click “restart and run all” to see
the relevant interactive visualizations.Design PrinciplesNovice focus. This library should make it as easy as possible to build
and manipulate solids, shapes, and other geometry.Immutable operation. Immutable math is easier for most audiences to reason
about. This library explicitly does not target strong real-time applications
like games that demand mutability for performance.Pluggable engines. CSG is complicated. Different engines have different
tradeoffs:The pymesh engine is the default where thepymesh2library is installed. It
uses the CGAL CSG engine, which is mature and quite fast. However, building
pymesh with CGAL support can be difficult for novices and in certain
environments (like Windows and OSX).cython-csg is relatively fast, but still requires a cython build toolchain.pycsg is a pure-python implementation. It is obviously quite slow, but works
everywhere python does. For example, pure python environments likepyiodidecan utilize this engine easily.Quickstart with DockerWe recommend using petrify inside our prepackageddockerimage. This image
has all the necessary libraries for running a Jupyter notebook server, and the
pymesh engine already installed:docker run -it -p 8888:8888 \
  -v $(pwd)/notebooks:/home/jovyan/work \
  anirishduck/petrifyThe above command will expose a notebook on port 8888 with the necessary volume
mounts for persisting theworkdirectory. The server will output a?token=<xxxxx>query parameter you will need for authentication.Installationpetrify is published online via pip:pip install petrifyWe strongly recommend using its visualization capabilities in combination withJupyter:pip install notebook pythreejsWhile petrify is functional from this point, you almost certainly want to
install a more powerful engine than the default pycsg one. See ourcsgexample
for more detail on why; read on to learn how.pymesh2pymesh is the most mature driver, but also has the most complicated installation
procedure. We currently only recommend this installation in a Linux-like
environment. You can also useWSLif on Windows, or a VM on OSX.You will need to build pymesh withCGALsupport to use this engine. To install
in Ubuntu or Debian environments:sudo apt-get install libcgal-devNow, you can install using the normal PyMesh installationprocedure. In
Linux-like environments, you can probably just install all the needed
library dependencies in the documentation, and then run:pip install pymesh2cython-csgInstallation of cython-csg requires a working build of cython, which should be
available on most major platforms:pip install cythonFrom here, the installation of cython-csg should be entirely automated:pip install cython-csgContributorsThis library is a fusion of:pycsgpyeuclid v3 fork (https://github.com/ezag/pyeuclid/)the reverbat STL PR on pycsg (https://github.com/timknip/pycsg/pull/9)