iMSTK
Interactive Medical Simulation Toolkit
Docs/Dynamical_Models/LevelSetModel.md
1 # LevelSet Method (LSM)
2 
3 The level set method can be used to smoothly evolve a PDE over a domain. This could just be distances or could even be something like the heat equation.
4 
5 The LevelSetModel is currently only implemented to evolve distances for regular 3d grids. It can do so in dense or sparse mode. With dense mode every voxel of the grid is updated every iteration. Whilst the sparse mode accepts a list of impulses to the velocities, evolving only voxels which actually have something to evolve.
6 
7 ## Usage
8 
9 With it we are able to achieve very fast collision detection and haptic response (>1000hz) and deformation of "statically deformable" object. This finds its uses for bone sawing, burring, drilling.
10 
11 <p align="center">
12  <img src="../media/lsmCutting.gif"/>
13 </p>
14 
15 ## Code
16 
17 ```cpp
18 // Setup config
19 auto lvlSetConfig = std::make_shared<LevelSetModelConfig>();
20 lvlSetConfig->m_sparseUpdate = true;
21 lvlSetConfig->m_substeps = 30;
22 
23 // Setup the Model
24 auto model = std::make_shared<LevelSetModel>();
25 model->setModelGeometry(sdfGeometry);
26 model->configure(lvlSetConfig);
27 ```
28 
29 This can be given to a LevelSetDeformableObject for usage in the scene.