Exemplo n.º 1
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVclosedSplines(String [] argv)
    {
        //Prefix Content is: ""

          // get the interactor ui[]
          // Now create the RenderWindow, Renderer and Interactor[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          math = new vtkMath();
          numberOfInputPoints = 30;
          aKSplineX = new vtkKochanekSpline();
          aKSplineX.ClosedOn();
          aKSplineY = new vtkKochanekSpline();
          aKSplineY.ClosedOn();
          aKSplineZ = new vtkKochanekSpline();
          aKSplineZ.ClosedOn();
          aCSplineX = new vtkCardinalSpline();
          aCSplineX.ClosedOn();
          aCSplineY = new vtkCardinalSpline();
          aCSplineY.ClosedOn();
          aCSplineZ = new vtkCardinalSpline();
          aCSplineZ.ClosedOn();
          // add some points[]
          inputPoints = new vtkPoints();
          x = -1.0;
          y = -1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)0,(double)x);
          aKSplineY.AddPoint((double)0,(double)y);
          aKSplineZ.AddPoint((double)0,(double)z);
          aCSplineX.AddPoint((double)0,(double)x);
          aCSplineY.AddPoint((double)0,(double)y);
          aCSplineZ.AddPoint((double)0,(double)z);
          inputPoints.InsertPoint((int)0,(double)x,(double)y,(double)z);
          x = 1.0;
          y = -1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)1,(double)x);
          aKSplineY.AddPoint((double)1,(double)y);
          aKSplineZ.AddPoint((double)1,(double)z);
          aCSplineX.AddPoint((double)1,(double)x);
          aCSplineY.AddPoint((double)1,(double)y);
          aCSplineZ.AddPoint((double)1,(double)z);
          inputPoints.InsertPoint((int)1,(double)x,(double)y,(double)z);
          x = 1.0;
          y = 1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)2,(double)x);
          aKSplineY.AddPoint((double)2,(double)y);
          aKSplineZ.AddPoint((double)2,(double)z);
          aCSplineX.AddPoint((double)2,(double)x);
          aCSplineY.AddPoint((double)2,(double)y);
          aCSplineZ.AddPoint((double)2,(double)z);
          inputPoints.InsertPoint((int)2,(double)x,(double)y,(double)z);
          x = -1.0;
          y = 1.0;
          z = 0.0;
          aKSplineX.AddPoint((double)3,(double)x);
          aKSplineY.AddPoint((double)3,(double)y);
          aKSplineZ.AddPoint((double)3,(double)z);
          aCSplineX.AddPoint((double)3,(double)x);
          aCSplineY.AddPoint((double)3,(double)y);
          aCSplineZ.AddPoint((double)3,(double)z);
          inputPoints.InsertPoint((int)3,(double)x,(double)y,(double)z);
          inputData = new vtkPolyData();
          inputData.SetPoints((vtkPoints)inputPoints);
          balls = new vtkSphereSource();
          balls.SetRadius((double).04);
          balls.SetPhiResolution((int)10);
          balls.SetThetaResolution((int)10);
          balls.Update();
          glyphPoints = new vtkGlyph3D();
          glyphPoints.SetInputData((vtkDataObject)inputData);
          glyphPoints.SetSourceData((vtkPolyData)balls.GetOutput());
          glyphMapper = vtkPolyDataMapper.New();
          glyphMapper.SetInputConnection((vtkAlgorithmOutput)glyphPoints.GetOutputPort());
          glyph = new vtkActor();
          glyph.SetMapper((vtkMapper)glyphMapper);
          glyph.GetProperty().SetDiffuseColor((double) 1.0000, 0.3882, 0.2784 );
          glyph.GetProperty().SetSpecular((double).3);
          glyph.GetProperty().SetSpecularPower((double)30);
          ren1.AddActor((vtkProp)glyph);
          Kpoints = new vtkPoints();
          Cpoints = new vtkPoints();
          profileKData = new vtkPolyData();
          profileCData = new vtkPolyData();
          numberOfInputPoints = 5;
          numberOfOutputPoints = 100;
          offset = 1.0;
          //method moved
          fit();
          lines = new vtkCellArray();
          lines.InsertNextCell((int)numberOfOutputPoints);
          i = 0;
          while((i) < numberOfOutputPoints)
        {
          lines.InsertCellPoint((int)i);
          i = i + 1;
        }

          profileKData.SetPoints((vtkPoints)Kpoints);
          profileKData.SetLines((vtkCellArray)lines);
          profileCData.SetPoints((vtkPoints)Cpoints);
          profileCData.SetLines((vtkCellArray)lines);
          profileKTubes = new vtkTubeFilter();
          profileKTubes.SetNumberOfSides((int)8);
          profileKTubes.SetInputData((vtkDataObject)profileKData);
          profileKTubes.SetRadius((double).01);
          profileKMapper = vtkPolyDataMapper.New();
          profileKMapper.SetInputConnection((vtkAlgorithmOutput)profileKTubes.GetOutputPort());
          profileK = new vtkActor();
          profileK.SetMapper((vtkMapper)profileKMapper);
          profileK.GetProperty().SetDiffuseColor((double) 0.8900, 0.8100, 0.3400 );
          profileK.GetProperty().SetSpecular((double).3);
          profileK.GetProperty().SetSpecularPower((double)30);
          ren1.AddActor((vtkProp)profileK);
          profileCTubes = new vtkTubeFilter();
          profileCTubes.SetNumberOfSides((int)8);
          profileCTubes.SetInputData((vtkDataObject)profileCData);
          profileCTubes.SetRadius((double).01);
          profileCMapper = vtkPolyDataMapper.New();
          profileCMapper.SetInputConnection((vtkAlgorithmOutput)profileCTubes.GetOutputPort());
          profileC = new vtkActor();
          profileC.SetMapper((vtkMapper)profileCMapper);
          profileC.GetProperty().SetDiffuseColor((double) 0.2000, 0.6300, 0.7900 );
          profileC.GetProperty().SetSpecular((double).3);
          profileC.GetProperty().SetSpecularPower((double)30);
          ren1.AddActor((vtkProp)profileC);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Dolly((double)1.5);
          ren1.ResetCameraClippingRange();
          renWin.SetSize((int)300,(int)300);
          // render the image[]
          //[]
          iren.Initialize();
          // prevent the tk window from showing up then start the event loop[]
          //method moved
          //method moved
          //method moved
          //method moved
          //method moved
          //method moved

        //deleteAllVTKObjects();
    }
