예제 #1
1
        /// <summary>
        /// Instantiates an empty point cloud, ready for us to dump some data
        /// </summary>
        public vtkICP()
        {
            //instantiate empty lists and point clouds
            pointClouds = new List<PointCloud>();
            txpointClouds = new List<PointCloud>();
            pcd = new PointCloud();

            //instantiate vtk lists
            vtkICPAlgo = new vtkIterativeClosestPointTransform();
            sourceData = new vtkPoints();
            sourcePoints = new vtkCellArray();
        }
예제 #2
0
        public static vtkPolyData Create(List <double[]> xyz1, double radius)
        {
            vtkPoints points = new vtkPoints();

            for (int index = 0; index < xyz1.Count; index++)
            {
                double[] doubles = xyz1[index];
                points.InsertPoint(index, doubles[0], doubles[1], doubles[2]);
            }

            vtkCellArray lines = new vtkCellArray();

            lines.InsertNextCell(xyz1.Count);

            for (int index = 0; index < xyz1.Count; index++)
            {
                lines.InsertCellPoint(index);
            }

            vtkPolyData profileData = new vtkPolyData();

            profileData.SetPoints(points);
            profileData.SetLines(lines);
            profileData.SetVerts(lines);
            profileData.Update();

            vtkCleanPolyData cleanFilter = new vtkCleanPolyData();

            cleanFilter.SetInput(profileData);
            cleanFilter.Update();

            vtkTubeFilter profileTubes = new vtkTubeFilter();

            profileTubes.SetNumberOfSides(10);
            profileTubes.SetInput(cleanFilter.GetOutput());
            //profileTubes.SetVaryRadiusToVaryRadiusByVector();
            profileTubes.SetRadius(radius);
            profileTubes.SetInputArrayToProcess(1, 0, 0, 0, "vectors");

            return(profileTubes.GetOutput());
        }
예제 #3
0
        private void UnselectPointClick(vtkObject sender, vtkObjectEventArgs e)
        {
            if (ModelLoaded == true && SelectionMode == true)
            {
                int[]          clickPos    = Inter.GetEventPosition();
                vtkPointPicker PointPicker = vtkPointPicker.New();
                PointPicker.SetTolerance(0.05);
                PointPicker.Pick(clickPos[0], clickPos[1], 0, Viewport);


                double[]  PickPosition = PointPicker.GetPickPosition();
                vtkPoints temp         = vtkPoints.New();

                for (int j = 0; j < SelectionPoints.GetNumberOfPoints(); j++)
                {
                    if (Math.Abs(SelectionPoints.GetPoint(j)[0] - PickPosition[0]) < 1e-6 &&
                        Math.Abs(SelectionPoints.GetPoint(j)[1] - PickPosition[1]) < 1e-6 &&
                        Math.Abs(SelectionPoints.GetPoint(j)[2] - PickPosition[2]) < 1e-6)
                    {
                    }
                    else
                    {
                        temp.InsertNextPoint(SelectionPoints.GetPoint(j)[0],
                                             SelectionPoints.GetPoint(j)[1],
                                             SelectionPoints.GetPoint(j)[2]);
                    }
                }

                SelectionPoints.ShallowCopy(temp);
                SelectionPolyData.SetPoints(SelectionPoints);
                SelectionGlyph = vtkGlyph3D.New();
                SelectionGlyph.SetInput(SelectionPolyData);
                SelectionGlyph.SetSourceConnection(SelectionSphere.GetOutputPort());
                SelectionMapper.SetInputConnection(SelectionGlyph.GetOutputPort());
                SelectionActor.SetMapper(SelectionMapper);

                // Refresh Viewport
                Refresh();
            }
        }
예제 #4
0
        private void TriangleStrip()
        {
            vtkPoints points = vtkPoints.New();

            points.InsertNextPoint(0, 0, 0);
            points.InsertNextPoint(0, 1, 0);
            points.InsertNextPoint(1, 0, 0);
            points.InsertNextPoint(1.5, 1, 0);

            vtkTriangleStrip triangleStrip = vtkTriangleStrip.New();

            triangleStrip.GetPointIds().SetNumberOfIds(4);
            triangleStrip.GetPointIds().SetId(0, 0);
            triangleStrip.GetPointIds().SetId(1, 1);
            triangleStrip.GetPointIds().SetId(2, 2);
            triangleStrip.GetPointIds().SetId(3, 3);

            vtkCellArray cells = vtkCellArray.New();

            cells.InsertNextCell(triangleStrip);
            // Create a polydata to store everything in
            vtkPolyData polyData = vtkPolyData.New();

            // Add the points to the dataset
            polyData.SetPoints(points);
            // Add the strip to the dataset
            polyData.SetStrips(cells);

            //Create an actor and mapper
            vtkDataSetMapper mapper = vtkDataSetMapper.New();

            mapper.SetInput(polyData);
            vtkActor actor = vtkActor.New();

            actor.GetProperty().SetRepresentationToWireframe();

            actor.SetMapper(mapper);

            RenderAddActor(actor);
        }
예제 #5
0
        public VTKDataModel(SimulationModel sm)
        {
            simModel = sm;

            int numCells = sm.Cells.Count;

            cellIDs = vtkIntArray.New();
            cellIDs.SetNumberOfComponents(1);
            cellIDs.SetNumberOfValues(numCells);
            cellIDs.SetName(cellIdsArrayName);

            cellTypes = vtkIntArray.New();
            cellTypes.SetNumberOfComponents(1);
            cellTypes.SetNumberOfValues(numCells);
            cellTypes.SetName(cellTypeArrayName);

            points = vtkPoints.New();
            points.SetNumberOfPoints(numCells);

            verts = vtkCellArray.New();
            verts.Allocate(verts.EstimateSize(1, numCells), 1000);
            verts.InsertNextCell(numCells);

            foreach (MotileCell cell in sm.Cells)
            {
                int i = cell.CellId;
                int c = cell.CellType;
                double[] p = cell.Position;
                points.SetPoint(i, p[0], p[1], p[2]);
                cellIDs.SetValue(i, i);
                cellTypes.SetValue(i, c);
                verts.InsertCellPoint(i);
            }

            poly = vtkPolyData.New();
            poly.SetPoints(points);
            poly.SetVerts(verts);
            poly.GetPointData().AddArray(cellIDs);
            poly.GetPointData().AddArray(cellTypes);
        }
예제 #6
0
        //vtkPoints points = vtkPoints.New();
        //points.InsertNextPoint(0.0, 0.0, 0.0);
        //points.InsertNextPoint(200.0, 0.0, 0.0);
        //points.InsertNextPoint(200.0, 200.0, 0.0);
        //points.InsertNextPoint(0.0, 200.0, 0.0);
        //points.InsertNextPoint(0.0, 0.0, 0.0);

        //vtkPolygon polygon = vtkPolygon.New();
        //polygon.GetPointIds().SetNumberOfIds(5);
        //for (int i = 0; i < 5; i++)
        //{
        //    polygon.GetPointIds().SetId(i, i);
        //}

        public vtkActor2D AddMarkerLine(double[] startCoords, double[] endCoords, Color color)
        {
            vtkPoints points = vtkPoints.New();

            points.InsertNextPoint(startCoords[0], startCoords[1], 0.0);
            points.InsertNextPoint(endCoords[0], endCoords[1], 0.0);

            vtkPolyLine line = vtkPolyLine.New();

            line.GetPointIds().SetNumberOfIds(2);
            for (int i = 0; i < 2; i++)
            {
                line.GetPointIds().SetId(i, i);
            }

            vtkCellArray cellArray = vtkCellArray.New();

            cellArray.InsertNextCell(line);

            vtkPolyData polyData = vtkPolyData.New();

            polyData.SetPoints(points);
            polyData.SetLines(cellArray);

            vtkPolyDataMapper2D mapper = vtkPolyDataMapper2D.New();

            mapper.SetInputData(polyData);

            vtkActor2D actor = vtkActor2D.New();

            actor.SetMapper(mapper);

            actor.GetProperty().SetOpacity((float)color.A / 255);
            actor.GetProperty().SetColor((float)color.R / 255, (float)color.G / 255, (float)color.B / 255);

            _markerLayerRenderer.AddActor(actor);

            return(actor);
        }
예제 #7
0
        private void Triangle()
        {
            // Create a triangle
            vtkPoints points = vtkPoints.New();

            points.InsertNextPoint(1.0, 0.0, 0.0);
            points.InsertNextPoint(0.0, 0.0, 0.0);
            points.InsertNextPoint(0.0, 1.0, 0.0);

            vtkTriangle triangle = vtkTriangle.New();

            triangle.GetPointIds().SetId(0, 0);
            triangle.GetPointIds().SetId(1, 1);
            triangle.GetPointIds().SetId(2, 2);

            // Create a cell array to store the triangle in and add the triangle to it
            vtkCellArray cells = vtkCellArray.New();

            cells.InsertNextCell(triangle);

            // Create a polydata to store everything in
            vtkPolyData polyData = vtkPolyData.New();

            // Add the points to the dataset
            polyData.SetPoints(points);

            // Add the quad to the dataset
            polyData.SetPolys(cells);

            //Create an actor and mapper
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInput(polyData);
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            RenderAddActor(actor);
        }
예제 #8
0
        public static vtkMatrix4x4 GetTranform(double[] soucePoint1, double[] soucePoint2, double[] soucePoint3,
                                               double[] targetPoint1, double[] targetPoint2, double[] targetPoint3)
        {
            vtkPoints sourcePoints = new vtkPoints();

            sourcePoints.InsertNextPoint(soucePoint1[0], soucePoint1[1], soucePoint1[2]);
            sourcePoints.InsertNextPoint(soucePoint2[0], soucePoint2[1], soucePoint2[2]);
            sourcePoints.InsertNextPoint(soucePoint3[0], soucePoint3[1], soucePoint3[2]);

            vtkPoints targetPoints = new vtkPoints();

            targetPoints.InsertNextPoint(targetPoint1[0], targetPoint1[1], targetPoint1[2]);
            targetPoints.InsertNextPoint(targetPoint2[0], targetPoint2[1], targetPoint2[2]);
            targetPoints.InsertNextPoint(targetPoint3[0], targetPoint3[1], targetPoint3[2]);

            vtkLandmarkTransform landmark = new vtkLandmarkTransform();

            landmark.SetSourceLandmarks(sourcePoints);
            landmark.SetTargetLandmarks(targetPoints);
            landmark.Update();

            return(landmark.GetMatrix());
        }
예제 #9
0
        static public void DrawMesh(CMshBasicMesherDouble aMesher, vtkUnstructuredGrid anUnstructuredGrid)
        {
            vtkPoints sPoints = vtkPoints.New();

            for (int i = 0; i < aMesher.mesh().nbNodes(); ++i)
            {
                int aNodeId = aMesher.mesh().nodeId(i);

                var aNode = aMesher.mesh().node(aNodeId);

                sPoints.InsertNextPoint(aNode.x(), aNode.y(), aNode.z());
            }

            anUnstructuredGrid.SetPoints(sPoints);

            for (int i = 0; i < aMesher.mesh().nbElements(); ++i)
            {
                int anElementId = aMesher.mesh().elementId(i);

                var anElement = aMesher.mesh().element(anElementId);

                if (anElement.elementType() == EElementType.ET_HEXAHEDRON)
                {
                    var aHexahedron = vtkHexahedron.New();
                    aHexahedron.GetPointIds().SetId(0, aMesher.mesh().nodeIndex(anElement.nodeId(0)));
                    aHexahedron.GetPointIds().SetId(1, aMesher.mesh().nodeIndex(anElement.nodeId(1)));
                    aHexahedron.GetPointIds().SetId(2, aMesher.mesh().nodeIndex(anElement.nodeId(2)));
                    aHexahedron.GetPointIds().SetId(3, aMesher.mesh().nodeIndex(anElement.nodeId(3)));
                    aHexahedron.GetPointIds().SetId(4, aMesher.mesh().nodeIndex(anElement.nodeId(4)));
                    aHexahedron.GetPointIds().SetId(5, aMesher.mesh().nodeIndex(anElement.nodeId(5)));
                    aHexahedron.GetPointIds().SetId(6, aMesher.mesh().nodeIndex(anElement.nodeId(6)));
                    aHexahedron.GetPointIds().SetId(7, aMesher.mesh().nodeIndex(anElement.nodeId(7)));

                    anUnstructuredGrid.InsertNextCell(aHexahedron.GetCellType(), aHexahedron.GetPointIds());
                }
            }
        }
예제 #10
0
        private void PlanesIntersection()
        {
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            double[] bounds = new double[6];
            bounds = sphereSource.GetOutput().GetBounds();

            vtkPoints box = vtkPoints.New();

            box.SetNumberOfPoints(8);

            double xMin, xMax, yMin, yMax, zMin, zMax;

            xMin = bounds[0]; xMax = bounds[1];
            yMin = bounds[2]; yMax = bounds[3];
            zMin = bounds[4]; zMax = bounds[5];

            box.SetPoint(0, xMax, yMin, zMax);
            box.SetPoint(1, xMax, yMin, zMin);
            box.SetPoint(2, xMax, yMax, zMin);
            box.SetPoint(3, xMax, yMax, zMax);
            box.SetPoint(4, xMin, yMin, zMax);
            box.SetPoint(5, xMin, yMin, zMin);
            box.SetPoint(6, xMin, yMax, zMin);
            box.SetPoint(7, xMin, yMax, zMax);

            vtkPlanesIntersection planesIntersection = vtkPlanesIntersection.New();

            planesIntersection.SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
            int intersects = planesIntersection.IntersectsRegion(box);

            Debug.WriteLine("Intersects? " + ((intersects == 1) ? true : false).ToString());
            // nothing to visualize
        }
예제 #11
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetpentaPoints(vtkPoints toSet)
 {
     pentaPoints = toSet;
 }
예제 #12
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetselectionPoints(vtkPoints toSet)
 {
     selectionPoints = toSet;
 }
예제 #13
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SethexaPoints(vtkPoints toSet)
 {
     hexaPoints = toSet;
 }
