<div dir="ltr">No luck. Still doesn't work and the iso-surfaces seem to be accumulating.<div>Probably I need to completely update the actor. How can I do that?</div><div><br></div><div>In addition to the suggested function, I modified the callback as follows (and I still see GetNumberOfContours returning 1):</div>

<div><div><br></div><div><div><br></div><div class="gmail_extra"><span style="color:rgb(80,0,80)">class vtkSliderCallback : public vtkCommand</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">{</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">public:</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">static vtkSliderCallback *New()</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">{</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">return new vtkSliderCallback;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">}</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">virtual void Execute(vtkObject *caller, unsigned long, void*)</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">{</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">vtkSliderWidget *sliderWidget = reinterpret_cast<</span><span style="color:rgb(80,0,80)">vtkSliderWidget*>(caller);</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">int value = static_cast<int>(static_cast<</span><span style="color:rgb(80,0,80)">vtkSliderRepresentation *>(sliderWidget-></span><span style="color:rgb(80,0,80)">GetRepresentation())-></span><span style="color:rgb(80,0,80)">GetValue());</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">this->contourFilter->SetValue(</span><span style="color:rgb(80,0,80)">0, value);</span><br style="color:rgb(80,0,80)"><div><span class="" style="white-space:pre">                   </span>cout << "# of contours, Now = " << this->contourFilter->GetNumberOfContours();</div>

<div><span class="" style="white-space:pre">                    </span>this->contourFilter->SetValue(0, value);</div><div><span class="" style="white-space:pre">                     </span>cout << " and now = " << this->contourFilter->GetNumberOfContours() << endl;</div>

<div><span class="" style="white-space:pre">                    </span>this->contourFilter->Modified();</div><div><span class="" style="white-space:pre">                     </span>this->contourFilter->Update();</div><div><span class="" style="white-space:pre">                       </span></div>

<div><span class="" style="white-space:pre">                    </span>this->polyDataNormals->Modified();</div><div><span class="" style="white-space:pre">                   </span>this->polyDataNormals->Update();</div><div><span class="" style="white-space:pre">                     </span></div>

<div><span class="" style="white-space:pre">                    </span>this->stripper->Modified();</div><div><span class="" style="white-space:pre">                  </span>this->stripper->Update();</div><div><span class="" style="white-space:pre">                    </span></div>

<div><span class="" style="white-space:pre">                    </span>this->polyDataMapper->Modified();</div><div><span class="" style="white-space:pre">                    </span>this->polyDataMapper->Update();</div><div><br></div><div><span class="" style="white-space:pre">                     </span>this->renderWindow->Modified();</div>

<div><span class="" style="white-space:pre">                    </span>this->renderWindow->Render();</div><div><br></div><span style="color:rgb(80,0,80)">}</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">vtkSliderCallback():</span><span style="color:rgb(80,0,80)">ImageActor(0)</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">{</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">contourFilter = NULL;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">polyDataNormals = NULL;</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">stripper = NULL;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">polyDataMapper = NULL;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">renderWindow = NULL;</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">}</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">vtkContourFilter *contourFilter;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">vtkPolyDataNormals *polyDataNormals;</span><br style="color:rgb(80,0,80)">

<span style="color:rgb(80,0,80)">vtkStripper *stripper;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">vtkPolyDataMapper *polyDataMapper;</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">vtkRenderWindow* renderWindow;</span><br style="color:rgb(80,0,80)">

<br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">};</span><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">regards,</div><div class="gmail_extra">Divya</div>

<div class="gmail_extra"><br clear="all"><div>"The difference between school and life? In school, you're taught a lesson and then given a test. In life, you're given a test that teaches you a lesson."</div>


<br><br><div class="gmail_quote">On Wed, Jan 29, 2014 at 11:16 PM, Divya Rathore <span dir="ltr"><<a href="mailto:divyarathore@gmail.com" target="_blank">divyarathore@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr">Thanks for the Gerrick!<div>Will check it out at the first chance (couple of hours from now).</div><div><br></div><div>Is this to be set just once initially or with each slider move?</div><div><br></div><div>


<br></div><div>best regards,</div><div>Divya</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div>"The difference between school and life? In school, you're taught a lesson and then given a test. In life, you're given a test that teaches you a lesson."</div>

<div><div class="h5">

<br><br><div class="gmail_quote">On Wed, Jan 29, 2014 at 11:06 PM, Gerrick Bivins <span dir="ltr"><<a href="mailto:Gerrick.Bivins@halliburton.com" target="_blank">Gerrick.Bivins@halliburton.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Divya,<br>
<br>
I also found this a little "unintuitive". Even though you specify the same "contour index" in SetValue,<br>
<br>
you also need to make sure you set  the number of contours to 1. Otherwise, the filter just continues to add them:<br>
<br>
<a href="http://www.vtk.org/doc/nightly/html/classvtkContourFilter.html#a5485ad7720282f2001fa6443c303003a" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkContourFilter.html#a5485ad7720282f2001fa6443c303003a</a><br>



