2. Getting Started

2.1. Pre-requisites

Before building and using SlicerSOFA you should be familiar with:

  • Linux, CMake and building C++ projects.

  • Building Slicer from source (required to compile the C++ extensions).

  • Basic SOFA knowledge (scene files, solvers, meshes) is helpful to author or modify SOFA scenes.

2.3. Cloning

Assuming a development workspace:

mkdir -p ~/dev
cd ~/dev
git clone https://github.com/yourorg/SlicerSOFA.git
cd SlicerSOFA

2.4. Building overview

There are two main approaches to build SlicerSOFA depending on how you want to manage external dependencies:

  1. Use the included SuperBuild to fetch and build SOFA and other third-party libraries. This is useful if you do not already have SOFA available.

  2. If you already have a Slicer build and external dependencies (SOFA and libraries) installed on your system, build only the Slicer extension and point CMake to your Slicer build directory.

2.5. Basic build example (using SuperBuild)

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DSlicer_DIR:PATH=/path/to/your/Slicer-build
make -j4

Alternatively, if building the Slicer module only:

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DSlicer_DIR:PATH=/path/to/your/Slicer-build -DUSE_SUPERBUILD=OFF
make -j4

2.6. Loading the module into Slicer

After a successful build:

  • Ensure Slicer can find SlicerSOFA binaries and any required dynamic libraries. If you built against a Slicer build tree and used the build install steps, the module will be placed into the Slicer extensions path in the build area.

  • Start Slicer from the same shell where environment variables are correct (if you built/install in custom locations set LD_LIBRARY_PATH accordingly). Example:

cd /path/to/Slicer-build
./Slicer

Inside Slicer the SlicerSOFA module(s) should appear under the Modules menu (names: SlicerSofa, SoftTissueSimulation, SparseGridSimulation).

2.7. Quick start with Python

Once the module is loaded you can control simulations from Slicer’s Python interactor. Example (pseudo-API; see integration docs for real API):

import slicer
logic = slicer.util.getModuleLogic('SlicerSofa')
# Load a scene file (path relative to your project or absolute)
sofaSceneNode = logic.LoadSofaScene('/path/to/scene.scn')
# Start simulation (run on a timer integrated with Slicer UI)
sofaSceneNode.Play()
# Pause and step
sofaSceneNode.Pause()
sofaSceneNode.Step()

See pages/integration.rst for the API details and examples.