예제 #14
0
        //Parameters for building a model

        private void BasicVTKBuilder(ref vtkActor actor, ref vtkPoints points, ref vtkCellArray polys,
                                     ref vtkFloatArray scalars, ref vtkLookupTable Luk, ref vtkActor2D actor2D)
        {
            int pointsNum = 0;

            TowerModelInstance.VTKDrawModel(ref points, ref polys, ref scalars, ref pointsNum, paras);

            vtkPolyData profile = vtkPolyData.New();

            profile.SetPoints(points);
            profile.SetPolys(polys);

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            if (paras.RotateAngle == 0)
            {
                profile.GetCellData().SetScalars(scalars);
                mapper.SetInput(profile);
            }
            else
            {
                vtkRotationalExtrusionFilter refilter = vtkRotationalExtrusionFilter.New();
                profile.Update();
                profile.GetCellData().SetScalars(scalars);
                //profile.GetPointData().SetScalars(scalars);
                refilter.SetInput(profile);
                refilter.SetResolution(50);
                refilter.SetAngle(paras.RotateAngle);
                refilter.SetTranslation(0);
                refilter.SetDeltaRadius(0);

                mapper.SetInputConnection(refilter.GetOutputPort());
            }

            mapper.SetScalarRange(TowerModelInstance.GetColorGenColorTableMinvalue(),
                                  TowerModelInstance.GetColorGenColorTableMaxValue());
            actor.SetMapper(mapper);

            // This text property is for scalarBar
            vtkTextProperty textProperty = vtkTextProperty.New();

            //textProperty.SetFontFamilyToCourier();
            //textProperty.SetColor(1.0, 1.0, 0.5);
            textProperty.SetFontSize(10);

            vtkScalarBarActor scalarBar = vtkScalarBarActor.New();

            scalarBar.SetLookupTable(mapper.GetLookupTable());
            scalarBar.SetTitle("Color Table");
            scalarBar.SetNumberOfLabels(TowerModelInstance.GetColorGenColorTableSize());
            scalarBar.SetTitleTextProperty(textProperty);
            scalarBar.SetLabelTextProperty(textProperty);
            scalarBar.SetWidth(0.07);
            scalarBar.SetHeight(0.6);
            //scalarBar.SetDrawFrame(1);

            vtkLookupTable hueLut = vtkLookupTable.New();

            hueLut.SetTableRange(TowerModelInstance.GetColorGenColorTableMinvalue(),
                                 TowerModelInstance.GetColorGenColorTableMaxValue());
            hueLut.SetHueRange(0.667, 0);
            hueLut.SetSaturationRange(1, 1);
            hueLut.SetValueRange(1, 1);
            hueLut.SetNumberOfTableValues(TowerModelInstance.GetColorGenColorTableSize());
            hueLut.Build();

            mapper.SetLookupTable(hueLut);
            scalarBar.SetLookupTable(hueLut);

            // The actor links the data pipeline to the rendering subsystem
            actor2D = scalarBar;
            //actor.GetProperty().SetColor(0.388, 0.388, 0.388);
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestCellDerivs(String [] argv)
    {
        //Prefix Content is: ""

          // Demonstrates vtkCellDerivatives for all cell types[]
          //[]
          // get the interactor ui[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // create a scene with one of each cell type[]
          // Voxel[]
          voxelPoints = new vtkPoints();
          voxelPoints.SetNumberOfPoints((int)8);
          voxelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          voxelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          voxelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          voxelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          voxelPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          voxelPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          voxelPoints.InsertPoint((int)6,(double)0,(double)1,(double)1);
          voxelPoints.InsertPoint((int)7,(double)1,(double)1,(double)1);
          aVoxel = new vtkVoxel();
          aVoxel.GetPointIds().SetId((int)0,(int)0);
          aVoxel.GetPointIds().SetId((int)1,(int)1);
          aVoxel.GetPointIds().SetId((int)2,(int)2);
          aVoxel.GetPointIds().SetId((int)3,(int)3);
          aVoxel.GetPointIds().SetId((int)4,(int)4);
          aVoxel.GetPointIds().SetId((int)5,(int)5);
          aVoxel.GetPointIds().SetId((int)6,(int)6);
          aVoxel.GetPointIds().SetId((int)7,(int)7);
          aVoxelGrid = new vtkUnstructuredGrid();
          aVoxelGrid.Allocate((int)1,(int)1);
          aVoxelGrid.InsertNextCell((int)aVoxel.GetCellType(),(vtkIdList)aVoxel.GetPointIds());
          aVoxelGrid.SetPoints((vtkPoints)voxelPoints);
          aVoxelMapper = new vtkDataSetMapper();
          aVoxelMapper.SetInput((vtkDataSet)aVoxelGrid);
          aVoxelActor = new vtkActor();
          aVoxelActor.SetMapper((vtkMapper)aVoxelMapper);
          aVoxelActor.GetProperty().BackfaceCullingOn();
          // Hexahedron[]
          hexahedronPoints = new vtkPoints();
          hexahedronPoints.SetNumberOfPoints((int)8);
          hexahedronPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
          hexahedronPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
          aHexahedron = new vtkHexahedron();
          aHexahedron.GetPointIds().SetId((int)0,(int)0);
          aHexahedron.GetPointIds().SetId((int)1,(int)1);
          aHexahedron.GetPointIds().SetId((int)2,(int)2);
          aHexahedron.GetPointIds().SetId((int)3,(int)3);
          aHexahedron.GetPointIds().SetId((int)4,(int)4);
          aHexahedron.GetPointIds().SetId((int)5,(int)5);
          aHexahedron.GetPointIds().SetId((int)6,(int)6);
          aHexahedron.GetPointIds().SetId((int)7,(int)7);
          aHexahedronGrid = new vtkUnstructuredGrid();
          aHexahedronGrid.Allocate((int)1,(int)1);
          aHexahedronGrid.InsertNextCell((int)aHexahedron.GetCellType(),(vtkIdList)aHexahedron.GetPointIds());
          aHexahedronGrid.SetPoints((vtkPoints)hexahedronPoints);
          aHexahedronMapper = new vtkDataSetMapper();
          aHexahedronMapper.SetInput((vtkDataSet)aHexahedronGrid);
          aHexahedronActor = new vtkActor();
          aHexahedronActor.SetMapper((vtkMapper)aHexahedronMapper);
          aHexahedronActor.AddPosition((double)2,(double)0,(double)0);
          aHexahedronActor.GetProperty().BackfaceCullingOn();
          // Tetra[]
          tetraPoints = new vtkPoints();
          tetraPoints.SetNumberOfPoints((int)4);
          tetraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          tetraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          tetraPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          tetraPoints.InsertPoint((int)3,(double)1,(double)1,(double)1);
          aTetra = new vtkTetra();
          aTetra.GetPointIds().SetId((int)0,(int)0);
          aTetra.GetPointIds().SetId((int)1,(int)1);
          aTetra.GetPointIds().SetId((int)2,(int)2);
          aTetra.GetPointIds().SetId((int)3,(int)3);
          aTetraGrid = new vtkUnstructuredGrid();
          aTetraGrid.Allocate((int)1,(int)1);
          aTetraGrid.InsertNextCell((int)aTetra.GetCellType(),(vtkIdList)aTetra.GetPointIds());
          aTetraGrid.SetPoints((vtkPoints)tetraPoints);
          aTetraMapper = new vtkDataSetMapper();
          aTetraMapper.SetInput((vtkDataSet)aTetraGrid);
          aTetraActor = new vtkActor();
          aTetraActor.SetMapper((vtkMapper)aTetraMapper);
          aTetraActor.AddPosition((double)4,(double)0,(double)0);
          aTetraActor.GetProperty().BackfaceCullingOn();
          // Wedge[]
          wedgePoints = new vtkPoints();
          wedgePoints.SetNumberOfPoints((int)6);
          wedgePoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          wedgePoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          wedgePoints.InsertPoint((int)2,(double)0,(double).5,(double).5);
          wedgePoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)0);
          wedgePoints.InsertPoint((int)5,(double)1,(double).5,(double).5);
          aWedge = new vtkWedge();
          aWedge.GetPointIds().SetId((int)0,(int)0);
          aWedge.GetPointIds().SetId((int)1,(int)1);
          aWedge.GetPointIds().SetId((int)2,(int)2);
          aWedge.GetPointIds().SetId((int)3,(int)3);
          aWedge.GetPointIds().SetId((int)4,(int)4);
          aWedge.GetPointIds().SetId((int)5,(int)5);
          aWedgeGrid = new vtkUnstructuredGrid();
          aWedgeGrid.Allocate((int)1,(int)1);
          aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds());
          aWedgeGrid.SetPoints((vtkPoints)wedgePoints);
          aWedgeMapper = new vtkDataSetMapper();
          aWedgeMapper.SetInput((vtkDataSet)aWedgeGrid);
          aWedgeActor = new vtkActor();
          aWedgeActor.SetMapper((vtkMapper)aWedgeMapper);
          aWedgeActor.AddPosition((double)6,(double)0,(double)0);
          aWedgeActor.GetProperty().BackfaceCullingOn();
          // Pyramid[]
          pyramidPoints = new vtkPoints();
          pyramidPoints.SetNumberOfPoints((int)5);
          pyramidPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)4,(double).5,(double).5,(double)1);
          aPyramid = new vtkPyramid();
          aPyramid.GetPointIds().SetId((int)0,(int)0);
          aPyramid.GetPointIds().SetId((int)1,(int)1);
          aPyramid.GetPointIds().SetId((int)2,(int)2);
          aPyramid.GetPointIds().SetId((int)3,(int)3);
          aPyramid.GetPointIds().SetId((int)4,(int)4);
          aPyramidGrid = new vtkUnstructuredGrid();
          aPyramidGrid.Allocate((int)1,(int)1);
          aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
          aPyramidGrid.SetPoints((vtkPoints)pyramidPoints);
          aPyramidMapper = new vtkDataSetMapper();
          aPyramidMapper.SetInput((vtkDataSet)aPyramidGrid);
          aPyramidActor = new vtkActor();
          aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
          aPyramidActor.AddPosition((double)8,(double)0,(double)0);
          aPyramidActor.GetProperty().BackfaceCullingOn();
          // Pixel[]
          pixelPoints = new vtkPoints();
          pixelPoints.SetNumberOfPoints((int)4);
          pixelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pixelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pixelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          pixelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          aPixel = new vtkPixel();
          aPixel.GetPointIds().SetId((int)0,(int)0);
          aPixel.GetPointIds().SetId((int)1,(int)1);
          aPixel.GetPointIds().SetId((int)2,(int)2);
          aPixel.GetPointIds().SetId((int)3,(int)3);
          aPixelGrid = new vtkUnstructuredGrid();
          aPixelGrid.Allocate((int)1,(int)1);
          aPixelGrid.InsertNextCell((int)aPixel.GetCellType(),(vtkIdList)aPixel.GetPointIds());
          aPixelGrid.SetPoints((vtkPoints)pixelPoints);
          aPixelMapper = new vtkDataSetMapper();
          aPixelMapper.SetInput((vtkDataSet)aPixelGrid);
          aPixelActor = new vtkActor();
          aPixelActor.SetMapper((vtkMapper)aPixelMapper);
          aPixelActor.AddPosition((double)0,(double)0,(double)2);
          aPixelActor.GetProperty().BackfaceCullingOn();
          // Quad[]
          quadPoints = new vtkPoints();
          quadPoints.SetNumberOfPoints((int)4);
          quadPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          quadPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          quadPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          quadPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aQuad = new vtkQuad();
          aQuad.GetPointIds().SetId((int)0,(int)0);
          aQuad.GetPointIds().SetId((int)1,(int)1);
          aQuad.GetPointIds().SetId((int)2,(int)2);
          aQuad.GetPointIds().SetId((int)3,(int)3);
          aQuadGrid = new vtkUnstructuredGrid();
          aQuadGrid.Allocate((int)1,(int)1);
          aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds());
          aQuadGrid.SetPoints((vtkPoints)quadPoints);
          aQuadMapper = new vtkDataSetMapper();
          aQuadMapper.SetInput((vtkDataSet)aQuadGrid);
          aQuadActor = new vtkActor();
          aQuadActor.SetMapper((vtkMapper)aQuadMapper);
          aQuadActor.AddPosition((double)2,(double)0,(double)2);
          aQuadActor.GetProperty().BackfaceCullingOn();
          // Triangle[]
          trianglePoints = new vtkPoints();
          trianglePoints.SetNumberOfPoints((int)3);
          trianglePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          trianglePoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          trianglePoints.InsertPoint((int)2,(double).5,(double).5,(double)0);
          triangleTCoords = new vtkFloatArray();
          triangleTCoords.SetNumberOfComponents((int)2);
          triangleTCoords.SetNumberOfTuples((int)3);
          triangleTCoords.InsertTuple2((int)0,(double)1,(double)1);
          triangleTCoords.InsertTuple2((int)1,(double)2,(double)2);
          triangleTCoords.InsertTuple2((int)2,(double)3,(double)3);
          aTriangle = new vtkTriangle();
          aTriangle.GetPointIds().SetId((int)0,(int)0);
          aTriangle.GetPointIds().SetId((int)1,(int)1);
          aTriangle.GetPointIds().SetId((int)2,(int)2);
          aTriangleGrid = new vtkUnstructuredGrid();
          aTriangleGrid.Allocate((int)1,(int)1);
          aTriangleGrid.InsertNextCell((int)aTriangle.GetCellType(),(vtkIdList)aTriangle.GetPointIds());
          aTriangleGrid.SetPoints((vtkPoints)trianglePoints);
          aTriangleGrid.GetPointData().SetTCoords((vtkDataArray)triangleTCoords);
          aTriangleMapper = new vtkDataSetMapper();
          aTriangleMapper.SetInput((vtkDataSet)aTriangleGrid);
          aTriangleActor = new vtkActor();
          aTriangleActor.SetMapper((vtkMapper)aTriangleMapper);
          aTriangleActor.AddPosition((double)4,(double)0,(double)2);
          aTriangleActor.GetProperty().BackfaceCullingOn();
          // Polygon[]
          polygonPoints = new vtkPoints();
          polygonPoints.SetNumberOfPoints((int)4);
          polygonPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polygonPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polygonPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          polygonPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aPolygon = new vtkPolygon();
          aPolygon.GetPointIds().SetNumberOfIds((int)4);
          aPolygon.GetPointIds().SetId((int)0,(int)0);
          aPolygon.GetPointIds().SetId((int)1,(int)1);
          aPolygon.GetPointIds().SetId((int)2,(int)2);
          aPolygon.GetPointIds().SetId((int)3,(int)3);
          aPolygonGrid = new vtkUnstructuredGrid();
          aPolygonGrid.Allocate((int)1,(int)1);
          aPolygonGrid.InsertNextCell((int)aPolygon.GetCellType(),(vtkIdList)aPolygon.GetPointIds());
          aPolygonGrid.SetPoints((vtkPoints)polygonPoints);
          aPolygonMapper = new vtkDataSetMapper();
          aPolygonMapper.SetInput((vtkDataSet)aPolygonGrid);
          aPolygonActor = new vtkActor();
          aPolygonActor.SetMapper((vtkMapper)aPolygonMapper);
          aPolygonActor.AddPosition((double)6,(double)0,(double)2);
          aPolygonActor.GetProperty().BackfaceCullingOn();
          // Triangle strip[]
          triangleStripPoints = new vtkPoints();
          triangleStripPoints.SetNumberOfPoints((int)5);
          triangleStripPoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)3,(double)1,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)4,(double)2,(double)1,(double)0);
          triangleStripTCoords = new vtkFloatArray();
          triangleStripTCoords.SetNumberOfComponents((int)2);
          triangleStripTCoords.SetNumberOfTuples((int)3);
          triangleStripTCoords.InsertTuple2((int)0,(double)1,(double)1);
          triangleStripTCoords.InsertTuple2((int)1,(double)2,(double)2);
          triangleStripTCoords.InsertTuple2((int)2,(double)3,(double)3);
          triangleStripTCoords.InsertTuple2((int)3,(double)4,(double)4);
          triangleStripTCoords.InsertTuple2((int)4,(double)5,(double)5);
          aTriangleStrip = new vtkTriangleStrip();
          aTriangleStrip.GetPointIds().SetNumberOfIds((int)5);
          aTriangleStrip.GetPointIds().SetId((int)0,(int)0);
          aTriangleStrip.GetPointIds().SetId((int)1,(int)1);
          aTriangleStrip.GetPointIds().SetId((int)2,(int)2);
          aTriangleStrip.GetPointIds().SetId((int)3,(int)3);
          aTriangleStrip.GetPointIds().SetId((int)4,(int)4);
          aTriangleStripGrid = new vtkUnstructuredGrid();
          aTriangleStripGrid.Allocate((int)1,(int)1);
          aTriangleStripGrid.InsertNextCell((int)aTriangleStrip.GetCellType(),(vtkIdList)aTriangleStrip.GetPointIds());
          aTriangleStripGrid.SetPoints((vtkPoints)triangleStripPoints);
          aTriangleStripGrid.GetPointData().SetTCoords((vtkDataArray)triangleStripTCoords);
          aTriangleStripMapper = new vtkDataSetMapper();
          aTriangleStripMapper.SetInput((vtkDataSet)aTriangleStripGrid);
          aTriangleStripActor = new vtkActor();
          aTriangleStripActor.SetMapper((vtkMapper)aTriangleStripMapper);
          aTriangleStripActor.AddPosition((double)8,(double)0,(double)2);
          aTriangleStripActor.GetProperty().BackfaceCullingOn();
          // Line[]
          linePoints = new vtkPoints();
          linePoints.SetNumberOfPoints((int)2);
          linePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          linePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          aLine = new vtkLine();
          aLine.GetPointIds().SetId((int)0,(int)0);
          aLine.GetPointIds().SetId((int)1,(int)1);
          aLineGrid = new vtkUnstructuredGrid();
          aLineGrid.Allocate((int)1,(int)1);
          aLineGrid.InsertNextCell((int)aLine.GetCellType(),(vtkIdList)aLine.GetPointIds());
          aLineGrid.SetPoints((vtkPoints)linePoints);
          aLineMapper = new vtkDataSetMapper();
          aLineMapper.SetInput((vtkDataSet)aLineGrid);
          aLineActor = new vtkActor();
          aLineActor.SetMapper((vtkMapper)aLineMapper);
          aLineActor.AddPosition((double)0,(double)0,(double)4);
          aLineActor.GetProperty().BackfaceCullingOn();
          // Polyline[]
          polyLinePoints = new vtkPoints();
          polyLinePoints.SetNumberOfPoints((int)3);
          polyLinePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyLinePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          polyLinePoints.InsertPoint((int)2,(double)1,(double)0,(double)0);
          aPolyLine = new vtkPolyLine();
          aPolyLine.GetPointIds().SetNumberOfIds((int)3);
          aPolyLine.GetPointIds().SetId((int)0,(int)0);
          aPolyLine.GetPointIds().SetId((int)1,(int)1);
          aPolyLine.GetPointIds().SetId((int)2,(int)2);
          aPolyLineGrid = new vtkUnstructuredGrid();
          aPolyLineGrid.Allocate((int)1,(int)1);
          aPolyLineGrid.InsertNextCell((int)aPolyLine.GetCellType(),(vtkIdList)aPolyLine.GetPointIds());
          aPolyLineGrid.SetPoints((vtkPoints)polyLinePoints);
          aPolyLineMapper = new vtkDataSetMapper();
          aPolyLineMapper.SetInput((vtkDataSet)aPolyLineGrid);
          aPolyLineActor = new vtkActor();
          aPolyLineActor.SetMapper((vtkMapper)aPolyLineMapper);
          aPolyLineActor.AddPosition((double)2,(double)0,(double)4);
          aPolyLineActor.GetProperty().BackfaceCullingOn();
          // Vertex[]
          vertexPoints = new vtkPoints();
          vertexPoints.SetNumberOfPoints((int)1);
          vertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          aVertex = new vtkVertex();
          aVertex.GetPointIds().SetId((int)0,(int)0);
          aVertexGrid = new vtkUnstructuredGrid();
          aVertexGrid.Allocate((int)1,(int)1);
          aVertexGrid.InsertNextCell((int)aVertex.GetCellType(),(vtkIdList)aVertex.GetPointIds());
          aVertexGrid.SetPoints((vtkPoints)vertexPoints);
          aVertexMapper = new vtkDataSetMapper();
          aVertexMapper.SetInput((vtkDataSet)aVertexGrid);
          aVertexActor = new vtkActor();
          aVertexActor.SetMapper((vtkMapper)aVertexMapper);
          aVertexActor.AddPosition((double)0,(double)0,(double)6);
          aVertexActor.GetProperty().BackfaceCullingOn();
          // Polyvertex[]
          polyVertexPoints = new vtkPoints();
          polyVertexPoints.SetNumberOfPoints((int)3);
          polyVertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          aPolyVertex = new vtkPolyVertex();
          aPolyVertex.GetPointIds().SetNumberOfIds((int)3);
          aPolyVertex.GetPointIds().SetId((int)0,(int)0);
          aPolyVertex.GetPointIds().SetId((int)1,(int)1);
          aPolyVertex.GetPointIds().SetId((int)2,(int)2);
          aPolyVertexGrid = new vtkUnstructuredGrid();
          aPolyVertexGrid.Allocate((int)1,(int)1);
          aPolyVertexGrid.InsertNextCell((int)aPolyVertex.GetCellType(),(vtkIdList)aPolyVertex.GetPointIds());
          aPolyVertexGrid.SetPoints((vtkPoints)polyVertexPoints);
          aPolyVertexMapper = new vtkDataSetMapper();
          aPolyVertexMapper.SetInput((vtkDataSet)aPolyVertexGrid);
          aPolyVertexActor = new vtkActor();
          aPolyVertexActor.SetMapper((vtkMapper)aPolyVertexMapper);
          aPolyVertexActor.AddPosition((double)2,(double)0,(double)6);
          aPolyVertexActor.GetProperty().BackfaceCullingOn();
          // Pentagonal prism[]
          pentaPoints = new vtkPoints();
          pentaPoints.SetNumberOfPoints((int)10);
          pentaPoints.InsertPoint((int)0,(double)0.25,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)1,(double)0.75,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)3,(double)0.5,(double)1.0,(double)0.0);
          pentaPoints.InsertPoint((int)4,(double)0.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)5,(double)0.25,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)6,(double)0.75,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)7,(double)1.0,(double)0.5,(double)1.0);
          pentaPoints.InsertPoint((int)8,(double)0.5,(double)1.0,(double)1.0);
          pentaPoints.InsertPoint((int)9,(double)0.0,(double)0.5,(double)1.0);
          aPenta = new vtkPentagonalPrism();
          aPenta.GetPointIds().SetId((int)0,(int)0);
          aPenta.GetPointIds().SetId((int)1,(int)1);
          aPenta.GetPointIds().SetId((int)2,(int)2);
          aPenta.GetPointIds().SetId((int)3,(int)3);
          aPenta.GetPointIds().SetId((int)4,(int)4);
          aPenta.GetPointIds().SetId((int)5,(int)5);
          aPenta.GetPointIds().SetId((int)6,(int)6);
          aPenta.GetPointIds().SetId((int)7,(int)7);
          aPenta.GetPointIds().SetId((int)8,(int)8);
          aPenta.GetPointIds().SetId((int)9,(int)9);
          aPentaGrid = new vtkUnstructuredGrid();
          aPentaGrid.Allocate((int)1,(int)1);
          aPentaGrid.InsertNextCell((int)aPenta.GetCellType(),(vtkIdList)aPenta.GetPointIds());
          aPentaGrid.SetPoints((vtkPoints)pentaPoints);
          aPentaMapper = new vtkDataSetMapper();
          aPentaMapper.SetInput((vtkDataSet)aPentaGrid);
          aPentaActor = new vtkActor();
          aPentaActor.SetMapper((vtkMapper)aPentaMapper);
          aPentaActor.AddPosition((double)10,(double)0,(double)0);
          aPentaActor.GetProperty().BackfaceCullingOn();
          // Hexagonal prism[]
          hexaPoints = new vtkPoints();
          hexaPoints.SetNumberOfPoints((int)12);
          hexaPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)1,(double)0.5,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)3,(double)1.0,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)4,(double)0.5,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)5,(double)0.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)6,(double)0.0,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)7,(double)0.5,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)8,(double)1.0,(double)0.5,(double)1.0);
          hexaPoints.InsertPoint((int)9,(double)1.0,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)10,(double)0.5,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)11,(double)0.0,(double)0.5,(double)1.0);
          aHexa = new vtkHexagonalPrism();
          aHexa.GetPointIds().SetId((int)0,(int)0);
          aHexa.GetPointIds().SetId((int)1,(int)1);
          aHexa.GetPointIds().SetId((int)2,(int)2);
          aHexa.GetPointIds().SetId((int)3,(int)3);
          aHexa.GetPointIds().SetId((int)4,(int)4);
          aHexa.GetPointIds().SetId((int)5,(int)5);
          aHexa.GetPointIds().SetId((int)6,(int)6);
          aHexa.GetPointIds().SetId((int)7,(int)7);
          aHexa.GetPointIds().SetId((int)8,(int)8);
          aHexa.GetPointIds().SetId((int)9,(int)9);
          aHexa.GetPointIds().SetId((int)10,(int)10);
          aHexa.GetPointIds().SetId((int)11,(int)11);
          aHexaGrid = new vtkUnstructuredGrid();
          aHexaGrid.Allocate((int)1,(int)1);
          aHexaGrid.InsertNextCell((int)aHexa.GetCellType(),(vtkIdList)aHexa.GetPointIds());
          aHexaGrid.SetPoints((vtkPoints)hexaPoints);
          aHexaMapper = new vtkDataSetMapper();
          aHexaMapper.SetInput((vtkDataSet)aHexaGrid);
          aHexaActor = new vtkActor();
          aHexaActor.SetMapper((vtkMapper)aHexaMapper);
          aHexaActor.AddPosition((double)12,(double)0,(double)0);
          aHexaActor.GetProperty().BackfaceCullingOn();
          ren1.SetBackground((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aVoxelActor);
          aVoxelActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)0);
          ren1.AddActor((vtkProp)aHexahedronActor);
          aHexahedronActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          ren1.AddActor((vtkProp)aTetraActor);
          aTetraActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)0);
          ren1.AddActor((vtkProp)aWedgeActor);
          aWedgeActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPyramidActor);
          aPyramidActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aPixelActor);
          aPixelActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aQuadActor);
          aQuadActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aTriangleActor);
          aTriangleActor.GetProperty().SetDiffuseColor((double).3,(double)1,(double).5);
          ren1.AddActor((vtkProp)aPolygonActor);
          aPolygonActor.GetProperty().SetDiffuseColor((double)1,(double).4,(double).5);
          ren1.AddActor((vtkProp)aTriangleStripActor);
          aTriangleStripActor.GetProperty().SetDiffuseColor((double).3,(double).7,(double)1);
          ren1.AddActor((vtkProp)aLineActor);
          aLineActor.GetProperty().SetDiffuseColor((double).2,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyLineActor);
          aPolyLineActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aVertexActor);
          aVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyVertexActor);
          aPolyVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPentaActor);
          aPentaActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          ren1.AddActor((vtkProp)aHexaActor);
          aHexaActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          //[]
          // get the cell center of each type and put a glyph there[]
          //[]
          ball = new vtkSphereSource();
          ball.SetRadius((double).2);

            bool tryWorked = false;
          aVoxelScalars = new vtkFloatArray();
          N = aVoxelGrid.GetNumberOfPoints();
          aVoxelScalar = new vtkFloatArray();
          aVoxelScalar.SetNumberOfTuples((int)N);
          aVoxelScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aVoxelScalar.SetValue(i,0);
          i = i + 1;
        }

          aVoxelScalar.SetValue(0,4);
          aVoxelGrid.GetPointData().SetScalars(aVoxelScalar);

          aHexahedronScalars = new vtkFloatArray();
          N = aHexahedronGrid.GetNumberOfPoints();
          aHexahedronScalar = new vtkFloatArray();
          aHexahedronScalar.SetNumberOfTuples((int)N);
          aHexahedronScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aHexahedronScalar.SetValue(i,0);
          i = i + 1;
        }

          aHexahedronScalar.SetValue(0,4);
          aHexahedronGrid.GetPointData().SetScalars(aHexahedronScalar);

          aWedgeScalars = new vtkFloatArray();
          N = aWedgeGrid.GetNumberOfPoints();
          aWedgeScalar = new vtkFloatArray();
          aWedgeScalar.SetNumberOfTuples((int)N);
          aWedgeScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aWedgeScalar.SetValue(i,0);
          i = i + 1;
        }

          aWedgeScalar.SetValue(0,4);
          aWedgeGrid.GetPointData().SetScalars(aWedgeScalar);

          aPyramidScalars = new vtkFloatArray();
          N = aPyramidGrid.GetNumberOfPoints();
          aPyramidScalar = new vtkFloatArray();
          aPyramidScalar.SetNumberOfTuples((int)N);
          aPyramidScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPyramidScalar.SetValue(i,0);
          i = i + 1;
        }

          aPyramidScalar.SetValue(0,4);
          aPyramidGrid.GetPointData().SetScalars(aPyramidScalar);

          aTetraScalars = new vtkFloatArray();
          N = aTetraGrid.GetNumberOfPoints();
          aTetraScalar = new vtkFloatArray();
          aTetraScalar.SetNumberOfTuples((int)N);
          aTetraScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aTetraScalar.SetValue(i,0);
          i = i + 1;
        }

          aTetraScalar.SetValue(0,4);
          aTetraGrid.GetPointData().SetScalars(aTetraScalar);

          aQuadScalars = new vtkFloatArray();
          N = aQuadGrid.GetNumberOfPoints();
          aQuadScalar = new vtkFloatArray();
          aQuadScalar.SetNumberOfTuples((int)N);
          aQuadScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aQuadScalar.SetValue(i,0);
          i = i + 1;
        }

          aQuadScalar.SetValue(0,4);
          aQuadGrid.GetPointData().SetScalars(aQuadScalar);

          aTriangleScalars = new vtkFloatArray();
          N = aTriangleGrid.GetNumberOfPoints();
          aTriangleScalar = new vtkFloatArray();
          aTriangleScalar.SetNumberOfTuples((int)N);
          aTriangleScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aTriangleScalar.SetValue(i,0);
          i = i + 1;
        }

          aTriangleScalar.SetValue(0,4);
          aTriangleGrid.GetPointData().SetScalars(aTriangleScalar);

          aTriangleStripScalars = new vtkFloatArray();
          N = aTriangleStripGrid.GetNumberOfPoints();
          aTriangleStripScalar = new vtkFloatArray();
          aTriangleStripScalar.SetNumberOfTuples((int)N);
          aTriangleStripScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aTriangleStripScalar.SetValue(i,0);
          i = i + 1;
        }

          aTriangleStripScalar.SetValue(0,4);
          aTriangleStripGrid.GetPointData().SetScalars(aTriangleStripScalar);

          aLineScalars = new vtkFloatArray();
          N = aLineGrid.GetNumberOfPoints();
          aLineScalar = new vtkFloatArray();
          aLineScalar.SetNumberOfTuples((int)N);
          aLineScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aLineScalar.SetValue(i,0);
          i = i + 1;
        }

          aLineScalar.SetValue(0,4);
          aLineGrid.GetPointData().SetScalars(aLineScalar);

          aPolyLineScalars = new vtkFloatArray();
          N = aPolyLineGrid.GetNumberOfPoints();
          aPolyLineScalar = new vtkFloatArray();
          aPolyLineScalar.SetNumberOfTuples((int)N);
          aPolyLineScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPolyLineScalar.SetValue(i,0);
          i = i + 1;
        }

          aPolyLineScalar.SetValue(0,4);
          aPolyLineGrid.GetPointData().SetScalars(aPolyLineScalar);

          aVertexScalars = new vtkFloatArray();
          N = aVertexGrid.GetNumberOfPoints();
          aVertexScalar = new vtkFloatArray();
          aVertexScalar.SetNumberOfTuples((int)N);
          aVertexScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aVertexScalar.SetValue(i,0);
          i = i + 1;
        }

          aVertexScalar.SetValue(0,4);
          aVertexGrid.GetPointData().SetScalars(aVertexScalar);

          aPolyVertexScalars = new vtkFloatArray();
          N = aPolyVertexGrid.GetNumberOfPoints();
          aPolyVertexScalar = new vtkFloatArray();
          aPolyVertexScalar.SetNumberOfTuples((int)N);
          aPolyVertexScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPolyVertexScalar.SetValue(i,0);
          i = i + 1;
        }

          aPolyVertexScalar.SetValue(0,4);
          aPolyVertexGrid.GetPointData().SetScalars(aPolyVertexScalar);

          aPixelScalars = new vtkFloatArray();
          N = aPixelGrid.GetNumberOfPoints();
          aPixelScalar = new vtkFloatArray();
          aPixelScalar.SetNumberOfTuples((int)N);
          aPixelScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPixelScalar.SetValue(i,0);
          i = i + 1;
        }

          aPixelScalar.SetValue(0,4);
          aPixelGrid.GetPointData().SetScalars(aPixelScalar);

          aPolygonScalars = new vtkFloatArray();
          N = aPolygonGrid.GetNumberOfPoints();
          aPolygonScalar = new vtkFloatArray();
          aPolygonScalar.SetNumberOfTuples((int)N);
          aPolygonScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPolygonScalar.SetValue(i,0);
          i = i + 1;
        }

          aPolygonScalar.SetValue(0,4);
          aPolygonGrid.GetPointData().SetScalars(aPolygonScalar);

          aPentaScalars = new vtkFloatArray();
          N = aPentaGrid.GetNumberOfPoints();
          aPentaScalar = new vtkFloatArray();
          aPentaScalar.SetNumberOfTuples((int)N);
          aPentaScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aPentaScalar.SetValue(i,0);
          i = i + 1;
        }

          aPentaScalar.SetValue(0,4);
          aPentaGrid.GetPointData().SetScalars(aPentaScalar);

          aHexaScalars = new vtkFloatArray();
          N = aHexaGrid.GetNumberOfPoints();
          aHexaScalar = new vtkFloatArray();
          aHexaScalar.SetNumberOfTuples((int)N);
          aHexaScalar.SetNumberOfComponents(1);
          i = 0;
          while((i) < N)
        {
          aHexaScalar.SetValue(i,0);
          i = i + 1;
        }

          aHexaScalar.SetValue(0,4);
          aHexaGrid.GetPointData().SetScalars(aHexaScalar);

          // write to the temp directory if possible, otherwise use .[]
          dir = ".";
          dir = TclToCsScriptTestDriver.GetTempDirectory();

        aVoxelderivs = new vtkCellDerivatives();
          aVoxelderivs.SetInput(aVoxelGrid);
          aVoxelderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aVoxel";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aVoxelWriter = new vtkUnstructuredGridWriter();
          aVoxelWriter.SetInputConnection(aVoxelderivs.GetOutputPort());
          aVoxelWriter.SetFileName(FileName);
          aVoxelWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aVoxelCenters = new vtkCellCenters();
          aVoxelCenters.SetInputConnection(aVoxelderivs.GetOutputPort());
          aVoxelCenters.VertexCellsOn();
          aVoxelhog = new vtkHedgeHog();
          aVoxelhog.SetInputConnection(aVoxelCenters.GetOutputPort());
          aVoxelmapHog = vtkPolyDataMapper.New();
          aVoxelmapHog.SetInputConnection(aVoxelhog.GetOutputPort());
          aVoxelmapHog.SetScalarModeToUseCellData();
          aVoxelmapHog.ScalarVisibilityOff();
          aVoxelhogActor = new vtkActor();
          aVoxelhogActor.SetMapper(aVoxelmapHog);
          aVoxelhogActor.GetProperty().SetColor(0,1,0);
          aVoxelGlyph3D = new vtkGlyph3D();
          aVoxelGlyph3D.SetInputConnection(aVoxelCenters.GetOutputPort());
          aVoxelGlyph3D.SetSource(ball.GetOutput());
          aVoxelCentersMapper = vtkPolyDataMapper.New();
          aVoxelCentersMapper.SetInputConnection(aVoxelGlyph3D.GetOutputPort());
          aVoxelCentersActor = new vtkActor();
        aVoxelCentersActor.SetMapper(aVoxelCentersMapper);
        aVoxelhogActor.SetPosition(aVoxelActor.GetPosition()[0],aVoxelActor.GetPosition()[1],aVoxelActor.GetPosition()[2]);
        ren1.AddActor((vtkProp)aVoxelhogActor);
        aVoxelhogActor.GetProperty().SetRepresentationToWireframe();

          aHexahedronderivs = new vtkCellDerivatives();
        aHexahedronderivs.SetInput(aHexahedronGrid);
        aHexahedronderivs.SetVectorModeToComputeGradient();
        FileName = dir;
        FileName += "/aHexahedron";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aHexahedronWriter = new vtkUnstructuredGridWriter();
          aHexahedronWriter.SetInputConnection(aHexahedronderivs.GetOutputPort());
          aHexahedronWriter.SetFileName(FileName);
          aHexahedronWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aHexahedronCenters = new vtkCellCenters();
          aHexahedronCenters.SetInputConnection(aHexahedronderivs.GetOutputPort());
          aHexahedronCenters.VertexCellsOn();
          aHexahedronhog = new vtkHedgeHog();
          aHexahedronhog.SetInputConnection(aHexahedronCenters.GetOutputPort());
          aHexahedronmapHog = vtkPolyDataMapper.New();
          aHexahedronmapHog.SetInputConnection(aHexahedronhog.GetOutputPort());
          aHexahedronmapHog.SetScalarModeToUseCellData();
          aHexahedronmapHog.ScalarVisibilityOff();
          aHexahedronhogActor = new vtkActor();
          aHexahedronhogActor.SetMapper(aHexahedronmapHog);
          aHexahedronhogActor.GetProperty().SetColor(0,1,0);
          aHexahedronGlyph3D = new vtkGlyph3D();
          aHexahedronGlyph3D.SetInputConnection(aHexahedronCenters.GetOutputPort());
          aHexahedronGlyph3D.SetSource(ball.GetOutput());
          aHexahedronCentersMapper = vtkPolyDataMapper.New();
          aHexahedronCentersMapper.SetInputConnection(aHexahedronGlyph3D.GetOutputPort());
          aHexahedronCentersActor = new vtkActor();
          aHexahedronCentersActor.SetMapper(aHexahedronCentersMapper);
          aHexahedronhogActor.SetPosition(aHexahedronActor.GetPosition()[0],aHexahedronActor.GetPosition()[1],aHexahedronActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aHexahedronhogActor);
          aHexahedronhogActor.GetProperty().SetRepresentationToWireframe();

        aWedgederivs = new vtkCellDerivatives();
          aWedgederivs.SetInput(aWedgeGrid);
          aWedgederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aWedge";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aWedgeWriter = new vtkUnstructuredGridWriter();
          aWedgeWriter.SetInputConnection(aWedgederivs.GetOutputPort());
          aWedgeWriter.SetFileName(FileName);
          aWedgeWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aWedgeCenters = new vtkCellCenters();
          aWedgeCenters.SetInputConnection(aWedgederivs.GetOutputPort());
          aWedgeCenters.VertexCellsOn();
          aWedgehog = new vtkHedgeHog();
          aWedgehog.SetInputConnection(aWedgeCenters.GetOutputPort());
          aWedgemapHog = vtkPolyDataMapper.New();
          aWedgemapHog.SetInputConnection(aWedgehog.GetOutputPort());
          aWedgemapHog.SetScalarModeToUseCellData();
          aWedgemapHog.ScalarVisibilityOff();
          aWedgehogActor = new vtkActor();
          aWedgehogActor.SetMapper(aWedgemapHog);
          aWedgehogActor.GetProperty().SetColor(0,1,0);
          aWedgeGlyph3D = new vtkGlyph3D();
          aWedgeGlyph3D.SetInputConnection(aWedgeCenters.GetOutputPort());
          aWedgeGlyph3D.SetSource(ball.GetOutput());
          aWedgeCentersMapper = vtkPolyDataMapper.New();
          aWedgeCentersMapper.SetInputConnection(aWedgeGlyph3D.GetOutputPort());
          aWedgeCentersActor = new vtkActor();
          aWedgeCentersActor.SetMapper(aWedgeCentersMapper);
          aWedgehogActor.SetPosition(aWedgeActor.GetPosition()[0],aWedgeActor.GetPosition()[1],aWedgeActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aWedgehogActor);
          aWedgehogActor.GetProperty().SetRepresentationToWireframe();

        aPyramidderivs = new vtkCellDerivatives();
          aPyramidderivs.SetInput(aPyramidGrid);
          aPyramidderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPyramid";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPyramidWriter = new vtkUnstructuredGridWriter();
          aPyramidWriter.SetInputConnection(aPyramidderivs.GetOutputPort());
          aPyramidWriter.SetFileName(FileName);
          aPyramidWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPyramidCenters = new vtkCellCenters();
          aPyramidCenters.SetInputConnection(aPyramidderivs.GetOutputPort());
          aPyramidCenters.VertexCellsOn();
          aPyramidhog = new vtkHedgeHog();
          aPyramidhog.SetInputConnection(aPyramidCenters.GetOutputPort());
          aPyramidmapHog = vtkPolyDataMapper.New();
          aPyramidmapHog.SetInputConnection(aPyramidhog.GetOutputPort());
          aPyramidmapHog.SetScalarModeToUseCellData();
          aPyramidmapHog.ScalarVisibilityOff();
          aPyramidhogActor = new vtkActor();
          aPyramidhogActor.SetMapper(aPyramidmapHog);
          aPyramidhogActor.GetProperty().SetColor(0,1,0);
          aPyramidGlyph3D = new vtkGlyph3D();
          aPyramidGlyph3D.SetInputConnection(aPyramidCenters.GetOutputPort());
          aPyramidGlyph3D.SetSource(ball.GetOutput());
          aPyramidCentersMapper = vtkPolyDataMapper.New();
          aPyramidCentersMapper.SetInputConnection(aPyramidGlyph3D.GetOutputPort());
          aPyramidCentersActor = new vtkActor();
          aPyramidCentersActor.SetMapper(aPyramidCentersMapper);
          aPyramidhogActor.SetPosition(aPyramidActor.GetPosition()[0],aPyramidActor.GetPosition()[1],aPyramidActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPyramidhogActor);
          aPyramidhogActor.GetProperty().SetRepresentationToWireframe();

        aTetraderivs = new vtkCellDerivatives();
          aTetraderivs.SetInput(aTetraGrid);
          aTetraderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aTetra";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aTetraWriter = new vtkUnstructuredGridWriter();
          aTetraWriter.SetInputConnection(aTetraderivs.GetOutputPort());
          aTetraWriter.SetFileName(FileName);
          aTetraWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aTetraCenters = new vtkCellCenters();
          aTetraCenters.SetInputConnection(aTetraderivs.GetOutputPort());
          aTetraCenters.VertexCellsOn();
          aTetrahog = new vtkHedgeHog();
          aTetrahog.SetInputConnection(aTetraCenters.GetOutputPort());
          aTetramapHog = vtkPolyDataMapper.New();
          aTetramapHog.SetInputConnection(aTetrahog.GetOutputPort());
          aTetramapHog.SetScalarModeToUseCellData();
          aTetramapHog.ScalarVisibilityOff();
          aTetrahogActor = new vtkActor();
          aTetrahogActor.SetMapper(aTetramapHog);
          aTetrahogActor.GetProperty().SetColor(0,1,0);
          aTetraGlyph3D = new vtkGlyph3D();
          aTetraGlyph3D.SetInputConnection(aTetraCenters.GetOutputPort());
          aTetraGlyph3D.SetSource(ball.GetOutput());
          aTetraCentersMapper = vtkPolyDataMapper.New();
          aTetraCentersMapper.SetInputConnection(aTetraGlyph3D.GetOutputPort());
          aTetraCentersActor = new vtkActor();
          aTetraCentersActor.SetMapper(aTetraCentersMapper);
          aTetrahogActor.SetPosition(aTetraActor.GetPosition()[0],aTetraActor.GetPosition()[1],aTetraActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aTetrahogActor);
          aTetrahogActor.GetProperty().SetRepresentationToWireframe();

        aQuadderivs = new vtkCellDerivatives();
          aQuadderivs.SetInput(aQuadGrid);
          aQuadderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aQuad";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aQuadWriter = new vtkUnstructuredGridWriter();
          aQuadWriter.SetInputConnection(aQuadderivs.GetOutputPort());
          aQuadWriter.SetFileName(FileName);
          aQuadWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aQuadCenters = new vtkCellCenters();
          aQuadCenters.SetInputConnection(aQuadderivs.GetOutputPort());
          aQuadCenters.VertexCellsOn();
          aQuadhog = new vtkHedgeHog();
          aQuadhog.SetInputConnection(aQuadCenters.GetOutputPort());
          aQuadmapHog = vtkPolyDataMapper.New();
          aQuadmapHog.SetInputConnection(aQuadhog.GetOutputPort());
          aQuadmapHog.SetScalarModeToUseCellData();
          aQuadmapHog.ScalarVisibilityOff();
          aQuadhogActor = new vtkActor();
          aQuadhogActor.SetMapper(aQuadmapHog);
          aQuadhogActor.GetProperty().SetColor(0,1,0);
          aQuadGlyph3D = new vtkGlyph3D();
          aQuadGlyph3D.SetInputConnection(aQuadCenters.GetOutputPort());
          aQuadGlyph3D.SetSource(ball.GetOutput());
          aQuadCentersMapper = vtkPolyDataMapper.New();
          aQuadCentersMapper.SetInputConnection(aQuadGlyph3D.GetOutputPort());
          aQuadCentersActor = new vtkActor();
          aQuadCentersActor.SetMapper(aQuadCentersMapper);
          aQuadhogActor.SetPosition(aQuadActor.GetPosition()[0],aQuadActor.GetPosition()[1],aQuadActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aQuadhogActor);
          aQuadhogActor.GetProperty().SetRepresentationToWireframe();

        aTrianglederivs = new vtkCellDerivatives();
          aTrianglederivs.SetInput(aTriangleGrid);
          aTrianglederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aTriangle";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aTriangleWriter = new vtkUnstructuredGridWriter();
          aTriangleWriter.SetInputConnection(aTrianglederivs.GetOutputPort());
          aTriangleWriter.SetFileName(FileName);
          aTriangleWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aTriangleCenters = new vtkCellCenters();
          aTriangleCenters.SetInputConnection(aTrianglederivs.GetOutputPort());
          aTriangleCenters.VertexCellsOn();
          aTrianglehog = new vtkHedgeHog();
          aTrianglehog.SetInputConnection(aTriangleCenters.GetOutputPort());
          aTrianglemapHog = vtkPolyDataMapper.New();
          aTrianglemapHog.SetInputConnection(aTrianglehog.GetOutputPort());
          aTrianglemapHog.SetScalarModeToUseCellData();
          aTrianglemapHog.ScalarVisibilityOff();
          aTrianglehogActor = new vtkActor();
          aTrianglehogActor.SetMapper(aTrianglemapHog);
          aTrianglehogActor.GetProperty().SetColor(0,1,0);
          aTriangleGlyph3D = new vtkGlyph3D();
          aTriangleGlyph3D.SetInputConnection(aTriangleCenters.GetOutputPort());
          aTriangleGlyph3D.SetSource(ball.GetOutput());
          aTriangleCentersMapper = vtkPolyDataMapper.New();
          aTriangleCentersMapper.SetInputConnection(aTriangleGlyph3D.GetOutputPort());
          aTriangleCentersActor = new vtkActor();
          aTriangleCentersActor.SetMapper(aTriangleCentersMapper);
          aTrianglehogActor.SetPosition(aTriangleActor.GetPosition()[0],aTriangleActor.GetPosition()[1],aTriangleActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aTrianglehogActor);
          aTrianglehogActor.GetProperty().SetRepresentationToWireframe();

        aTriangleStripderivs = new vtkCellDerivatives();
          aTriangleStripderivs.SetInput(aTriangleStripGrid);
          aTriangleStripderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aTriangleStrip";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aTriangleStripWriter = new vtkUnstructuredGridWriter();
          aTriangleStripWriter.SetInputConnection(aTriangleStripderivs.GetOutputPort());
          aTriangleStripWriter.SetFileName(FileName);
          aTriangleStripWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aTriangleStripCenters = new vtkCellCenters();
          aTriangleStripCenters.SetInputConnection(aTriangleStripderivs.GetOutputPort());
          aTriangleStripCenters.VertexCellsOn();
          aTriangleStriphog = new vtkHedgeHog();
          aTriangleStriphog.SetInputConnection(aTriangleStripCenters.GetOutputPort());
          aTriangleStripmapHog = vtkPolyDataMapper.New();
          aTriangleStripmapHog.SetInputConnection(aTriangleStriphog.GetOutputPort());
          aTriangleStripmapHog.SetScalarModeToUseCellData();
          aTriangleStripmapHog.ScalarVisibilityOff();
          aTriangleStriphogActor = new vtkActor();
          aTriangleStriphogActor.SetMapper(aTriangleStripmapHog);
          aTriangleStriphogActor.GetProperty().SetColor(0,1,0);
          aTriangleStripGlyph3D = new vtkGlyph3D();
          aTriangleStripGlyph3D.SetInputConnection(aTriangleStripCenters.GetOutputPort());
          aTriangleStripGlyph3D.SetSource(ball.GetOutput());
          aTriangleStripCentersMapper = vtkPolyDataMapper.New();
          aTriangleStripCentersMapper.SetInputConnection(aTriangleStripGlyph3D.GetOutputPort());
          aTriangleStripCentersActor = new vtkActor();
          aTriangleStripCentersActor.SetMapper(aTriangleStripCentersMapper);
          aTriangleStriphogActor.SetPosition(aTriangleStripActor.GetPosition()[0],aTriangleStripActor.GetPosition()[1],aTriangleStripActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aTriangleStriphogActor);
          aTriangleStriphogActor.GetProperty().SetRepresentationToWireframe();

        aLinederivs = new vtkCellDerivatives();
          aLinederivs.SetInput(aLineGrid);
          aLinederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aLine";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aLineWriter = new vtkUnstructuredGridWriter();
          aLineWriter.SetInputConnection(aLinederivs.GetOutputPort());
          aLineWriter.SetFileName(FileName);
          aLineWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aLineCenters = new vtkCellCenters();
          aLineCenters.SetInputConnection(aLinederivs.GetOutputPort());
          aLineCenters.VertexCellsOn();
          aLinehog = new vtkHedgeHog();
          aLinehog.SetInputConnection(aLineCenters.GetOutputPort());
          aLinemapHog = vtkPolyDataMapper.New();
          aLinemapHog.SetInputConnection(aLinehog.GetOutputPort());
          aLinemapHog.SetScalarModeToUseCellData();
          aLinemapHog.ScalarVisibilityOff();
          aLinehogActor = new vtkActor();
          aLinehogActor.SetMapper(aLinemapHog);
          aLinehogActor.GetProperty().SetColor(0,1,0);
          aLineGlyph3D = new vtkGlyph3D();
          aLineGlyph3D.SetInputConnection(aLineCenters.GetOutputPort());
          aLineGlyph3D.SetSource(ball.GetOutput());
          aLineCentersMapper = vtkPolyDataMapper.New();
          aLineCentersMapper.SetInputConnection(aLineGlyph3D.GetOutputPort());
          aLineCentersActor = new vtkActor();
          aLineCentersActor.SetMapper(aLineCentersMapper);
          aLinehogActor.SetPosition(aLineActor.GetPosition()[0],aLineActor.GetPosition()[1],aLineActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aLinehogActor);
          aLinehogActor.GetProperty().SetRepresentationToWireframe();

        aPolyLinederivs = new vtkCellDerivatives();
          aPolyLinederivs.SetInput(aPolyLineGrid);
          aPolyLinederivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPolyLine";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPolyLineWriter = new vtkUnstructuredGridWriter();
          aPolyLineWriter.SetInputConnection(aPolyLinederivs.GetOutputPort());
          aPolyLineWriter.SetFileName(FileName);
          aPolyLineWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPolyLineCenters = new vtkCellCenters();
          aPolyLineCenters.SetInputConnection(aPolyLinederivs.GetOutputPort());
          aPolyLineCenters.VertexCellsOn();
          aPolyLinehog = new vtkHedgeHog();
          aPolyLinehog.SetInputConnection(aPolyLineCenters.GetOutputPort());
          aPolyLinemapHog = vtkPolyDataMapper.New();
          aPolyLinemapHog.SetInputConnection(aPolyLinehog.GetOutputPort());
          aPolyLinemapHog.SetScalarModeToUseCellData();
          aPolyLinemapHog.ScalarVisibilityOff();
          aPolyLinehogActor = new vtkActor();
          aPolyLinehogActor.SetMapper(aPolyLinemapHog);
          aPolyLinehogActor.GetProperty().SetColor(0,1,0);
          aPolyLineGlyph3D = new vtkGlyph3D();
          aPolyLineGlyph3D.SetInputConnection(aPolyLineCenters.GetOutputPort());
          aPolyLineGlyph3D.SetSource(ball.GetOutput());
          aPolyLineCentersMapper = vtkPolyDataMapper.New();
          aPolyLineCentersMapper.SetInputConnection(aPolyLineGlyph3D.GetOutputPort());
          aPolyLineCentersActor = new vtkActor();
          aPolyLineCentersActor.SetMapper(aPolyLineCentersMapper);
          aPolyLinehogActor.SetPosition(aPolyLineActor.GetPosition()[0],aPolyLineActor.GetPosition()[1],aPolyLineActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPolyLinehogActor);
          aPolyLinehogActor.GetProperty().SetRepresentationToWireframe();

        aVertexderivs = new vtkCellDerivatives();
          aVertexderivs.SetInput(aVertexGrid);
          aVertexderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aVertex";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aVertexWriter = new vtkUnstructuredGridWriter();
          aVertexWriter.SetInputConnection(aVertexderivs.GetOutputPort());
          aVertexWriter.SetFileName(FileName);
          aVertexWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aVertexCenters = new vtkCellCenters();
          aVertexCenters.SetInputConnection(aVertexderivs.GetOutputPort());
          aVertexCenters.VertexCellsOn();
          aVertexhog = new vtkHedgeHog();
          aVertexhog.SetInputConnection(aVertexCenters.GetOutputPort());
          aVertexmapHog = vtkPolyDataMapper.New();
          aVertexmapHog.SetInputConnection(aVertexhog.GetOutputPort());
          aVertexmapHog.SetScalarModeToUseCellData();
          aVertexmapHog.ScalarVisibilityOff();
          aVertexhogActor = new vtkActor();
          aVertexhogActor.SetMapper(aVertexmapHog);
          aVertexhogActor.GetProperty().SetColor(0,1,0);
          aVertexGlyph3D = new vtkGlyph3D();
          aVertexGlyph3D.SetInputConnection(aVertexCenters.GetOutputPort());
          aVertexGlyph3D.SetSource(ball.GetOutput());
          aVertexCentersMapper = vtkPolyDataMapper.New();
          aVertexCentersMapper.SetInputConnection(aVertexGlyph3D.GetOutputPort());
          aVertexCentersActor = new vtkActor();
          aVertexCentersActor.SetMapper(aVertexCentersMapper);
          aVertexhogActor.SetPosition(aVertexActor.GetPosition()[0],aVertexActor.GetPosition()[1],aVertexActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aVertexhogActor);
          aVertexhogActor.GetProperty().SetRepresentationToWireframe();

        aPolyVertexderivs = new vtkCellDerivatives();
          aPolyVertexderivs.SetInput(aPolyVertexGrid);
          aPolyVertexderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPolyVertex";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPolyVertexWriter = new vtkUnstructuredGridWriter();
          aPolyVertexWriter.SetInputConnection(aPolyVertexderivs.GetOutputPort());
          aPolyVertexWriter.SetFileName(FileName);
          aPolyVertexWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPolyVertexCenters = new vtkCellCenters();
          aPolyVertexCenters.SetInputConnection(aPolyVertexderivs.GetOutputPort());
          aPolyVertexCenters.VertexCellsOn();
          aPolyVertexhog = new vtkHedgeHog();
          aPolyVertexhog.SetInputConnection(aPolyVertexCenters.GetOutputPort());
          aPolyVertexmapHog = vtkPolyDataMapper.New();
          aPolyVertexmapHog.SetInputConnection(aPolyVertexhog.GetOutputPort());
          aPolyVertexmapHog.SetScalarModeToUseCellData();
          aPolyVertexmapHog.ScalarVisibilityOff();
          aPolyVertexhogActor = new vtkActor();
          aPolyVertexhogActor.SetMapper(aPolyVertexmapHog);
          aPolyVertexhogActor.GetProperty().SetColor(0,1,0);
          aPolyVertexGlyph3D = new vtkGlyph3D();
          aPolyVertexGlyph3D.SetInputConnection(aPolyVertexCenters.GetOutputPort());
          aPolyVertexGlyph3D.SetSource(ball.GetOutput());
          aPolyVertexCentersMapper = vtkPolyDataMapper.New();
          aPolyVertexCentersMapper.SetInputConnection(aPolyVertexGlyph3D.GetOutputPort());
          aPolyVertexCentersActor = new vtkActor();
          aPolyVertexCentersActor.SetMapper(aPolyVertexCentersMapper);
          aPolyVertexhogActor.SetPosition(aPolyVertexActor.GetPosition()[0],aPolyVertexActor.GetPosition()[1],aPolyVertexActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPolyVertexhogActor);
          aPolyVertexhogActor.GetProperty().SetRepresentationToWireframe();

        aPixelderivs = new vtkCellDerivatives();
          aPixelderivs.SetInput(aPixelGrid);
          aPixelderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPixel";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPixelWriter = new vtkUnstructuredGridWriter();
          aPixelWriter.SetInputConnection(aPixelderivs.GetOutputPort());
          aPixelWriter.SetFileName(FileName);
          aPixelWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPixelCenters = new vtkCellCenters();
          aPixelCenters.SetInputConnection(aPixelderivs.GetOutputPort());
          aPixelCenters.VertexCellsOn();
          aPixelhog = new vtkHedgeHog();
          aPixelhog.SetInputConnection(aPixelCenters.GetOutputPort());
          aPixelmapHog = vtkPolyDataMapper.New();
          aPixelmapHog.SetInputConnection(aPixelhog.GetOutputPort());
          aPixelmapHog.SetScalarModeToUseCellData();
          aPixelmapHog.ScalarVisibilityOff();
          aPixelhogActor = new vtkActor();
          aPixelhogActor.SetMapper(aPixelmapHog);
          aPixelhogActor.GetProperty().SetColor(0,1,0);
          aPixelGlyph3D = new vtkGlyph3D();
          aPixelGlyph3D.SetInputConnection(aPixelCenters.GetOutputPort());
          aPixelGlyph3D.SetSource(ball.GetOutput());
          aPixelCentersMapper = vtkPolyDataMapper.New();
          aPixelCentersMapper.SetInputConnection(aPixelGlyph3D.GetOutputPort());
          aPixelCentersActor = new vtkActor();
          aPixelCentersActor.SetMapper(aPixelCentersMapper);
          aPixelhogActor.SetPosition(aPixelActor.GetPosition()[0],aPixelActor.GetPosition()[1],aPixelActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPixelhogActor);
          aPixelhogActor.GetProperty().SetRepresentationToWireframe();

        aPolygonderivs = new vtkCellDerivatives();
          aPolygonderivs.SetInput(aPolygonGrid);
          aPolygonderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPolygon";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPolygonWriter = new vtkUnstructuredGridWriter();
          aPolygonWriter.SetInputConnection(aPolygonderivs.GetOutputPort());
          aPolygonWriter.SetFileName(FileName);
          aPolygonWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPolygonCenters = new vtkCellCenters();
          aPolygonCenters.SetInputConnection(aPolygonderivs.GetOutputPort());
          aPolygonCenters.VertexCellsOn();
          aPolygonhog = new vtkHedgeHog();
          aPolygonhog.SetInputConnection(aPolygonCenters.GetOutputPort());
          aPolygonmapHog = vtkPolyDataMapper.New();
          aPolygonmapHog.SetInputConnection(aPolygonhog.GetOutputPort());
          aPolygonmapHog.SetScalarModeToUseCellData();
          aPolygonmapHog.ScalarVisibilityOff();
          aPolygonhogActor = new vtkActor();
          aPolygonhogActor.SetMapper(aPolygonmapHog);
          aPolygonhogActor.GetProperty().SetColor(0,1,0);
          aPolygonGlyph3D = new vtkGlyph3D();
          aPolygonGlyph3D.SetInputConnection(aPolygonCenters.GetOutputPort());
          aPolygonGlyph3D.SetSource(ball.GetOutput());
          aPolygonCentersMapper = vtkPolyDataMapper.New();
          aPolygonCentersMapper.SetInputConnection(aPolygonGlyph3D.GetOutputPort());
          aPolygonCentersActor = new vtkActor();
          aPolygonCentersActor.SetMapper(aPolygonCentersMapper);
          aPolygonhogActor.SetPosition(aPolygonActor.GetPosition()[0],aPolygonActor.GetPosition()[1],aPolygonActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPolygonhogActor);
          aPolygonhogActor.GetProperty().SetRepresentationToWireframe();

        aPentaderivs = new vtkCellDerivatives();
          aPentaderivs.SetInput(aPentaGrid);
          aPentaderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aPenta";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aPentaWriter = new vtkUnstructuredGridWriter();
          aPentaWriter.SetInputConnection(aPentaderivs.GetOutputPort());
          aPentaWriter.SetFileName(FileName);
          aPentaWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aPentaCenters = new vtkCellCenters();
          aPentaCenters.SetInputConnection(aPentaderivs.GetOutputPort());
          aPentaCenters.VertexCellsOn();
          aPentahog = new vtkHedgeHog();
          aPentahog.SetInputConnection(aPentaCenters.GetOutputPort());
          aPentamapHog = vtkPolyDataMapper.New();
          aPentamapHog.SetInputConnection(aPentahog.GetOutputPort());
          aPentamapHog.SetScalarModeToUseCellData();
          aPentamapHog.ScalarVisibilityOff();
          aPentahogActor = new vtkActor();
          aPentahogActor.SetMapper(aPentamapHog);
          aPentahogActor.GetProperty().SetColor(0,1,0);
          aPentaGlyph3D = new vtkGlyph3D();
          aPentaGlyph3D.SetInputConnection(aPentaCenters.GetOutputPort());
          aPentaGlyph3D.SetSource(ball.GetOutput());
          aPentaCentersMapper = vtkPolyDataMapper.New();
          aPentaCentersMapper.SetInputConnection(aPentaGlyph3D.GetOutputPort());
          aPentaCentersActor = new vtkActor();
          aPentaCentersActor.SetMapper(aPentaCentersMapper);
          aPentahogActor.SetPosition(aPentaActor.GetPosition()[0],aPentaActor.GetPosition()[1],aPentaActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aPentahogActor);
          aPentahogActor.GetProperty().SetRepresentationToWireframe();

        aHexaderivs = new vtkCellDerivatives();
          aHexaderivs.SetInput(aHexaGrid);
          aHexaderivs.SetVectorModeToComputeGradient();
          FileName = dir;
          FileName += "/aHexa";
          FileName += ".vtk";
          // make sure the directory is writeable first[]
          tryWorked = false;
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
         tryWorked = true;
          }
          catch(Exception)
        {
        tryWorked = false;
        }
          if(tryWorked)
        {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          aHexaWriter = new vtkUnstructuredGridWriter();
          aHexaWriter.SetInputConnection(aHexaderivs.GetOutputPort());
          aHexaWriter.SetFileName(FileName);
          aHexaWriter.Write();
          // delete the file[]
          File.Delete("FileName");
        }

          aHexaCenters = new vtkCellCenters();
          aHexaCenters.SetInputConnection(aHexaderivs.GetOutputPort());
          aHexaCenters.VertexCellsOn();
          aHexahog = new vtkHedgeHog();
          aHexahog.SetInputConnection(aHexaCenters.GetOutputPort());
          aHexamapHog = vtkPolyDataMapper.New();
          aHexamapHog.SetInputConnection(aHexahog.GetOutputPort());
          aHexamapHog.SetScalarModeToUseCellData();
          aHexamapHog.ScalarVisibilityOff();
          aHexahogActor = new vtkActor();
          aHexahogActor.SetMapper(aHexamapHog);
          aHexahogActor.GetProperty().SetColor(0,1,0);
          aHexaGlyph3D = new vtkGlyph3D();
          aHexaGlyph3D.SetInputConnection(aHexaCenters.GetOutputPort());
          aHexaGlyph3D.SetSource(ball.GetOutput());
          aHexaCentersMapper = vtkPolyDataMapper.New();
          aHexaCentersMapper.SetInputConnection(aHexaGlyph3D.GetOutputPort());
          aHexaCentersActor = new vtkActor();
          aHexaCentersActor.SetMapper(aHexaCentersMapper);
          aHexahogActor.SetPosition(aHexaActor.GetPosition()[0],aHexaActor.GetPosition()[1],aHexaActor.GetPosition()[2]);
          ren1.AddActor((vtkProp)aHexahogActor);
          aHexahogActor.GetProperty().SetRepresentationToWireframe();

          ren1.ResetCamera();
          ren1.GetActiveCamera().Azimuth((double)30);
          ren1.GetActiveCamera().Elevation((double)20);
          ren1.GetActiveCamera().Dolly((double)3.0);
          ren1.ResetCameraClippingRange();
          renWin.SetSize((int)300,(int)150);
          renWin.Render();
          // render the image[]
          //[]
          iren.Initialize();

        //deleteAllVTKObjects();
    }
