Creating a New Module
OpenStructure can be extended by writing additional modules. A module will usually consist of a set of C++ classes and methods, most of which will also be exported to Python. It is also possible to write modules completely in Python.
The build system of OpenStructure is quite simple. The main difference to other projects is the use of a so-called stage directory. The stage directory replicates the normal layout of a standard Linux directory structure, with an 'include' directory for the headers, a 'lib' directory containing the shared library files, a bin directory for the executables and a 'share' directory for the platform-independent data like icons, images and examples.
OpenStructure uses CMake to build the project. The rules for the build-system are defined in CMakeLists.txt files. When running cmake, the files are compiled and copied into stage. The real installation, if necessary, happens at a later stage. This is referred to as staging of the files.
If a new module is written following the guidelines in this page, it will be seamlessly included in the build system and will then be available form both the DNG python console and the OpenStructure command line as any other native module.
As a first step, a new directory structure must be created to accommodate the new module.
Directory Structure
For the purpose of this example, let's assume we are creating a new module called 'mod' (for 'modeling'). Let's create a directory named mod under the 'modules' directory in the OpenStructure development tree, and populate it with the three subdirectories src, pymod, and tests. Then we add a CMakeLists.txt file in the 'mod' directory, consisting of three lines:
add_subdirectory(src)
add_subdirectory(pymod)
add_subdirectory(tests)