Package: opencamlib
IntroductionOpenCAMLib (ocl) is a library for creating 3D toolpaths for CNC-machines such as mills and lathes.
It is written in C++ and has bindings for Python, Node.js and the browser.
At the moment it supports the following algorithms:Drop-cutterThe drop cutter algorithm drops a cutter, positioned at a predefined (x,y) location, until it touches the 3D model.Push-cutterThe Push-cutter is used to create a Waterline toolpath that follows the shape of the model at a constant z-height in the xy-plane.CuttersThe algorithms listed above can be used with following cutters:CylCutter(flat end mill / cylindrical)BallCutter(ball end mill / spherical)BullCutter(radius end mill / toroidal)ConeCutter(tapered end mill / conical)CompositeCutter(combinations of the above / compound)From August 2018 OpenCAMLib is released under LGPL license.Pre-compiled LibrariesOpenCAMLib provides pre-compiled C++, Node.js and Python libraries for the following platforms and architectures:Windowsia32 / x64macOSx86_64 / arm64Linuxx86_64 / aarch64The Python library is calledopencamliband is hosted on PyPi (pypi.org), precompiled libraries are available for Python v3.7 up to v3.11.The Node.js + emscripten library is called@opencamlib/opencamliband is hosted on npm (npmjs.org), precompiled libraries are available for Node-API v3 and up.The C++ library is calledlibocland is hosted on our Github Releases page.PythonThe Python library (hosted on PyPi) can be installed like this:pipinstallopencamlibOn some platforms, pip is called pip3, you might have to run:pip3installopencamlibNote that pip / pip3 is will install packages for to the system installation of Python, if you want to install a package in a custom Python installation that is not in your $PATH
(for example, the Python which comes with Blender), you can install packages like so:/path/to/your/custom/python-mpipinstallopencamlibIf you don’t know where Python is, but you have access to it’s interpreter (FreeCAD and Blender both have a Python console), you can simply enter this command in there to install OpenCAMLib:importsys;importsubprocess;subprocess.check_call([sys.executable,'-m','pip','install','opencamlib'])JavaScriptThe JavaScript library (hosted on npm) works in Node.js and the browser (by leveraging emscripten / WASM) can be installed like this:npminstall--save@opencamlib/opencamlibOr, using yarn:yarnadd@opencamlib/opencamlibNote that it is not 100% feature complete and lacking some functionality still.C++Pre-compiled C++ libraries are available on the Github Releases page (https://github.com/aewallin/opencamlib/releases).
This project also installs a OpenCAMLibConfig.cmake, which, if your project uses CMake, allows you to usefind_package(OpenCAMLib REQUIRED).You can see an example of that in use over here:examples/cpp/test/CMakeLists.txtYou can see an example of that in use over here:examples/cpp/test/CMakeLists.txtBuilding from SourceHaving trouble with a pre-compiled library? Please report it to us.
If there are no pre-compiled libraries for your platform or architecture, or want to customize or package opencamlib, this is for you.OpenCAMLib uses functionality from a library called Boost.
For the Python library it uses an extra library called Boost.Python.Only the Python bindings need Boost to becompiled(with Boost.Python).
All other librariesDO NOTneed Boost to be compiled, in those cases, a headers only version will suffice.
So, if you are not compiling the Python libraries, simply download Boost, extract it into a folder, and tell CMake where to look for it.Make sure to download Boost from the boost.org downloads page, if you download it from github, you have to make sure to install the git submodulesandbuild the headers.We provide ainstall.shscript that helps with installation of dependencies and building OpenCAMLib libraries, you might want to take a look at it first.
You can run./install.sh--helpto look at the available options, or inspect it’s source code to find out more.DependenciesTo compile OpenCAMLib, you need:C++ compiler(It should at least support C++ 14)Git(This is used for cloning the repository, and the emscripten SDK)CMake(At least version 3.15)Boost(When compiling the Python library, you have tocompileBoost.Python for your Python version after installation)At this time of writing, here are the packages to install:Ubuntu Dependenciessudoaptinstall-ygitcmakecurlbuild-essentiallibboost-devmacOS Dependenciesbrewinstallgitcmakecurlboostpython@3.11boost-python3Windows DependenciesInstallVisual Studio Build Tools (https://visualstudio.microsoft.com/visual-cpp-build-tools/)Git (https://git-scm.com/download/win)CMake (https://git-scm.com/download/win)By downloading the installers from the internet, or by using your package manager.Building for C++The C++ library is the easiest to build, it only depends on Boost’s headers.
Make sure you have a compiler, git, cmake and Boost installed (or simply download and extract it somewhere).gitclonehttps://github.com/aewallin/opencamlibcdopencamlibmkdirbuildcdbuildcmake..-DCXX_LIB="ON"make.# try make -j4 for a faster build if you have a multi-core machinemakeinstall.When boost is not in a standard location, you can add the-DBOOST_ROOT=/path/to/boostoption to the cmake command.Building for EmscriptenTo compile the emscripten library, first download, install and activate it using the following commands:gitclonehttps://github.com/emscripten-core/emsdk.gitcdemsdk./emsdkinstalllatest./emsdkactivatelatestNow you can compile OpenCAMLib like this (make sure to replace thepath/to/sections):sourcepath/to/emsdk/emsdk_env.shgitclonehttps://github.com/aewallin/opencamlibcdopencamlibmkdirbuildcdbuildemcmakecmake\-DCMAKE_BUILD_TYPE="Release"\-DBUILD_EMSCRIPTEN_LIB="ON"\-DUSE_OPENMP="OFF"\-DCMAKE_INSTALL_PREFIX="/path/to/opencamlib/src/npmpackage/build"\-DBOOST_ROOT="/path/to/boost"\..emmakemake# try emmake make -j4 for a faster build if you have a multi-core machineNote thatUSE_OPENMPhas been turned off, OpenMP is not supported with Emscripten at the momentBuilding for Node.jsTo compile the Node.js library, install the dependencies insrc/nodejslib:cdsrc/nodejslibnpminstallNext, use cmake-js to compile the library:gitclonehttps://github.com/aewallin/opencamlibcdopencamlibmkdirbuildcdbuild../src/nodejslib/node_modules/.bin/cmake-js\build\--directory".."\--out"."\--parallel4\--CDBUILD_NODEJS_LIB="ON"\--CDUSE_OPENMP="ON"\--CDCMAKE_INSTALL_PREFIX="/path/to/opencamlib/build/Release/$(node--print'process.platform')-nodejs-$(node--print'process.arch')"\--CDBOOST_ROOT="/path/to/boost"\--config"Release"Building for PythonThe Python library can be compiled similarly to the C++ example above, however, this time Boost.Python has to be compiled first.
Most systems have Boost.Python available as a download, but only for a specific Python version only (usually the latest Python version).
These might work if you are using Python from the same package provider, but, unfortunately, this is not a very reliable method, so compiling them yourself is usually the best option.First, download and extract Boost:curl"https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz"--output"boost_1_80_0.tar.gz"--locationtar-zxfboost_1_80_0.tar.gz-C/tmp/boostcd/tmp/boost/boost_1_80_0Now we can compile it:echo"using python ;">./user-config.jam./bootstrap.sh./b2\-a\threading="multi"\-j4\variant="release"\link="static"\address-model="64"\architecture="x86"\--layout="system"\--with-python\--user-config="./user-config.jam"\cxxflags="-fPIC"\stageNote that you can customize the user-config.jam file to point it to your Python installation
(see:https://www.boost.org/doc/libs/1_78_0/libs/python/doc/html/building/configuring_boost_build.html).
You should also specify the correct architecture and address-model.
On windows, make sure to use windows style paths, e.g.C:\\path\\to\\PythonUsagePlease take a look at theexamples/folder on how to use OpenCAMLib.
For each language there is an example namedtestwhich calls all of the algorithms.There is also some API documentation over here:https://opencamlib.readthedocs.ioCommon ProblemsCompiling OpenCAMLib is unfortunately not very easy and there are many things that can go wrong.
Here is a list of common problems and solutions.Could NOT find Boost (missing: Boost_INCLUDE_DIR)This happens a lot, here are some of the reasons why this happens:You don’t have Boost installed.If you forgot to install boost, go ahead and download Boost from from their website:https://www.boost.org/users/download/and extract it somewhere.
Now, when compiling the C++ or node.js module, add the-DBOOST_ROOT=/path/to/extracted/boostflag to thecmake ..command, or the.--boost-prefix/path/to/extracted/boostflag to the./install.shcommandYou installed Boost from Github.The boost that is hosted on Github does not have the headers yet! To compile those, you should run the following commands:./bootstrap.sh./b2headersYour CMake version has a FindBoost module which is unaware of your Boost’s version.The CMake module that looks for Boost, is usually not aware of the existence of the latest Boost versions.
You can help it by providing the version number of your Boost with the-DBoost_ADDITIONAL_VERSIONS="1.80.0"flag.
Make sure to change 1.80.0 with your version of Boost.It can also be helpfull to enableBoost_DEBUGin the CMake configuration.Cross CompilingTo compile OpenCAMLib for other architectures, we recommend the following strategies.
Always make sure to compile Boost for the correct architecture as well!macOSCross compiling on macOS is possible by setting the CMakeCMAKE_OSX_ARCHITECTURESflag.
When using theinstall.shscript, you can use the--macos-architectureflag to accomplish the same thing.
Make sure to take a look at the other--*-architectureflags when cross compiling.WindowsCross compiling on Windows is possible by using the “Visual Studio” generator (default) and by setting the CMakeCMAKE_GENERATOR_PLATFORMflag.
When using theinstall.shscript, you can use the--cmake-generator-platformflag to accomplish the same thing.
Make sure to take a look at the other--*-architectureflags when cross compiling.LinuxTo ensure that compiled libraries work on older linux versions, it has to be compiled with an older Glibc version.
The easiest way to accomplish this is by using Docker, there are images available especially for this purpose.
When using theinstall.shscript, you can use the--docker-imageflag which will make the command run in a container with the given image name.C++ docker imageWhen cross compiling the C++ library, make sure to use an old Glibc, this is included in the dockcross docker images.
For a list of supported architectures, take a look at:https://github.com/dockcross/dockcross#summary-cross-compilersNode.js docker imageCross compilers for node.js are available here:https://github.com/prebuild/docker-imagesPython docker imageCross compilers for python are here:https://github.com/pypa/manylinux#manylinux2014-centos-7-basedLinksrepositoryhttps://github.com/aewallin/opencamlibPPAs
-https://launchpad.net/~iacobs/+archive/ubuntu/cnc/-https://launchpad.net/~neomilium/+archive/ubuntu/cam-https://launchpad.net/~freecad-community/+archive/ubuntu/ppa- (updated 2012)https://launchpad.net/~anders-e-e-wallin/+archive/ubuntu/cammailing-listhttp://groups.google.com/group/opencamlibIRC-channel #cam on irc.freenode.netcoding standard (?)http://www.possibility.com/Cpp/CppCodingStandard.htmlOrganization of Files(generate this with ‘tree -dL 2’):├── docs                        documentation (not much here yet!)
├── examples                    c++, emscripten, nodejs and python examples
├── scripts                     CI scripts for installing and building ocl
├── src
│   ├── algo                    algorithms under development
│   ├── common                  common algorithms and data-structures
│   ├── cutters                 cutter-classes
│   ├── cxxlib                  c++ library cmake config
│   ├── deb                     debian package cmake config
│   ├── dropcutter              drop-cutter algorithms and operations
│   ├── emscriptenlib           bindings for emscripten library
│   ├── geo                     primitive geometry classes (point, triangle, stlsurf, etc.)
│   ├── nodejslib               Node.js library bindings and cmake config
│   ├── npmpackage              combined Node.js and emscripten wrappers, for publishing to npm
│   ├── pythonlib               python library bindings and cmake config
└── stl                         STL files for testing