예제 #16
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SettetraPoints(vtkPoints toSet)
 {
     tetraPoints = toSet;
 }
예제 #17
0
        /// <summary>
        /// 左键释放时获取选择的对象
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void m_interactor_LeftButtonReleaseEvt(vtkObject sender, vtkObjectEventArgs e)
        {
            if (m_pickTarget == ePickTarget.None)
            {
                return;
            }

            //if (m_iren.GetControlKey() != 0)
            //    m_pickBoolean = ePickBollean.Add;
            //else if (m_iren.GetShiftKey() != 0)
            //    m_pickBoolean = ePickBollean.Sub;

            m_iren.GetEventPosition(ref endx, ref endy);
            #region 点选对象
            if (m_pickMode == ePickMode.DotPickMode) //如果是点选模式
            {
                vtkCellPicker cellPicker = new vtkCellPicker();
                cellPicker.SetTolerance(0.005);
                if (0 == cellPicker.Pick(endx, endy, 0, m_renderer))
                {
                    return;  //什么都没有选到就返回
                }
                FEMActor actor = cellPicker.GetActor() as FEMActor;
                if (actor == null)
                {
                    return;
                }
                if (m_pickTarget == ePickTarget.Actor)
                {                          //如果选择对象为
                    actor.IsSelected = true;
                    m_RWCtrl.Invalidate(); //貌似必须要用这个函数,update 不行
                    OnObjectsSelected(sender, e);
                }
                else if (m_pickTarget == ePickTarget.Cell)
                {
                    int cellId = cellPicker.GetCellId();
                    actor.AddCellId(cellId, m_pickBoolean);
                    OnObjectsSelected(sender, e);
                    //if (cellId > 0)
                    //    Console.WriteLine("dotselect cellid:{0}", cellId);
                }
                else if (m_pickTarget == ePickTarget.Point)
                {
                    int pointId = cellPicker.GetPointId();
                    if (pointId != -1)
                    {
                        actor.AddPointId(pointId, m_pickBoolean);
                        OnObjectsSelected(sender, e);
                        //   Console.WriteLine("dotselect pointid:{0}", pointId);
                    }
                }
            }
            #endregion
            else if (m_pickMode == ePickMode.RectPickMode) //如果是框选
            {
                vtkAreaPicker areaPicker = new vtkAreaPicker();
                if (0 == areaPicker.AreaPick(startx, starty, endx, endy, m_renderer))
                { //如果什么也没选到就返回
                    //this.impactViewForm.ClearAllSelectCells();
                    return;
                }
                vtkProp3DCollection selectedActors = areaPicker.GetProp3Ds();
                selectedActors.InitTraversal();
                FEMActor selectedActor;
                while ((selectedActor = selectedActors.GetNextProp3D() as FEMActor) != null)
                {
                    vtkSelection     selection     = new vtkSelection();
                    vtkSelectionNode selectionNode = new vtkSelectionNode();
                    selection.AddNode(selectionNode);

                    vtkIdFilter idFilter = new vtkIdFilter();
                    idFilter.FieldDataOn();
                    idFilter.SetInput(selectedActor.GetMapper().GetInput());
                    idFilter.Update();

                    vtkExtractSelection frustum = new vtkExtractSelection();
                    frustum.SetInput(0, idFilter.GetOutput());
                    frustum.SetInput(1, selection);

                    selectionNode.Initialize();
                    selectionNode.SetContentType((int)vtkSelectionNode.SelectionContent.FRUSTUM);

                    if (m_pickTarget == ePickTarget.Cell)//如果选择的目标是cell
                    {
                        selectionNode.SetFieldType((int)vtkSelectionNode.SelectionField.CELL);
                    }
                    else if (m_pickTarget == ePickTarget.Point) //如果选择的目标是point
                    {
                        selectionNode.SetFieldType((int)vtkSelectionNode.SelectionField.POINT);
                    }

                    vtkPoints      points         = areaPicker.GetClipPoints();
                    vtkDoubleArray frustumcorners = new vtkDoubleArray();
                    frustumcorners.SetNumberOfComponents(4);
                    frustumcorners.SetNumberOfTuples(8);
                    for (int i = 0; i < 8; ++i)
                    {
                        double[] point = points.GetPoint(i);
                        frustumcorners.SetTuple4(i, point[0], point[1], point[2], 0.0);
                    }
                    selectionNode.SetSelectionList(frustumcorners);

                    frustum.Update();
                    vtkUnstructuredGrid grid = new vtkUnstructuredGrid();
                    grid = vtkUnstructuredGrid.SafeDownCast(frustum.GetOutput());
                    vtkIdTypeArray ids = null;
                    if (m_pickTarget == ePickTarget.Cell)
                    {
                        ids = vtkIdTypeArray.SafeDownCast(grid.GetCellData().GetArray("vtkOriginalCellIds"));
                        if (ids == null)
                        {
                            continue;
                        }
                        selectedActor.AddCellId(ids, m_pickBoolean);
                        OnObjectsSelected(sender, e);
                    }
                    else if (m_pickTarget == ePickTarget.Point)
                    {
                        ids = vtkIdTypeArray.SafeDownCast(grid.GetPointData().GetArray("vtkOriginalPointIds"));
                        if (ids == null)
                        {
                            continue;
                        }
                        selectedActor.AddPointId(ids, m_pickBoolean);
                        OnObjectsSelected(sender, e);
                    }
                }
            }
        }