<br>
<br>
<br>
Hopefully that helps.<br>
<br>
Gerrick<br>
<br>
________________________________<br>
From: vtkusers [<a href="mailto:vtkusers-bounces@vtk.org" target="_blank">vtkusers-bounces@vtk.org</a>] on behalf of Divya Rathore [<a href="mailto:divyarathore@gmail.com" target="_blank">divyarathore@gmail.com</a>]<br>
Sent: Wednesday, January 29, 2014 11:06 AM<br>
To: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
Subject: [vtkusers] Interactivly changing isovalue using slider<br>
<div><div><br>
Hi All,<br>
<br>
I am trying to change the isovalue interactively in the medical2 sample. I am trying to use the 3D Slider example (<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/Slider" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/Slider</a>) to do this.<br>



<br>
I have modified the above class vtkSliderCallback as:<br>
<br>
class vtkSliderCallback : public vtkCommand<br>
{<br>
public:<br>
static vtkSliderCallback *New()<br>
{<br>
return new vtkSliderCallback;<br>
}<br>
virtual void Execute(vtkObject *caller, unsigned long, void*)<br>
{<br>
vtkSliderWidget *sliderWidget = reinterpret_cast<vtkSliderWidget*>(caller);<br>
int value = static_cast<int>(static_cast<vtkSliderRepresentation *>(sliderWidget->GetRepresentation())->GetValue());<br>
this->contourFilter->SetValue(0, value);<br>
this->contourFilter->Update();<br>
this->polyDataNormals->Update();<br>
this->stripper->Update();<br>
this->polyDataMapper->Update();<br>
this->renderWindow->Render();<br>
}<br>
vtkSliderCallback():ImageActor(0)<br>
{<br>
contourFilter = NULL;<br>
polyDataNormals = NULL;<br>
stripper = NULL;<br>
polyDataMapper = NULL;<br>
renderWindow = NULL;<br>
}<br>
vtkContourFilter *contourFilter;<br>
vtkPolyDataNormals *polyDataNormals;<br>
vtkStripper *stripper;<br>
vtkPolyDataMapper *polyDataMapper;<br>
vtkRenderWindow* renderWindow;<br>
<br>
};<br>
<br>
<br>
main()<br>
{<br>
<br>
// read data<br>
  // short data<br>
  vtkSmartPointer<vtkImageReader> v16 = vtkSmartPointer<vtkImageReader>::New();<br>
  v16->SetFileName(argv[2]);<br>
  v16->SetFileDimensionality(3);<br>
  v16->SetDataScalarTypeToUnsignedShort();<br>
  v16->SetDataByteOrderToLittleEndian();<br>
  v16->SetNumberOfScalarComponents(1);<br>
  v16->SetDataExtent(0,width-1, 0,height-1, 0,depth-1);<br>
  v16->SetDataSpacing (1.0, 1.0, 1.0);<br>
  v16->Update();<br>
  //..##<br>
<br>
// An isosurface, or contour value of 500 is known to correspond to<br>
// the skin of the patient. Once generated, a vtkPolyDataNormals<br>
// filter is is used to create normals for smooth surface shading<br>
// during rendering.  The triangle stripper is used to create triangle<br>
// strips from the isosurface; these render much faster on may<br>
// systems.<br>
  vtkSmartPointer<vtkContourFilter> Extractor =<br>
    vtkSmartPointer<vtkContourFilter>::New();<br>
  Extractor->SetInputConnection( v16->GetOutputPort());<br>
  Extractor->ReleaseDataFlagOn();<br>
  Extractor->SetValue(0, 10240.0);<br>
  Extractor->Update();<br>
<br>
  vtkSmartPointer<vtkPolyDataNormals> Normals =<br>
    vtkSmartPointer<vtkPolyDataNormals>::New();<br>
  Normals->SetInputConnection(grainExtractor->GetOutputPort());<br>
  Normals->ReleaseDataFlagOn();<br>
  Normals->SetFeatureAngle(60.0);<br>
  Normals->Update();<br>
<br>
  vtkSmartPointer<vtkStripper> Stripper =<br>
    vtkSmartPointer<vtkStripper>::New();<br>
  Stripper->SetInputConnection(grainNormals->GetOutputPort());<br>
  Stripper->ReleaseDataFlagOn();<br>
  Stripper->Update();<br>
<br>
  vtkSmartPointer<vtkPolyDataMapper> Mapper =<br>
    vtkSmartPointer<vtkPolyDataMapper>::New();<br>
  Mapper->SetInputConnection(grainStripper->GetOutputPort());<br>
  Mapper->ReleaseDataFlagOn();<br>
  Mapper->ScalarVisibilityOff();<br>
<br>
  vtkSmartPointer<vtkActor> surface =<br>
    vtkSmartPointer<vtkActor>::New();<br>
  surface->SetMapper(grainMapper);<br>
  surface->GetProperty()->SetDiffuseColor(.66, .92, .33);<br>
  surface->GetProperty()->SetSpecular(.3);<br>
  surface->GetProperty()->SetSpecularPower(20);<br>
  surface->GetProperty()->SetOpacity(1.0);<br>
<br>
<br>
// set up the slider<br>
  vtkSmartPointer<vtkSliderCallback> callbackSlider = vtkSmartPointer<vtkSliderCallback>::New();<br>
  callbackSlider->contourFilter = Extractor;<br>
  callbackSlider->polyDataNormals = Normals;<br>
  callbackSlider->stripper = Stripper;<br>
  callbackSlider->polyDataMapper = Mapper;<br>
  callbackSlider->renderWindow = renWin;<br>
<br>
//..<br>
// other aspects as covered in the above URL<br>
//..<br>
<br>
// Finally add observer<br>
sliderWidgetSCP->AddObserver(vtkCommand::EndInteractionEvent, callbackSlider);<br>
<br>
}<br>
<br>
<br>
<br>
As such the interactivity pipeline is in place. But the problem is that on moving the slider the previous iso-values are not clearing and the surfaces keep on adding up (the shown surface keeps growing, obviously it all having the same color due to the call this->contourFilter->SetValue(0, value))<br>



<br>
What am I missing here? I want just that iso-value to be shown that the slider reflects.<br>
<br>
best regards,<br>
Divya<br>
<br>
</div></div>----------------------------------------------------------------------<br>
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.<br>



</blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div></div>