public static vtkPolyData Create(List <List <double[]> > xyzList, double radius)
        {
            vtkAppendPolyData append = new vtkAppendPolyData();

            foreach (List <double[]> list in xyzList)
            {
                append.AddInput(Create(list, radius));
            }

            append.Update();

            return(append.GetOutput());
        }
Exemple #2
0
        public static void ShowPolydata(string airwayPath, string lesionPath)
        {
            vtkAppendPolyData appendPolydata = new vtkAppendPolyData();

            if (File.Exists(airwayPath))
            {
                vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader();
                reader.SetFileName(airwayPath);
                reader.Update();
                appendPolydata.AddInput(reader.GetOutput());
                reader.Dispose();
            }
            else
            {
                MessageBox.Show("airwayPath : " + airwayPath + "文件不存在!");
            }

            if (File.Exists(lesionPath))
            {
                vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader();
                reader.SetFileName(lesionPath);
                reader.Update();
                appendPolydata.AddInput(reader.GetOutput());
                reader.Dispose();
            }
            else
            {
                MessageBox.Show("lesionPath : " + lesionPath + "文件不存在!");
            }

            vtkRenderWindow renWin = vtkRenderWindow.New();

            renWin.SetSize(600, 600);

            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();

            renWin.SetInteractor(iren);

            vtkInteractorStyleTrackballCamera interactorStyle = new vtkInteractorStyleTrackballCamera();

            iren.SetInteractorStyle(interactorStyle);

            vtkRenderer renderer = vtkRenderer.New();

            renderer.GradientBackgroundOn();
            renderer.SetBackground(0, 0, 0);
            renderer.SetBackground2(0, 0, 1);
            renWin.AddRenderer(renderer);


            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.ScalarVisibilityOff();
            mapper.SetInput(appendPolydata.GetOutput());
            vtkActor actor = new vtkActor();

            actor.SetMapper(mapper);

            renderer.AddActor(actor);

            renderer.Render();
            renderer.ResetCamera();
            renWin.Render();

            //Thread thread = new Thread(new ThreadStart(
            //                                       delegate
            //                                       {
            //                                           iren.Start();
            //                                       }));
            //thread.Start();
        }