예제 #18
0
        public void WriteVTUTriangle(string filePath, List <Vector3d> point_data, List <Vector3> trianglepoints, Dictionary <String, vtkDataArray> scalar_dataArray, List <String> arrayNames, int numberOfPoints, int numberOfTetraPoints)
        {
            vtkPoints points = vtkPoints.New();

            for (int i = 0; i < numberOfPoints; i++)
            {
                points.InsertNextPoint(point_data[i].X, point_data[i].Y, point_data[i].Z);
            }

            vtkUnstructuredGrid unstructuredGrid = vtkUnstructuredGrid.New();


            vtkCellArray cellArrayOne = vtkCellArray.New();

            for (int i = 0; i < numberOfTetraPoints; i++)
            {
                vtkTriangle triangle = vtkTriangle.New();

                triangle.GetPointIds().SetId(0, (long)trianglepoints[i][0]);
                triangle.GetPointIds().SetId(1, (long)trianglepoints[i][1]);
                triangle.GetPointIds().SetId(2, (long)trianglepoints[i][2]);


                cellArrayOne.InsertNextCell(triangle);
            }


            unstructuredGrid.SetPoints(points);

            const int VTK_TRIANGLE = 5;

            unstructuredGrid.SetCells(VTK_TRIANGLE, cellArrayOne);



            int numberOfScalarData = scalar_dataArray.Count();

            for (int i = 0; i < numberOfScalarData; i++)
            {
                scalar_dataArray.TryGetValue(arrayNames[i], out vtkDataArray scalars);
                unstructuredGrid.GetPointData().AddArray(scalars);
            }

            // add file ending if it is not existent
            string suffix = (".vtu");

            if (!(filePath.EndsWith(suffix)))
            {
                filePath += suffix;
            }

            // Write file
            vtkXMLUnstructuredGridWriter writer = vtkXMLUnstructuredGridWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(unstructuredGrid);
            writer.Write();

            // Read and display file for verification that it was written correctly
            vtkXMLUnstructuredGridReader reader = vtkXMLUnstructuredGridReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                //MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            Console.WriteLine("VTU file was writen and is saved at {0}", filePath);
        }
예제 #19
0
        public void WriteSimpleVTUExample()
        {
            string    filePath = "C:\\DatenE\\02Studium\\02WiSe1718\\06IndividualProjekt\\03Daten\\testData\\simpleTest4Points.vtu";
            vtkPoints points   = vtkPoints.New();

            points.InsertNextPoint(0, 0, 0);
            points.InsertNextPoint(1, 0, 0);
            points.InsertNextPoint(1, 1, 0);
            points.InsertNextPoint(0, 1, 1);

            points.InsertNextPoint(2, 0, 0);
            //points.InsertNextPoint(2, 2, 0);


            vtkTetra tetra = vtkTetra.New();

            tetra.GetPointIds().SetId(0, 0);
            tetra.GetPointIds().SetId(1, 1);
            tetra.GetPointIds().SetId(2, 2);
            tetra.GetPointIds().SetId(3, 3);

            vtkCellArray cellArray = vtkCellArray.New();

            cellArray.InsertNextCell(tetra);



            tetra.GetPointIds().SetId(0, 1);
            tetra.GetPointIds().SetId(1, 0);
            tetra.GetPointIds().SetId(2, 3);
            tetra.GetPointIds().SetId(3, 2);

            cellArray.InsertNextCell(tetra);
            tetra.GetPointIds().SetId(0, 0);
            tetra.GetPointIds().SetId(1, 2);
            tetra.GetPointIds().SetId(2, 3);
            tetra.GetPointIds().SetId(3, 1);

            cellArray.InsertNextCell(tetra);
            tetra.GetPointIds().SetId(0, 3);
            tetra.GetPointIds().SetId(1, 1);
            tetra.GetPointIds().SetId(2, 0);
            tetra.GetPointIds().SetId(3, 2);

            cellArray.InsertNextCell(tetra);

            tetra.GetPointIds().SetId(0, 3);
            tetra.GetPointIds().SetId(1, 0);
            tetra.GetPointIds().SetId(2, 2);
            tetra.GetPointIds().SetId(3, 4);

            cellArray.InsertNextCell(tetra);

            //tetra.GetPointIds().SetId(0, 4);
            //tetra.GetPointIds().SetId(1, 3);
            //tetra.GetPointIds().SetId(2, 0);
            //tetra.GetPointIds().SetId(3, 2);

            //cellArray.InsertNextCell(tetra);

            vtkUnstructuredGrid unstructuredGrid = vtkUnstructuredGrid.New();

            unstructuredGrid.SetPoints(points);
            const int VTK_TETRA = 10;

            unstructuredGrid.SetCells(VTK_TETRA, cellArray);


            // vX
            vtkDoubleArray scalarsX = new vtkDoubleArray();

            scalarsX.SetNumberOfValues(5);
            scalarsX.SetValue(0, 4);
            scalarsX.SetValue(1, 1);
            scalarsX.SetValue(2, 2);
            scalarsX.SetValue(3, 3);
            scalarsX.SetValue(4, 1);
            //scalarsX.SetValue(5, 2);
            scalarsX.SetName("Vx");
            unstructuredGrid.GetPointData().AddArray(scalarsX);
            // vY
            vtkDoubleArray scalarsY = new vtkDoubleArray();

            scalarsY.SetNumberOfValues(5);
            scalarsY.SetValue(0, 1);
            scalarsY.SetValue(1, 2);
            scalarsY.SetValue(2, 3);
            scalarsY.SetValue(3, 4);
            scalarsY.SetValue(4, 1);
            //scalarsY.SetValue(5, 2);
            scalarsY.SetName("Vy");
            unstructuredGrid.GetPointData().AddArray(scalarsY);
            // vZ
            vtkDoubleArray scalarsZ = new vtkDoubleArray();

            scalarsZ.SetNumberOfValues(5);
            scalarsZ.SetValue(0, 3);
            scalarsZ.SetValue(1, 1);
            scalarsZ.SetValue(2, 4);
            scalarsZ.SetValue(3, 2);
            scalarsZ.SetValue(4, 1);
            //scalarsZ.SetValue(5, 2);
            scalarsZ.SetName("Vz");
            unstructuredGrid.GetPointData().AddArray(scalarsZ);


            // Write file
            vtkXMLUnstructuredGridWriter writer = vtkXMLUnstructuredGridWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(unstructuredGrid);
            writer.Write();
        }
예제 #20
0
        static public void GenerateMesh(CMshTriangleMesherDouble aMesher, vtkRenderer aRenderer)
        {
            var aNode1 = new CMshNodeDouble(0.0, 0.0, 0.0);
            var aNode2 = new CMshNodeDouble(1.0, 0.0, 0.0);
            var aNode3 = new CMshNodeDouble(1.0, 1.0, 0.0);
            var aNode4 = new CMshNodeDouble(0.0, 1.0, 0.0);

            var anEdgeMesh = new CMshMeshDouble();

            anEdgeMesh.addNode(1, aNode1);
            anEdgeMesh.addNode(2, aNode2);
            anEdgeMesh.addNode(3, aNode3);
            anEdgeMesh.addNode(4, aNode4);

            var anElement1 = new CMshElementDouble(EElementType.ET_BEAM);

            anElement1.addNodeId(1);
            anElement1.addNodeId(2);

            var anElement2 = new CMshElementDouble(EElementType.ET_BEAM);

            anElement2.addNodeId(2);
            anElement2.addNodeId(3);

            var anElement3 = new CMshElementDouble(EElementType.ET_BEAM);

            anElement3.addNodeId(3);
            anElement3.addNodeId(4);

            var anElement4 = new CMshElementDouble(EElementType.ET_BEAM);

            anElement4.addNodeId(4);
            anElement4.addNodeId(1);

            anEdgeMesh.addElement(1, anElement1);
            anEdgeMesh.addElement(2, anElement2);
            anEdgeMesh.addElement(3, anElement3);
            anEdgeMesh.addElement(4, anElement4);

            Mesh2D.AddCircle(anEdgeMesh, 0.3, 0.3, 0.1);
            Mesh2D.AddCircle(anEdgeMesh, 0.7, 0.3, 0.1);
            Mesh2D.AddCircle(anEdgeMesh, 0.7, 0.7, 0.1);
            Mesh2D.AddCircle(anEdgeMesh, 0.3, 0.7, 0.1);

            var sLinesPolyData = vtkPolyData.New();

            vtkPoints sPoints = vtkPoints.New();

            for (int i = 0; i < anEdgeMesh.nbNodes(); ++i)
            {
                int aNodeId = anEdgeMesh.nodeId(i);

                var aNode = anEdgeMesh.node(aNodeId);

                sPoints.InsertNextPoint(aNode.x(), aNode.y(), aNode.z());
            }

            sLinesPolyData.SetPoints(sPoints);

            var sLines = vtkCellArray.New();

            for (int i = 0; i < anEdgeMesh.nbElements(); ++i)
            {
                int anElementId = anEdgeMesh.elementId(i);

                var anElement = anEdgeMesh.element(anElementId);

                var aLine = vtkLine.New();
                aLine.GetPointIds().SetId(0, anEdgeMesh.nodeIndex(anElement.nodeId(0)));
                aLine.GetPointIds().SetId(1, anEdgeMesh.nodeIndex(anElement.nodeId(1)));

                sLines.InsertNextCell(aLine);
            }

            sLinesPolyData.SetLines(sLines);

            // add actor to the renderer
            var anEdgeActor = vtkActor.New();

            aRenderer.AddActor(anEdgeActor);

            var anEdgeMapper = vtkDataSetMapper.New();

            anEdgeMapper.SetInput(sLinesPolyData);

            anEdgeActor.SetMapper(anEdgeMapper);

            var aMeshSize = 0.026;

            anEdgeMesh.generateFaces(1E-3);

            aMesher.remesh(anEdgeMesh, aMeshSize);
            aMesher.generate(anEdgeMesh, 99999, aMeshSize, aMeshSize * 0.1, aMeshSize * 10.0, 1E-6);

            for (int i = 0; i < 3; i++)
            {
                aMesher.relaxNodes(1E-5);
                aMesher.flipEdges(1E-5);
            }

            aMesher.mesh().renumber();
        }
예제 #21
0
        public void WriteVTM(string filePath, List <Vector3d> point_data, List <Vector4> tetrapoints, Dictionary <String, vtkDataArray> scalar_dataArray, List <String> arrayNames, int numberOfPoints, int numberOfTetraPoints)
        {
            vtkPoints points = vtkPoints.New();

            for (int i = 0; i < numberOfPoints; i++)
            {
                points.InsertNextPoint(point_data[i].X, point_data[i].Y, point_data[i].Z);
            }
            vtkMultiBlockDataSet multiBlockDataSet = vtkMultiBlockDataSet.New();

            double countBlocks = Math.Ceiling((double)((1.0 * numberOfTetraPoints) / 1000000));

            multiBlockDataSet.SetNumberOfBlocks((uint)1);
            for (int j = 0; j < 1; j++)
            {
                vtkUnstructuredGrid unstructuredGrid = vtkUnstructuredGrid.New();

                vtkCellArray cellArrayOne = vtkCellArray.New();
                int          countTetras  = 0;
                int          startTetras  = j * 1000000;
                if (numberOfTetraPoints < (j * 1000000) + 1000000)
                {
                    countTetras = numberOfTetraPoints;
                }
                else
                {
                    countTetras = (j * 1000000) + 1000000;
                }
                for (int i = startTetras; i < tetrapoints.Count(); i++)
                {
                    vtkTetra tetra = vtkTetra.New();

                    tetra.GetPointIds().SetId(0, (long)tetrapoints[i][0]);
                    tetra.GetPointIds().SetId(1, (long)tetrapoints[i][1]);
                    tetra.GetPointIds().SetId(2, (long)tetrapoints[i][2]);
                    tetra.GetPointIds().SetId(3, (long)tetrapoints[i][3]);

                    cellArrayOne.InsertNextCell(tetra);
                }
                //for (int i = 0; i < tetrapoints2.Count(); i++)
                //{
                //    vtkTetra tetra = vtkTetra.New();

                //    tetra.GetPointIds().SetId(0, (long)tetrapoints2[i][0]);
                //    tetra.GetPointIds().SetId(1, (long)tetrapoints2[i][1]);
                //    tetra.GetPointIds().SetId(2, (long)tetrapoints2[i][2]);
                //    tetra.GetPointIds().SetId(3, (long)tetrapoints2[i][3]);

                //    cellArrayOne.InsertNextCell(tetra);
                //}

                unstructuredGrid.SetPoints(points);

                const int VTK_TETRA = 10;
                unstructuredGrid.SetCells(VTK_TETRA, cellArrayOne);


                int numberOfScalarData = scalar_dataArray.Count();
                for (int i = 0; i < numberOfScalarData; i++)
                {
                    scalar_dataArray.TryGetValue(arrayNames[i], out vtkDataArray scalars);
                    unstructuredGrid.GetPointData().AddArray(scalars);
                }
                multiBlockDataSet.SetBlock((uint)j, unstructuredGrid);
            }

            // add file ending if it is not existent
            string suffix = (".vtm");

            if (!(filePath.EndsWith(suffix)))
            {
                filePath += suffix;
            }

            // Write file
            vtkXMLMultiBlockDataWriter writer = vtkXMLMultiBlockDataWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(multiBlockDataSet);
            writer.Write();

            // Read and display file for verification that it was written correctly
            vtkXMLMultiBlockDataReader reader = vtkXMLMultiBlockDataReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                //MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            Console.WriteLine("VTU file was writen and is saved at {0}", filePath);
        }
예제 #22
0
        static public vtkProp3D genRayActor(List <RayLineCluster> data)
        {
            vtkPoints    points    = vtkPoints.New();
            vtkCellArray pLineCell = vtkCellArray.New();

            vtkLine p1   = vtkLine.New();
            int     cout = 0;

            System.Windows.Forms.MessageBox.Show("cluster.start_radius:" + data.Count.ToString());
            for (int i = 0; i < data.Count; i++)
            {
                RayLineCluster cluster = data[i];
                if (i != data.Count - 1)
                {
                    // 第一个的起点连第二次的起点
                    List <RayLine> rays_start = cluster.ray_cluster;
                    List <RayLine> rays_end   = data[i + 1].ray_cluster;
                    for (int j = 0; j < rays_start.Count; j++)
                    {
                        points.InsertNextPoint(rays_start[j].start_point.x,
                                               rays_start[j].start_point.y, rays_start[j].start_point.z);
                        points.InsertNextPoint(rays_end[j].start_point.x,
                                               rays_end[j].start_point.y, rays_end[j].start_point.z);

                        p1.GetPointIds().SetId(0, cout++);
                        p1.GetPointIds().SetId(1, cout++);
                        pLineCell.InsertNextCell(p1);
                    }
                }
                else
                {
                    foreach (var line in cluster.ray_cluster)
                    {
                        points.InsertNextPoint(line.start_point.x,
                                               line.start_point.y, line.start_point.z);
                        points.InsertNextPoint(
                            line.start_point.x + 0.5 * line.normal_line.x,
                            line.start_point.y + 0.5 * line.normal_line.y,
                            line.start_point.z + 0.5 * line.normal_line.z);
                        p1.GetPointIds().SetId(0, cout++);
                        p1.GetPointIds().SetId(1, cout++);
                        pLineCell.InsertNextCell(p1);
                    }
                }
            }

            vtkPolyData pointsData = vtkPolyData.New();

            pointsData.SetPoints(points); //获得网格模型中的几何数据:点集
            pointsData.SetLines(pLineCell);

            vtkPolyDataMapper pointMapper = vtkPolyDataMapper.New();

            pointMapper.SetInput(pointsData);
            pointMapper.Update();

            vtkActor actor = vtkActor.New();

            actor.SetMapper(pointMapper);
            actor.GetProperty().SetColor(1, 0, 0);
            return(actor);
        }
예제 #23
0
        /*********************************************
        * VTK functions:
        * DrawModel -- Basic function to draw model
        * DrawEdgesModel -- Add grids to the model
        * LabelGetter -- Add label to the model
        *********************************************/
        public int VTKDrawModel(ref vtkPoints points,
                                ref vtkCellArray strips,
                                ref vtkFloatArray scalars,
                                ref int pointsNum,
                                FormParas paras)
        {
            // The following routine is built for general purpose

            for (int i = 0; i < NodeList.Count(); i++)
            {
                points.InsertPoint(i,
                                   NodeList[i].Node_Coord[0],
                                   0,
                                   -NodeList[i].Node_Coord[1]);
            }
            pointsNum = NodeList.Count();

            if (paras.StageID != -1)
            {
                scalars.SetNumberOfValues(ElemList.Count());
            }
            int    cnt          = 0;
            double MAX_R        = 0;
            double MAX_R_VALUE  = 0;
            int    MAX_ELEM_NUM = 0;

            foreach (ListElemBase elem in ElemList)
            {
                strips.InsertNextCell(8);
                if (paras.StageID == -1)
                {
                    scalars.InsertNextValue(elem.Elem_Modeltype[0]);
                }
                else
                {
                    if (IfElemToPropertyKeyExists(elem.Elem_Number))
                    {
                        scalars.SetValue(cnt, (float)GetElemToProperty(elem.Elem_Number));
                    }
                    else
                    {
                        scalars.SetValue(cnt, 0);
                    }
                    //MessageBox.Show(((float)GetElemToProperty(elem.Elem_Number)).ToString());
                }

                for (int i = 0; i < 8; i++)
                {
                    int NodeId = elem.Elem_Nodes[i];
                    int NodePosInPointsArray = GetNodePositionInNodeListFromNodeId(NodeId);
                    strips.InsertCellPoint(NodePosInPointsArray);
                    if (paras.StageID != -1)
                    {
                        if (NodeList[NodePosInPointsArray].Node_Coord[0] > MAX_R)
                        {
                            MAX_R = NodeList[NodePosInPointsArray].Node_Coord[0];
                            if (IfElemToPropertyKeyExists(elem.Elem_Number))
                            {
                                MAX_R_VALUE = GetElemToProperty(elem.Elem_Number);
                            }
                            else
                            {
                                MAX_R_VALUE = 0;
                            }
                            MAX_ELEM_NUM = elem.Elem_Number;
                        }
                    }
                }

                cnt++;
            }
            //MessageBox.Show(MAX_R.ToString() + ' ' + MAX_R_VALUE.ToString() + ' ' + MAX_ELEM_NUM.ToString());

            return(1);
        }
