Пример #1
0
        public void SetDefaultColor()
        {
            vtkUnsignedCharArray cellColors = new vtkUnsignedCharArray();

            cellColors.SetNumberOfComponents(3);
            int cellNum = this.GetMapper().GetInput().GetNumberOfCells();

            cellColors.SetNumberOfTuples(cellNum);
            for (int i = 0; i < cellNum; ++i)
            {
                cellColors.SetTuple3(i, this.m_defaultColor[0], this.m_defaultColor[1], this.m_defaultColor[2]);
            }
            this.GetMapper().GetInput().GetCellData().SetScalars(cellColors);

            vtkUnsignedCharArray ptColors = new vtkUnsignedCharArray();

            ptColors.SetNumberOfComponents(3);
            int ptNum = this.GetMapper().GetInput().GetNumberOfPoints();

            ptColors.SetNumberOfTuples(ptNum);
            for (int i = 0; i < ptNum; i++)
            {
                ptColors.SetTuple3(i, this.m_defaultColor[0], this.m_defaultColor[1], this.m_defaultColor[2]);
            }
            this.GetMapper().GetInput().GetPointData().SetScalars(ptColors);
            // this.GetMapper().SetScalarModeToUsePointData();

            this.GetMapper().SetScalarModeToUseCellData();
            this.GetMapper().Update();
        }
Пример #2
0
        /// <summary>
        /// 当有点和cell被选择是更新颜色
        /// </summary>
        public override void UpdateSelectedColor()
        {
            ///cell
            if (m_selectedCellsIds != null && m_selectedCellsIds.Count > 0)
            {
                vtkUnsignedCharArray colors = new vtkUnsignedCharArray();
                colors.SetNumberOfComponents(3);
                int cellNum = this.GetMapper().GetInput().GetNumberOfCells();
                colors.SetNumberOfTuples(cellNum);
                for (int i = 0; i < cellNum; ++i)
                {
                    colors.SetTuple3(i, m_defaultColor [0], m_defaultColor [1], m_defaultColor [2]);
                }
                foreach (int cellID in m_selectedCellsIds.Keys)
                {
                    colors.SetTuple3(cellID, ModelUtils.SelectedColor[0], ModelUtils.SelectedColor[1],
                                     ModelUtils.SelectedColor[2]);
                }
                this.GetMapper().GetInput().GetCellData().SetScalars(colors);
            }
            ///point
            else if (m_selectedPointsIds != null && m_selectedPointsIds.Count > 0)
            {
                vtkUnsignedCharArray ptcolors = new vtkUnsignedCharArray();
                ptcolors.SetNumberOfComponents(3);
                int ptNum = this.GetMapper().GetInput().GetNumberOfPoints();
                ptcolors.SetNumberOfTuples(ptNum);

                for (int i = 0; i < ptNum; ++i)
                {
                    ptcolors.SetTuple3(i, m_defaultColor[0], m_defaultColor[1], m_defaultColor[2]);
                }
                foreach (int ptid in m_selectedPointsIds.Keys)
                {
                    ptcolors.SetTuple3(ptid, ModelUtils.SelectedColor[0], ModelUtils.SelectedColor[1], ModelUtils.SelectedColor[2]);
                }

                this.GetMapper().SetScalarModeToUsePointData();
                this.GetMapper().GetInput().GetPointData().SetScalars(ptcolors);

                //this.GetProperty().SetPointSize(4);
                //this.GetProperty().SetRepresentationToPoints();
            }
            this.GetMapper().Update();
        }