<div dir="ltr">dear All,<div><br></div><div>I have vtk poly data , that I use vtkbox widget to select part to cut and re display it ,</div><div><br></div><div>I use the follwoing code but the vtkpolydata cannot be updated </div>
<div><br></div><div><div> vtk.vtkDICOMImageReader VDR = new vtk.vtkDICOMImageReader();</div><div> VDR.SetDirectoryName(@"G:\Master Degree\DataSet\case2\DICOM\PA1\ST1\SE2");</div><div> VDR.SetDataOrigin(0, 0, 0);</div>
<div> VDR.Update();</div><div><br></div><div> // decrease the dataset data for large data preprocessing </div><div><br></div><div> vtkImageShrink3D VIS = new vtkImageShrink3D();</div>
<div> VIS.SetShrinkFactors(2, 2, 2);</div><div> VIS.SetInputConnection(VDR.GetOutputPort());</div><div> VIS.Update();</div><div><br></div><div> vtkImageThreshold VIT = new vtkImageThreshold();</div>
<div> VIT.ThresholdBetween(200, 2000);</div><div> VIT.SetInputConnection(VIS.GetOutputPort());</div><div> VIT.Update();</div><div><br></div><div> double isovalue = 500;</div>
<div><br></div><div> vtkContourFilter skinExtractor = new vtkContourFilter();</div><div> skinExtractor.SetInputConnection(VIT.GetOutputPort());</div><div> skinExtractor.SetValue(0, isovalue);</div>
<div> skinExtractor.ComputeGradientsOn();</div><div> skinExtractor.Update();</div><div> gpd = skinExtractor.GetOutput();</div><div> </div><div><br></div><div> vtk.vtkPolyDataMapper coneMapper = new vtk.vtkPolyDataMapper();</div>
<div> coneMapper.ScalarVisibilityOff();</div><div> coneMapper.SetInput(gpd);</div><div> maceActor = new vtkLODActor();</div><div> maceActor.SetMapper(coneMapper);</div><div> //////////////////////// Selection Part /////////////////////////</div>
<div> planes = new vtkPlanes();</div><div><br></div><div> clipper = new vtkClipPolyData();</div><div> clipper.SetInput(gpd);</div><div> clipper.SetClipFunction(planes);</div><div>
clipper.InsideOutOn();</div><div><br></div><div> </div><div> ///////////////////////////////////////// Cutting part /////////////////// </div><div> clipper_Cut = new vtkClipPolyData();</div>
<div> clipper_Cut.SetInput(gpd);</div><div> clipper_Cut.SetClipFunction(planes);</div><div> clipper_Cut.InsideOutOff();</div><div><br></div><div> //////////////////////////////////////////////////</div>
<div><br></div><div> vtkPolyDataMapper selectMapper = new vtkPolyDataMapper();</div><div> selectMapper.SetInput(clipper.GetOutput());</div><div> selectMapper.ScalarVisibilityOff();</div><div>
selectActor = new vtkLODActor();</div><div> selectActor.SetMapper(selectMapper);</div><div> selectActor.GetProperty().SetColor(0, 1, 0);</div><div> selectActor.VisibilityOff();</div>
<div> selectActor.SetScale(1.01, 1.01, 1.01);</div><div><br></div><div> </div><div><br></div><div> /////////////////////// End of selection part////////////////////</div><div> ren1 = new vtk.vtkRenderer();</div>
<div><br></div><div> renWin.AddRenderer(ren1);</div><div> //ren1.SetBackground(0.0f, 0.0f, 0.0f);</div><div><br></div><div> vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();</div>
<div> iren.SetRenderWindow(renWin);</div><div><br></div><div> //The SetInteractor method is how 3D widgets are associated with the</div><div> //render window interactor. Internally, SetInteractor sets up a bunch</div>
<div> //of callbacks using the Command/Observer mechanism (AddObserver()).</div><div> vtkBoxWidget boxWidget = new vtkBoxWidget();</div><div> boxWidget.SetInteractor(iren);</div><div> boxWidget.SetPlaceFactor(1.25);</div>
<div> boxWidget.TranslationEnabledOn();</div><div><br></div><div> ren1.AddActor(maceActor);</div><div> ren1.AddActor(selectActor);</div><div><br></div><div> boxWidget.SetInput(gpd);</div>
<div> boxWidget.PlaceWidget();</div><div><br></div><div> boxWidget.AddObserver((uint)vtk.EventIds.StartInteractionEvent, new vtk.vtkDotNetCallback(StartInteractionEvent));</div><div> boxWidget.AddObserver((uint)vtk.EventIds.InteractionEvent, new vtk.vtkDotNetCallback(InteractionEvent));</div>
<div> boxWidget.AddObserver((uint)vtk.EventIds.EndInteractionEvent, new vtk.vtkDotNetCallback(EndInteractionEvent));</div><div><br></div><div><br></div><div> boxWidget.On();</div><div><br></div><div>
<br></div><div> renWin.AddRenderer(ren1);</div><div><br></div><div> GC.Collect(); </div></div><div>////////////////////////////////////////////////////////////////////////// the event of interaaction ///////////////////////////////////////////////////////////////// </div>
<div><br></div><div><div> public void InteractionEvent(vtk.vtkObject obj, uint eventId, Object data, IntPtr clientdata)</div><div> {</div><div> vtkBoxWidget widget = vtkBoxWidget.SafeDownCast(obj);</div>
<div> widget.GetPlanes(planes);</div><div> selectActor.VisibilityOn();</div><div><br></div><div><br></div><div><br></div><div> }</div></div><div><br></div><div>///////////////////////////////////////// the button callback which is the problem source ////////////////////////////////////////////////////////////</div>
<div><br></div><div><div> private void button1_Click(object sender, EventArgs e)</div><div> {</div><div> clipper_Cut.Modified();</div><div> gpd = clipper_Cut.GetOutput();</div><div> clipper_Cut.Modified(); </div>
<div> </div><div> gpd.Modified();</div><div> maceActor.Modified();</div><div> </div><div> }</div></div></div>