Exemplo n.º 2
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVclosedSplines(String [] argv)
    {
        //Prefix Content is: ""

        // get the interactor ui[]
        // Now create the RenderWindow, Renderer and Interactor[]
        //[]
        ren1   = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer((vtkRenderer)ren1);
        iren = new vtkRenderWindowInteractor();
        iren.SetRenderWindow((vtkRenderWindow)renWin);
        math = new vtkMath();
        numberOfInputPoints = 30;
        aKSplineX           = new vtkKochanekSpline();
        aKSplineX.ClosedOn();
        aKSplineY = new vtkKochanekSpline();
        aKSplineY.ClosedOn();
        aKSplineZ = new vtkKochanekSpline();
        aKSplineZ.ClosedOn();
        aCSplineX = new vtkCardinalSpline();
        aCSplineX.ClosedOn();
        aCSplineY = new vtkCardinalSpline();
        aCSplineY.ClosedOn();
        aCSplineZ = new vtkCardinalSpline();
        aCSplineZ.ClosedOn();
        // add some points[]
        inputPoints = new vtkPoints();
        x           = -1.0;
        y           = -1.0;
        z           = 0.0;
        aKSplineX.AddPoint((double)0, (double)x);
        aKSplineY.AddPoint((double)0, (double)y);
        aKSplineZ.AddPoint((double)0, (double)z);
        aCSplineX.AddPoint((double)0, (double)x);
        aCSplineY.AddPoint((double)0, (double)y);
        aCSplineZ.AddPoint((double)0, (double)z);
        inputPoints.InsertPoint((int)0, (double)x, (double)y, (double)z);
        x = 1.0;
        y = -1.0;
        z = 0.0;
        aKSplineX.AddPoint((double)1, (double)x);
        aKSplineY.AddPoint((double)1, (double)y);
        aKSplineZ.AddPoint((double)1, (double)z);
        aCSplineX.AddPoint((double)1, (double)x);
        aCSplineY.AddPoint((double)1, (double)y);
        aCSplineZ.AddPoint((double)1, (double)z);
        inputPoints.InsertPoint((int)1, (double)x, (double)y, (double)z);
        x = 1.0;
        y = 1.0;
        z = 0.0;
        aKSplineX.AddPoint((double)2, (double)x);
        aKSplineY.AddPoint((double)2, (double)y);
        aKSplineZ.AddPoint((double)2, (double)z);
        aCSplineX.AddPoint((double)2, (double)x);
        aCSplineY.AddPoint((double)2, (double)y);
        aCSplineZ.AddPoint((double)2, (double)z);
        inputPoints.InsertPoint((int)2, (double)x, (double)y, (double)z);
        x = -1.0;
        y = 1.0;
        z = 0.0;
        aKSplineX.AddPoint((double)3, (double)x);
        aKSplineY.AddPoint((double)3, (double)y);
        aKSplineZ.AddPoint((double)3, (double)z);
        aCSplineX.AddPoint((double)3, (double)x);
        aCSplineY.AddPoint((double)3, (double)y);
        aCSplineZ.AddPoint((double)3, (double)z);
        inputPoints.InsertPoint((int)3, (double)x, (double)y, (double)z);
        inputData = new vtkPolyData();
        inputData.SetPoints((vtkPoints)inputPoints);
        balls = new vtkSphereSource();
        balls.SetRadius((double).04);
        balls.SetPhiResolution((int)10);
        balls.SetThetaResolution((int)10);
        balls.Update();
        glyphPoints = new vtkGlyph3D();
        glyphPoints.SetInputData((vtkDataObject)inputData);
        glyphPoints.SetSourceData((vtkPolyData)balls.GetOutput());
        glyphMapper = vtkPolyDataMapper.New();
        glyphMapper.SetInputConnection((vtkAlgorithmOutput)glyphPoints.GetOutputPort());
        glyph = new vtkActor();
        glyph.SetMapper((vtkMapper)glyphMapper);
        glyph.GetProperty().SetDiffuseColor((double)1.0000, 0.3882, 0.2784);
        glyph.GetProperty().SetSpecular((double).3);
        glyph.GetProperty().SetSpecularPower((double)30);
        ren1.AddActor((vtkProp)glyph);
        Kpoints              = new vtkPoints();
        Cpoints              = new vtkPoints();
        profileKData         = new vtkPolyData();
        profileCData         = new vtkPolyData();
        numberOfInputPoints  = 5;
        numberOfOutputPoints = 100;
        offset = 1.0;
        //method moved
        fit();
        lines = new vtkCellArray();
        lines.InsertNextCell((int)numberOfOutputPoints);
        i = 0;
        while ((i) < numberOfOutputPoints)
        {
            lines.InsertCellPoint((int)i);
            i = i + 1;
        }

        profileKData.SetPoints((vtkPoints)Kpoints);
        profileKData.SetLines((vtkCellArray)lines);
        profileCData.SetPoints((vtkPoints)Cpoints);
        profileCData.SetLines((vtkCellArray)lines);
        profileKTubes = new vtkTubeFilter();
        profileKTubes.SetNumberOfSides((int)8);
        profileKTubes.SetInputData((vtkDataObject)profileKData);
        profileKTubes.SetRadius((double).01);
        profileKMapper = vtkPolyDataMapper.New();
        profileKMapper.SetInputConnection((vtkAlgorithmOutput)profileKTubes.GetOutputPort());
        profileK = new vtkActor();
        profileK.SetMapper((vtkMapper)profileKMapper);
        profileK.GetProperty().SetDiffuseColor((double)0.8900, 0.8100, 0.3400);
        profileK.GetProperty().SetSpecular((double).3);
        profileK.GetProperty().SetSpecularPower((double)30);
        ren1.AddActor((vtkProp)profileK);
        profileCTubes = new vtkTubeFilter();
        profileCTubes.SetNumberOfSides((int)8);
        profileCTubes.SetInputData((vtkDataObject)profileCData);
        profileCTubes.SetRadius((double).01);
        profileCMapper = vtkPolyDataMapper.New();
        profileCMapper.SetInputConnection((vtkAlgorithmOutput)profileCTubes.GetOutputPort());
        profileC = new vtkActor();
        profileC.SetMapper((vtkMapper)profileCMapper);
        profileC.GetProperty().SetDiffuseColor((double)0.2000, 0.6300, 0.7900);
        profileC.GetProperty().SetSpecular((double).3);
        profileC.GetProperty().SetSpecularPower((double)30);
        ren1.AddActor((vtkProp)profileC);
        ren1.ResetCamera();
        ren1.GetActiveCamera().Dolly((double)1.5);
        ren1.ResetCameraClippingRange();
        renWin.SetSize((int)300, (int)300);
        // render the image[]
        //[]
        iren.Initialize();
        // prevent the tk window from showing up then start the event loop[]
        //method moved
        //method moved
        //method moved
        //method moved
        //method moved
        //method moved

//deleteAllVTKObjects();
    }