[vtkusers] pipeline crached when vtkboxwidget PlaceWidget method called

Ali Habib ali.mahmoud.habib at gmail.com
Sun Sep 5 14:53:05 EDT 2010


Hi all ,

for small DICOM dataset , the pipleline work well , but for large dataset it
crashes at placewidget() method call
                /* vtk.vtkSphereSource cone = new vtk.vtkSphereSource();
                 cone.SetRadius(1.0f);*/

                vtk.vtkDICOMImageReader VDR = new vtk.vtkDICOMImageReader();
                VDR.SetDirectoryName(@"G:\Master Degree\test DataSet\My
Disc\07291640");
                VDR.SetDataOrigin(0, 0, 0);
                VDR.Modified();

                // decrease the dataset data for large data preprocessing

                vtkImageShrink3D VIS = new vtkImageShrink3D();
                VIS.SetShrinkFactors(2, 2, 2);
                VIS.SetInputConnection(VDR.GetOutputPort());
                VIS.Modified();

                 vtkImageThreshold VIT = new vtkImageThreshold();
                VIT.ThresholdBetween(200, 2000);
                VIT.SetInputConnection(VIS.GetOutputPort());
                VIT.Modified();

                ///// Start the creation of volume rendering

                //1. Gget the range of data
                vtk.vtkImageChangeInformation VIC = new
vtk.vtkImageChangeInformation();
                VIC.SetInput(VIT.GetOutput());
                VIC.CenterImageOn();
                VIC.Modified();

                vtk.vtkImageData VoxelData = new vtk.vtkImageData();
                VoxelData = VIC.GetOutput();

                double[] metaScalarRange = VoxelData.GetScalarRange();


                // Render the skin - Soft tissue
                double isovalue = 0.8 * (metaScalarRange[1] +
metaScalarRange[0]);


                vtkContourFilter skinExtractor = new vtkContourFilter();
                skinExtractor.SetInputConnection(VIT.GetOutputPort());
                skinExtractor.SetValue(0, isovalue);
                skinExtractor.ComputeGradientsOn();
                skinExtractor.Modified();


                gpd = skinExtractor.GetOutput();

                vtk.vtkPolyDataMapper coneMapper = new
vtk.vtkPolyDataMapper();
                coneMapper.SetInput(gpd);
                coneMapper.ScalarVisibilityOff();

                maceActor = new vtkLODActor();
                maceActor.SetMapper(coneMapper);
                maceActor.GetProperty().SetColor(1, 0, 0);
                //////////////////////// Selection Part
/////////////////////////
                planes = new vtkPlanes();

                clipper = new vtkClipPolyData();
                clipper.SetInput(gpd);
                clipper.SetClipFunction(planes);
                clipper.InsideOutOn();
                clipper.Modified();
                vtkPolyDataMapper selectMapper = new vtkPolyDataMapper();
                selectMapper.SetInput(clipper.GetOutput());
                selectMapper.ScalarVisibilityOff();
                selectMapper.Modified();
                selectActor = new vtkLODActor();
                selectActor.SetMapper(selectMapper);
                selectActor.GetProperty().SetColor(0, 1, 0);
                selectActor.VisibilityOff();
                selectActor.SetScale(1.01, 1.01, 1.01);
                selectActor.Modified();
                /////////////////////// End of selection
part////////////////////

                //////////////////////////// Cutting part
/////////////////////////////////


                clipper_cutting = new vtkClipPolyData();
                clipper_cutting.SetInput(gpd);
                clipper_cutting.SetClipFunction(planes);
                clipper_cutting.InsideOutOff();
                clipper_cutting.GenerateClippedOutputOff();
                clipper_cutting.Modified();
                vtkPolyDataMapper selectMapper_cutting = new
vtkPolyDataMapper();
                selectMapper_cutting.SetInput(clipper_cutting.GetOutput());
                selectMapper_cutting.ScalarVisibilityOff();
                selectMapper_cutting.Modified();
                selectActor_cutting = new vtkLODActor();
                selectActor_cutting.SetMapper(selectMapper_cutting);
                selectActor_cutting.GetProperty().SetColor(1, 0, 0);
                selectActor_cutting.VisibilityOff();
                selectActor_cutting.SetScale(1.01, 1.01, 1.01);
                selectActor_cutting.Modified();

                //////////////////////////// End Cutting part
//////////////////////////////////////
                vtk.vtkRenderer ren1 = new vtk.vtkRenderer();
                ren1.Modified();
                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);
                ren1.AddActor(selectActor_cutting);

                boxWidget.SetInput(gpd);
                boxWidget.Modified();  // crash here
                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); renWin.Modified();

Any suggestion please
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100905/e5fd59cc/attachment.htm>


More information about the vtkusers mailing list