Пример #1
0
        /// <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();
            }
        }
Пример #2
0
        public void ClipBC(vtkPlane ClipPlane, bool clip)
        {
            if (clip == true)
            {
                ClipperX = vtkTableBasedClipDataSet.New();
                ClipperX.SetClipFunction(ClipPlane);
                ClipperX.SetInputConnection(GlyphX.GetOutputPort());
                ClipperX.Update();
                MapperX.SetInputConnection(ClipperX.GetOutputPort());
                MapperX.Update();

                ClipperY = vtkTableBasedClipDataSet.New();
                ClipperY.SetClipFunction(ClipPlane);
                ClipperY.SetInputConnection(GlyphY.GetOutputPort());
                ClipperY.Update();
                MapperY.SetInputConnection(ClipperY.GetOutputPort());
                MapperY.Update();

                ClipperZ = vtkTableBasedClipDataSet.New();
                ClipperZ.SetClipFunction(ClipPlane);
                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();
            }
        }
Пример #3
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);
        }