# Controlling Contour Widget interaction using points

**URL:** <https://discourse.vtk.org/t/controlling-contour-widget-interaction-using-points/15676>\
**Category:** Development\
**Created:** [May 28, 2025, 1:26pm UTC](https://discourse.vtk.org/t/controlling-contour-widget-interaction-using-points/15676 "2025-05-28T13:26:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleena](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@Aleena](https://discourse.vtk.org/u/Aleena)\
**Post date:** [May 28, 2025, 1:26pm UTC](https://discourse.vtk.org/t/controlling-contour-widget-interaction-using-points/15676/1 "2025-05-28T13:26:50Z")

</div>

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

```auto
        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](https://discourse.vtk.org/uploads/default/original/2X/d/d385ac2a069c04248676ec822ccd4062e496d810.gif)

---

<div class="post-metadata">

**Author:** ![Aleena](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@Aleena](https://discourse.vtk.org/u/Aleena)\
**Post date:** [May 29, 2025, 10:32am UTC](https://discourse.vtk.org/t/controlling-contour-widget-interaction-using-points/15676/2 "2025-05-29T10:32:33Z")

</div>

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

```
