Ejemplo n.º 1
0
Archivo: Part.cs Proyecto: ovevans/STAN
        /// <summary>
        /// Clip this part - Set Mapper input to Clipper
        /// </summary>
        public void ClipPart(vtkPlane ClipPlane, bool clip)
        {
            if (clip == true)
            {
                Clipper = vtkTableBasedClipDataSet.New();
                Clipper.SetClipFunction(ClipPlane);
                Clipper.SetInputConnection(Grid.GetProducerPort());
                Clipper.Update();
                Mapper.SetInputConnection(Clipper.GetOutputPort());
                Mapper.Update();

                // Update Feature Filter -> will update Edges and Faces
                Filter.SetInput(Clipper.GetOutput());
                Filter.Update();



                // ------- Alternative without Clip Surface Extraction --------------

                //vtkPlaneCollection planes = vtkPlaneCollection.New();
                //planes.AddItem(ClipPlane);
                //Edges.GetMapper().SetClippingPlanes(planes);
                //Edges.GetMapper().Update();

                //vtkPlaneCollection Planes = vtkPlaneCollection.New();
                //Planes.AddItem(ClipPlane);
                //Mapper.SetClippingPlanes(Planes);
                //Mapper.Update();
            }
            else
            {
                Mapper.SetInput(Grid);
                Mapper.Update();

                // Update Feature Filter -> will update Edges and Faces
                Filter.SetInput(Grid);
                Filter.Update();


                // ------- Alternative without Clip Surface Extraction --------------
                // Edges
                //vtkPlaneCollection planes = vtkPlaneCollection.New();
                //Edges.GetMapper().SetClippingPlanes(planes);
                //Edges.GetMapper().Update();

                //vtkPlaneCollection Planes = vtkPlaneCollection.New();
                //Mapper.SetClippingPlanes(Planes);
                //Mapper.Update();
            }
        }
Ejemplo n.º 2
0
Archivo: Part.cs Proyecto: ovevans/STAN
        public void ExtractFeatures()
        {
            Filter = vtkDataSetSurfaceFilter.New();
            Filter.SetInput(Grid);
            Filter.Update();
            Faces = Filter.GetOutput();

            vtkFeatureEdges FeatureEdges = vtkFeatureEdges.New();

            FeatureEdges.SetInput(Filter.GetOutput());
            FeatureEdges.Update();

            FeatureEdges.BoundaryEdgesOn();
            FeatureEdges.FeatureEdgesOn();
            FeatureEdges.ManifoldEdgesOn();
            FeatureEdges.NonManifoldEdgesOn();

            // Change Edge color
            FeatureEdges.SetColoring(0);

            // Update
            FeatureEdges.Update();

            vtkPolyDataMapper EdgeMapper = vtkPolyDataMapper.New();

            EdgeMapper.SetInput(FeatureEdges.GetOutput());
            EdgeMapper.ScalarVisibilityOff();

            Edges.SetMapper(EdgeMapper);
            Edges.GetProperty().SetEdgeColor(0, 0, 0);
            Edges.GetProperty().SetColor(0.0, 0.0, 0.0);
            Edges.GetProperty().SetLineWidth((float)1.0);   // Set default edge thickness
            Edges.SetVisibility(0);
        }
Ejemplo n.º 3
0
        private void MatrixMathFilter()
        {
            // 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\tensors.vtk");
            vtkUnstructuredGridReader reader = vtkUnstructuredGridReader.New();

            reader.SetFileName(filePath);
            reader.Update();

            vtkDataSetSurfaceFilter surfaceFilter = vtkDataSetSurfaceFilter.New();

            surfaceFilter.SetInputConnection(reader.GetOutputPort());
            surfaceFilter.Update();

            vtkMatrixMathFilter matrixMathFilter = vtkMatrixMathFilter.New();

            //matrixMathFilter.SetOperationToDeterminant();
            matrixMathFilter.SetOperationToEigenvalue();
            matrixMathFilter.SetInputConnection(surfaceFilter.GetOutputPort());
            matrixMathFilter.Update();
            matrixMathFilter.GetOutput().GetPointData().SetActiveScalars("Eigenvalue");

            vtkXMLPolyDataWriter writer = vtkXMLPolyDataWriter.New();

            writer.SetInputConnection(matrixMathFilter.GetOutputPort());
            writer.SetFileName(System.IO.Path.Combine(root, @"Data\output.vtp"));
            writer.Write();

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInputConnection(matrixMathFilter.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);
        }
Ejemplo n.º 4
0
        void GenerateData(ref vtkPolyData input)
        {
            // Create a sphere
            vtkSphereSource sphereSource = vtkSphereSource.New();

            sphereSource.Update();

            // Remove some cells
            vtkIdTypeArray ids = vtkIdTypeArray.New();

            ids.SetNumberOfComponents(1);

            // Set values
            ids.InsertNextValue(2);
            ids.InsertNextValue(10);

            vtkSelectionNode selectionNode = vtkSelectionNode.New();

            selectionNode.SetFieldType((int)vtkSelectionNode.SelectionField.CELL);
            selectionNode.SetContentType((int)vtkSelectionNode.SelectionContent.INDICES);
            selectionNode.SetSelectionList(ids);
            selectionNode.GetProperties().Set(vtkSelectionNode.INVERSE(), 1); //invert the selection

            vtkSelection selection = vtkSelection.New();

            selection.AddNode(selectionNode);

            vtkExtractSelection extractSelection = vtkExtractSelection.New();

            extractSelection.SetInputConnection(0, sphereSource.GetOutputPort());
#if VTK_MAJOR_VERSION_5
            extractSelection.SetInput(1, selection);
#else
            extractSelection.SetInputData(1, selection);
#endif
            extractSelection.Update();

            // In selection
            vtkDataSetSurfaceFilter surfaceFilter = vtkDataSetSurfaceFilter.New();
            surfaceFilter.SetInputConnection(extractSelection.GetOutputPort());
            surfaceFilter.Update();

            input.ShallowCopy(surfaceFilter.GetOutput());
        }