예제 #24
0
        private void ColoredElevationMap()
        {
            // Create a grid of points (height/terrian map)
            vtkPoints points = vtkPoints.New();

            uint   GridSize = 20;
            double xx, yy, zz;

            for (uint x = 0; x < GridSize; x++)
            {
                for (uint y = 0; y < GridSize; y++)
                {
                    xx = x + vtkMath.Random(-.2, .2);
                    yy = y + vtkMath.Random(-.2, .2);
                    zz = vtkMath.Random(-.5, .5);
                    points.InsertNextPoint(xx, yy, zz);
                }
            }

            // Add the grid points to a polydata object
            vtkPolyData inputPolyData = vtkPolyData.New();

            inputPolyData.SetPoints(points);

            // Triangulate the grid points
            vtkDelaunay2D delaunay = vtkDelaunay2D.New();

#if VTK_MAJOR_VERSION_5
            delaunay.SetInput(inputPolyData);
#else
            delaunay.SetInputData(inputPolyData);
#endif
            delaunay.Update();
            vtkPolyData outputPolyData = delaunay.GetOutput();

            double[] bounds = outputPolyData.GetBounds();

            // Find min and max z
            double minz = bounds[4];
            double maxz = bounds[5];

            Debug.WriteLine("minz: " + minz);
            Debug.WriteLine("maxz: " + maxz);

            // Create the color map
            vtkLookupTable colorLookupTable = vtkLookupTable.New();
            colorLookupTable.SetTableRange(minz, maxz);
            colorLookupTable.Build();

            // Generate the colors for each point based on the color map
            vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
            colors.SetNumberOfComponents(3);
            colors.SetName("Colors");

            Debug.WriteLine("There are " + outputPolyData.GetNumberOfPoints()
                            + " points.");


#if UNSAFE // fastest way to fill color array
            colors.SetNumberOfTuples(outputPolyData.GetNumberOfPoints());
            unsafe {
                byte *pColor = (byte *)colors.GetPointer(0).ToPointer();

                for (int i = 0; i < outputPolyData.GetNumberOfPoints(); i++)
                {
                    double[] p = outputPolyData.GetPoint(i);

                    double[] dcolor = colorLookupTable.GetColor(p[2]);
                    Debug.WriteLine("dcolor: "
                                    + dcolor[0] + " "
                                    + dcolor[1] + " "
                                    + dcolor[2]);

                    byte[] color = new byte[3];
                    for (uint j = 0; j < 3; j++)
                    {
                        color[j] = (byte)(255 * dcolor[j]);
                    }
                    Debug.WriteLine("color: "
                                    + color[0] + " "
                                    + color[1] + " "
                                    + color[2]);

                    *(pColor + 3 * i)     = color[0];
                    *(pColor + 3 * i + 1) = color[1];
                    *(pColor + 3 * i + 2) = color[2];
                }
            }
#else
            for (int i = 0; i < outputPolyData.GetNumberOfPoints(); i++)
            {
                double[] p = outputPolyData.GetPoint(i);

                double[] dcolor = colorLookupTable.GetColor(p[2]);
                Debug.WriteLine("dcolor: "
                                + dcolor[0] + " "
                                + dcolor[1] + " "
                                + dcolor[2]);

                byte[] color = new byte[3];
                for (uint j = 0; j < 3; j++)
                {
                    color[j] = (byte)(255 * dcolor[j]);
                }
                Debug.WriteLine("color: "
                                + color[0] + " "
                                + color[1] + " "
                                + color[2]);
                colors.InsertNextTuple3(color[0], color[1], color[2]);
                //IntPtr pColor = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(byte)) * 3);
                //Marshal.Copy(color, 0, pColor, 3);
                //colors.InsertNextTupleValue(pColor);
                //Marshal.FreeHGlobal(pColor);
            }
#endif

            outputPolyData.GetPointData().SetScalars(colors);

            // Create a mapper and actor
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            mapper.SetInputConnection(outputPolyData.GetProducerPort());
#else
            mapper.SetInputData(outputPolyData);
#endif

            vtkActor actor = vtkActor.New();
            actor.SetMapper(mapper);

            // 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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
예제 #25
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetpolyLinePoints(vtkPoints toSet)
 {
     polyLinePoints = toSet;
 }
예제 #26
0
        public void WritSimpleVTM()
        {
            string filePath = "..\\..\\..\\..\\..\\03Daten\\testData\\simpleTest8Points.vtm";
            vtkMultiBlockDataSet multiBlockDataSet = vtkMultiBlockDataSet.New();

            multiBlockDataSet.SetNumberOfBlocks(2);

            vtkUnstructuredGrid unstructuredGrid1 = vtkUnstructuredGrid.New();

            vtkPoints points1 = vtkPoints.New();

            points1.InsertNextPoint(0, 0, 0);
            points1.InsertNextPoint(1, 0, 0);
            points1.InsertNextPoint(1, 1, 0);
            points1.InsertNextPoint(0, 1, 1);

            vtkPoints points2 = vtkPoints.New();

            points1.InsertNextPoint(2, 0, 0);
            points1.InsertNextPoint(2, 2, 0);
            points1.InsertNextPoint(2, 2, 3);
            points1.InsertNextPoint(0, 2, 3);

            vtkTetra tetra = vtkTetra.New();

            tetra.GetPointIds().SetId(0, 0);
            tetra.GetPointIds().SetId(1, 1);
            tetra.GetPointIds().SetId(2, 2);
            tetra.GetPointIds().SetId(3, 3);

            vtkCellArray cellArray1 = vtkCellArray.New();

            cellArray1.InsertNextCell(tetra);

            unstructuredGrid1.SetPoints(points1);
            const int VTK_TETRA = 10;

            unstructuredGrid1.SetCells(VTK_TETRA, cellArray1);

            vtkCellArray cellArray2 = vtkCellArray.New();

            tetra = vtkTetra.New();
            tetra.GetPointIds().SetId(0, 4);
            tetra.GetPointIds().SetId(1, 5);
            tetra.GetPointIds().SetId(2, 6);
            tetra.GetPointIds().SetId(3, 7);
            cellArray2.InsertNextCell(tetra);
            tetra = vtkTetra.New();
            tetra.GetPointIds().SetId(0, 7);
            tetra.GetPointIds().SetId(1, 5);
            tetra.GetPointIds().SetId(2, 2);
            tetra.GetPointIds().SetId(3, 4);

            cellArray2.InsertNextCell(tetra);


            vtkUnstructuredGrid unstructuredGrid = vtkUnstructuredGrid.New();

            unstructuredGrid.SetPoints(points1);
            unstructuredGrid.SetCells(VTK_TETRA, cellArray2);

            multiBlockDataSet.SetBlock(0, unstructuredGrid1);
            multiBlockDataSet.SetBlock(1, unstructuredGrid);

            // Write file
            vtkXMLMultiBlockDataWriter writer = vtkXMLMultiBlockDataWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(multiBlockDataSet);
            writer.Write();
        }
예제 #27
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetpyramidPoints(vtkPoints toSet)
 {
     pyramidPoints = toSet;
 }
예제 #28
0
        public void WriteSimpleStructuredGrid(string filePath)
        {
            vtkPoints points = vtkPoints.New();

            double x, y, z;

            x = 0.0;
            y = 0.0;
            z = 0.0;

            for (uint k = 0; k < 2; k++)
            {
                z += 2.0;
                for (uint j = 0; j < 3; j++)
                {
                    y += 1.0;
                    for (uint i = 0; i < 2; i++)
                    {
                        x += .5;
                        points.InsertNextPoint(x, y, z);
                    }
                }
            }

            vtkDataArray dataArrayVx;
            vtkDataArray dataArrayVy;
            vtkDataArray dataArrayVz;

            vtkDoubleArray Vx = new vtkDoubleArray();
            vtkDoubleArray Vy = new vtkDoubleArray();
            vtkDoubleArray Vz = new vtkDoubleArray();

            for (int i = 0; i < 12; i++)
            {
                Vx.InsertNextValue(-1 + i);
                Vz.InsertNextValue(2 - i);
                Vy.InsertNextValue(-4 + i);
            }
            dataArrayVx = Vx;
            dataArrayVx.SetName("Vx");
            dataArrayVy = Vy;
            dataArrayVy.SetName("Vy");
            dataArrayVz = Vz;
            dataArrayVz.SetName("Vz");


            vtkStructuredGrid structuredGrid = vtkStructuredGrid.New();

            structuredGrid.SetDimensions(2, 3, 2);
            structuredGrid.SetPoints(points);

            structuredGrid.GetPointData().AddArray(dataArrayVx);
            structuredGrid.GetPointData().AddArray(dataArrayVy);
            structuredGrid.GetPointData().AddArray(dataArrayVz);

            // add file ending if it is not existent
            string suffix = (".vts");

            if (!(filePath.EndsWith(suffix)))
            {
                filePath += suffix;
            }
            // Write file
            vtkXMLStructuredGridWriter writer = vtkXMLStructuredGridWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(structuredGrid);
            writer.Write();

            // Read and display file for verification that it was written correctly
            vtkXMLStructuredGridReader reader = vtkXMLStructuredGridReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                //MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            Console.WriteLine("VTU file was writen and is saved at {0}", filePath);
        }
예제 #29
0
        private void WriteVTUFile()
        {
            // Path to vtk data must be set as an environment variable
            // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0"
            vtkTesting test     = vtkTesting.New();
            string     root     = test.GetDataRoot();
            string     filePath = System.IO.Path.Combine(root, @"Data\tetra_test.vtu");

            vtkPoints points = vtkPoints.New();

            points.InsertNextPoint(0, 0, 0);
            points.InsertNextPoint(1, 0, 0);
            points.InsertNextPoint(1, 1, 0);
            points.InsertNextPoint(0, 1, 1);

            vtkTetra tetra = vtkTetra.New();

            tetra.GetPointIds().SetId(0, 0);
            tetra.GetPointIds().SetId(1, 1);
            tetra.GetPointIds().SetId(2, 2);
            tetra.GetPointIds().SetId(3, 3);

            vtkCellArray cellArray = vtkCellArray.New();

            cellArray.InsertNextCell(tetra);

            vtkUnstructuredGrid unstructuredGrid = vtkUnstructuredGrid.New();

            unstructuredGrid.SetPoints(points);
            const int VTK_TETRA = 10;

            unstructuredGrid.SetCells(VTK_TETRA, cellArray);

            // Write file
            vtkXMLUnstructuredGridWriter writer = vtkXMLUnstructuredGridWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(unstructuredGrid);
            writer.Write();

            // Read and display file for verification that it was written correctly
            vtkXMLUnstructuredGridReader reader = vtkXMLUnstructuredGridReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update();

            vtkDataSetMapper mapper = vtkDataSetMapper.New();

            mapper.SetInputConnection(reader.GetOutputPort());

            // actor
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);

            // 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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
예제 #30
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetCpoints(vtkPoints toSet)
 {
     Cpoints = toSet;
 }
        private void ParametricObjectsDemo()
        {
            // we create a matrix of 4x4 renderer in our renderwindow
            // each renderer can be interacted with independently from one another
            int rendererSize   = 189; // width per renderer
            int gridDimensions = 4;

            this.Size = new System.Drawing.Size(756, 756);
            Random rnd = new Random(2);
            List <vtkParametricFunction> parametricObjects = new List <vtkParametricFunction>();

            parametricObjects.Add(vtkParametricBoy.New());
            parametricObjects.Add(vtkParametricConicSpiral.New());
            parametricObjects.Add(vtkParametricCrossCap.New());
            parametricObjects.Add(vtkParametricDini.New());
            vtkParametricEllipsoid ellipsoid = vtkParametricEllipsoid.New();

            ellipsoid.SetXRadius(0.5);
            ellipsoid.SetYRadius(2.0);
            parametricObjects.Add(ellipsoid);
            parametricObjects.Add(vtkParametricEnneper.New());
            parametricObjects.Add(vtkParametricFigure8Klein.New());
            parametricObjects.Add(vtkParametricKlein.New());
            parametricObjects.Add(vtkParametricMobius.New());
            vtkParametricRandomHills randomHills = vtkParametricRandomHills.New();

            randomHills.AllowRandomGenerationOff();
            parametricObjects.Add(randomHills);
            parametricObjects.Add(vtkParametricRoman.New());
            vtkParametricSuperEllipsoid superEllipsoid = vtkParametricSuperEllipsoid.New();

            superEllipsoid.SetN1(.50);
            superEllipsoid.SetN2(.1);
            parametricObjects.Add(superEllipsoid);
            vtkParametricSuperToroid superToroid = vtkParametricSuperToroid.New();

            superToroid.SetN1(0.2);
            superToroid.SetN2(3.0);
            parametricObjects.Add(superToroid);
            parametricObjects.Add(vtkParametricTorus.New());

            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);

            parametricObjects.Add(spline);


            List <vtkParametricFunctionSource> parametricFunctionSources = new List <vtkParametricFunctionSource>();
            List <vtkRenderer>       renderers   = new List <vtkRenderer>();
            List <vtkPolyDataMapper> mappers     = new List <vtkPolyDataMapper>();
            List <vtkActor>          actors      = new List <vtkActor>();
            List <vtkTextMapper>     textMappers = new List <vtkTextMapper>();
            List <vtkActor2D>        textActors  = new List <vtkActor2D>();

            // Create one text property for all
            vtkTextProperty textProperty = vtkTextProperty.New();

            textProperty.SetFontSize(12);
            textProperty.SetJustificationToCentered();

            // Create a source, renderer, mapper, and actor
            // for each object
            for (int i = 0; i < parametricObjects.Count; i++)
            {
                parametricFunctionSources.Add(vtkParametricFunctionSource.New());
                parametricFunctionSources[i].SetParametricFunction(parametricObjects[i]);
                parametricFunctionSources[i].Update();
                mappers.Add(vtkPolyDataMapper.New());
                mappers[i].SetInputConnection(parametricFunctionSources[i].GetOutputPort());

                actors.Add(vtkActor.New());
                actors[i].SetMapper(mappers[i]);

                textMappers.Add(vtkTextMapper.New());
                textMappers[i].SetInput(parametricObjects[i].GetClassName());
                textMappers[i].SetTextProperty(textProperty);

                textActors.Add(vtkActor2D.New());
                textActors[i].SetMapper(textMappers[i]);
                textActors[i].SetPosition(rendererSize / 2, 16);

                renderers.Add(vtkRenderer.New());
            }

            // Need a renderer even if there is no actor
            for (int i = parametricObjects.Count; i < gridDimensions * gridDimensions; i++)
            {
                renderers.Add(vtkRenderer.New());
            }

            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;

            renderWindow.SetSize(rendererSize * gridDimensions, rendererSize * gridDimensions);

            for (int row = 0; row < gridDimensions; row++)
            {
                for (int col = 0; col < gridDimensions; col++)
                {
                    int index = row * gridDimensions + col;

                    // (xmin, ymin, xmax, ymax)
                    double[] viewport = new double[] {
                        (col) * rendererSize / (double)(gridDimensions * rendererSize),
                        (gridDimensions - (row + 1)) * rendererSize / (double)(gridDimensions * rendererSize),
                        (col + 1) * rendererSize / (double)(gridDimensions * rendererSize),
                        (gridDimensions - row) * rendererSize / (double)(gridDimensions * rendererSize)
                    };

                    //Debug.WriteLine(viewport[0] + " " + viewport[1] + " " + viewport[2] + " " + viewport[3]);
                    renderWindow.AddRenderer(renderers[index]);
                    IntPtr pViewport = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 4);
                    Marshal.Copy(viewport, 0, pViewport, 4);
                    renderers[index].SetViewport(pViewport);
                    Marshal.FreeHGlobal(pViewport);
                    if (index > parametricObjects.Count - 1)
                    {
                        continue;
                    }

                    renderers[index].AddActor(actors[index]);
                    renderers[index].AddActor(textActors[index]);
                    renderers[index].SetBackground(.2 + rnd.NextDouble() / 8, .3 + rnd.NextDouble() / 8, .4 + rnd.NextDouble() / 8);
                    renderers[index].ResetCamera();
                    renderers[index].GetActiveCamera().Azimuth(30);
                    renderers[index].GetActiveCamera().Elevation(-50);
                    renderers[index].GetActiveCamera().Pitch(-2);
                    renderers[index].ResetCameraClippingRange();
                }
            }
        }
예제 #32
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetinputPoints(vtkPoints toSet)
 {
     inputPoints = toSet;
 }
 ///<summary> A Set Method for Static Variables </summary>
 public static void SettriPoints(vtkPoints toSet)
 {
     triPoints = toSet;
 }
예제 #34
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetKpoints(vtkPoints toSet)
 {
     Kpoints = toSet;
 }
