Beispiel #1
0
        public void ExtractEdgesVTKBuilderWithoutRunning(ref vtkActor actor, ref vtkPoints points, ref vtkCellArray polys,
                                                         ref vtkFloatArray scalars, ref vtkLookupTable Luk)
        {
            int pointsNum = 0;

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

            vtkPolyData profile = vtkPolyData.New();

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

            vtkExtractEdges ExtProfile = new vtkExtractEdges();


            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            if (paras.RotateAngle == 0)
            {
                profile.GetCellData().SetScalars(scalars);
                ExtProfile.SetInput(profile);
                mapper.SetInputConnection(ExtProfile.GetOutputPort());
            }
            else
            {
                vtkRotationalExtrusionFilter refilter = vtkRotationalExtrusionFilter.New();
                profile.Update();
                profile.GetCellData().SetScalars(scalars);
                //profile.GetPointData().SetScalars(scalars);
                ExtProfile.SetInput(profile);

                refilter.SetInputConnection(ExtProfile.GetOutputPort());
                refilter.SetResolution(50);
                refilter.SetAngle(paras.RotateAngle);
                refilter.SetTranslation(0);
                refilter.SetDeltaRadius(0);

                mapper.SetInputConnection(refilter.GetOutputPort());
            }
            mapper.SetScalarRange(0, 5);
            mapper.SetLookupTable(Luk);
            actor.SetMapper(mapper);

            Luk.SetNumberOfTableValues(7);
            Luk.SetTableValue(0, 0, 1, 0, 1);   //
            Luk.SetTableValue(1, 0, 0, 0.8, 1); //inner surface
            Luk.SetTableValue(2, 0, 1, 0, 1);   //
            Luk.SetTableValue(3, 0, 0, 1, 1);
            Luk.SetTableValue(4, 0, 0, 0.8, 1); //insider
            Luk.SetTableValue(5, 0, 0.8, 0, 1); //outer surface
            Luk.Build();
        }
Beispiel #2
0
        /// <summary>
        /// 进行三维结构的转换
        /// </summary>
        /// <param name="degree"></param>
        /// <param name="polyData"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        private static vtkPolyData Extrude3DSection(float degree, vtkPolyData polyData, ModelingBaseInfo info)
        {
            //进行拉伸以构造的三维实体
            vtkRotationalExtrusionFilter extrude = vtkRotationalExtrusionFilter.New();

            extrude.SetInput(polyData);
            extrude.SetResolution(80);
            extrude.SetAngle(degree);//旋转
            extrude.CappingOn();

            vtkPolyDataNormals normals = vtkPolyDataNormals.New();

            normals.SetInput(extrude.GetOutput());
            normals.SetFeatureAngle(100);
            //进行转换
            vtkTransform transform = vtkTransform.New();

            transform.RotateX(info.Angle);                                                            //逆时针为正,顺时针为负
            transform.Translate(info.BaseCoordinate.X, info.BaseCoordinate.Y, info.BaseCoordinate.Z); //先旋转后平移

            vtkTransformFilter transFilter = vtkTransformFilter.New();

            transFilter.SetTransform(transform);
            transFilter.SetInput(normals.GetOutput());

            //vtkTriangleFilter filter = vtkTriangleFilter.New();
            //filter.SetInput(transFilter.GetOutput());

            //return filter.GetPolyDataInput(0);

            vtkCleanPolyData clearPolydata = vtkCleanPolyData.New();//清除重合的点和片

            clearPolydata.SetInput(transFilter.GetOutput());
            return(clearPolydata.GetOutput());
            //return transFilter.GetPolyDataOutput();
        }
Beispiel #3
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);
        }