示例#1
0
        static public vtkProp3D genQuadricSurfaceActor(CompontData data, vtkProperty pro)
        {
            if (data.restriction != null)
            {
                return(genActorByRestriction(data, pro));
            }
            QuadricSurfaceData s = (QuadricSurfaceData)data;

            vtkQuadric quadric = vtkQuadric.New();

            quadric.SetCoefficients(s.param[0], s.param[1], s.param[2], s.param[3], s.param[4], s.param[5], s.param[6],
                                    s.param[7], s.param[8], s.param[9] + 1);

            //二次函数采样分辨率
            vtkSampleFunction sample = vtkSampleFunction.New();

            sample.SetSampleDimensions(60, 60, 30);
            sample.SetImplicitFunction(quadric);
            sample.SetModelBounds(s.param[10], s.param[11], s.param[12], s.param[13], s.param[14], s.param[15]);
            vtkContourFilter contourFilter = vtkContourFilter.New();

            contourFilter.SetInputConnection(sample.GetOutputPort());
            contourFilter.GenerateValues(1, 1, 1);
            contourFilter.Update();

            return(genUserActor(data, contourFilter.GetOutputPort(), pro));
        }
示例#2
0
        private void DrawVisQuad()
        {
            //# This example demonstrates the use of the contour filter, and the use of
            //# the vtkSampleFunction to generate a volume of data samples from an
            //# implicit function.

            //# VTK supports implicit functions of the form f(x,y,z)=constant. These
            //# functions can represent things spheres, cones, etc. Here we use a
            //# general form for a quadric to create an elliptical data field.

            vtkQuadric quadricFunction = vtkQuadric.New();

            quadricFunction.SetCoefficients(0.5, 1, 0.2, 0, 0.1, 0, 0, 0.2, 0, 0);

            //# vtkSampleFunction samples an implicit function over the x-y-z range
            //# specified (here it defaults to -1,1 in the x,y,z directions).
            vtkSampleFunction sample = vtkSampleFunction.New();

            sample.SetSampleDimensions(30, 30, 30);
            sample.SetImplicitFunction(quadricFunction);

            //# Create five surfaces F(x,y,z) = constant between range specified. The
            //# GenerateValues() method creates n isocontour values between the range
            //# specified.
            vtkContourFilter contourFilter = vtkContourFilter.New();

            contourFilter.SetInputConnection(sample.GetOutputPort());
            contourFilter.GenerateValues(10, 0.0, 1.2);

            vtkPolyDataMapper contMapper = vtkPolyDataMapper.New();

            contMapper.SetInputConnection(contourFilter.GetOutputPort());
            contMapper.SetScalarRange(0.0, 1.2);

            vtkActor conActor = vtkActor.New();

            conActor.SetMapper(contMapper);

            //We'll put a simple outline around the data
            vtkOutlineFilter outline = vtkOutlineFilter.New();

            outline.SetInputConnection(sample.GetOutputPort());

            vtkPolyDataMapper outlineMapper = vtkPolyDataMapper.New();

            outlineMapper.SetInputConnection(outline.GetOutputPort());

            vtkActor outlineActor = vtkActor.New();

            outlineActor.SetMapper(outlineMapper);
            outlineActor.GetProperty().SetColor(0, 0, 0);

            //The usual rendering stuff
            vtkRenderer     ren    = vtkRenderer.New();
            vtkRenderWindow renWin = myRenderWindowControl.RenderWindow;

            //vtkRenderWindow renWin = vtkRenderWindow.New();
            renWin.AddRenderer(ren);
            //vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();
            //iren.SetRenderWindow(renWin);

            ren.SetBackground(1, 1, 1);
            ren.AddActor(conActor);
            ren.AddActor(outlineActor);

            //iren.Initialize();
            //renWin.Render();
            //iren.Start();
        }