예제 #35
0
        private void ElevationFilter()
        {
            // Created a grid of points (heigh/terrian map)
            vtkPoints points = vtkPoints.New();

            uint GridSize = 10;

            for (uint x = 0; x < GridSize; x++)
            {
                for (uint y = 0; y < GridSize; y++)
                {
                    points.InsertNextPoint(x, y, (x + y) / (y + 1));
                }
            }
            double[] bounds = points.GetBounds();

            // Add the grid points to a polydata object
            vtkPolyData inputPolyData = vtkPolyData.New();

            inputPolyData.SetPoints(points);

            // Triangulate the grid points
            vtkDelaunay2D delaunay = vtkDelaunay2D.New();

#if VTK_MAJOR_VERSION_5
            delaunay.SetInput(inputPolyData);
#else
            delaunay.SetInputData(inputPolyData);
#endif
            delaunay.Update();

            vtkElevationFilter elevationFilter = vtkElevationFilter.New();
            elevationFilter.SetInputConnection(delaunay.GetOutputPort());
            elevationFilter.SetLowPoint(0.0, 0.0, bounds[4]);
            elevationFilter.SetHighPoint(0.0, 0.0, bounds[5]);
            elevationFilter.Update();

            vtkPolyData output = vtkPolyData.New();
            output.ShallowCopy(vtkPolyData.SafeDownCast(elevationFilter.GetOutput()));

            vtkFloatArray elevation =
                vtkFloatArray.SafeDownCast(output.GetPointData().GetArray("Elevation"));

            // Create the color map
            vtkLookupTable colorLookupTable = vtkLookupTable.New();
            colorLookupTable.SetTableRange(bounds[4], bounds[5]);
            colorLookupTable.Build();

            // Generate the colors for each point based on the color map
            vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
            colors.SetNumberOfComponents(3);
            colors.SetName("Colors");

            for (int i = 0; i < output.GetNumberOfPoints(); i++)
            {
                double val = elevation.GetValue(i);
                Debug.WriteLine("val: " + val);

                double[] dcolor = colorLookupTable.GetColor(val);
                //Debug.WriteLine("dcolor: "
                //          + dcolor[0] + " "
                //          + dcolor[1] + " "
                //          + dcolor[2]);
                byte[] color = new byte[3];
                for (int j = 0; j < 3; j++)
                {
                    color[j] = (byte)(255 * dcolor[j]);
                }
                //Debug.WriteLine("color: "
                //          + color[0] + " "
                //          + color[1] + " "
                //          + color[2]);

                colors.InsertNextTuple3(color[0], color[1], color[2]);
            }

            output.GetPointData().AddArray(colors);

            // Visualize
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
#if VTK_MAJOR_VERSION_5
            mapper.SetInputConnection(output.GetProducerPort());
#else
            mapper.SetInputData(output);
#endif

            vtkActor actor = vtkActor.New();
            actor.SetMapper(mapper);

            // 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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
예제 #36
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);
          glyphPoints = new vtkGlyph3D();
          glyphPoints.SetInput((vtkDataObject)inputData);
          glyphPoints.SetSource((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.SetInput((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.SetInput((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();
    }
예제 #37
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVpickCells(String [] argv)
    {
        //Prefix Content is: ""

          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // create a scene with one of each cell type[]
          // Voxel[]
          voxelPoints = new vtkPoints();
          voxelPoints.SetNumberOfPoints((int)8);
          voxelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          voxelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          voxelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          voxelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          voxelPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          voxelPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          voxelPoints.InsertPoint((int)6,(double)0,(double)1,(double)1);
          voxelPoints.InsertPoint((int)7,(double)1,(double)1,(double)1);
          aVoxel = new vtkVoxel();
          aVoxel.GetPointIds().SetId((int)0,(int)0);
          aVoxel.GetPointIds().SetId((int)1,(int)1);
          aVoxel.GetPointIds().SetId((int)2,(int)2);
          aVoxel.GetPointIds().SetId((int)3,(int)3);
          aVoxel.GetPointIds().SetId((int)4,(int)4);
          aVoxel.GetPointIds().SetId((int)5,(int)5);
          aVoxel.GetPointIds().SetId((int)6,(int)6);
          aVoxel.GetPointIds().SetId((int)7,(int)7);
          aVoxelGrid = new vtkUnstructuredGrid();
          aVoxelGrid.Allocate((int)1,(int)1);
          aVoxelGrid.InsertNextCell((int)aVoxel.GetCellType(),(vtkIdList)aVoxel.GetPointIds());
          aVoxelGrid.SetPoints((vtkPoints)voxelPoints);
          aVoxelMapper = new vtkDataSetMapper();
          aVoxelMapper.SetInput((vtkDataSet)aVoxelGrid);
          aVoxelActor = new vtkActor();
          aVoxelActor.SetMapper((vtkMapper)aVoxelMapper);
          aVoxelActor.GetProperty().BackfaceCullingOn();
          // Hexahedron[]
          hexahedronPoints = new vtkPoints();
          hexahedronPoints.SetNumberOfPoints((int)8);
          hexahedronPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          hexahedronPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          hexahedronPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          hexahedronPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
          hexahedronPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
          aHexahedron = new vtkHexahedron();
          aHexahedron.GetPointIds().SetId((int)0,(int)0);
          aHexahedron.GetPointIds().SetId((int)1,(int)1);
          aHexahedron.GetPointIds().SetId((int)2,(int)2);
          aHexahedron.GetPointIds().SetId((int)3,(int)3);
          aHexahedron.GetPointIds().SetId((int)4,(int)4);
          aHexahedron.GetPointIds().SetId((int)5,(int)5);
          aHexahedron.GetPointIds().SetId((int)6,(int)6);
          aHexahedron.GetPointIds().SetId((int)7,(int)7);
          aHexahedronGrid = new vtkUnstructuredGrid();
          aHexahedronGrid.Allocate((int)1,(int)1);
          aHexahedronGrid.InsertNextCell((int)aHexahedron.GetCellType(),(vtkIdList)aHexahedron.GetPointIds());
          aHexahedronGrid.SetPoints((vtkPoints)hexahedronPoints);
          aHexahedronMapper = new vtkDataSetMapper();
          aHexahedronMapper.SetInput((vtkDataSet)aHexahedronGrid);
          aHexahedronActor = new vtkActor();
          aHexahedronActor.SetMapper((vtkMapper)aHexahedronMapper);
          aHexahedronActor.AddPosition((double)2,(double)0,(double)0);
          aHexahedronActor.GetProperty().BackfaceCullingOn();
          // Tetra[]
          tetraPoints = new vtkPoints();
          tetraPoints.SetNumberOfPoints((int)4);
          tetraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          tetraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          tetraPoints.InsertPoint((int)2,(double).5,(double)1,(double)0);
          tetraPoints.InsertPoint((int)3,(double).5,(double).5,(double)1);
          aTetra = new vtkTetra();
          aTetra.GetPointIds().SetId((int)0,(int)0);
          aTetra.GetPointIds().SetId((int)1,(int)1);
          aTetra.GetPointIds().SetId((int)2,(int)2);
          aTetra.GetPointIds().SetId((int)3,(int)3);
          aTetraGrid = new vtkUnstructuredGrid();
          aTetraGrid.Allocate((int)1,(int)1);
          aTetraGrid.InsertNextCell((int)aTetra.GetCellType(),(vtkIdList)aTetra.GetPointIds());
          aTetraGrid.SetPoints((vtkPoints)tetraPoints);
          aTetraMapper = new vtkDataSetMapper();
          aTetraMapper.SetInput((vtkDataSet)aTetraGrid);
          aTetraActor = new vtkActor();
          aTetraActor.SetMapper((vtkMapper)aTetraMapper);
          aTetraActor.AddPosition((double)4,(double)0,(double)0);
          aTetraActor.GetProperty().BackfaceCullingOn();
          // Wedge[]
          wedgePoints = new vtkPoints();
          wedgePoints.SetNumberOfPoints((int)6);
          wedgePoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          wedgePoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          wedgePoints.InsertPoint((int)2,(double)0,(double).5,(double).5);
          wedgePoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)0);
          wedgePoints.InsertPoint((int)5,(double)1,(double).5,(double).5);
          aWedge = new vtkWedge();
          aWedge.GetPointIds().SetId((int)0,(int)0);
          aWedge.GetPointIds().SetId((int)1,(int)1);
          aWedge.GetPointIds().SetId((int)2,(int)2);
          aWedge.GetPointIds().SetId((int)3,(int)3);
          aWedge.GetPointIds().SetId((int)4,(int)4);
          aWedge.GetPointIds().SetId((int)5,(int)5);
          aWedgeGrid = new vtkUnstructuredGrid();
          aWedgeGrid.Allocate((int)1,(int)1);
          aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds());
          aWedgeGrid.SetPoints((vtkPoints)wedgePoints);
          aWedgeMapper = new vtkDataSetMapper();
          aWedgeMapper.SetInput((vtkDataSet)aWedgeGrid);
          aWedgeActor = new vtkActor();
          aWedgeActor.SetMapper((vtkMapper)aWedgeMapper);
          aWedgeActor.AddPosition((double)6,(double)0,(double)0);
          aWedgeActor.GetProperty().BackfaceCullingOn();
          // Pyramid[]
          pyramidPoints = new vtkPoints();
          pyramidPoints.SetNumberOfPoints((int)5);
          pyramidPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pyramidPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          pyramidPoints.InsertPoint((int)4,(double).5,(double).5,(double)1);
          aPyramid = new vtkPyramid();
          aPyramid.GetPointIds().SetId((int)0,(int)0);
          aPyramid.GetPointIds().SetId((int)1,(int)1);
          aPyramid.GetPointIds().SetId((int)2,(int)2);
          aPyramid.GetPointIds().SetId((int)3,(int)3);
          aPyramid.GetPointIds().SetId((int)4,(int)4);
          aPyramidGrid = new vtkUnstructuredGrid();
          aPyramidGrid.Allocate((int)1,(int)1);
          aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
          aPyramidGrid.SetPoints((vtkPoints)pyramidPoints);
          aPyramidMapper = new vtkDataSetMapper();
          aPyramidMapper.SetInput((vtkDataSet)aPyramidGrid);
          aPyramidActor = new vtkActor();
          aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
          aPyramidActor.AddPosition((double)8,(double)0,(double)0);
          aPyramidActor.GetProperty().BackfaceCullingOn();
          // Pixel[]
          pixelPoints = new vtkPoints();
          pixelPoints.SetNumberOfPoints((int)4);
          pixelPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pixelPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pixelPoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          pixelPoints.InsertPoint((int)3,(double)1,(double)1,(double)0);
          aPixel = new vtkPixel();
          aPixel.GetPointIds().SetId((int)0,(int)0);
          aPixel.GetPointIds().SetId((int)1,(int)1);
          aPixel.GetPointIds().SetId((int)2,(int)2);
          aPixel.GetPointIds().SetId((int)3,(int)3);
          aPixelGrid = new vtkUnstructuredGrid();
          aPixelGrid.Allocate((int)1,(int)1);
          aPixelGrid.InsertNextCell((int)aPixel.GetCellType(),(vtkIdList)aPixel.GetPointIds());
          aPixelGrid.SetPoints((vtkPoints)pixelPoints);
          aPixelMapper = new vtkDataSetMapper();
          aPixelMapper.SetInput((vtkDataSet)aPixelGrid);
          aPixelActor = new vtkActor();
          aPixelActor.SetMapper((vtkMapper)aPixelMapper);
          aPixelActor.AddPosition((double)0,(double)0,(double)2);
          aPixelActor.GetProperty().BackfaceCullingOn();
          // Quad[]
          quadPoints = new vtkPoints();
          quadPoints.SetNumberOfPoints((int)4);
          quadPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          quadPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          quadPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          quadPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aQuad = new vtkQuad();
          aQuad.GetPointIds().SetId((int)0,(int)0);
          aQuad.GetPointIds().SetId((int)1,(int)1);
          aQuad.GetPointIds().SetId((int)2,(int)2);
          aQuad.GetPointIds().SetId((int)3,(int)3);
          aQuadGrid = new vtkUnstructuredGrid();
          aQuadGrid.Allocate((int)1,(int)1);
          aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds());
          aQuadGrid.SetPoints((vtkPoints)quadPoints);
          aQuadMapper = new vtkDataSetMapper();
          aQuadMapper.SetInput((vtkDataSet)aQuadGrid);
          aQuadActor = new vtkActor();
          aQuadActor.SetMapper((vtkMapper)aQuadMapper);
          aQuadActor.AddPosition((double)2,(double)0,(double)2);
          aQuadActor.GetProperty().BackfaceCullingOn();
          // Triangle[]
          trianglePoints = new vtkPoints();
          trianglePoints.SetNumberOfPoints((int)3);
          trianglePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          trianglePoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          trianglePoints.InsertPoint((int)2,(double).5,(double).5,(double)0);
          aTriangle = new vtkTriangle();
          aTriangle.GetPointIds().SetId((int)0,(int)0);
          aTriangle.GetPointIds().SetId((int)1,(int)1);
          aTriangle.GetPointIds().SetId((int)2,(int)2);
          aTriangleGrid = new vtkUnstructuredGrid();
          aTriangleGrid.Allocate((int)1,(int)1);
          aTriangleGrid.InsertNextCell((int)aTriangle.GetCellType(),(vtkIdList)aTriangle.GetPointIds());
          aTriangleGrid.SetPoints((vtkPoints)trianglePoints);
          aTriangleMapper = new vtkDataSetMapper();
          aTriangleMapper.SetInput((vtkDataSet)aTriangleGrid);
          aTriangleActor = new vtkActor();
          aTriangleActor.SetMapper((vtkMapper)aTriangleMapper);
          aTriangleActor.AddPosition((double)4,(double)0,(double)2);
          aTriangleActor.GetProperty().BackfaceCullingOn();
          // Polygon[]
          polygonPoints = new vtkPoints();
          polygonPoints.SetNumberOfPoints((int)4);
          polygonPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polygonPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polygonPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          polygonPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          aPolygon = new vtkPolygon();
          aPolygon.GetPointIds().SetNumberOfIds((int)4);
          aPolygon.GetPointIds().SetId((int)0,(int)0);
          aPolygon.GetPointIds().SetId((int)1,(int)1);
          aPolygon.GetPointIds().SetId((int)2,(int)2);
          aPolygon.GetPointIds().SetId((int)3,(int)3);
          aPolygonGrid = new vtkUnstructuredGrid();
          aPolygonGrid.Allocate((int)1,(int)1);
          aPolygonGrid.InsertNextCell((int)aPolygon.GetCellType(),(vtkIdList)aPolygon.GetPointIds());
          aPolygonGrid.SetPoints((vtkPoints)polygonPoints);
          aPolygonMapper = new vtkDataSetMapper();
          aPolygonMapper.SetInput((vtkDataSet)aPolygonGrid);
          aPolygonActor = new vtkActor();
          aPolygonActor.SetMapper((vtkMapper)aPolygonMapper);
          aPolygonActor.AddPosition((double)6,(double)0,(double)2);
          aPolygonActor.GetProperty().BackfaceCullingOn();
          // Triangle Strip[]
          triangleStripPoints = new vtkPoints();
          triangleStripPoints.SetNumberOfPoints((int)5);
          triangleStripPoints.InsertPoint((int)0,(double)0,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)1,(double)0,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          triangleStripPoints.InsertPoint((int)3,(double)1,(double)0,(double)0);
          triangleStripPoints.InsertPoint((int)4,(double)2,(double)1,(double)0);
          aTriangleStrip = new vtkTriangleStrip();
          aTriangleStrip.GetPointIds().SetNumberOfIds((int)5);
          aTriangleStrip.GetPointIds().SetId((int)0,(int)0);
          aTriangleStrip.GetPointIds().SetId((int)1,(int)1);
          aTriangleStrip.GetPointIds().SetId((int)2,(int)2);
          aTriangleStrip.GetPointIds().SetId((int)3,(int)3);
          aTriangleStrip.GetPointIds().SetId((int)4,(int)4);
          aTriangleStripGrid = new vtkUnstructuredGrid();
          aTriangleStripGrid.Allocate((int)1,(int)1);
          aTriangleStripGrid.InsertNextCell((int)aTriangleStrip.GetCellType(),(vtkIdList)aTriangleStrip.GetPointIds());
          aTriangleStripGrid.SetPoints((vtkPoints)triangleStripPoints);
          aTriangleStripMapper = new vtkDataSetMapper();
          aTriangleStripMapper.SetInput((vtkDataSet)aTriangleStripGrid);
          aTriangleStripActor = new vtkActor();
          aTriangleStripActor.SetMapper((vtkMapper)aTriangleStripMapper);
          aTriangleStripActor.AddPosition((double)8,(double)0,(double)2);
          aTriangleStripActor.GetProperty().BackfaceCullingOn();
          // Line[]
          linePoints = new vtkPoints();
          linePoints.SetNumberOfPoints((int)2);
          linePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          linePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          aLine = new vtkLine();
          aLine.GetPointIds().SetId((int)0,(int)0);
          aLine.GetPointIds().SetId((int)1,(int)1);
          aLineGrid = new vtkUnstructuredGrid();
          aLineGrid.Allocate((int)1,(int)1);
          aLineGrid.InsertNextCell((int)aLine.GetCellType(),(vtkIdList)aLine.GetPointIds());
          aLineGrid.SetPoints((vtkPoints)linePoints);
          aLineMapper = new vtkDataSetMapper();
          aLineMapper.SetInput((vtkDataSet)aLineGrid);
          aLineActor = new vtkActor();
          aLineActor.SetMapper((vtkMapper)aLineMapper);
          aLineActor.AddPosition((double)0,(double)0,(double)4);
          aLineActor.GetProperty().BackfaceCullingOn();
          // Poly line[]
          polyLinePoints = new vtkPoints();
          polyLinePoints.SetNumberOfPoints((int)3);
          polyLinePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyLinePoints.InsertPoint((int)1,(double)1,(double)1,(double)0);
          polyLinePoints.InsertPoint((int)2,(double)1,(double)0,(double)0);
          aPolyLine = new vtkPolyLine();
          aPolyLine.GetPointIds().SetNumberOfIds((int)3);
          aPolyLine.GetPointIds().SetId((int)0,(int)0);
          aPolyLine.GetPointIds().SetId((int)1,(int)1);
          aPolyLine.GetPointIds().SetId((int)2,(int)2);
          aPolyLineGrid = new vtkUnstructuredGrid();
          aPolyLineGrid.Allocate((int)1,(int)1);
          aPolyLineGrid.InsertNextCell((int)aPolyLine.GetCellType(),(vtkIdList)aPolyLine.GetPointIds());
          aPolyLineGrid.SetPoints((vtkPoints)polyLinePoints);
          aPolyLineMapper = new vtkDataSetMapper();
          aPolyLineMapper.SetInput((vtkDataSet)aPolyLineGrid);
          aPolyLineActor = new vtkActor();
          aPolyLineActor.SetMapper((vtkMapper)aPolyLineMapper);
          aPolyLineActor.AddPosition((double)2,(double)0,(double)4);
          aPolyLineActor.GetProperty().BackfaceCullingOn();
          // Vertex[]
          vertexPoints = new vtkPoints();
          vertexPoints.SetNumberOfPoints((int)1);
          vertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          aVertex = new vtkVertex();
          aVertex.GetPointIds().SetId((int)0,(int)0);
          aVertexGrid = new vtkUnstructuredGrid();
          aVertexGrid.Allocate((int)1,(int)1);
          aVertexGrid.InsertNextCell((int)aVertex.GetCellType(),(vtkIdList)aVertex.GetPointIds());
          aVertexGrid.SetPoints((vtkPoints)vertexPoints);
          aVertexMapper = new vtkDataSetMapper();
          aVertexMapper.SetInput((vtkDataSet)aVertexGrid);
          aVertexActor = new vtkActor();
          aVertexActor.SetMapper((vtkMapper)aVertexMapper);
          aVertexActor.AddPosition((double)0,(double)0,(double)6);
          aVertexActor.GetProperty().BackfaceCullingOn();
          // Poly Vertex[]
          polyVertexPoints = new vtkPoints();
          polyVertexPoints.SetNumberOfPoints((int)3);
          polyVertexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          polyVertexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          aPolyVertex = new vtkPolyVertex();
          aPolyVertex.GetPointIds().SetNumberOfIds((int)3);
          aPolyVertex.GetPointIds().SetId((int)0,(int)0);
          aPolyVertex.GetPointIds().SetId((int)1,(int)1);
          aPolyVertex.GetPointIds().SetId((int)2,(int)2);
          aPolyVertexGrid = new vtkUnstructuredGrid();
          aPolyVertexGrid.Allocate((int)1,(int)1);
          aPolyVertexGrid.InsertNextCell((int)aPolyVertex.GetCellType(),(vtkIdList)aPolyVertex.GetPointIds());
          aPolyVertexGrid.SetPoints((vtkPoints)polyVertexPoints);
          aPolyVertexMapper = new vtkDataSetMapper();
          aPolyVertexMapper.SetInput((vtkDataSet)aPolyVertexGrid);
          aPolyVertexActor = new vtkActor();
          aPolyVertexActor.SetMapper((vtkMapper)aPolyVertexMapper);
          aPolyVertexActor.AddPosition((double)2,(double)0,(double)6);
          aPolyVertexActor.GetProperty().BackfaceCullingOn();
          // Pentagonal prism[]
          pentaPoints = new vtkPoints();
          pentaPoints.SetNumberOfPoints((int)10);
          pentaPoints.InsertPoint((int)0,(double)0.25,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)1,(double)0.75,(double)0.0,(double)0.0);
          pentaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)3,(double)0.5,(double)1.0,(double)0.0);
          pentaPoints.InsertPoint((int)4,(double)0.0,(double)0.5,(double)0.0);
          pentaPoints.InsertPoint((int)5,(double)0.25,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)6,(double)0.75,(double)0.0,(double)1.0);
          pentaPoints.InsertPoint((int)7,(double)1.0,(double)0.5,(double)1.0);
          pentaPoints.InsertPoint((int)8,(double)0.5,(double)1.0,(double)1.0);
          pentaPoints.InsertPoint((int)9,(double)0.0,(double)0.5,(double)1.0);
          aPenta = new vtkPentagonalPrism();
          aPenta.GetPointIds().SetId((int)0,(int)0);
          aPenta.GetPointIds().SetId((int)1,(int)1);
          aPenta.GetPointIds().SetId((int)2,(int)2);
          aPenta.GetPointIds().SetId((int)3,(int)3);
          aPenta.GetPointIds().SetId((int)4,(int)4);
          aPenta.GetPointIds().SetId((int)5,(int)5);
          aPenta.GetPointIds().SetId((int)6,(int)6);
          aPenta.GetPointIds().SetId((int)7,(int)7);
          aPenta.GetPointIds().SetId((int)8,(int)8);
          aPenta.GetPointIds().SetId((int)9,(int)9);
          aPentaGrid = new vtkUnstructuredGrid();
          aPentaGrid.Allocate((int)1,(int)1);
          aPentaGrid.InsertNextCell((int)aPenta.GetCellType(),(vtkIdList)aPenta.GetPointIds());
          aPentaGrid.SetPoints((vtkPoints)pentaPoints);
          aPentaMapper = new vtkDataSetMapper();
          aPentaMapper.SetInput((vtkDataSet)aPentaGrid);
          aPentaActor = new vtkActor();
          aPentaActor.SetMapper((vtkMapper)aPentaMapper);
          aPentaActor.AddPosition((double)10,(double)0,(double)0);
          aPentaActor.GetProperty().BackfaceCullingOn();
          // Hexagonal prism[]
          hexaPoints = new vtkPoints();
          hexaPoints.SetNumberOfPoints((int)12);
          hexaPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)1,(double)0.5,(double)0.0,(double)0.0);
          hexaPoints.InsertPoint((int)2,(double)1.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)3,(double)1.0,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)4,(double)0.5,(double)1.0,(double)0.0);
          hexaPoints.InsertPoint((int)5,(double)0.0,(double)0.5,(double)0.0);
          hexaPoints.InsertPoint((int)6,(double)0.0,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)7,(double)0.5,(double)0.0,(double)1.0);
          hexaPoints.InsertPoint((int)8,(double)1.0,(double)0.5,(double)1.0);
          hexaPoints.InsertPoint((int)9,(double)1.0,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)10,(double)0.5,(double)1.0,(double)1.0);
          hexaPoints.InsertPoint((int)11,(double)0.0,(double)0.5,(double)1.0);
          aHexa = new vtkHexagonalPrism();
          aHexa.GetPointIds().SetId((int)0,(int)0);
          aHexa.GetPointIds().SetId((int)1,(int)1);
          aHexa.GetPointIds().SetId((int)2,(int)2);
          aHexa.GetPointIds().SetId((int)3,(int)3);
          aHexa.GetPointIds().SetId((int)4,(int)4);
          aHexa.GetPointIds().SetId((int)5,(int)5);
          aHexa.GetPointIds().SetId((int)6,(int)6);
          aHexa.GetPointIds().SetId((int)7,(int)7);
          aHexa.GetPointIds().SetId((int)8,(int)8);
          aHexa.GetPointIds().SetId((int)9,(int)9);
          aHexa.GetPointIds().SetId((int)10,(int)10);
          aHexa.GetPointIds().SetId((int)11,(int)11);
          aHexaGrid = new vtkUnstructuredGrid();
          aHexaGrid.Allocate((int)1,(int)1);
          aHexaGrid.InsertNextCell((int)aHexa.GetCellType(),(vtkIdList)aHexa.GetPointIds());
          aHexaGrid.SetPoints((vtkPoints)hexaPoints);
          aHexaMapper = new vtkDataSetMapper();
          aHexaMapper.SetInput((vtkDataSet)aHexaGrid);
          aHexaActor = new vtkActor();
          aHexaActor.SetMapper((vtkMapper)aHexaMapper);
          aHexaActor.AddPosition((double)12,(double)0,(double)0);
          aHexaActor.GetProperty().BackfaceCullingOn();
          ren1.SetBackground((double).1,(double).2,(double).4);
          ren1.AddActor((vtkProp)aVoxelActor);
          aVoxelActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)0);
          ren1.AddActor((vtkProp)aHexahedronActor);
          aHexahedronActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)0);
          ren1.AddActor((vtkProp)aTetraActor);
          aTetraActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)0);
          ren1.AddActor((vtkProp)aWedgeActor);
          aWedgeActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPyramidActor);
          aPyramidActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aPixelActor);
          aPixelActor.GetProperty().SetDiffuseColor((double)0,(double)1,(double)1);
          ren1.AddActor((vtkProp)aQuadActor);
          aQuadActor.GetProperty().SetDiffuseColor((double)1,(double)0,(double)1);
          ren1.AddActor((vtkProp)aTriangleActor);
          aTriangleActor.GetProperty().SetDiffuseColor((double).3,(double)1,(double).5);
          ren1.AddActor((vtkProp)aPolygonActor);
          aPolygonActor.GetProperty().SetDiffuseColor((double)1,(double).4,(double).5);
          ren1.AddActor((vtkProp)aTriangleStripActor);
          aTriangleStripActor.GetProperty().SetDiffuseColor((double).3,(double).7,(double)1);
          ren1.AddActor((vtkProp)aLineActor);
          aLineActor.GetProperty().SetDiffuseColor((double).2,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyLineActor);
          aPolyLineActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aVertexActor);
          aVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPolyVertexActor);
          aPolyVertexActor.GetProperty().SetDiffuseColor((double)1,(double)1,(double)1);
          ren1.AddActor((vtkProp)aPentaActor);
          aPentaActor.GetProperty().SetDiffuseColor((double).2,(double).4,(double).7);
          ren1.AddActor((vtkProp)aHexaActor);
          aHexaActor.GetProperty().SetDiffuseColor((double).7,(double).5,(double)1);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Azimuth((double)30);
          ren1.GetActiveCamera().Elevation((double)20);
          ren1.GetActiveCamera().Dolly((double)1.25);
          ren1.ResetCameraClippingRange();
          renWin.Render();
          cellPicker = new vtkCellPicker();
          pointPicker = new vtkPointPicker();
          worldPicker = new vtkWorldPointPicker();
          cellCount = 0;
          pointCount = 0;
          ren1.IsInViewport((int)0,(int)0);
          x = 0;
          while((x) <= 265)
        {
          y = 100;
          while((y) <= 200)
        {
          cellPicker.Pick((double)x,(double)y,(double)0,(vtkRenderer)ren1);
          pointPicker.Pick((double)x,(double)y,(double)0,(vtkRenderer)ren1);
          worldPicker.Pick((double)x,(double)y,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
            {
              cellCount = cellCount + 1;
            }

          if ((pointPicker.GetPointId()) != -1)
            {
              pointCount = pointCount + 1;
            }

          y = y + 6;
        }

          x = x + 6;
        }

          // render the image[]
          //[]
          iren.Initialize();

        //deleteAllVTKObjects();
    }
예제 #38
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);
        }
예제 #39
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetlinePoints(vtkPoints toSet)
 {
     linePoints = toSet;
 }
예제 #40
0
        private void Tetrahedron()
        {
            vtkPoints points = vtkPoints.New();

            points.InsertNextPoint(0, 0, 0);
            points.InsertNextPoint(1, 0, 0);
            points.InsertNextPoint(1, 1, 0);
            points.InsertNextPoint(0, 1, 1);
            points.InsertNextPoint(5, 5, 5);
            points.InsertNextPoint(6, 5, 5);
            points.InsertNextPoint(6, 6, 5);
            points.InsertNextPoint(5, 6, 6);

            // Method 1
            vtkUnstructuredGrid unstructuredGrid1 = vtkUnstructuredGrid.New();

            unstructuredGrid1.SetPoints(points);

            int[]  ptIds        = new int[] { 0, 1, 2, 3 };
            IntPtr ptIdsPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * 4);

            Marshal.Copy(ptIds, 0, ptIdsPointer, 4);
            unstructuredGrid1.InsertNextCell(10, 4, ptIdsPointer);
            Marshal.FreeHGlobal(ptIdsPointer);

            // Method 2
            vtkUnstructuredGrid unstructuredGrid2 = vtkUnstructuredGrid.New();

            unstructuredGrid2.SetPoints(points);

            vtkTetra tetra = vtkTetra.New();

            tetra.GetPointIds().SetId(0, 4);
            tetra.GetPointIds().SetId(1, 5);
            tetra.GetPointIds().SetId(2, 6);
            tetra.GetPointIds().SetId(3, 7);

            vtkCellArray cellArray = vtkCellArray.New();

            cellArray.InsertNextCell(tetra);
            unstructuredGrid2.SetCells(10, cellArray);

            // Create a mapper and actor
            vtkDataSetMapper mapper1 = vtkDataSetMapper.New();

            mapper1.SetInputConnection(unstructuredGrid1.GetProducerPort());

            vtkActor actor1 = vtkActor.New();

            actor1.SetMapper(mapper1);

            // Create a mapper and actor
            vtkDataSetMapper mapper2 = vtkDataSetMapper.New();

            mapper2.SetInputConnection(unstructuredGrid2.GetProducerPort());

            vtkActor actor2 = vtkActor.New();

            actor2.SetMapper(mapper2);

            vtkRenderWindow renderWindow = myRenderWindowControl.RenderWindow;
            vtkRenderer     renderer     = renderWindow.GetRenderers().GetFirstRenderer();

            renderer.SetBackground(0.2, 0.3, 0.4);
            // Add the actor to the scene
            renderer.AddActor(actor1);
            renderer.AddActor(actor2);
            renderer.SetBackground(.3, .6, .3); // Background color green
        }
예제 #41
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetpixelPoints(vtkPoints toSet)
 {
     pixelPoints = toSet;
 }
