<div dir="ltr">I wante to cut part using vtk box widget , but the pipeline always fail any suggestion please<div><br></div><div>the code is </div><div><br></div><div><div> static vtkBoxWidget boxWidget;</div><div><br>
</div><div> static vtkPlanes planes;</div><div><br></div><div> static vtkLODActor selectActor;</div><div><br></div><div> static void Main(string[] args)</div><div> {</div><div> //Create a mace out of filters.</div>
<div><br></div><div> vtkSphereSource sphere = new vtkSphereSource();</div><div> vtkConeSource cone = new vtkConeSource();</div><div> vtkGlyph3D glyph = new vtkGlyph3D();</div><div> glyph.SetInputConnection(sphere.GetOutputPort());</div>
<div> glyph.SetSource(cone.GetOutput());</div><div> glyph.SetVectorModeToUseNormal();</div><div> glyph.SetScaleModeToScaleByVector();</div><div> glyph.SetScaleFactor(0.25);</div>
<div><br></div><div> //The sphere and spikes are appended into a single polydata. This just makes things</div><div> //simpler to manage.</div><div> vtkAppendPolyData apd = new vtkAppendPolyData();</div>
<div> apd.AddInput(glyph.GetOutput());</div><div> apd.AddInput(sphere.GetOutput());</div><div> vtkPolyDataMapper maceMapper = new vtkPolyDataMapper();</div><div> maceMapper.SetInputConnection(apd.GetOutputPort());</div>
<div> vtkLODActor maceActor = new vtkLODActor();</div><div> maceActor.SetMapper(maceMapper);</div><div> maceActor.VisibilityOn();</div><div><br></div><div><br></div><div> //This portion of the code clips the mace with the vtkPlanes implicit function.</div>
<div> //The clipped region is colored green.</div><div><br></div><div><br></div><div> //Create the RenderWindow, Renderer and both Actors</div><div><br></div><div> vtkRenderer ren1 = new vtkRenderer();</div>
<div> vtkRenderWindow renWin = new vtkRenderWindow();</div><div> renWin.AddRenderer(ren1);</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 render</div><div> //window interactor. Internally, SetInteractor sets up a bunch of callbacks</div>
<div> //using the Command/Observer mechanism (AddObserver()).</div><div> boxWidget = new vtkBoxWidget();</div><div> boxWidget.SetInteractor(iren);</div><div> boxWidget.SetPlaceFactor(1.25);</div>
<div><br></div><div> ren1.AddActor(maceActor);</div><div> ren1.AddActor(selectActor);</div><div><br></div><div> //Add the actors to the renderer, set the background and size</div><div><br>
</div><div> ren1.SetBackground(0.1, 0.2, 0.4);</div><div> renWin.SetSize(300, 300);</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> //Place the interactor initially. The input to a 3D widget is used to </div>
<div> //initially position and scale the widget. The EndInteractionEvent is</div><div> //observed which invokes the SelectPolygons callback.</div><div> boxWidget.SetInput(glyph.GetOutput());</div>
<div> boxWidget.PlaceWidget();</div><div> iren.AddObserver((uint)vtk.EventIds.EndInteractionEvent, new vtk.vtkDotNetCallback(SelectPolygons));</div><div> iren.Initialize();</div><div><br></div>
<div> </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> }</div><div> public static void SelectPolygons(vtk.vtkObject obj, uint eventId, Object data, IntPtr clientdata)</div>
<div> {</div><div> boxWidget.GetPlanes( planes);</div><div> selectActor.VisibilityOn();</div><div> }</div></div></div>