Sculpt like feature

Can anyone provide me with some ideas on how to achieve a similar effect using VTK (Visualization Toolkit)?

An idea: use the vtkBooleanOperationPolyDataFilter to keep merging the sphere geometry with the main geometry. I guess a custom widget would would make it easier to use in an application.

Good point.
But I have tried vtkBooleanOperationPolyDataFilter. It’s too slow, each boolean takes up to 1 seconds.

Another idea - Setup your widget to modify scalar values at the points that you sculpt over. And then use either the WarpByScalar filter or elevation filter. To improve performance you could write your own filter that just runs the warping on a small extent of the whole dataset.

@Charles_Gueunet

For faster boolean operation, you may have a look at the vespa project. In your case, I would not use it directly but instead create a new version of the boolean operation filter in order to keep the VTK and the CGAL meshes internally so to reduce the number of VTK / CGAL translation (for efficiency purpose).
I assume this will not be interactive anyway, as reconstructing the whole mesh is not really good.

I guess having your own filter that takes the initial mesh and the sphere as input and internally uses a Distance Polydata Filter to move the points of the output mesh to those of the given sphere would be faster. No remeshing, and you can reuse the same output mesh, so it can stay interactive.
You need to deep copy the input mesh first as you do not want to modify the input mesh.

1 Like

In 3D Slicer we implemented this with plain VTK features: real-time preview with adding spheres, then when the mouse is released then regenerate the mesh. We use labelmap image representation and regenerate the mesh for 3D display, that’s why the preview is needed (otherwise updates would be quite choppy).

You could probably avoid the preview by using a faster mesh generator (e.g., the new surface net filter) or render the underlying image directly using volume raycast mapper (then you don’t need to create a mesh for rendering at all).

I would note that adding spheres to a 3D model does not work very well. The result is exactly as ugly as you see it in this video and in the video in the original question. If you use it along with thresholding or as mask for post-processing then it may be OK, but not for creating any decent shape. Sculpting tools in Blender and even in MeshMixer produce much more usable results. Blender is open-source so you can study how these tools are implemented (and you may even use it in your own application via Blender’s Python interface).

3 Likes