예제 #42
0
        private void WritePolyData()
        {
            // Path to vtk data must be set as an environment variable
            // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0"
            vtkTesting test     = vtkTesting.New();
            string     root     = test.GetDataRoot();
            string     filePath = System.IO.Path.Combine(root, @"Data\poly_test.vtp");
            // Create 4 points for a tetrahedron
            vtkPoints points = vtkPoints.New();

            points.InsertNextPoint(0, 0, 0);
            points.InsertNextPoint(0, 0, 1);
            points.InsertNextPoint(1, 0, 0);
            points.InsertNextPoint(0, 1, 0);

            // Create a polydata object and add the points to it.
            vtkPolyData polydata = vtkPolyData.New();

            polydata.SetPoints(points);

            // it's not enough only to define points
            // we need to define faces too
            // (must be defined in counter clockwise order as viewed from the outside)
            vtkTriangle face0 = vtkTriangle.New();

            face0.GetPointIds().SetId(0, 0);
            face0.GetPointIds().SetId(1, 2);
            face0.GetPointIds().SetId(2, 1);
            vtkTriangle face1 = vtkTriangle.New();

            face1.GetPointIds().SetId(0, 0);
            face1.GetPointIds().SetId(1, 3);
            face1.GetPointIds().SetId(2, 2);
            vtkTriangle face2 = vtkTriangle.New();

            face2.GetPointIds().SetId(0, 0);
            face2.GetPointIds().SetId(1, 1);
            face2.GetPointIds().SetId(2, 3);
            vtkTriangle face3 = vtkTriangle.New();

            face3.GetPointIds().SetId(0, 1);
            face3.GetPointIds().SetId(1, 2);
            face3.GetPointIds().SetId(2, 3);

            vtkCellArray faces = vtkCellArray.New();

            faces.InsertNextCell(face0);
            faces.InsertNextCell(face1);
            faces.InsertNextCell(face2);
            faces.InsertNextCell(face3);

            polydata.SetPolys(faces);

            // Write the file
            vtkXMLPolyDataWriter writer = vtkXMLPolyDataWriter.New();

            writer.SetFileName(filePath);
            writer.SetInput(polydata);

            // Optional - set the mode. The default is binary.
            //writer.SetDataModeToBinary();
            writer.SetDataModeToAscii();
            writer.Write();

            // Read and display file for verification that it was written correctly
            vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New();

            if (reader.CanReadFile(filePath) == 0)
            {
                MessageBox.Show("Cannot read file \"" + filePath + "\"", "Error", MessageBoxButtons.OK);
                return;
            }
            reader.SetFileName(filePath);
            reader.Update();

            vtkDataSetMapper mapper = vtkDataSetMapper.New();

            mapper.SetInputConnection(reader.GetOutputPort());

            // actor
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            // 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.2, 0.3, 0.4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
예제 #43
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetpolyVertexPoints(vtkPoints toSet)
 {
     polyVertexPoints = toSet;
 }
예제 #44
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetvertexPoints(vtkPoints toSet)
 {
     vertexPoints = toSet;
 }
예제 #45
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetquadPoints(vtkPoints toSet)
 {
     quadPoints = toSet;
 }
예제 #46
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetwedgePoints(vtkPoints toSet)
 {
     wedgePoints = toSet;
 }
예제 #47
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SettriangleStripPoints(vtkPoints toSet)
 {
     triangleStripPoints = toSet;
 }
        private void BandedPolyDataContourFilter()
        {
            vtkPoints pts = vtkPoints.New();

            pts.InsertPoint(0, 0, 0, 0);
            pts.InsertPoint(1, 0, 1, 0);
            pts.InsertPoint(2, 0, 2, 0);
            pts.InsertPoint(3, 1, 0, 0);
            pts.InsertPoint(4, 1, 1, 0);
            pts.InsertPoint(5, 1, 2, 0);
            pts.InsertPoint(6, 2, 0, 0);
            pts.InsertPoint(7, 2, 2, 0);
            pts.InsertPoint(8, 3, 0, 0);
            pts.InsertPoint(9, 3, 1, 0);
            pts.InsertPoint(10, 3, 2, 0);
            pts.InsertPoint(11, 4, 0, 0);
            pts.InsertPoint(12, 6, 0, 0);
            pts.InsertPoint(13, 5, 2, 0);
            pts.InsertPoint(14, 7, 0, 0);
            pts.InsertPoint(15, 9, 0, 0);
            pts.InsertPoint(16, 7, 2, 0);
            pts.InsertPoint(17, 9, 2, 0);
            pts.InsertPoint(18, 10, 0, 0);
            pts.InsertPoint(19, 12, 0, 0);
            pts.InsertPoint(20, 10, 1, 0);
            pts.InsertPoint(21, 12, 1, 0);
            pts.InsertPoint(22, 10, 2, 0);
            pts.InsertPoint(23, 12, 2, 0);
            pts.InsertPoint(24, 10, 3, 0);
            pts.InsertPoint(25, 12, 3, 0);

            vtkCellArray polys = vtkCellArray.New();

            polys.InsertNextCell(4);
            polys.InsertCellPoint(14);
            polys.InsertCellPoint(15);
            polys.InsertCellPoint(17);
            polys.InsertCellPoint(16);
            polys.InsertNextCell(3);
            polys.InsertCellPoint(11);
            polys.InsertCellPoint(12);
            polys.InsertCellPoint(13);

            vtkFloatArray scalars = vtkFloatArray.New();

            scalars.SetNumberOfTuples(26);
            scalars.SetTuple1(0, 0);
            scalars.SetTuple1(1, 50);
            scalars.SetTuple1(2, 100);
            scalars.SetTuple1(3, 0);
            scalars.SetTuple1(4, 50);
            scalars.SetTuple1(5, 100);
            scalars.SetTuple1(6, 10);
            scalars.SetTuple1(7, 90);
            scalars.SetTuple1(8, 10);
            scalars.SetTuple1(9, 50);
            scalars.SetTuple1(10, 90);
            scalars.SetTuple1(11, 10);
            scalars.SetTuple1(12, 40);
            scalars.SetTuple1(13, 100);
            scalars.SetTuple1(14, 0);
            scalars.SetTuple1(15, 60);
            scalars.SetTuple1(16, 40);
            scalars.SetTuple1(17, 100);
            scalars.SetTuple1(18, 0);
            scalars.SetTuple1(19, 25);
            scalars.SetTuple1(20, 25);
            scalars.SetTuple1(21, 50);
            scalars.SetTuple1(22, 50);
            scalars.SetTuple1(23, 75);
            scalars.SetTuple1(24, 75);
            scalars.SetTuple1(25, 100);

            vtkPolyData polyData = vtkPolyData.New();

            polyData.SetPoints(pts);
            polyData.SetPolys(polys);
            polyData.GetPointData().SetScalars(scalars);

            vtkBandedPolyDataContourFilter bf = vtkBandedPolyDataContourFilter.New();

#if VTK_MAJOR_VERSION_5
            bf.SetInput(polyData);
#else
            bf.SetInputData(polyData);
#endif
            bf.GenerateValues(3, 25, 75);

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
            mapper.SetInputConnection(bf.GetOutputPort());
            mapper.SetScalarModeToUseCellData();
            mapper.SetScalarRange(0, 4);
            vtkActor actor = vtkActor.New();
            actor.SetMapper(mapper);

            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;
            // renderer
            vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer();
            // set background color
            renderer.SetBackground(.2, .3, .4);
            // add our actor to the renderer
            renderer.AddActor(actor);
        }
예제 #49
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void SetvoxelPoints(vtkPoints toSet)
 {
     voxelPoints = toSet;
 }
예제 #50
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVSelectionLoop(String [] argv)
    {
        //Prefix Content is: ""

          //[]
          // Demonstrate the use of implicit selection loop as well as closest point[]
          // connectivity[]
          //[]
          // create pipeline[]
          //[]
          sphere = new vtkSphereSource();
          sphere.SetRadius((double)1);
          sphere.SetPhiResolution((int)100);
          sphere.SetThetaResolution((int)100);
          selectionPoints = new vtkPoints();
          selectionPoints.InsertPoint((int)0,(double)0.07325,(double)0.8417,(double)0.5612);
          selectionPoints.InsertPoint((int)1,(double)0.07244,(double)0.6568,(double)0.7450);
          selectionPoints.InsertPoint((int)2,(double)0.1727,(double)0.4597,(double)0.8850);
          selectionPoints.InsertPoint((int)3,(double)0.3265,(double)0.6054,(double)0.7309);
          selectionPoints.InsertPoint((int)4,(double)0.5722,(double)0.5848,(double)0.5927);
          selectionPoints.InsertPoint((int)5,(double)0.4305,(double)0.8138,(double)0.4189);
          loop = new vtkImplicitSelectionLoop();
          loop.SetLoop((vtkPoints)selectionPoints);
          extract = new vtkExtractGeometry();
          extract.SetInputConnection((vtkAlgorithmOutput)sphere.GetOutputPort());
          extract.SetImplicitFunction((vtkImplicitFunction)loop);
          connect = new vtkConnectivityFilter();
          connect.SetInputConnection((vtkAlgorithmOutput)extract.GetOutputPort());
          connect.SetExtractionModeToClosestPointRegion();
          connect.SetClosestPoint((double)selectionPoints.GetPoint((int)0)[0], (double)selectionPoints.GetPoint((int)0)[1],(double)selectionPoints.GetPoint((int)0)[2]);
          clipMapper = new vtkDataSetMapper();
          clipMapper.SetInputConnection((vtkAlgorithmOutput)connect.GetOutputPort());
          backProp = new vtkProperty();
          backProp.SetDiffuseColor((double) 1.0000, 0.3882, 0.2784 );
          clipActor = new vtkActor();
          clipActor.SetMapper((vtkMapper)clipMapper);
          clipActor.GetProperty().SetColor((double) 0.2000, 0.6300, 0.7900 );
          clipActor.SetBackfaceProperty((vtkProperty)backProp);
          // Create graphics stuff[]
          //[]
          ren1 = vtkRenderer.New();
          renWin = vtkRenderWindow.New();
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          // Add the actors to the renderer, set the background and size[]
          //[]
          ren1.AddActor((vtkProp)clipActor);
          ren1.SetBackground((double)1,(double)1,(double)1);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Azimuth((double)30);
          ren1.GetActiveCamera().Elevation((double)30);
          ren1.GetActiveCamera().Dolly((double)1.2);
          ren1.ResetCameraClippingRange();
          renWin.SetSize((int)400,(int)400);
          renWin.Render();
          // render the image[]
          //[]
          // prevent the tk window from showing up then start the event loop[]

        //deleteAllVTKObjects();
    }
예제 #51
0
        /// <summary>
        /// Update Boundary Condition actor (arrows) in Viewport
        /// </summary>
        public void Update_Arrows(Dictionary <int, Node> NodeLib, double scale, int Step, bool ClipMode)
        {
            vtkPoints PointsX = vtkPoints.New();
            vtkPoints PointsY = vtkPoints.New();
            vtkPoints PointsZ = vtkPoints.New();

            // Create Cone Sources for X, Y and Z direction
            vtkConeSource ConeSourceX = vtkConeSource.New();
            vtkConeSource ConeSourceY = vtkConeSource.New();
            vtkConeSource ConeSourceZ = vtkConeSource.New();

            ConeSourceX.SetAngle(15);
            ConeSourceX.SetHeight(scale);
            ConeSourceX.SetRadius(scale / 4);
            ConeSourceX.SetResolution(12);
            ConeSourceX.SetDirection(1, 0, 0);

            ConeSourceY.SetAngle(15);
            ConeSourceY.SetHeight(scale);
            ConeSourceY.SetRadius(scale / 4);
            ConeSourceY.SetResolution(12);
            ConeSourceY.SetDirection(0, 1, 0);

            ConeSourceZ.SetAngle(15);
            ConeSourceZ.SetHeight(scale);
            ConeSourceZ.SetRadius(scale / 4);
            ConeSourceZ.SetResolution(12);
            ConeSourceZ.SetDirection(0, 0, 1);

            // Create Points
            foreach (int i in NodalValues.Keys)
            {
                double X = NodeLib[i].X + NodeLib[i].GetDisp(Step, 0);
                double Y = NodeLib[i].Y + NodeLib[i].GetDisp(Step, 1);
                double Z = NodeLib[i].Z + NodeLib[i].GetDisp(Step, 2);

                if (NodalValues[i].Get(0, 0) != 0)
                {
                    PointsX.InsertNextPoint(X - scale / 2, Y, Z);
                }
                if (NodalValues[i].Get(1, 0) != 0)
                {
                    PointsY.InsertNextPoint(X, Y - scale / 2, Z);
                }
                if (NodalValues[i].Get(2, 0) != 0)
                {
                    PointsZ.InsertNextPoint(X, Y, Z - scale / 2);
                }
            }

            // Set Points to PolyData
            vtkPolyData PolyX = vtkPolyData.New(); PolyX.SetPoints(PointsX);
            vtkPolyData PolyY = vtkPolyData.New(); PolyY.SetPoints(PointsY);
            vtkPolyData PolyZ = vtkPolyData.New(); PolyZ.SetPoints(PointsZ);

            // Create Glyphs 3D
            GlyphX = vtkGlyph3D.New();
            GlyphY = vtkGlyph3D.New();
            GlyphZ = vtkGlyph3D.New();

            GlyphX.SetSourceConnection(ConeSourceX.GetOutputPort());
            GlyphX.SetInput(PolyX);
            GlyphX.Update();

            GlyphY.SetSourceConnection(ConeSourceY.GetOutputPort());
            GlyphY.SetInput(PolyY);
            GlyphY.Update();

            GlyphZ.SetSourceConnection(ConeSourceZ.GetOutputPort());
            GlyphZ.SetInput(PolyZ);
            GlyphZ.Update();

            // Set Mapper based on Clip Mode
            if (ClipMode == true)
            {
                // Add Clippers to Mapper
                ClipperX.SetInputConnection(GlyphX.GetOutputPort());
                ClipperX.Update();
                MapperX.SetInputConnection(ClipperX.GetOutputPort());
                MapperX.Update();

                ClipperY.SetInputConnection(GlyphY.GetOutputPort());
                ClipperY.Update();
                MapperY.SetInputConnection(ClipperY.GetOutputPort());
                MapperY.Update();

                ClipperZ.SetInputConnection(GlyphZ.GetOutputPort());
                ClipperZ.Update();
                MapperZ.SetInputConnection(ClipperZ.GetOutputPort());
                MapperZ.Update();
            }
            else
            {
                // Add Glyphs to Mapper
                MapperX.SetInputConnection(GlyphX.GetOutputPort());
                MapperY.SetInputConnection(GlyphY.GetOutputPort());
                MapperZ.SetInputConnection(GlyphZ.GetOutputPort());
                MapperX.Update();
                MapperY.Update();
                MapperZ.Update();
            }

            // Update Actor color
            ActorX.GetProperty().SetColor(
                GetColor()[0] / 255.0,
                GetColor()[1] / 255.0,
                GetColor()[2] / 255.0);

            ActorY.GetProperty().SetColor(
                GetColor()[0] / 255.0,
                GetColor()[1] / 255.0,
                GetColor()[2] / 255.0);

            ActorZ.GetProperty().SetColor(
                GetColor()[0] / 255.0,
                GetColor()[1] / 255.0,
                GetColor()[2] / 255.0);
        }
예제 #52
0
    /// <summary>
    /// Entry Point
    /// </summary>
    /// <param name="argv"></param>
    public static void Main(String[] argv)
    {
        // This example demonstrates how to use 2D Delaunay triangulation.
        // We create a fancy image of a 2D Delaunay triangulation. Points are
        // randomly generated.
        // first we load in the standard vtk packages into tcl
        // Generate some random points
        math = vtkMath.New();
        points = vtkPoints.New();
        for(int i = 0; i < 50; i++)
        {
            points.InsertPoint(i, vtkMath.Random(0, 1), vtkMath.Random(0, 1), 0.0);
        }

        // Create a polydata with the points we just created.
        profile = vtkPolyData.New();
        profile.SetPoints(points);

        // Perform a 2D Delaunay triangulation on them.
        del = vtkDelaunay2D.New();
        del.SetInput(profile);
        del.SetTolerance(0.001);

        mapMesh = vtkPolyDataMapper.New();
        mapMesh.SetInputConnection(del.GetOutputPort());

        meshActor = vtkActor.New();
        meshActor.SetMapper(mapMesh);
        meshActor.GetProperty().SetColor(.1, .2, .4);

        // We will now create a nice looking mesh by wrapping the edges in tubes,
        // and putting fat spheres at the points.
        extract = vtkExtractEdges.New();
        extract.SetInputConnection(del.GetOutputPort());

        tubes = vtkTubeFilter.New();
        tubes.SetInputConnection(extract.GetOutputPort());
        tubes.SetRadius(0.01);
        tubes.SetNumberOfSides(6);

        mapEdges = vtkPolyDataMapper.New();
        mapEdges.SetInputConnection(tubes.GetOutputPort());

        edgeActor = vtkActor.New();
        edgeActor.SetMapper(mapEdges);
        edgeActor.GetProperty().SetColor(0.2000, 0.6300, 0.7900);
        edgeActor.GetProperty().SetSpecularColor(1, 1, 1);
        edgeActor.GetProperty().SetSpecular(0.3);
        edgeActor.GetProperty().SetSpecularPower(20);
        edgeActor.GetProperty().SetAmbient(0.2);
        edgeActor.GetProperty().SetDiffuse(0.8);

        ball = vtkSphereSource.New();
        ball.SetRadius(0.025);
        ball.SetThetaResolution(12);
        ball.SetPhiResolution(12);

        balls = vtkGlyph3D.New();
        balls.SetInputConnection(del.GetOutputPort());
        balls.SetSourceConnection(ball.GetOutputPort());

        mapBalls = vtkPolyDataMapper.New();
        mapBalls.SetInputConnection(balls.GetOutputPort());

        ballActor = vtkActor.New();
        ballActor.SetMapper(mapBalls);
        ballActor.GetProperty().SetColor(1.0000, 0.4118, 0.7059);
        ballActor.GetProperty().SetSpecularColor(1, 1, 1);
        ballActor.GetProperty().SetSpecular(0.3);
        ballActor.GetProperty().SetSpecularPower(20);
        ballActor.GetProperty().SetAmbient(0.2);
        ballActor.GetProperty().SetDiffuse(0.8);

        // Create graphics objects
        // Create the rendering window, renderer, and interactive renderer
        ren1 = vtkRenderer.New();
        renWin = vtkRenderWindow.New();
        renWin.AddRenderer(ren1);
        iren = vtkRenderWindowInteractor.New();
        iren.SetRenderWindow(renWin);

        // Add the actors to the renderer, set the background and size
        ren1.AddActor(ballActor);
        ren1.AddActor(edgeActor);
        ren1.SetBackground(1, 1, 1);
        renWin.SetSize(150, 150);

        // render the image
        ren1.ResetCamera();
        ren1.GetActiveCamera().Zoom(1.5);
        iren.Initialize();
        iren.Start();

        // Clean Up
        deleteAllVTKObjects();
    }
예제 #53
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            vtkPoints points = vtkPoints.New();

            int GridSize = 10;

            for (int x = 0; x < GridSize; x++)
            {
                for (int y = 0; y < GridSize; y++)
                {
                    points.InsertNextPoint(x, y, (x + y) / (y + 1));
                }
            }

            // Add the grid points to a polydata object
            vtkPolyData polydata = vtkPolyData.New();

            polydata.SetPoints(points);

            // Triangulate the grid points
            vtkDelaunay2D delaunay = vtkDelaunay2D.New();

            delaunay.SetInput(polydata);
            delaunay.Update();

            vtkPlaneSource plane = vtkPlaneSource.New();

            //Read the image data from a file
            vtkJPEGReader reader = vtkJPEGReader.New();

            reader.SetFileName("C:\\Users\\georg\\Desktop\\texture.jpg");

            //Create texture object
            vtkTexture texture = vtkTexture.New();

            texture.SetInputConnection(reader.GetOutputPort());

            //Map texture coordinates
            vtkTextureMapToPlane map_to_plane = vtkTextureMapToPlane.New();

            map_to_plane.SetInputConnection(plane.GetOutputPort());
            map_to_plane.SetInputConnection(delaunay.GetOutputPort());

            //Create mapper and set the mapped texture as input
            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(map_to_plane.GetOutputPort());

            //Create actor and set the mapper and the texture
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);
            actor.SetTexture(texture);

            vtkRenderer renderer = vtkRenderer.New();

            renderer.AddActor(actor);


            RenderControl1.RenderWindow.AddRenderer(renderer);
        }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVLineIntersectQuadraticCells(String [] argv)
    {
        //Prefix Content is: ""

          // Contour every quadratic cell type[]
          // Create a scene with one of each cell type.[]
          // QuadraticEdge[]
          edgePoints = new vtkPoints();
          edgePoints.SetNumberOfPoints((int)3);
          edgePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          edgePoints.InsertPoint((int)1,(double)1.0,(double)0,(double)0);
          edgePoints.InsertPoint((int)2,(double)0.5,(double)0.25,(double)0);
          edgeScalars = new vtkFloatArray();
          edgeScalars.SetNumberOfTuples((int)3);
          edgeScalars.InsertValue((int)0,(float)0.0);
          edgeScalars.InsertValue((int)1,(float)0.0);
          edgeScalars.InsertValue((int)2,(float)0.9);
          aEdge = new vtkQuadraticEdge();
          aEdge.GetPointIds().SetId((int)0,(int)0);
          aEdge.GetPointIds().SetId((int)1,(int)1);
          aEdge.GetPointIds().SetId((int)2,(int)2);
          aEdgeGrid = new vtkUnstructuredGrid();
          aEdgeGrid.Allocate((int)1,(int)1);
          aEdgeGrid.InsertNextCell((int)aEdge.GetCellType(),(vtkIdList)aEdge.GetPointIds());
          aEdgeGrid.SetPoints((vtkPoints)edgePoints);
          aEdgeGrid.GetPointData().SetScalars((vtkDataArray)edgeScalars);
          aEdgeMapper = new vtkDataSetMapper();
          aEdgeMapper.SetInputData((vtkDataSet)aEdgeGrid);
          aEdgeMapper.ScalarVisibilityOff();
          aEdgeActor = new vtkActor();
          aEdgeActor.SetMapper((vtkMapper)aEdgeMapper);
          aEdgeActor.GetProperty().SetRepresentationToWireframe();
          aEdgeActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic triangle[]
          triPoints = new vtkPoints();
          triPoints.SetNumberOfPoints((int)6);
          triPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          triPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0);
          triPoints.InsertPoint((int)2,(double)0.5,(double)0.8,(double)0.0);
          triPoints.InsertPoint((int)3,(double)0.5,(double)0.0,(double)0.0);
          triPoints.InsertPoint((int)4,(double)0.75,(double)0.4,(double)0.0);
          triPoints.InsertPoint((int)5,(double)0.25,(double)0.4,(double)0.0);
          triScalars = new vtkFloatArray();
          triScalars.SetNumberOfTuples((int)6);
          triScalars.InsertValue((int)0,(float)0.0);
          triScalars.InsertValue((int)1,(float)0.0);
          triScalars.InsertValue((int)2,(float)0.0);
          triScalars.InsertValue((int)3,(float)1.0);
          triScalars.InsertValue((int)4,(float)0.0);
          triScalars.InsertValue((int)5,(float)0.0);
          aTri = new vtkQuadraticTriangle();
          aTri.GetPointIds().SetId((int)0,(int)0);
          aTri.GetPointIds().SetId((int)1,(int)1);
          aTri.GetPointIds().SetId((int)2,(int)2);
          aTri.GetPointIds().SetId((int)3,(int)3);
          aTri.GetPointIds().SetId((int)4,(int)4);
          aTri.GetPointIds().SetId((int)5,(int)5);
          aTriGrid = new vtkUnstructuredGrid();
          aTriGrid.Allocate((int)1,(int)1);
          aTriGrid.InsertNextCell((int)aTri.GetCellType(),(vtkIdList)aTri.GetPointIds());
          aTriGrid.SetPoints((vtkPoints)triPoints);
          aTriGrid.GetPointData().SetScalars((vtkDataArray)triScalars);
          aTriMapper = new vtkDataSetMapper();
          aTriMapper.SetInputData((vtkDataSet)aTriGrid);
          aTriMapper.ScalarVisibilityOff();
          aTriActor = new vtkActor();
          aTriActor.SetMapper((vtkMapper)aTriMapper);
          aTriActor.GetProperty().SetRepresentationToWireframe();
          aTriActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic quadrilateral[]
          quadPoints = new vtkPoints();
          quadPoints.SetNumberOfPoints((int)8);
          quadPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          quadPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0);
          quadPoints.InsertPoint((int)2,(double)1.0,(double)1.0,(double)0.0);
          quadPoints.InsertPoint((int)3,(double)0.0,(double)1.0,(double)0.0);
          quadPoints.InsertPoint((int)4,(double)0.5,(double)0.0,(double)0.0);
          quadPoints.InsertPoint((int)5,(double)1.0,(double)0.5,(double)0.0);
          quadPoints.InsertPoint((int)6,(double)0.5,(double)1.0,(double)0.0);
          quadPoints.InsertPoint((int)7,(double)0.0,(double)0.5,(double)0.0);
          quadScalars = new vtkFloatArray();
          quadScalars.SetNumberOfTuples((int)8);
          quadScalars.InsertValue((int)0,(float)0.0);
          quadScalars.InsertValue((int)1,(float)0.0);
          quadScalars.InsertValue((int)2,(float)1.0);
          quadScalars.InsertValue((int)3,(float)1.0);
          quadScalars.InsertValue((int)4,(float)1.0);
          quadScalars.InsertValue((int)5,(float)0.0);
          quadScalars.InsertValue((int)6,(float)0.0);
          quadScalars.InsertValue((int)7,(float)0.0);
          aQuad = new vtkQuadraticQuad();
          aQuad.GetPointIds().SetId((int)0,(int)0);
          aQuad.GetPointIds().SetId((int)1,(int)1);
          aQuad.GetPointIds().SetId((int)2,(int)2);
          aQuad.GetPointIds().SetId((int)3,(int)3);
          aQuad.GetPointIds().SetId((int)4,(int)4);
          aQuad.GetPointIds().SetId((int)5,(int)5);
          aQuad.GetPointIds().SetId((int)6,(int)6);
          aQuad.GetPointIds().SetId((int)7,(int)7);
          aQuadGrid = new vtkUnstructuredGrid();
          aQuadGrid.Allocate((int)1,(int)1);
          aQuadGrid.InsertNextCell((int)aQuad.GetCellType(),(vtkIdList)aQuad.GetPointIds());
          aQuadGrid.SetPoints((vtkPoints)quadPoints);
          aQuadGrid.GetPointData().SetScalars((vtkDataArray)quadScalars);
          aQuadMapper = new vtkDataSetMapper();
          aQuadMapper.SetInputData((vtkDataSet)aQuadGrid);
          aQuadMapper.ScalarVisibilityOff();
          aQuadActor = new vtkActor();
          aQuadActor.SetMapper((vtkMapper)aQuadMapper);
          aQuadActor.GetProperty().SetRepresentationToWireframe();
          aQuadActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic tetrahedron[]
          tetPoints = new vtkPoints();
          tetPoints.SetNumberOfPoints((int)10);
          tetPoints.InsertPoint((int)0,(double)0.0,(double)0.0,(double)0.0);
          tetPoints.InsertPoint((int)1,(double)1.0,(double)0.0,(double)0.0);
          tetPoints.InsertPoint((int)2,(double)0.5,(double)0.8,(double)0.0);
          tetPoints.InsertPoint((int)3,(double)0.5,(double)0.4,(double)1.0);
          tetPoints.InsertPoint((int)4,(double)0.5,(double)0.0,(double)0.0);
          tetPoints.InsertPoint((int)5,(double)0.75,(double)0.4,(double)0.0);
          tetPoints.InsertPoint((int)6,(double)0.25,(double)0.4,(double)0.0);
          tetPoints.InsertPoint((int)7,(double)0.25,(double)0.2,(double)0.5);
          tetPoints.InsertPoint((int)8,(double)0.75,(double)0.2,(double)0.5);
          tetPoints.InsertPoint((int)9,(double)0.50,(double)0.6,(double)0.5);
          tetScalars = new vtkFloatArray();
          tetScalars.SetNumberOfTuples((int)10);
          tetScalars.InsertValue((int)0,(float)1.0);
          tetScalars.InsertValue((int)1,(float)1.0);
          tetScalars.InsertValue((int)2,(float)1.0);
          tetScalars.InsertValue((int)3,(float)1.0);
          tetScalars.InsertValue((int)4,(float)0.0);
          tetScalars.InsertValue((int)5,(float)0.0);
          tetScalars.InsertValue((int)6,(float)0.0);
          tetScalars.InsertValue((int)7,(float)0.0);
          tetScalars.InsertValue((int)8,(float)0.0);
          tetScalars.InsertValue((int)9,(float)0.0);
          aTet = new vtkQuadraticTetra();
          aTet.GetPointIds().SetId((int)0,(int)0);
          aTet.GetPointIds().SetId((int)1,(int)1);
          aTet.GetPointIds().SetId((int)2,(int)2);
          aTet.GetPointIds().SetId((int)3,(int)3);
          aTet.GetPointIds().SetId((int)4,(int)4);
          aTet.GetPointIds().SetId((int)5,(int)5);
          aTet.GetPointIds().SetId((int)6,(int)6);
          aTet.GetPointIds().SetId((int)7,(int)7);
          aTet.GetPointIds().SetId((int)8,(int)8);
          aTet.GetPointIds().SetId((int)9,(int)9);
          aTetGrid = new vtkUnstructuredGrid();
          aTetGrid.Allocate((int)1,(int)1);
          aTetGrid.InsertNextCell((int)aTet.GetCellType(),(vtkIdList)aTet.GetPointIds());
          aTetGrid.SetPoints((vtkPoints)tetPoints);
          aTetGrid.GetPointData().SetScalars((vtkDataArray)tetScalars);
          aTetMapper = new vtkDataSetMapper();
          aTetMapper.SetInputData((vtkDataSet)aTetGrid);
          aTetMapper.ScalarVisibilityOff();
          aTetActor = new vtkActor();
          aTetActor.SetMapper((vtkMapper)aTetMapper);
          aTetActor.GetProperty().SetRepresentationToWireframe();
          aTetActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic hexahedron[]
          hexPoints = new vtkPoints();
          hexPoints.SetNumberOfPoints((int)20);
          hexPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          hexPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          hexPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          hexPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          hexPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          hexPoints.InsertPoint((int)5,(double)1,(double)0,(double)1);
          hexPoints.InsertPoint((int)6,(double)1,(double)1,(double)1);
          hexPoints.InsertPoint((int)7,(double)0,(double)1,(double)1);
          hexPoints.InsertPoint((int)8,(double)0.5,(double)0,(double)0);
          hexPoints.InsertPoint((int)9,(double)1,(double)0.5,(double)0);
          hexPoints.InsertPoint((int)10,(double)0.5,(double)1,(double)0);
          hexPoints.InsertPoint((int)11,(double)0,(double)0.5,(double)0);
          hexPoints.InsertPoint((int)12,(double)0.5,(double)0,(double)1);
          hexPoints.InsertPoint((int)13,(double)1,(double)0.5,(double)1);
          hexPoints.InsertPoint((int)14,(double)0.5,(double)1,(double)1);
          hexPoints.InsertPoint((int)15,(double)0,(double)0.5,(double)1);
          hexPoints.InsertPoint((int)16,(double)0,(double)0,(double)0.5);
          hexPoints.InsertPoint((int)17,(double)1,(double)0,(double)0.5);
          hexPoints.InsertPoint((int)18,(double)1,(double)1,(double)0.5);
          hexPoints.InsertPoint((int)19,(double)0,(double)1,(double)0.5);
          hexScalars = new vtkFloatArray();
          hexScalars.SetNumberOfTuples((int)20);
          hexScalars.InsertValue((int)0,(float)1.0);
          hexScalars.InsertValue((int)1,(float)1.0);
          hexScalars.InsertValue((int)2,(float)1.0);
          hexScalars.InsertValue((int)3,(float)1.0);
          hexScalars.InsertValue((int)4,(float)1.0);
          hexScalars.InsertValue((int)5,(float)1.0);
          hexScalars.InsertValue((int)6,(float)1.0);
          hexScalars.InsertValue((int)7,(float)1.0);
          hexScalars.InsertValue((int)8,(float)0.0);
          hexScalars.InsertValue((int)9,(float)0.0);
          hexScalars.InsertValue((int)10,(float)0.0);
          hexScalars.InsertValue((int)11,(float)0.0);
          hexScalars.InsertValue((int)12,(float)0.0);
          hexScalars.InsertValue((int)13,(float)0.0);
          hexScalars.InsertValue((int)14,(float)0.0);
          hexScalars.InsertValue((int)15,(float)0.0);
          hexScalars.InsertValue((int)16,(float)0.0);
          hexScalars.InsertValue((int)17,(float)0.0);
          hexScalars.InsertValue((int)18,(float)0.0);
          hexScalars.InsertValue((int)19,(float)0.0);
          aHex = new vtkQuadraticHexahedron();
          aHex.GetPointIds().SetId((int)0,(int)0);
          aHex.GetPointIds().SetId((int)1,(int)1);
          aHex.GetPointIds().SetId((int)2,(int)2);
          aHex.GetPointIds().SetId((int)3,(int)3);
          aHex.GetPointIds().SetId((int)4,(int)4);
          aHex.GetPointIds().SetId((int)5,(int)5);
          aHex.GetPointIds().SetId((int)6,(int)6);
          aHex.GetPointIds().SetId((int)7,(int)7);
          aHex.GetPointIds().SetId((int)8,(int)8);
          aHex.GetPointIds().SetId((int)9,(int)9);
          aHex.GetPointIds().SetId((int)10,(int)10);
          aHex.GetPointIds().SetId((int)11,(int)11);
          aHex.GetPointIds().SetId((int)12,(int)12);
          aHex.GetPointIds().SetId((int)13,(int)13);
          aHex.GetPointIds().SetId((int)14,(int)14);
          aHex.GetPointIds().SetId((int)15,(int)15);
          aHex.GetPointIds().SetId((int)16,(int)16);
          aHex.GetPointIds().SetId((int)17,(int)17);
          aHex.GetPointIds().SetId((int)18,(int)18);
          aHex.GetPointIds().SetId((int)19,(int)19);
          aHexGrid = new vtkUnstructuredGrid();
          aHexGrid.Allocate((int)1,(int)1);
          aHexGrid.InsertNextCell((int)aHex.GetCellType(),(vtkIdList)aHex.GetPointIds());
          aHexGrid.SetPoints((vtkPoints)hexPoints);
          aHexGrid.GetPointData().SetScalars((vtkDataArray)hexScalars);
          aHexMapper = new vtkDataSetMapper();
          aHexMapper.SetInputData((vtkDataSet)aHexGrid);
          aHexMapper.ScalarVisibilityOff();
          aHexActor = new vtkActor();
          aHexActor.SetMapper((vtkMapper)aHexMapper);
          aHexActor.GetProperty().SetRepresentationToWireframe();
          aHexActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic wedge[]
          wedgePoints = new vtkPoints();
          wedgePoints.SetNumberOfPoints((int)15);
          wedgePoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          wedgePoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          wedgePoints.InsertPoint((int)2,(double)0,(double)1,(double)0);
          wedgePoints.InsertPoint((int)3,(double)0,(double)0,(double)1);
          wedgePoints.InsertPoint((int)4,(double)1,(double)0,(double)1);
          wedgePoints.InsertPoint((int)5,(double)0,(double)1,(double)1);
          wedgePoints.InsertPoint((int)6,(double)0.5,(double)0,(double)0);
          wedgePoints.InsertPoint((int)7,(double)0.5,(double)0.5,(double)0);
          wedgePoints.InsertPoint((int)8,(double)0,(double)0.5,(double)0);
          wedgePoints.InsertPoint((int)9,(double)0.5,(double)0,(double)1);
          wedgePoints.InsertPoint((int)10,(double)0.5,(double)0.5,(double)1);
          wedgePoints.InsertPoint((int)11,(double)0,(double)0.5,(double)1);
          wedgePoints.InsertPoint((int)12,(double)0,(double)0,(double)0.5);
          wedgePoints.InsertPoint((int)13,(double)1,(double)0,(double)0.5);
          wedgePoints.InsertPoint((int)14,(double)0,(double)1,(double)0.5);
          wedgeScalars = new vtkFloatArray();
          wedgeScalars.SetNumberOfTuples((int)15);
          wedgeScalars.InsertValue((int)0,(float)1.0);
          wedgeScalars.InsertValue((int)1,(float)1.0);
          wedgeScalars.InsertValue((int)2,(float)1.0);
          wedgeScalars.InsertValue((int)3,(float)1.0);
          wedgeScalars.InsertValue((int)4,(float)1.0);
          wedgeScalars.InsertValue((int)5,(float)1.0);
          wedgeScalars.InsertValue((int)6,(float)1.0);
          wedgeScalars.InsertValue((int)7,(float)1.0);
          wedgeScalars.InsertValue((int)8,(float)0.0);
          wedgeScalars.InsertValue((int)9,(float)0.0);
          wedgeScalars.InsertValue((int)10,(float)0.0);
          wedgeScalars.InsertValue((int)11,(float)0.0);
          wedgeScalars.InsertValue((int)12,(float)0.0);
          wedgeScalars.InsertValue((int)13,(float)0.0);
          wedgeScalars.InsertValue((int)14,(float)0.0);
          aWedge = new vtkQuadraticWedge();
          aWedge.GetPointIds().SetId((int)0,(int)0);
          aWedge.GetPointIds().SetId((int)1,(int)1);
          aWedge.GetPointIds().SetId((int)2,(int)2);
          aWedge.GetPointIds().SetId((int)3,(int)3);
          aWedge.GetPointIds().SetId((int)4,(int)4);
          aWedge.GetPointIds().SetId((int)5,(int)5);
          aWedge.GetPointIds().SetId((int)6,(int)6);
          aWedge.GetPointIds().SetId((int)7,(int)7);
          aWedge.GetPointIds().SetId((int)8,(int)8);
          aWedge.GetPointIds().SetId((int)9,(int)9);
          aWedge.GetPointIds().SetId((int)10,(int)10);
          aWedge.GetPointIds().SetId((int)11,(int)11);
          aWedge.GetPointIds().SetId((int)12,(int)12);
          aWedge.GetPointIds().SetId((int)13,(int)13);
          aWedge.GetPointIds().SetId((int)14,(int)14);
          aWedgeGrid = new vtkUnstructuredGrid();
          aWedgeGrid.Allocate((int)1,(int)1);
          aWedgeGrid.InsertNextCell((int)aWedge.GetCellType(),(vtkIdList)aWedge.GetPointIds());
          aWedgeGrid.SetPoints((vtkPoints)wedgePoints);
          aWedgeGrid.GetPointData().SetScalars((vtkDataArray)wedgeScalars);
          wedgeContours = new vtkClipDataSet();
          wedgeContours.SetInputData((vtkDataObject)aWedgeGrid);
          wedgeContours.SetValue((double)0.5);
          aWedgeContourMapper = new vtkDataSetMapper();
          aWedgeContourMapper.SetInputConnection((vtkAlgorithmOutput)wedgeContours.GetOutputPort());
          aWedgeContourMapper.ScalarVisibilityOff();
          aWedgeMapper = new vtkDataSetMapper();
          aWedgeMapper.SetInputData((vtkDataSet)aWedgeGrid);
          aWedgeMapper.ScalarVisibilityOff();
          aWedgeActor = new vtkActor();
          aWedgeActor.SetMapper((vtkMapper)aWedgeMapper);
          aWedgeActor.GetProperty().SetRepresentationToWireframe();
          aWedgeActor.GetProperty().SetAmbient((double)1.0);
          aWedgeContourActor = new vtkActor();
          aWedgeContourActor.SetMapper((vtkMapper)aWedgeContourMapper);
          aWedgeContourActor.GetProperty().SetAmbient((double)1.0);
          // Quadratic pyramid[]
          pyraPoints = new vtkPoints();
          pyraPoints.SetNumberOfPoints((int)13);
          pyraPoints.InsertPoint((int)0,(double)0,(double)0,(double)0);
          pyraPoints.InsertPoint((int)1,(double)1,(double)0,(double)0);
          pyraPoints.InsertPoint((int)2,(double)1,(double)1,(double)0);
          pyraPoints.InsertPoint((int)3,(double)0,(double)1,(double)0);
          pyraPoints.InsertPoint((int)4,(double)0,(double)0,(double)1);
          pyraPoints.InsertPoint((int)5,(double)0.5,(double)0,(double)0);
          pyraPoints.InsertPoint((int)6,(double)1,(double)0.5,(double)0);
          pyraPoints.InsertPoint((int)7,(double)0.5,(double)1,(double)0);
          pyraPoints.InsertPoint((int)8,(double)0,(double)0.5,(double)0);
          pyraPoints.InsertPoint((int)9,(double)0,(double)0,(double)0.5);
          pyraPoints.InsertPoint((int)10,(double)0.5,(double)0,(double)0.5);
          pyraPoints.InsertPoint((int)11,(double)0.5,(double)0.5,(double)0.5);
          pyraPoints.InsertPoint((int)12,(double)0,(double)0.5,(double)0.5);
          pyraScalars = new vtkFloatArray();
          pyraScalars.SetNumberOfTuples((int)13);
          pyraScalars.InsertValue((int)0,(float)1.0);
          pyraScalars.InsertValue((int)1,(float)1.0);
          pyraScalars.InsertValue((int)2,(float)1.0);
          pyraScalars.InsertValue((int)3,(float)1.0);
          pyraScalars.InsertValue((int)4,(float)1.0);
          pyraScalars.InsertValue((int)5,(float)1.0);
          pyraScalars.InsertValue((int)6,(float)1.0);
          pyraScalars.InsertValue((int)7,(float)1.0);
          pyraScalars.InsertValue((int)8,(float)0.0);
          pyraScalars.InsertValue((int)9,(float)0.0);
          pyraScalars.InsertValue((int)10,(float)0.0);
          pyraScalars.InsertValue((int)11,(float)0.0);
          pyraScalars.InsertValue((int)12,(float)0.0);
          aPyramid = new vtkQuadraticPyramid();
          aPyramid.GetPointIds().SetId((int)0,(int)0);
          aPyramid.GetPointIds().SetId((int)1,(int)1);
          aPyramid.GetPointIds().SetId((int)2,(int)2);
          aPyramid.GetPointIds().SetId((int)3,(int)3);
          aPyramid.GetPointIds().SetId((int)4,(int)4);
          aPyramid.GetPointIds().SetId((int)5,(int)5);
          aPyramid.GetPointIds().SetId((int)6,(int)6);
          aPyramid.GetPointIds().SetId((int)7,(int)7);
          aPyramid.GetPointIds().SetId((int)8,(int)8);
          aPyramid.GetPointIds().SetId((int)9,(int)9);
          aPyramid.GetPointIds().SetId((int)10,(int)10);
          aPyramid.GetPointIds().SetId((int)11,(int)11);
          aPyramid.GetPointIds().SetId((int)12,(int)12);
          aPyramidGrid = new vtkUnstructuredGrid();
          aPyramidGrid.Allocate((int)1,(int)1);
          aPyramidGrid.InsertNextCell((int)aPyramid.GetCellType(),(vtkIdList)aPyramid.GetPointIds());
          aPyramidGrid.SetPoints((vtkPoints)pyraPoints);
          aPyramidGrid.GetPointData().SetScalars((vtkDataArray)pyraScalars);
          pyraContours = new vtkClipDataSet();
          pyraContours.SetInputData((vtkDataObject)aPyramidGrid);
          pyraContours.SetValue((double)0.5);
          aPyramidContourMapper = new vtkDataSetMapper();
          aPyramidContourMapper.SetInputConnection((vtkAlgorithmOutput)pyraContours.GetOutputPort());
          aPyramidContourMapper.ScalarVisibilityOff();
          aPyramidMapper = new vtkDataSetMapper();
          aPyramidMapper.SetInputData((vtkDataSet)aPyramidGrid);
          aPyramidMapper.ScalarVisibilityOff();
          aPyramidActor = new vtkActor();
          aPyramidActor.SetMapper((vtkMapper)aPyramidMapper);
          aPyramidActor.GetProperty().SetRepresentationToWireframe();
          aPyramidActor.GetProperty().SetAmbient((double)1.0);
          aPyramidContourActor = new vtkActor();
          aPyramidContourActor.SetMapper((vtkMapper)aPyramidContourMapper);
          aPyramidContourActor.GetProperty().SetAmbient((double)1.0);
          // Create the rendering related stuff.[]
          // Since some of our actors are a single vertex, we need to remove all[]
          // cullers so the single vertex actors will render[]
          ren1 = vtkRenderer.New();
          ren1.GetCullers().RemoveAllItems();
          renWin = vtkRenderWindow.New();
          renWin.SetMultiSamples(0);
          renWin.AddRenderer((vtkRenderer)ren1);
          iren = new vtkRenderWindowInteractor();
          iren.SetRenderWindow((vtkRenderWindow)renWin);
          ren1.SetBackground((double).1,(double).2,(double).3);
          renWin.SetSize((int)400,(int)200);
          // specify properties[]
          ren1.AddActor((vtkProp)aEdgeActor);
          ren1.AddActor((vtkProp)aTriActor);
          ren1.AddActor((vtkProp)aQuadActor);
          ren1.AddActor((vtkProp)aTetActor);
          ren1.AddActor((vtkProp)aHexActor);
          ren1.AddActor((vtkProp)aWedgeActor);
          ren1.AddActor((vtkProp)aPyramidActor);
          // places everyone!![]
          aTriActor.AddPosition((double)2,(double)0,(double)0);
          aQuadActor.AddPosition((double)4,(double)0,(double)0);
          aTetActor.AddPosition((double)6,(double)0,(double)0);
          aHexActor.AddPosition((double)8,(double)0,(double)0);
          aWedgeActor.AddPosition((double)10,(double)0,(double)0);
          aPyramidActor.AddPosition((double)12,(double)0,(double)0);
          BuildBackdrop(-1, 15, -1, 4, -1, 2, .1);
          ren1.AddActor((vtkProp)base1);
          base1.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
          ren1.AddActor((vtkProp)left);
          left.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
          ren1.AddActor((vtkProp)back);
          back.GetProperty().SetDiffuseColor((double).2,(double).2,(double).2);
          ren1.ResetCamera();
          ren1.GetActiveCamera().Dolly((double)2.5);
          ren1.ResetCameraClippingRange();
          renWin.Render();
          // create a little scorecard above each of the cells. These are displayed[]
          // if a ray cast hits the cell, otherwise they are not shown.[]
          pm = new vtkPlaneSource();
          pm.SetXResolution((int)1);
          pm.SetYResolution((int)1);
          pmapper = vtkPolyDataMapper.New();
          pmapper.SetInputConnection((vtkAlgorithmOutput)pm.GetOutputPort());
          // now try intersecting rays with the cell[]
          cellPicker = new vtkCellPicker();
          edgeCheck = new vtkActor();
          edgeCheck.SetMapper((vtkMapper)pmapper);
          edgeCheck.AddPosition((double)0.5,(double)2.5,(double)0);
          cellPicker.Pick((double)87,(double)71,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)edgeCheck);
        }

          triCheck = new vtkActor();
          triCheck.SetMapper((vtkMapper)pmapper);
          triCheck.AddPosition((double)2.5,(double)2.5,(double)0);
          cellPicker.Pick((double)139,(double)72,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)triCheck);
        }

          quadCheck = new vtkActor();
          quadCheck.SetMapper((vtkMapper)pmapper);
          quadCheck.AddPosition((double)4.5,(double)2.5,(double)0);
          cellPicker.Pick((double)192,(double)78,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)quadCheck);
        }

          tetCheck = new vtkActor();
          tetCheck.SetMapper((vtkMapper)pmapper);
          tetCheck.AddPosition((double)6.5,(double)2.5,(double)0);
          cellPicker.Pick((double)233,(double)70,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)tetCheck);
        }

          hexCheck = new vtkActor();
          hexCheck.SetMapper((vtkMapper)pmapper);
          hexCheck.AddPosition((double)8.5,(double)2.5,(double)0);
          cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)hexCheck);
        }

          wedgeCheck = new vtkActor();
          wedgeCheck.SetMapper((vtkMapper)pmapper);
          wedgeCheck.AddPosition((double)10.5,(double)2.5,(double)0);
          cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)wedgeCheck);
        }

          pyraCheck = new vtkActor();
          pyraCheck.SetMapper((vtkMapper)pmapper);
          pyraCheck.AddPosition((double)12.5,(double)2.5,(double)0);
          cellPicker.Pick((double)287,(double)80,(double)0,(vtkRenderer)ren1);
          if ((cellPicker.GetCellId()) != -1)
        {
          ren1.AddActor((vtkProp)pyraCheck);
        }

          // render the image[]
          //[]
          iren.Initialize();

        //deleteAllVTKObjects();
    }
