inflating a part of an object in VTK

Hi everyone!
How can I inflate a part of an object by getting an input from user in VTK using C++?(something like what I attached here)

@Tiffany_Chhim @Charles_Gueunet

For the user input part, you may rely on the already existing VTK pickers, like on this example. There are a lots of pickers for you to explore, I have chosen one quickly here, maybe not the best.

For the deformation part, the vespa library has a deformation algorithm, I encourage you to use the corresponding test to see how it works.

With these tools, the pipeline would be:

  1. Load your data set and generate global ids (and maybe normals ?)
  2. The user create a selection on cells or points
  3. You apply a transform on the selection like a warp by vector
  4. You use the vepa deformation filter with both the dataset and the transformed points as input (global ides are used to identify with points to move where)
  5. You obtain the result you want.

Bonus, the deformation filter can also take a Regoin Of Interest to be able to move some points and provide a smoother result

Thank you so much!
I will test it

well, I tried to build Vespa with CMake but the error which I attched here occured.(I should say that I have built VTK without Python wrapper before


I think you have the BUILD_PYTHON_WRAPPERS option set to ON. In this case, the VTK you use should support Python also.
The simplest solution is to set BUILD_PYTHON_WRAPPERS to OFF during vespa configuration.
Otherwise, you may try to set VTK_WRAP_PYTHON to ON in your VTK build, to be able to access VTK (and Vespa) in python.

could you please tell me how can I move points(target points in deformation algorithm) by dragging the mouse?
in this test “TestPMPDeformExecution.cxx” the target points coordinates have been valued in the code, but I want to deform the points by the mouse to wherever I want.


@kimia_ghodoosi are you familiar with VTK widgets ? I this situation you may want to use a vtkHandleWidget. This will provide you with one handle that you may move (and constrain) in your scene.
Of course, when applying the deformation filter, you need to transform your widget into a valid point set, with an array of Ids consistent with the one of your initial dataset, so the algorithm can match the points to move.

There are various tests that uses the vtkHandleWidget that can serve as examples.

well, I tried to inflate a part of my object with vtkCGALAlphaWrapping but it warp the area larger than our selected area. the results have shown below:

In this method two parameters can be changed: alpha and offset. the more increase the offset parameter, the area is expanded from all sides. how can I specify the direction of it’s inflating process. I mean I want it to be apply more perpendicular to the surface and a bit from the sides. Is this possible with this method or should I use another solution?


Nice, things are coming together.

I would see sevral things here to improve the restult:

  1. vtkCGAHMeshDeformation has two modes, the smooth (by default) and the sre_arap. Please ensure you are using the second one (you can use the SetMode method) and play with the SreAlpha variable.
  2. check you selection only consist of points inside the selected area
  3. recompute normals as deforming the mesh may lead to visual artifacts if old normals stay in use.

could you please tell me how can I generate global ids?
because my STL files doesn’t have any ids.

The best way would be to use the vtkGenerateGlobalIds filter in the FiltersParallelDIY2 module. Unfortunately it requires VTK to be compiled with MPI, even for sequential executions, I hope we will be able to fix that one day.

The other way is to write a really simple VTK filter that create an array filled with number from 0 to # of points and attach it to the input dataset.

Thannk you so much. I will check it