Пример #1
0
        private vtkActor DiskSector(double innerRadius, double radius, double clip1X, double clip1Y, double clip2X, double clip2Y, Color color)
        {
            vtkProperty arcColor = vtkProperty.New();

            arcColor.SetColor(color.r, color.g, color.b);

            vtkDiskSource outerDisk = vtkDiskSource.New();

            outerDisk.SetCircumferentialResolution(50);
            outerDisk.SetRadialResolution(50);
            outerDisk.SetInnerRadius(innerRadius);
            outerDisk.SetOuterRadius(innerRadius + radius);

            // Define a clipping plane
            vtkPlane clipPlane = vtkPlane.New();

            clipPlane.SetNormal(clip1X, clip1Y, 0);
            clipPlane.SetOrigin(0.0, 0.0, 0.0);

            // Define a clipping plane
            vtkPlane clipPlane2 = vtkPlane.New();

            clipPlane2.SetNormal(clip2X, clip2Y, 0);
            clipPlane2.SetOrigin(0, 0, 0);


            vtkClipPolyData clipper = vtkClipPolyData.New();

            clipper.SetInputConnection(outerDisk.GetOutputPort());
            clipper.SetClipFunction(clipPlane);

            vtkClipPolyData clipper2 = vtkClipPolyData.New();

            clipper2.SetInputConnection(clipper.GetOutputPort());
            clipper2.SetClipFunction(clipPlane2);


            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(clipper2.GetOutputPort());


            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.SetProperty(arcColor);


            return(actor);
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestExtrudePiece(String [] argv)
    {
        //Prefix Content is: ""

          disk = new vtkDiskSource();
          disk.SetRadialResolution((int)2);
          disk.SetCircumferentialResolution((int)9);
          clean = new vtkCleanPolyData();
          clean.SetInputConnection((vtkAlgorithmOutput)disk.GetOutputPort());
          clean.SetTolerance((double)0.01);
          piece = new vtkExtractPolyDataPiece();
          piece.SetInputConnection((vtkAlgorithmOutput)clean.GetOutputPort());
          extrude = new vtkPLinearExtrusionFilter();
          extrude.SetInputConnection((vtkAlgorithmOutput)piece.GetOutputPort());
          extrude.PieceInvariantOn();
          // Create the RenderWindow, Renderer and both Actors[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          mapper = vtkPolyDataMapper.New();
          mapper.SetInputConnection((vtkAlgorithmOutput)extrude.GetOutputPort());
          mapper.SetNumberOfPieces((int)2);
          mapper.SetPiece((int)1);
          bf = new vtkProperty();
          bf.SetColor((double)1,(double)0,(double)0);
          actor = new vtkActor();
          actor.SetMapper((vtkMapper)mapper);
          actor.GetProperty().SetColor((double)1,(double)1,(double)0.8);
          actor.SetBackfaceProperty((vtkProperty)bf);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)actor);
          ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
          renWin.SetSize((int)300,(int)300);
          // render the image[]
          //[]
          cam1 = ren1.GetActiveCamera();
          cam1.Azimuth((double)20);
          cam1.Elevation((double)40);
          ren1.ResetCamera();
          cam1.Zoom((double)1.2);
          iren.Initialize();
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
Пример #3
0
        private void BoundaryEdges()
        {
            vtkDiskSource diskSource = vtkDiskSource.New();

            diskSource.Update();

            vtkFeatureEdges featureEdges = vtkFeatureEdges.New();

#if VTK_MAJOR_VERSION_5
            featureEdges.SetInputConnection(diskSource.GetOutputPort());
#else
            featureEdges.SetInputData(diskSource);
#endif
            featureEdges.BoundaryEdgesOn();
            featureEdges.FeatureEdgesOff();
            featureEdges.ManifoldEdgesOff();
            featureEdges.NonManifoldEdgesOff();
            featureEdges.Update();

            // Visualize
            vtkPolyDataMapper edgeMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            edgeMapper.SetInputConnection(featureEdges.GetOutputPort());
#else
            edgeMapper.SetInputData(featureEdges);
#endif
            vtkActor edgeActor = vtkActor.New();
            edgeActor.GetProperty().SetLineWidth(3);
            edgeActor.SetMapper(edgeMapper);

            vtkPolyDataMapper diskMapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            diskMapper.SetInputConnection(diskSource.GetOutputPort());
#else
            diskMapper.SetInputData(diskSource);
#endif
            vtkActor diskActor = vtkActor.New();
            diskActor.SetMapper(diskMapper);

            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            // renderer
            vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer();
            // set background color
            renderer.SetBackground(0.3, 0.6, 0.3);
            // add our actor to the renderer
            renderer.AddActor(diskActor);
            renderer.AddActor(edgeActor);
        }
Пример #4
0
        private void Disk()
        {
            // Create a disk.
            vtkDiskSource diskSource = vtkDiskSource.New();
            //diskSource.SetCircumferentialResolution(16);
            //diskSource.SetRadialResolution(16);
            //diskSource.SetInnerRadius(0.25);
            //diskSource.SetOuterRadius(1.25);
            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(diskSource.GetOutputPort());
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.2, 0.3, 0.4);
            renderer.AddActor(actor);
            renderer.ResetCamera();
        }
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setdisk(vtkDiskSource toSet)
 {
     disk = toSet;
 }