예제 #55
0
        private void ColoredLines()
        {
            // Create three points. Join (Origin and P0) with a red line and
            // (Origin and P1) with a green line
            double[] origin = new double[] { 0.0, 0.0, 0.0 };
            double[] p0     = new double[] { 1.0, 0.0, 0.0 };
            double[] p1     = new double[] { 0.0, 1.0, 0.0 };

            // Create a vtkPoints object and store the points in it
            vtkPoints pts = vtkPoints.New();

            pts.InsertNextPoint(origin[0], origin[1], origin[2]);
            pts.InsertNextPoint(p0[0], p0[1], p0[2]);
            pts.InsertNextPoint(p1[0], p1[1], p1[2]);

            // Setup two colors - one for each line
            byte[] red   = new byte[] { 255, 0, 0 };
            byte[] green = new byte[] { 0, 255, 0 };

            // Setup the colors array
            vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();

            colors.SetNumberOfComponents(3);
            colors.SetName("Colors");

            // Add the colors we created to the colors array
            colors.InsertNextValue(red[0]);
            colors.InsertNextValue(red[1]);
            colors.InsertNextValue(red[2]);

            colors.InsertNextValue(green[0]);
            colors.InsertNextValue(green[1]);
            colors.InsertNextValue(green[2]);

            // Create the first line (between Origin and P0)
            vtkLine line0 = vtkLine.New();

            line0.GetPointIds().SetId(0, 0); //the second 0 is the index of the Origin in the vtkPoints
            line0.GetPointIds().SetId(1, 1); //the second 1 is the index of P0 in the vtkPoints

            // Create the second line (between Origin and P1)
            vtkLine line1 = vtkLine.New();

            line1.GetPointIds().SetId(0, 0); //the second 0 is the index of the Origin in the vtkPoints
            line1.GetPointIds().SetId(1, 2); //2 is the index of P1 in the vtkPoints

            // Create a cell array to store the lines in and add the lines to it
            vtkCellArray lines = vtkCellArray.New();

            lines.InsertNextCell(line0);
            lines.InsertNextCell(line1);

            // Create a polydata to store everything in
            vtkPolyData linesPolyData = vtkPolyData.New();

            // Add the points to the dataset
            linesPolyData.SetPoints(pts);

            // Add the lines to the dataset
            linesPolyData.SetLines(lines);

            // Color the lines - associate the first component (red) of the
            // colors array with the first component of the cell array (line 0)
            // and the second component (green) of the colors array with the
            // second component of the cell array (line 1)
            linesPolyData.GetCellData().SetScalars(colors);

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInput(linesPolyData);
            // create an actor
            vtkActor actor = vtkActor.New();

            actor.SetMapper(mapper);

            RenderAddActor(actor);
        }
예제 #56
0
        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            // Create components of the rendering subsystem
            //
            vtkRenderer     ren1   = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
            vtkRenderWindow renWin = renderWindowControl1.RenderWindow;

            renWin.SetSize((int)paras.Height, (int)paras.Width);

            // Add the actors to the renderer, set the window size
            //
            vtkPoints      points  = vtkPoints.New();
            vtkCellArray   polys   = vtkCellArray.New();
            vtkFloatArray  scalars = vtkFloatArray.New();
            vtkLookupTable Luk     = vtkLookupTable.New();

            if (paras.Using3DTower == 1)
            {
                vtkActor   actor1  = new vtkActor();
                vtkActor2D actor2D = new vtkActor2D();
                if (paras.StageID != -1)
                {
                    if (paras.UsingEdges == 1)
                    {
                        MessageBox.Show("单元显示无法使用");
                    }
                    else
                    {
                        BasicVTKBuilder(ref actor1, ref points, ref polys, ref scalars, ref Luk, ref actor2D);
                        ren1.AddActor(actor1);
                        ren1.AddActor2D(actor2D);

                        vtkActor2D textActor = new vtkActor2D();
                        VTKInfoBuilder(ref textActor);
                        ren1.AddActor2D(textActor);
                    }
                }
                else
                {
                    if (paras.UsingEdges == 1)
                    {
                        ExtractEdgesVTKBuilderWithoutRunning(ref actor1, ref points, ref polys, ref scalars, ref Luk);
                    }
                    else
                    {
                        BasicVTKBuilderWithoutRunning(ref actor1, ref points, ref polys, ref scalars, ref Luk);
                    }
                    ren1.AddActor(actor1);
                }
            }

            if (paras.UsingVirtualHeater == 1)
            {
                //MessageBox.Show("!");
                vtkActor2D actor2 = VirtualHeaterVTKBuilder();
                ren1.AddActor(actor2);
            }


            renWin.Render();
            vtkCamera camera = ren1.GetActiveCamera();

            //camera.ParallelProjectionOn();
            //camera.Elevation(20);
            int[] camera_pos = new int[3];

            if (paras.globalEnv == 1)
            {
                camera_pos[1] = -70;
            }
            else
            {
                camera_pos[1] = -80;
            }

            if (paras.RotateAngle == 0)
            {
                camera_pos[1] = -camera_pos[1];
                camera_pos[0] = camera_pos[2] = 0;
                camera.SetRoll(-2);
            }
            else if (paras.RotateAngle == 180)
            {
                camera_pos[0] = camera_pos[2] = 0;
                camera.SetRoll(180);
            }
            else if (paras.RotateAngle == 90)
            {
                double r = (double)Math.Abs(camera_pos[1]);
                camera_pos[0] = (int)(-r * 0.707);
                camera_pos[1] = (int)(-r * 0.707);
                camera_pos[2] = 0;
                camera.SetRoll(225);
            }
            else if (paras.RotateAngle == 270)
            {
                double r = (double)Math.Abs(camera_pos[1]);
                camera_pos[0] = (int)(r * 0.707);
                camera_pos[1] = (int)(-r * 0.707);
                camera_pos[2] = 0;
                camera.SetRoll(135);
            }

            camera.SetPosition((double)camera_pos[0], (double)camera_pos[1], (double)camera_pos[2]);
            //camera.Yaw(10);
            camera.Elevation(1);
            camera.ParallelProjectionOn();
            camera.Zoom(0.9);
            StoredViewCamera = new List <vtkCamera>();
            for (int i = 0; i < 3; i++)
            {
                vtkCamera ViewCamera = new vtkCamera();


                if (i == 0)
                {
                    ViewCamera.SetPosition(camera.GetPosition()[0],
                                           camera.GetPosition()[1],
                                           camera.GetPosition()[2]);
                    ViewCamera.SetRoll(camera.GetRoll());
                }
                else if (i == 1)
                {
                    ViewCamera.SetPosition(80, 0, 0);
                    ViewCamera.SetRoll(180);
                }
                else if (i == 2)
                {
                    ViewCamera.SetPosition(0, 0, -80);
                    ViewCamera.SetRoll(camera.GetRoll());
                }
                ViewCamera.SetFocalPoint(camera.GetFocalPoint()[0],
                                         camera.GetFocalPoint()[1],
                                         camera.GetFocalPoint()[2]);
                ViewCamera.SetViewUp(camera.GetViewUp()[0],
                                     camera.GetViewUp()[1],
                                     camera.GetViewUp()[2]);
                StoredViewCamera.Add(ViewCamera);
            }

            //camera.Zoom(1.5);
        }