示例#1
0
        public void SetPosition(double[] xyz1, double[] xyz2)
        {
            vtkPoints points = vtkPoints.New();

            points.InsertPoint(0, xyz1[0], xyz1[1], xyz1[2]);
            points.InsertPoint(1, xyz2[0], xyz2[1], xyz2[2]);

            vtkCellArray lines = vtkCellArray.New();

            lines.InsertNextCell(2);

            lines.InsertCellPoint(0);
            lines.InsertCellPoint(1);

            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(1);
            profileTubes.SetInputArrayToProcess(1, 0, 0, 0, "vectors");

            //vtkPolyDataMapper profileMapper = new vtkPolyDataMapper();
            //profileMapper.SetInputConnection(profileTubes.GetOutputPort());

            vtkPolyDataMapper mapper = vtkPolyDataMapper.New();

            mapper.SetInput(profileTubes.GetOutput());

            centerLineActor.SetMapper(mapper);
            centerLineActor.GetProperty().SetOpacity(0.5);
        }
示例#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
        /// <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();
        }