예제 #1
0
        private void ParametricObjects()
        {
            // Select one of the following (matching the selection above)
            vtkParametricTorus parametricObject = vtkParametricTorus.New();
            //vtkParametricBoy parametricObject = vtkParametricBoy.New();
            //vtkParametricConicSpiral parametricObject = vtkParametricConicSpiral.New();
            //vtkParametricCrossCap parametricObject = vtkParametricCrossCap.New();
            //vtkParametricDini parametricObject = vtkParametricDini.New();
            //vtkParametricEllipsoid parametricObject = vtkParametricEllipsoid.New();
            //vtkParametricEnneper parametricObject = vtkParametricEnneper.New();
            //vtkParametricFigure8Klein parametricObject = vtkParametricFigure8Klein.New();
            //vtkParametricKlein parametricObject = vtkParametricKlein.New();
            //vtkParametricMobius parametricObject = vtkParametricMobius.New();
            //vtkParametricRandomHills parametricObject = vtkParametricRandomHills.New();
            //vtkParametricRoman parametricObject = vtkParametricRoman.New();
            //vtkParametricSpline parametricObject = vtkParametricSpline.New();
            //vtkParametricSuperEllipsoid parametricObject = vtkParametricSuperEllipsoid.New();
            //vtkParametricSuperToroid parametricObject = vtkParametricSuperToroid.New();
            //vtkParametricTorus parametricObject = vtkParametricTorus.New();


            vtkParametricFunctionSource parametricFunctionSource = vtkParametricFunctionSource.New();

            parametricFunctionSource.SetParametricFunction(parametricObject);
            parametricFunctionSource.Update();

            // Setup mapper and actor
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

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

            actor.SetMapper(mapper);

            // Visualize
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.2, 0.3, 0.4);
            renderer.AddActor(actor);
        }
예제 #2
0
        private void DrawParametricObjects(VTKParametric type)
        {
            // Select one of the following (matching the selection above)
            vtkParametricFunctionSource parametricFunctionSource = vtkParametricFunctionSource.New();

            switch (type)
            {
            case VTKParametric.Torus:
                vtkParametricTorus Torus = vtkParametricTorus.New();
                parametricFunctionSource.SetParametricFunction(Torus);
                break;

            case VTKParametric.Boy:
                vtkParametricBoy Boy = vtkParametricBoy.New();
                parametricFunctionSource.SetParametricFunction(Boy);
                break;

            case VTKParametric.ConicSpiral:
                vtkParametricConicSpiral ConicSpiral = vtkParametricConicSpiral.New();
                parametricFunctionSource.SetParametricFunction(ConicSpiral);
                break;

            case VTKParametric.CrossCap:
                vtkParametricCrossCap CrossCap = vtkParametricCrossCap.New();
                parametricFunctionSource.SetParametricFunction(CrossCap);
                break;

            case VTKParametric.Dini:
                vtkParametricDini Dini = vtkParametricDini.New();
                parametricFunctionSource.SetParametricFunction(Dini);
                break;

            case VTKParametric.Ellipsoid:
                vtkParametricEllipsoid Ellipsoid = vtkParametricEllipsoid.New();
                Ellipsoid.SetXRadius(0.5);
                Ellipsoid.SetYRadius(2.0);

                parametricFunctionSource.SetParametricFunction(Ellipsoid);
                break;

            case VTKParametric.Enneper:
                vtkParametricEnneper Enneper = vtkParametricEnneper.New();
                parametricFunctionSource.SetParametricFunction(Enneper);
                break;

            case VTKParametric.Figure8Klein:
                vtkParametricFigure8Klein Figure8Klein = vtkParametricFigure8Klein.New();
                parametricFunctionSource.SetParametricFunction(Figure8Klein);
                break;

            case VTKParametric.Klein:
                vtkParametricKlein Klein = vtkParametricKlein.New();
                parametricFunctionSource.SetParametricFunction(Klein);
                break;

            case VTKParametric.Mobius:
                vtkParametricMobius Mobius = vtkParametricMobius.New();
                parametricFunctionSource.SetParametricFunction(Mobius);
                break;

            case VTKParametric.RandomHills:
                vtkParametricRandomHills RandomHills = vtkParametricRandomHills.New();
                parametricFunctionSource.SetParametricFunction(RandomHills);
                break;

            case VTKParametric.Roman:
                vtkParametricRoman Roman = vtkParametricRoman.New();
                parametricFunctionSource.SetParametricFunction(Roman);
                break;

            case VTKParametric.Spline:
                vtkParametricSpline spline      = vtkParametricSpline.New();
                vtkPoints           inputPoints = vtkPoints.New();
                vtkMath.RandomSeed(8775070);
                for (int p = 0; p < 10; p++)
                {
                    double x = vtkMath.Random(0.0, 1.0);
                    double y = vtkMath.Random(0.0, 1.0);
                    double z = vtkMath.Random(0.0, 1.0);
                    inputPoints.InsertNextPoint(x, y, z);
                }
                spline.SetPoints(inputPoints);

                parametricFunctionSource.SetParametricFunction(spline);
                break;

            case VTKParametric.SuperEllipsoid:
                vtkParametricSuperEllipsoid superEllipsoid = vtkParametricSuperEllipsoid.New();
                superEllipsoid.SetN1(.50);
                superEllipsoid.SetN2(.1);
                parametricFunctionSource.SetParametricFunction(superEllipsoid);
                break;

            case VTKParametric.SuperToroid:
                vtkParametricSuperToroid SuperToroid = vtkParametricSuperToroid.New();
                SuperToroid.SetN1(0.5);
                SuperToroid.SetN2(0.1);

                parametricFunctionSource.SetParametricFunction(SuperToroid);
                break;
            }

            parametricFunctionSource.Update();

            // Setup mapper and actor
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

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

            actor.SetMapper(mapper);

            // Visualize
            RenderAddActor(actor);
        }