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