Example #1
0
        //接收fy3DModelCanvas更新数据的消息
        //初始化所有参数
        void m_3DModelCanvas_UpdatefyGridEvent()
        {
            //激活控制面板
            this.Enabled = true;


            numericUpDown1.Minimum = 0;
            numericUpDown1.Maximum = m_3DModelCanvas.KCount - 1;

            numericUpDown2.Minimum = 0;
            numericUpDown2.Maximum = m_3DModelCanvas.JCount - 1;

            numericUpDown3.Minimum = 0;
            numericUpDown3.Maximum = m_3DModelCanvas.ICount - 1;

            trackBar2.Minimum = 0;
            trackBar2.Maximum = m_3DModelCanvas.KCount - 1;

            trackBar1.Minimum = 0;
            trackBar1.Maximum = m_3DModelCanvas.JCount - 1;

            trackBar3.Minimum = 0;
            trackBar3.Maximum = m_3DModelCanvas.ICount - 1;

            label_ICount.Text = "ICount=" + m_3DModelCanvas.ICount.ToString();
            label_JCount.Text = "JCount=" + m_3DModelCanvas.JCount.ToString();
            label_KCount.Text = "KCount=" + m_3DModelCanvas.KCount.ToString();

            label_MinValue.Text = "Min=" + m_3DModelCanvas.MinValue.ToString();
            label_MaxValue.Text = "Max=" + m_3DModelCanvas.MaxValue.ToString();

            textBox1.Text = m_3DModelCanvas.MinValue + "," + m_3DModelCanvas.MaxValue;

            //初始化镂空参数(采用默认的镂空参数)
            TransparentRanges = new List <fyTransparentRange>();
            fyTransparentRange TransparentRange = new fyTransparentRange();

            TransparentRange.Min = m_3DModelCanvas.MinValue;
            TransparentRange.Max = m_3DModelCanvas.MaxValue;
            TransparentRanges.Add(TransparentRange);

            //默认启动普通模式
            radioButton1.Checked = true;
            //启动默认设置(普通视图模式)
            m_3DModelCanvas.LookAt_NormalMode(fy3DModelViewMode.None);
        }
        double EPSILON = 0.000000001;    //最小值E

        public fy3DModelPage(ExGrid Grid, double[] CameraFocalPoint, double[] CameraPoint, double[] CameraViewUp,
                             List <fyTransparentRange> TransparentRanges)
        {
            InitializeComponent();

            m_PageMode = fy3DModelPageMode.HollowOut_Mode;

            m_CameraFocalPoint = CameraFocalPoint;
            m_CameraPoint      = CameraPoint;
            m_CameraViewUp     = CameraViewUp;

            m_ImageData = ConvertfyGrid2vtkImageData(Grid);

            m_Range     = new fyTransparentRange();
            m_Range.Min = Grid.Min;
            m_Range.Max = Grid.Max;

            m_UserRanges = TransparentRanges;

            //初始化渲染的颜色和透明度
            InitializeColor_HollowOut(Grid);
        }
Example #3
0
 //镂空显示
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         TransparentRanges = new List <fyTransparentRange>();
         string   str  = textBox1.Text.Trim();
         string[] str1 = str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
         for (int i = 0; i < str1.Length; i++)
         {
             string[]           str2             = str1[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             double             min              = double.Parse(str2[0]);
             double             max              = double.Parse(str2[1]);
             fyTransparentRange TransparentRange = new fyTransparentRange();
             TransparentRange.Min = min;
             TransparentRange.Max = max;
             //如果Min和Max的取值发生冲突,并且该镂空范围无效
             if (max < min)
             {
                 MessageBox.Show("来自fy3DModelManager的警告\nMin&Max不符合!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 continue;
             }
             TransparentRanges.Add(TransparentRange);
         }
     }
     catch
     {
         MessageBox.Show("来自fy3DModelManager的警告\n请输入正确的镂空范围!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         //初始化镂空参数(采用默认的镂空参数)
         TransparentRanges = new List <fyTransparentRange>();
         fyTransparentRange TransparentRange = new fyTransparentRange();
         TransparentRange.Min = m_3DModelCanvas.MinValue;
         TransparentRange.Max = m_3DModelCanvas.MaxValue;
         TransparentRanges.Add(TransparentRange);
     }
     m_3DModelCanvas.LookAt_HollowOutMode(TransparentRanges, fy3DModelViewMode.None);
 }
        void InitRanges()
        {
            //实例化透明度交集
            m_IntersectRanges = new List <fyTransparentRange>();

            //fyGrid数据的范围
            List <Interval> AllIntervals = new List <Interval>();

            AllIntervals.Add(new Interval(m_Range.Min, m_Range.Max));

            //用户设置的范围
            List <Interval> UserIntervals = new List <Interval>();

            foreach (var range in m_UserRanges)
            {
                double Min = range.Min;
                double Max = range.Max;
                //如果range的Min等于Max,即范围仅仅是一个点,那么对其进行修正
                //对Min加EPSILON,同时对Max减EPSILON,使其成为一个有效的范围
                if (range.Min == range.Max)
                {
                    Min = Min + EPSILON;
                    Max = Max - EPSILON;
                }
                UserIntervals.Add(new Interval(Min, Max));
            }

            //用户设置的范围补集
            List <Interval> UserIntervals_补集 = Interval.Complement(UserIntervals);

            //计算透明的范围
            var IntersectIntervals_透明 = Interval.Intersection(AllIntervals, UserIntervals);
            //计算不透明的范围
            var IntersectIntervals_不透明 = Interval.Intersection(AllIntervals, UserIntervals_补集);

            foreach (var interval in IntersectIntervals_透明)
            {
                if (interval.lowerbound == interval.upperbound)
                {
                    continue;
                }
                fyTransparentRange range = new fyTransparentRange();
                range.Min         = interval.lowerbound;
                range.Max         = interval.upperbound;
                range.Transparent = true;
                m_IntersectRanges.Add(range);
            }
            foreach (var interval in IntersectIntervals_不透明)
            {
                if (interval.lowerbound == interval.upperbound)
                {
                    continue;
                }
                fyTransparentRange range = new fyTransparentRange();
                range.Min         = interval.lowerbound;
                range.Max         = interval.upperbound;
                range.Transparent = false;
                m_IntersectRanges.Add(range);
            }
            //进行排序
            m_IntersectRanges = m_IntersectRanges.OrderBy(a => a.Min).ThenBy(a => a.Max).ToList();
        }