Skip to main content
This directory holds self-contained examples of common operations you may want to perform using nTop Core library. The examples themselves are meant to be fully self-contained in showing how you would utilize nTop Core to perform a commonly-requested task. This necessitates, however, a somewhat verbose preamble section in which Python-to-C-Library data marshalling and data primitive definitions are established. It is necessary to understand these sections if you want to use functionality of nTop Core that is not covered in these examples but we recommend starting by skipping to the sections which exercise the library first to get a feel for the library’s use.

Setup

The examples have been tested to run on Python 3.11.4 but other recent releases should function similarly. Now create an environment variable to locate the nTop Core library file.
# Establish the path to the nTop Core library to test if not previously set up
# via the environment variable `NTOP_CORE_LIB`. You can do this per session
# or in a .bashrc or System Environment Variable.

# In windows powershell
$env:NTOP_CORE_LIB = "c:\path\to\ntop_core.dll"
# In *nix
export NTOP_CORE_LIB="/path/to/libntop_core.so.{major}.{minor}.{patch}"
We have some common external dependencies in these examples, the specification is stored in requirements.txt. Install them using your package manager of choice.
# Using `pip` from this directory
pip install -r requirements.txt

Running the examples

You are now ready to run any of the examples using pattern similar to the following:
python mesh.py

Example Scripts

  • Bounding Box — loads an implicit body and prints the minimum/maximum corners of its axis-aligned bounding box.
  • Mesh — samples the body’s field on a voxel grid via ntop_core_query_field_array and reconstructs a surface mesh using scikit-image’s marching cubes.
  • Mesh by Dual Contouring — meshes the body directly using the library’s native ntop_core_generate_mesh_by_DC dual contouring function.
  • Slice — slices the body at 11 heights via ntop_core_query_contours and plots each resulting contour stack.
  • Transform and Scale — applies a scale and a rigid transform to an implicit body and exports the results to new .implicit files.