Using the python interpreter included with CMB and aevaCMB

Packaged python

If you download a Kitware-generated package of aevaCMB or CMB, it will come with a pvpython executable (in aevaCMB.app/Contents/bin on macos, in bin/pvpython on linux, and in bin/pvpython.exe on windows). You can use this python interpreter as you would any other; the difference is that it sets up the paths so that CMB plugins can be loaded.

Loading an SMTK resource

You can run pvpython on the command line and do things like load SMTK files. The script below will load the example data that comes in the aevaCMB package and print a list of surfaces.

First, we import the paraview.simple module so we can load plugins and the smtk modules needed for operations:

import paraview.simple
import smtk
import smtk.attribute
import smtk.model
import smtk.operation
import smtk.plugin

# Some files included in the aevaCMB download:
aevaPluginPath = '/path/to/smtkAEVASessionPlugin.so'
aevaExamplePath='/path/to/femur_acl_tibia.smtk'

Now load aeva functionality:

# Load the aeva "session" plugin.
# This plugin provides aeva with a resource type and operations.
paraview.simple.LoadPlugin(aevaPluginPath)
# Create an operation manager (a registry of operations)
opMgr = smtk.operation.Manager.create()
# It is empty by default:
opMgr.availableOperations()

# Tell the SMTK plugin system to populate the manager:
smtk.plugin.registerPluginsTo(opMgr)
opMgr.availableOperations()
# Returns a long list including smtk::session::aeva::Read

Create an SMTK operation to read the example data, set the filename, and run it:

readOp = opMgr.createOperation('smtk::session::aeva::Read')
readOp.parameters().findFile('filename').setValue(aevaExamplePath)
res = readOp.operate()

# Check that the operation succeeded:
res.findInt('outcome').value() == int(smtk.operation.Operation.SUCCEEDED)
# Should return True

Finally, we can get information from the operation result and ask the resource about its components:

# Get the resource created by the Read operation.
rsrc = res.findResource('resource').value(0)

# rsrc now holds an aeva resource whose components
# include the 3 models in the file (femur, tibia, and ACL).
# We can get a list of all the components:
rsrc.find('*')
# or just the surfaces:
faces = rsrc.find('face')
# We can print their names
names = [x.name() for x in faces]
names.sort()
print('\n'.join(names))
# Should print:
# ACL_FMB_insertion
# ACL_TBB_insertion
# FMB_ACL_insertion
# TBB_ACL_insertion
# face 5
# face 6
# face 7

Fancier queries are available and described in the SMTK documentation.
Once you have components of interest, you can create additional operations to select regions, add attributes, and export your processed data.

Privacy Notice