Controlling Contour Widget interaction using points

I am a beginner working with VTK (version 8.2) and C++ as my programming language. I have implemented a vtkContourWidget on a vtkResliceImageViewer and would like to control its interaction using a predefined set of points, rather than relying on the default interactive reshaping behavior.

However, I am encountering issues when trying to visualize the initial contour points. Specifically:

The default handle representation (the spherical glyphs) of the contour widget appears outside the image bounds.

I have attempted to use vtkImageActorPointPlacer and vtkSphereWidget to manage point placement, but have not had success in achieving the desired behavior.Using my image data I have used a few points to create the contour

        double point1[3] = {10,25, 0.0};
        double point2[3] = {width/4, height*.55, 0.0};
        double point3[3] = {width/2, height*.80, 0.0};
        double point4[3] = {(3*width)/4, height*.55, 0.0};
        double point5[3] = {width-10, 25, 0.0};
       
        points->InsertNextPoint(point1);
        points->InsertNextPoint(point2);
        points->InsertNextPoint(point3);
        points->InsertNextPoint(point4);
        points->InsertNextPoint(point5);

 contourRep->BuildRepresentation();
 contourRenderer->SetLayer(1);
contPolyData = contourRep->GetContourRepresentationAsPolyData();
contMapper->SetInputData(contPolyData);
contourActor->SetMapper(contMapper);
contourRenderer->AddActor(contourActor);
 contourRenderer->SetInteractive(false);
My goal is to:
  • Initialize the contour with a specific set of points.

  • Disable the default interactive reshaping behavior.

  • Ensure that all points are placed correctly on or within the bounds of the image displayed in the vtkResliceImageViewer.

  • Controlling the contour widget interaction using predefined points

Additionally, guidance on correctly placing the points within the image bounds would be greatly appreciated.

Thank you in advance for your help.
Best regards,
Aleena

point

     @lassoan @dgobbi @LucasGandel @mwestphal @ben.boeckel